Skip to content

Commit

Permalink
feat bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wyt1215819315 committed Dec 18, 2023
1 parent e09a8f3 commit 2ef2288
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/github/system/auth/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public interface UserService extends IService<SysUser> {
boolean editSelfPassword(SysUserVo sysUserVo);

String encodePassword(String password);

boolean checkIfAdmin(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.system.auth.dao.SysUserDao;
import com.github.system.auth.entity.SysUser;
import com.github.system.auth.service.SysRoleService;
import com.github.system.auth.service.UserService;
import com.github.system.auth.util.SessionUtils;
import com.github.system.base.configuration.SystemBean;
import com.github.system.auth.vo.SysUserVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<SysUserDao, SysUser> implements UserService {

@Resource
private SystemBean systemBean;
@Resource
private SysRoleService roleService;

@Override
public SysUser findUserByUsername(String username) {
Expand Down Expand Up @@ -60,4 +64,10 @@ public String encodePassword(String password) {
return SecureUtil.md5(password + systemBean.getPwdSalt());
}

@Override
public boolean checkIfAdmin(Long userId) {
List<String> userRole = roleService.getUserRole(userId);
return userRole == null || !userRole.contains("ADMIN");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
import com.github.system.auth.vo.SysUserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

Expand All @@ -37,14 +34,20 @@ public Page<SysUser> page(@RequestBody Page<SysUser> page, @RequestBody SysUserV
}

@ApiOperation("删除")
@RequestMapping("/delete/{id}")
public AjaxResult delete(@PathVariable String id) {
@GetMapping("/delete/{id}")
public AjaxResult delete(@PathVariable Long id) {
if (userService.checkIfAdmin(id)) {
return AjaxResult.doError("不能删除管理员用户!");
}
return AjaxResult.status(userService.removeById(id));
}

@ApiOperation("更新")
@RequestMapping("/update")
public AjaxResult update(@RequestBody SysUserVo sysUserVo) {
if (userService.checkIfAdmin(sysUserVo.getId())) {
return AjaxResult.doError("不能修改管理员用户!");
}
return AjaxResult.status(userService.updateUser(sysUserVo));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class QuartzJobController {

@RequestMapping("/page")
@ApiOperation("定时任务调度分页查询")
public Page<SysQuartzJob> page(@RequestBody Page<SysQuartzJob> page, @RequestBody(required = false) SysQuartzJobVo sysQuartzJobVo) {
public Page<SysQuartzJob> page(@RequestBody Page<SysQuartzJob> page, SysQuartzJobVo sysQuartzJobVo) {
LambdaQueryWrapper<SysQuartzJob> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(StrUtil.isNotEmpty(sysQuartzJobVo.getJobName()), SysQuartzJob::getJobName, sysQuartzJobVo.getJobName());
lambdaQueryWrapper.eq(sysQuartzJobVo.getStatus() != null, SysQuartzJob::getStatus, sysQuartzJobVo.getStatus());
Expand Down

0 comments on commit 2ef2288

Please sign in to comment.