diff --git a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/api/PageRequest.java b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/api/PageRequest.java index b64d85ef..3c65edcd 100644 --- a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/api/PageRequest.java +++ b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/api/PageRequest.java @@ -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.*; @@ -26,78 +27,76 @@ import java.util.Objects; @Builder public class PageRequest extends Request implements Serializable { - /** - * 分页大小 - */ - @Min(1) - @NotNull - private Integer pageSize; + /** + * 分页大小 + */ + @Min(1) + @NotNull + private Integer pageSize; - /** - * 当前页数 - */ - @Min(1) - @Max(100) - @NotNull - private Integer pageNum; + /** + * 当前页数 + */ + @Min(1) + @Max(100) + @NotNull + private Integer pageNum; - /** - * 排序 key为排序字段名 value为排序方向方向desc或者asc - */ - private Map sortMap; + /** + * 排序 key为排序字段名 value为排序方向方向desc或者asc + */ + private Map sortMap; + + /** + * 当前记录起始索引 默认值 + */ + public static final int DEFAULT_PAGE_NUM = 1; + + /** + * 每页显示记录数 默认值 + */ + public static final int DEFAULT_PAGE_SIZE = 20; - - /** - * 当前记录起始索引 默认值 - */ - public static final int DEFAULT_PAGE_NUM = 1; - - /** - * 每页显示记录数 默认值 - */ - public static final int DEFAULT_PAGE_SIZE = 20; - - - public static PageRequest of(T data) { - PageRequest pageRequest = new PageRequest<>(); - pageRequest.setPageSize(DEFAULT_PAGE_SIZE); - pageRequest.setPageNum(DEFAULT_PAGE_NUM); - pageRequest.setData(data); - pageRequest.setRequestId(String.valueOf(SnowflakeIdGeneratorUtil.getInstanceSnowflake().nextId())); - return pageRequest; - } - - public static PageRequest request2PageRequest(Request request) { - PageRequest pageRequest = new PageRequest<>(); - pageRequest.setData(request.getData()); - pageRequest.setPageNum(DEFAULT_PAGE_NUM); - pageRequest.setPageSize(DEFAULT_PAGE_SIZE); - pageRequest.setRequestId(request.getRequestId()); - return pageRequest; - } - - public PageRequest to(Class dtoClass) { - PageRequest pageRequest = new PageRequest<>(); - if(Objects.nonNull(getData())){ - pageRequest.setData(MapstructUtils.convert(getData(), dtoClass)); + public static PageRequest of(T data) { + PageRequest pageRequest = new PageRequest<>(); + pageRequest.setPageSize(DEFAULT_PAGE_SIZE); + pageRequest.setPageNum(DEFAULT_PAGE_NUM); + pageRequest.setData(data); + pageRequest.setRequestId(String.valueOf(SnowflakeIdGeneratorUtil.getInstanceSnowflake().nextId())); + return pageRequest; } - pageRequest.setPageNum(this.getPageNum()); - pageRequest.setPageSize(this.getPageSize()); - pageRequest.setRequestId(this.getRequestId()); - pageRequest.setSortMap(this.getSortMap()); - return pageRequest; - } - public Integer getPageSize() { - return pageSize == null ? DEFAULT_PAGE_SIZE : pageSize; - } + public static PageRequest request2PageRequest(Request request) { + PageRequest pageRequest = new PageRequest<>(); + pageRequest.setData(request.getData()); + pageRequest.setPageNum(DEFAULT_PAGE_NUM); + pageRequest.setPageSize(DEFAULT_PAGE_SIZE); + pageRequest.setRequestId(request.getRequestId()); + return pageRequest; + } - public Integer getPageNum() { - return pageNum == null ? DEFAULT_PAGE_NUM : pageNum; - } + public PageRequest to(Class dtoClass) { + PageRequest pageRequest = new PageRequest<>(); + if (Objects.nonNull(getData())) { + pageRequest.setData(MapstructUtils.convert(getData(), dtoClass)); + } + pageRequest.setPageNum(this.getPageNum()); + pageRequest.setPageSize(this.getPageSize()); + pageRequest.setRequestId(this.getRequestId()); + pageRequest.setSortMap(this.getSortMap()); + return pageRequest; + } - public Integer getOffset() { - return (getPageNum() - 1) * getPageSize(); - } + public Integer getPageSize() { + return pageSize == null ? DEFAULT_PAGE_SIZE : pageSize; + } + + public Integer getPageNum() { + return pageNum == null ? DEFAULT_PAGE_NUM : pageNum; + } + + public Integer getOffset() { + return (getPageNum() - 1) * getPageSize(); + } } diff --git a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/exception/BizException.java b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/exception/BizException.java index a917a79d..87e83942 100644 --- a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/exception/BizException.java +++ b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/exception/BizException.java @@ -38,6 +38,7 @@ public class BizException extends RuntimeException { public BizException(String message) { super(message); + this.message = message; this.code = ErrCode.SYSTEM_EXCEPTION.getKey(); } diff --git a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/exception/ViewException.java b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/exception/ViewException.java index 5a0def1d..ffb1b2e1 100644 --- a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/exception/ViewException.java +++ b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/exception/ViewException.java @@ -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) { diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysDeptDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysDeptDataImpl.java index 42ae3458..ebc38a95 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysDeptDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysDeptDataImpl.java @@ -62,7 +62,6 @@ public class SysDeptDataImpl implements ISysDeptData, IJPACommData 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())) diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java index 52d2deda..e9847220 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java @@ -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 tbSysMenuList; if (isSuperAdmin) { tbSysMenuList = jpaQueryFactory.select(tbSysMenu) + .from(tbSysMenu) .where(predicateBuilder.build()) .orderBy(tbSysMenu.parentId.asc(), tbSysMenu.orderNum.asc()).fetch(); } else { diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysOperLogDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysOperLogDataImpl.java index 43913d31..7c3fcac6 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysOperLogDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysOperLogDataImpl.java @@ -65,7 +65,12 @@ public class SysOperLogDataImpl implements ISysOperLogData, IJPACommData findAll(PageRequest 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 @@ -75,18 +80,18 @@ public class SysOperLogDataImpl implements ISysOperLogData, IJPACommData findAllByCondition(SysOperLog data) { - List ret=jpaQueryFactory.selectFrom(tbSysOperLog).where(buildQueryCondition(data)) + List ret = jpaQueryFactory.selectFrom(tbSysOperLog).where(buildQueryCondition(data)) .orderBy(tbSysOperLog.id.desc()).fetch(); return MapstructUtils.convert(ret, SysOperLog.class); } private Predicate buildQueryCondition(SysOperLog data) { return PredicateBuilder.instance() - .and(StringUtils.isNotBlank(data.getTitle()),()->tbSysOperLog.title.like(data.getTitle())) - .and(data.getBusinessType()!=null&&data.getBusinessType()>0,()->tbSysOperLog.businessType.eq(data.getBusinessType())) - .and(ArrayUtil.isNotEmpty(data.getBusinessTypes()),()->tbSysOperLog.businessType.in(Arrays.asList(data.getBusinessTypes()))) - .and(data.getStatus() != null && data.getStatus() > 0,()->tbSysOperLog.status.eq(data.getStatus())) - .and(StringUtils.isNotBlank(data.getOperName()),()->tbSysOperLog.operName.like(data.getOperName())) + .and(StringUtils.isNotBlank(data.getTitle()), () -> tbSysOperLog.title.like(data.getTitle())) + .and(data.getBusinessType() != null && data.getBusinessType() > 0, () -> tbSysOperLog.businessType.eq(data.getBusinessType())) + .and(ArrayUtil.isNotEmpty(data.getBusinessTypes()), () -> tbSysOperLog.businessType.in(Arrays.asList(data.getBusinessTypes()))) + .and(data.getStatus() != null && data.getStatus() > 0, () -> tbSysOperLog.status.eq(data.getStatus())) + .and(StringUtils.isNotBlank(data.getOperName()), () -> tbSysOperLog.operName.like(data.getOperName())) .build(); } } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysPostDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysPostDataImpl.java index 009f9cb5..4cf0eab1 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysPostDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysPostDataImpl.java @@ -57,12 +57,16 @@ public class SysPostDataImpl implements ISysPostData, IJPACommData findAll(PageRequest 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 public List selectPostListByUserId(Long userId) { - return jpaQueryFactory.select( tbSysPost.id) + return jpaQueryFactory.select(tbSysPost.id) .from(tbSysPost) .leftJoin(tbSysUserPost).on(tbSysUserPost.postId.eq(tbSysPost.id)) .leftJoin(tbSysUser).on(tbSysUser.id.eq(tbSysUserPost.userId)) @@ -73,9 +77,9 @@ public class SysPostDataImpl implements ISysPostData, IJPACommData selectPostList(SysPost post) { - List ret=jpaQueryFactory.selectFrom(tbSysPost).where(buildQueryCondition(post)) + List ret = jpaQueryFactory.selectFrom(tbSysPost).where(buildQueryCondition(post)) .orderBy(tbSysPost.postSort.asc()).fetch(); - return MapstructUtils.convert(ret,SysPost.class); + return MapstructUtils.convert(ret, SysPost.class); } @Override @@ -100,8 +104,8 @@ public class SysPostDataImpl implements ISysPostData, IJPACommDatatbSysPost.postCode.like(post.getPostCode())) - .and(StringUtils.isNotBlank(post.getPostName()),()->tbSysPost.postName.like(post.getPostName())) - .and(StringUtils.isNotBlank(post.getStatus()),()->tbSysPost.status.eq(post.getStatus())).build(); + .and(StringUtils.isNotBlank(post.getPostCode()), () -> tbSysPost.postCode.like(post.getPostCode())) + .and(StringUtils.isNotBlank(post.getPostName()), () -> tbSysPost.postName.like(post.getPostName())) + .and(StringUtils.isNotBlank(post.getStatus()), () -> tbSysPost.status.eq(post.getStatus())).build(); } } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleDataImpl.java index cd5147a4..6caab2a5 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysRoleDataImpl.java @@ -135,7 +135,12 @@ public class SysRoleDataImpl implements ISysRoleData, IJPACommData findAll(PageRequest 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 @@ -154,8 +159,8 @@ public class SysRoleDataImpl implements ISysRoleData, IJPACommData buildQueryTitle(Predicate predicate) { return jpaQueryFactory.select(Projections.fields(SysRole.class, tbSysRole.id, tbSysRole.roleName, - tbSysRole.roleKey, tbSysRole.roleSort, tbSysRole.menuCheckStrictly, tbSysRole.deptCheckStrictly, - tbSysRole.status, tbSysRole.delFlag, tbSysRole.createTime, tbSysRole.remark)) + tbSysRole.roleKey, tbSysRole.roleSort, tbSysRole.menuCheckStrictly, tbSysRole.deptCheckStrictly, + tbSysRole.status, tbSysRole.delFlag, tbSysRole.createTime, tbSysRole.remark)) .from(tbSysRole) .leftJoin(tbSysUserRole).on(tbSysUserRole.roleId.eq(tbSysRole.id)) .leftJoin(tbSysUser).on(tbSysUser.id.eq(tbSysUserRole.userId)) @@ -166,7 +171,6 @@ public class SysRoleDataImpl implements ISysRoleData, IJPACommData 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())) diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserDataImpl.java index 16a00d48..431018de 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysUserDataImpl.java @@ -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 sysRoles = sysRoleData.findByUserId(id); convert.setRoles(sysRoles); SysDept dept = sysDeptData.findById(convert.getDeptId()); - if(ObjectUtil.isNotNull(dept)){ + if (ObjectUtil.isNotNull(dept)) { convert.setDept(dept); } return convert; } + @Override public boolean checkEmailUnique(SysUser user) { final TbSysUser ret = jpaQueryFactory.select(tbSysUser).from(tbSysUser) @@ -175,13 +174,13 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData tbSysUser.deptId.eq(data.getDeptId())) .and(tbSysUser.delFlag.eq(UserConstants.ROLE_NORMAL)); QueryResults tbSysUserQueryResults = jpaQueryFactory.select(Projections.bean(TbSysUser.class, tbSysUser.id, tbSysUser.deptId, tbSysUser.userName, - tbSysUser.nickName, tbSysUser.email, tbSysUser.phonenumber, tbSysUser.createTime)).from(tbSysUser) + tbSysUser.nickName, tbSysUser.email, tbSysUser.phonenumber, tbSysUser.createTime)).from(tbSysUser) .leftJoin(tbSysDept).on(tbSysUser.deptId.eq(tbSysDept.id)) .leftJoin(tbSysUserRole).on(tbSysUser.id.eq(tbSysUserRole.userId)) .leftJoin(tbSysRole).on(tbSysUserRole.roleId.eq(tbSysRole.id)) @@ -234,7 +233,6 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData selectUnallocatedList(PageRequest to) { //TODO: 未分配用户列表 @@ -246,7 +244,7 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData tbSysUser.deptId.eq(data.getDeptId())) .and(tbSysUser.delFlag.eq(UserConstants.ROLE_NORMAL)); QueryResults sysUserQueryResults = jpaQueryFactory.select(Projections.bean(SysUser.class, tbSysUser.id, tbSysUser.deptId, tbSysUser.userName, - tbSysUser.nickName, tbSysUser.email, tbSysUser.phonenumber, tbSysUser.createTime)).from(tbSysUser) + tbSysUser.nickName, tbSysUser.email, tbSysUser.phonenumber, tbSysUser.createTime)).from(tbSysUser) .leftJoin(tbSysDept).on(tbSysUser.deptId.eq(tbSysDept.id)) .leftJoin(tbSysUserRole).on(tbSysUser.id.eq(tbSysUserRole.userId)) .leftJoin(tbSysRole).on(tbSysUserRole.roleId.eq(tbSysRole.id)) @@ -286,7 +284,7 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData ids; - if(Objects.nonNull(user)&&Objects.nonNull(user.getDeptId())){ + if (Objects.nonNull(user) && Objects.nonNull(user.getDeptId())) { Long deptId = user.getDeptId(); List depts = sysDeptData.findByDeptId(deptId); ids = StreamUtils.toList(depts, SysDept::getId); @@ -295,7 +293,6 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData 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())) diff --git a/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/core/BaseController.java b/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/core/BaseController.java index 1495d35c..43fd7dbf 100644 --- a/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/core/BaseController.java +++ b/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/core/BaseController.java @@ -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 void fail(T data) { diff --git a/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/handler/GlobalExceptionHandler.java b/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/handler/GlobalExceptionHandler.java index f4da4d00..c830f115 100644 --- a/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/handler/GlobalExceptionHandler.java +++ b/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/handler/GlobalExceptionHandler.java @@ -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; @@ -40,11 +41,15 @@ public class GlobalExceptionHandler { response.setStatus(403); return new RequestResult(403, "没有权限"); } - if (e instanceof BizException){ + 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); diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysRoleController.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysRoleController.java index 46432381..c462d79f 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysRoleController.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysRoleController.java @@ -47,7 +47,7 @@ public class SysRoleController extends BaseController { @ApiOperation(value = "获取角色信息列表", notes = "获取角色信息列表,根据查询条件分页") @SaCheckPermission("system:role:list") @PostMapping("/list") - public Paging list(PageRequest query) { + public Paging list(@RequestBody @Validated PageRequest 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 bo) { + SysRoleBo role = bo.getData(); roleService.checkRoleAllowed(role.getRoleId()); roleService.checkRoleDataScope(role.getRoleId()); roleService.updateRoleStatus(role.getRoleId(), role.getStatus()); diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysUserController.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysUserController.java index fb941a1b..b922b267 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysUserController.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysUserController.java @@ -70,7 +70,7 @@ public class SysUserController extends BaseController { @PostMapping("/export") public void export(@RequestBody @Validated(QueryGroup.class) Request req, HttpServletResponse response) { - SysUserBo user=req.getData(); + SysUserBo user = req.getData(); List list = userService.selectUserList(user); List listVo = MapstructUtils.convert(list, SysUserExportVo.class); ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response); @@ -123,13 +123,13 @@ public class SysUserController extends BaseController { /** * 根据用户编号获取详细信息 - *用户ID + * 用户ID */ @ApiOperation("根据用户编号获取详细信息") @SaCheckPermission("system:user:query") @PostMapping(value = {"/getDetail"}) - public SysUserInfoVo getInfo(@Validated @RequestBody Request req) { - Long userId = req.getData().getId(); + public SysUserInfoVo getInfo(@Validated @RequestBody Request req) { + Long userId = req.getData(); userService.checkUserDataScope(userId); SysUserInfoVo userInfoVo = new SysUserInfoVo(); List roles = roleService.selectRoleAll(); @@ -152,7 +152,7 @@ public class SysUserController extends BaseController { @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping("/add") public void add(@Validated(EditGroup.class) @RequestBody Request reqUser) { - SysUserBo user=reqUser.getData(); + SysUserBo user = reqUser.getData(); if (!userService.checkUserNameUnique(user)) { fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { @@ -177,7 +177,7 @@ public class SysUserController extends BaseController { @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PostMapping("/edit") public void edit(@Validated(EditGroup.class) @RequestBody Request reqUser) { - SysUserBo user=reqUser.getData(); + SysUserBo user = reqUser.getData(); userService.checkUserAllowed(user); userService.checkUserDataScope(user.getId()); if (!userService.checkUserNameUnique(user)) { @@ -192,7 +192,6 @@ public class SysUserController extends BaseController { /** * 删除用户 - * */ @ApiOperation("删除用户") @SaCheckPermission("system:user:remove") @@ -200,7 +199,7 @@ public class SysUserController extends BaseController { @PostMapping("/delete") public void remove(@Validated @RequestBody Request> bo) { List userIds = bo.getData(); - if (userIds.contains( LoginHelper.getUserId())) { + if (userIds.contains(LoginHelper.getUserId())) { fail("当前用户不能删除"); } userService.deleteUserByIds(userIds); @@ -213,8 +212,8 @@ public class SysUserController extends BaseController { @SaCheckPermission("system:user:resetPwd") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PostMapping("/resetPwd") - public void resetPwd(@RequestBody @Validated(EditGroup.class)Request reqUser) { - SysUserBo user=reqUser.getData(); + public void resetPwd(@RequestBody @Validated(EditGroup.class) Request reqUser) { + SysUserBo user = reqUser.getData(); userService.checkUserAllowed(user); userService.checkUserDataScope(user.getId()); user.setPassword(BCrypt.hashpw(user.getPassword())); @@ -228,8 +227,8 @@ public class SysUserController extends BaseController { @SaCheckPermission("system:user:edit") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PostMapping("/changeStatus") - public void changeStatus(@RequestBody @Validated(EditGroup.class)Request reqUser) { - SysUserBo user=reqUser.getData(); + public void changeStatus(@RequestBody @Validated(EditGroup.class) Request reqUser) { + SysUserBo user = reqUser.getData(); userService.checkUserAllowed(user); userService.checkUserDataScope(user.getId()); userService.updateUserStatus(user.getId(), user.getStatus()); @@ -255,15 +254,15 @@ public class SysUserController extends BaseController { /** * 用户授权角色 * - * @param reqUserId 用户Id - * @param roleIds 角色ID串 + * @param reqUserId 用户Id + * @param roleIds 角色ID串 */ @ApiOperation("用户授权角色") @SaCheckPermission("system:user:edit") @Log(title = "用户管理", businessType = BusinessType.GRANT) @PostMapping("/authRole") public void insertAuthRole(Request reqUserId, Long[] roleIds) { - Long userId=reqUserId.getData(); + Long userId = reqUserId.getData(); userService.checkUserDataScope(userId); userService.insertUserAuth(userId, roleIds); } diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/dto/vo/SysMenuVo.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/dto/vo/SysMenuVo.java index 65eab763..b57e1e44 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/dto/vo/SysMenuVo.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/dto/vo/SysMenuVo.java @@ -23,7 +23,7 @@ public class SysMenuVo implements Serializable { /** * 菜单ID */ - private Long menuId; + private Long id; /** * 菜单名称 diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysMenuServiceImpl.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysMenuServiceImpl.java index 1e0b2855..483762b5 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysMenuServiceImpl.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysMenuServiceImpl.java @@ -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())); diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysNoticeServiceImpl.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysNoticeServiceImpl.java index e0a413e0..f45c81ae 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysNoticeServiceImpl.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysNoticeServiceImpl.java @@ -27,7 +27,7 @@ import java.util.List; @Service public class SysNoticeServiceImpl implements ISysNoticeService { - private ISysNoticeData sysNoticeData; + private final ISysNoticeData sysNoticeData; @Override public Paging selectPageNoticeList( PageRequest query) { diff --git a/iot-starter/src/main/resources/application.yml b/iot-starter/src/main/resources/application.yml index 01e99ef5..28d5332d 100644 --- a/iot-starter/src/main/resources/application.yml +++ b/iot-starter/src/main/resources/application.yml @@ -11,7 +11,7 @@ spring: #注: 切换数据库时需要将项目根目录中的.init文件删除再重启 # <<=======内置H2数据库连接设置开始========== jpa: -# show-sql: true + show-sql: true hibernate: ddl-auto: update properties: