fix:系统管理相关接口报错修复
parent
8e41ad2711
commit
57e26656b4
|
@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.*;
|
||||
|
@ -46,8 +47,6 @@ public class PageRequest<T> extends Request<T> implements Serializable {
|
|||
*/
|
||||
private Map<String, String> sortMap;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 当前记录起始索引 默认值
|
||||
*/
|
||||
|
|
|
@ -38,6 +38,7 @@ public class BizException extends RuntimeException {
|
|||
|
||||
public BizException(String message) {
|
||||
super(message);
|
||||
this.message = message;
|
||||
this.code = ErrCode.SYSTEM_EXCEPTION.getKey();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ import lombok.EqualsAndHashCode;
|
|||
@Data
|
||||
public class ViewException extends RuntimeException {
|
||||
|
||||
public static final int CODE_FAILED = 0;
|
||||
public static final int CODE_WARN = 1;
|
||||
public static final int CODE_FAILED = 500;
|
||||
public static final int CODE_WARN = 601;
|
||||
|
||||
private int code;
|
||||
private String message;
|
||||
|
@ -25,6 +25,7 @@ public class ViewException extends RuntimeException {
|
|||
|
||||
public ViewException(String message) {
|
||||
super(message);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ViewException(int code, String message) {
|
||||
|
|
|
@ -62,7 +62,6 @@ public class SysDeptDataImpl implements ISysDeptData, IJPACommData<SysDept, Long
|
|||
@Override
|
||||
public List<SysDept> findDepts(SysDept dept) {
|
||||
PredicateBuilder predicateBuilder = PredicateBuilder.instance()
|
||||
.and(tbSysDept.delFlag.eq(UserConstants.USER_NORMAL))
|
||||
.and(ObjectUtil.isNotNull(dept.getId()), () -> tbSysDept.id.eq(dept.getId()))
|
||||
.and(ObjectUtil.isNotNull(dept.getParentId()), () -> tbSysDept.parentId.eq(dept.getParentId()))
|
||||
.and(StringUtils.isNotEmpty(dept.getDeptName()), () -> tbSysDept.deptName.like(dept.getDeptName()))
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.constant.UserConstants;
|
||||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
|
@ -112,6 +110,7 @@ public class SysMenuDataImpl implements ISysMenuData, IJPACommData<SysMenu, Long
|
|||
List<TbSysMenu> tbSysMenuList;
|
||||
if (isSuperAdmin) {
|
||||
tbSysMenuList = jpaQueryFactory.select(tbSysMenu)
|
||||
.from(tbSysMenu)
|
||||
.where(predicateBuilder.build())
|
||||
.orderBy(tbSysMenu.parentId.asc(), tbSysMenu.orderNum.asc()).fetch();
|
||||
} else {
|
||||
|
|
|
@ -65,7 +65,12 @@ public class SysOperLogDataImpl implements ISysOperLogData, IJPACommData<SysOper
|
|||
|
||||
@Override
|
||||
public Paging<SysOperLog> findAll(PageRequest<SysOperLog> pageRequest) {
|
||||
return PageBuilder.toPaging(operLogRepository.findAll(buildQueryCondition(pageRequest.getData()), PageBuilder.toPageable(pageRequest)));
|
||||
return PageBuilder.toPaging(
|
||||
operLogRepository.findAll(
|
||||
buildQueryCondition(pageRequest.getData()),
|
||||
PageBuilder.toPageable(pageRequest))
|
||||
, SysOperLog.class
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -57,7 +57,11 @@ public class SysPostDataImpl implements ISysPostData, IJPACommData<SysPost, Long
|
|||
|
||||
@Override
|
||||
public Paging<SysPost> findAll(PageRequest<SysPost> pageRequest) {
|
||||
return PageBuilder.toPaging(postRepository.findAll(buildQueryCondition(pageRequest.getData()), PageBuilder.toPageable(pageRequest)));
|
||||
return PageBuilder.toPaging(
|
||||
postRepository.findAll(
|
||||
buildQueryCondition(pageRequest.getData()), PageBuilder.toPageable(pageRequest))
|
||||
, SysPost.class
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -135,7 +135,12 @@ public class SysRoleDataImpl implements ISysRoleData, IJPACommData<SysRole, Long
|
|||
|
||||
@Override
|
||||
public Paging<SysRole> findAll(PageRequest<SysRole> pageRequest) {
|
||||
return PageBuilder.toPaging(sysRoleRepository.findAll(buildQueryWrapper(pageRequest.getData()), PageBuilder.toPageable(pageRequest)));
|
||||
return PageBuilder.toPaging(
|
||||
sysRoleRepository.findAll(
|
||||
buildQueryWrapper(pageRequest.getData()),
|
||||
PageBuilder.toPageable(pageRequest))
|
||||
, SysRole.class
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,7 +171,6 @@ public class SysRoleDataImpl implements ISysRoleData, IJPACommData<SysRole, Long
|
|||
|
||||
private Predicate buildQueryWrapper(SysRole role) {
|
||||
return PredicateBuilder.instance()
|
||||
.and(tbSysRole.delFlag.eq(UserConstants.ROLE_NORMAL))
|
||||
.and(Objects.nonNull(role.getId()), () -> tbSysRole.id.eq(role.getId()))
|
||||
.and(StringUtils.isNotBlank(role.getRoleName()), () -> tbSysRole.roleName.like(role.getRoleName()))
|
||||
.and(StringUtils.isNotBlank(role.getStatus()), () -> tbSysRole.roleName.eq(role.getStatus()))
|
||||
|
|
|
@ -21,7 +21,6 @@ import cc.iotkit.model.system.SysRole;
|
|||
import cc.iotkit.model.system.SysUser;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.querydsl.core.QueryResults;
|
||||
import com.querydsl.core.Tuple;
|
||||
import com.querydsl.core.types.Predicate;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
|
@ -75,7 +74,6 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
return SysUser.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long countByDeptId(Long aLong) {
|
||||
return 0;
|
||||
|
@ -115,6 +113,7 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
return convert;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEmailUnique(SysUser user) {
|
||||
final TbSysUser ret = jpaQueryFactory.select(tbSysUser).from(tbSysUser)
|
||||
|
@ -234,7 +233,6 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Paging<SysUser> selectUnallocatedList(PageRequest<SysUser> to) {
|
||||
//TODO: 未分配用户列表
|
||||
|
@ -295,7 +293,6 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
ids = null;
|
||||
}
|
||||
return PredicateBuilder.instance()
|
||||
.and(tbSysUser.delFlag.eq(UserConstants.USER_NORMAL))
|
||||
.and(ObjectUtil.isNotNull(user.getId()), () -> tbSysUser.id.eq(user.getId()))
|
||||
.and(StringUtils.isNotEmpty(user.getUserName()), () -> tbSysUser.userName.like(user.getUserName()))
|
||||
.and(StringUtils.isNotEmpty(user.getStatus()), () -> tbSysUser.status.eq(user.getStatus()))
|
||||
|
|
|
@ -16,7 +16,7 @@ public class BaseController {
|
|||
}
|
||||
|
||||
public static void fail(String msg) {
|
||||
throw new ViewException(msg);
|
||||
throw new ViewException(ViewException.CODE_FAILED, msg);
|
||||
}
|
||||
|
||||
public static <T> void fail(T data) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
package cc.iotkit.common.web.handler;
|
||||
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.exception.ViewException;
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.exception.NotPermissionException;
|
||||
import cn.dev33.satoken.exception.NotRoleException;
|
||||
|
@ -42,9 +43,13 @@ public class GlobalExceptionHandler {
|
|||
}
|
||||
if (e instanceof BizException) {
|
||||
BizException bizException = (BizException) e;
|
||||
response.setStatus(500);
|
||||
response.setStatus(200);
|
||||
return new RequestResult(bizException.getCode(), bizException.getMessage());
|
||||
}
|
||||
if (e instanceof ViewException) {
|
||||
response.setStatus(200);
|
||||
return new RequestResult(((ViewException) e).getCode(), e.getMessage());
|
||||
}
|
||||
|
||||
if (e.getMessage().contains("Unauthorized")) {
|
||||
response.setStatus(403);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class SysRoleController extends BaseController {
|
|||
@ApiOperation(value = "获取角色信息列表", notes = "获取角色信息列表,根据查询条件分页")
|
||||
@SaCheckPermission("system:role:list")
|
||||
@PostMapping("/list")
|
||||
public Paging<SysRoleVo> list(PageRequest<SysRoleBo> query) {
|
||||
public Paging<SysRoleVo> list(@RequestBody @Validated PageRequest<SysRoleBo> query) {
|
||||
return roleService.selectPageRoleList(query);
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,8 @@ public class SysRoleController extends BaseController {
|
|||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/changeStatus")
|
||||
public void changeStatus(@RequestBody SysRoleBo role) {
|
||||
public void changeStatus(@RequestBody Request<SysRoleBo> bo) {
|
||||
SysRoleBo role = bo.getData();
|
||||
roleService.checkRoleAllowed(role.getRoleId());
|
||||
roleService.checkRoleDataScope(role.getRoleId());
|
||||
roleService.updateRoleStatus(role.getRoleId(), role.getStatus());
|
||||
|
|
|
@ -128,8 +128,8 @@ public class SysUserController extends BaseController {
|
|||
@ApiOperation("根据用户编号获取详细信息")
|
||||
@SaCheckPermission("system:user:query")
|
||||
@PostMapping(value = {"/getDetail"})
|
||||
public SysUserInfoVo getInfo(@Validated @RequestBody Request<SysUserBo> req) {
|
||||
Long userId = req.getData().getId();
|
||||
public SysUserInfoVo getInfo(@Validated @RequestBody Request<Long> req) {
|
||||
Long userId = req.getData();
|
||||
userService.checkUserDataScope(userId);
|
||||
SysUserInfoVo userInfoVo = new SysUserInfoVo();
|
||||
List<SysRoleVo> roles = roleService.selectRoleAll();
|
||||
|
@ -192,7 +192,6 @@ public class SysUserController extends BaseController {
|
|||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
*/
|
||||
@ApiOperation("删除用户")
|
||||
@SaCheckPermission("system:user:remove")
|
||||
|
|
|
@ -23,7 +23,7 @@ public class SysMenuVo implements Serializable {
|
|||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
private Long menuId;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
|
|
|
@ -259,7 +259,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
return CollUtil.newArrayList();
|
||||
}
|
||||
return TreeBuildUtils.build(menus, (menu, tree) ->
|
||||
tree.setId(menu.getMenuId())
|
||||
tree.setId(menu.getId())
|
||||
.setParentId(menu.getParentId())
|
||||
.setName(menu.getMenuName())
|
||||
.setWeight(menu.getOrderNum()));
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.List;
|
|||
@Service
|
||||
public class SysNoticeServiceImpl implements ISysNoticeService {
|
||||
|
||||
private ISysNoticeData sysNoticeData;
|
||||
private final ISysNoticeData sysNoticeData;
|
||||
|
||||
@Override
|
||||
public Paging<SysNoticeVo> selectPageNoticeList( PageRequest<SysNoticeBo> query) {
|
||||
|
|
|
@ -11,7 +11,7 @@ spring:
|
|||
#注: 切换数据库时需要将项目根目录中的.init文件删除再重启
|
||||
# <<=======内置H2数据库连接设置开始==========
|
||||
jpa:
|
||||
# show-sql: true
|
||||
show-sql: true
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
properties:
|
||||
|
|
Loading…
Reference in New Issue