diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/IJPACommData.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/IJPACommData.java index e758ccd5..ee8a6743 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/IJPACommData.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/IJPACommData.java @@ -5,16 +5,12 @@ import cc.iotkit.common.api.Paging; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.ICommonData; import cc.iotkit.data.util.PageBuilder; -import cc.iotkit.data.util.PredicateBuilder; import cc.iotkit.model.Id; -import com.querydsl.core.types.Predicate; import org.springframework.data.domain.Example; import org.springframework.data.domain.Page; import org.springframework.data.jpa.repository.JpaRepository; -import java.lang.reflect.ParameterizedType; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Optional; diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysLogininfoDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysLogininfoDataImpl.java index c7705a48..90b846bc 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysLogininfoDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysLogininfoDataImpl.java @@ -1,16 +1,15 @@ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.StringUtils; import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysLogininforRepository; -import cc.iotkit.data.model.TbSysConfig; import cc.iotkit.data.model.TbSysLogininfor; import cc.iotkit.data.system.ISysLogininforData; import cc.iotkit.data.util.PageBuilder; import cc.iotkit.data.util.PredicateBuilder; -import cc.iotkit.model.system.SysConfig; import cc.iotkit.model.system.SysLogininfor; import com.querydsl.core.types.Predicate; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -20,7 +19,6 @@ import org.springframework.data.domain.Page; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; -import java.util.Collection; import java.util.List; import static cc.iotkit.data.model.QTbSysLogininfor.tbSysLogininfor; @@ -50,6 +48,11 @@ public class SysLogininfoDataImpl implements ISysLogininforData, IJPACommData findAll(PageRequest pageRequest) { + return PageBuilder.toPaging(logininfoRepository.findAll(genPredicate(pageRequest.getData()), PageBuilder.toPageable(pageRequest))); + } + @Override public List findByConditions(SysLogininfor data) { List ret=jpaQueryFactory.selectFrom(tbSysLogininfor).where(genPredicate(data)) @@ -81,10 +84,4 @@ public class SysLogininfoDataImpl implements ISysLogininforData, IJPACommData longs) { - logininfoRepository.deleteAllByIdInBatch(longs); - } } 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 59bf838d..4c80e33a 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 @@ -1,5 +1,6 @@ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.StringUtils; @@ -7,9 +8,11 @@ import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysOperLogRepository; import cc.iotkit.data.model.TbSysOperLog; import cc.iotkit.data.system.ISysOperLogData; +import cc.iotkit.data.util.PageBuilder; import cc.iotkit.data.util.PredicateBuilder; import cc.iotkit.model.system.SysOperLog; import cn.hutool.core.util.ArrayUtil; +import com.querydsl.core.types.Predicate; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Primary; @@ -17,7 +20,6 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import java.util.Arrays; -import java.util.Collection; import java.util.List; import static cc.iotkit.data.model.QTbSysOperLog.tbSysOperLog; @@ -56,27 +58,30 @@ public class SysOperLogDataImpl implements ISysOperLogData, IJPACommData findAll(PageRequest pageRequest) { + return PageBuilder.toPaging(operLogRepository.findAll(buildQueryCondition(pageRequest.getData()), PageBuilder.toPageable(pageRequest))); + } + @Override public void deleteAll() { operLogRepository.deleteAll(); } - - @Override - public void deleteByIds(Collection longs) { - operLogRepository.deleteAllByIdInBatch(longs); - } - @Override public List findAllByCondition(SysOperLog data) { - List ret=jpaQueryFactory.selectFrom(tbSysOperLog).where(PredicateBuilder.instance() + 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())) - .build()) - .orderBy(tbSysOperLog.id.desc()).fetch(); - return MapstructUtils.convert(ret, SysOperLog.class); + .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 adbfe2f8..c8b61676 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 @@ -1,13 +1,17 @@ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; +import cc.iotkit.common.api.Paging; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.StringUtils; import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysPostRepository; import cc.iotkit.data.model.TbSysPost; import cc.iotkit.data.system.ISysPostData; +import cc.iotkit.data.util.PageBuilder; import cc.iotkit.data.util.PredicateBuilder; import cc.iotkit.model.system.SysPost; +import com.querydsl.core.types.Predicate; import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; @@ -15,7 +19,6 @@ import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; -import java.util.Collection; import java.util.List; import java.util.Objects; @@ -48,8 +51,8 @@ public class SysPostDataImpl implements ISysPostData, IJPACommData findAll() { - return MapstructUtils.convert(postRepository.findAll(),SysPost.class); + public Paging findAll(PageRequest pageRequest) { + return PageBuilder.toPaging(postRepository.findAll(buildQueryCondition(pageRequest.getData()), PageBuilder.toPageable(pageRequest))); } @Override @@ -65,10 +68,7 @@ public class SysPostDataImpl implements ISysPostData, IJPACommData selectPostList(SysPost post) { - List ret=jpaQueryFactory.selectFrom(tbSysPost).where(PredicateBuilder.instance() - .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()) + List ret=jpaQueryFactory.selectFrom(tbSysPost).where(buildQueryCondition(post)) .orderBy(tbSysPost.postSort.asc()).fetch(); return MapstructUtils.convert(ret,SysPost.class); } @@ -93,21 +93,10 @@ public class SysPostDataImpl implements ISysPostData, IJPACommData longs) { - postRepository.deleteAllByIdInBatch(longs); + private Predicate buildQueryCondition(SysPost post) { + return PredicateBuilder.instance() + .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 449d9dc7..9397162a 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 @@ -1,11 +1,14 @@ 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.utils.MapstructUtils; import cc.iotkit.data.dao.IJPACommData; import cc.iotkit.data.dao.SysRoleRepository; import cc.iotkit.data.model.TbSysRole; import cc.iotkit.data.system.ISysRoleData; +import cc.iotkit.data.util.PageBuilder; import cc.iotkit.data.util.PredicateBuilder; import cc.iotkit.model.system.SysRole; import com.querydsl.core.types.Predicate; @@ -125,6 +128,11 @@ public class SysRoleDataImpl implements ISysRoleData, IJPACommData findAll(PageRequest pageRequest) { + return PageBuilder.toPaging(sysRoleRepository.findAll(buildQueryWrapper(pageRequest.getData()), PageBuilder.toPageable(pageRequest))); + } + @Override public List selectRoleList(SysRole role) { return buildQueryTitle(buildQueryWrapper(role)); 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 b9e99093..8f897db6 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 @@ -11,10 +11,12 @@ import cc.iotkit.data.dao.SysUserRepository; import cc.iotkit.data.model.TbSysUser; import cc.iotkit.data.system.ISysDeptData; import cc.iotkit.data.system.ISysUserData; +import cc.iotkit.data.util.PageBuilder; import cc.iotkit.data.util.PredicateBuilder; import cc.iotkit.model.system.SysDept; import cc.iotkit.model.system.SysUser; import cn.hutool.core.util.ObjectUtil; +import com.querydsl.core.types.Predicate; import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; @@ -22,7 +24,6 @@ import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; -import java.util.Collection; import java.util.List; import java.util.Objects; @@ -92,47 +93,37 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData findAll(PageRequest pageRequest) { + return PageBuilder.toPaging(userRepository.findAll(buildQueryCondition(pageRequest.getData()), PageBuilder.toPageable(pageRequest))); } - - - @Override - public SysUser save(SysUser sysUser) { - return MapstructUtils.convert(userRepository.save(MapstructUtils.convert(sysUser,TbSysUser.class)),SysUser.class); - } - - - @Override - public void deleteByIds(Collection collection) { - userRepository.deleteAllByIdInBatch(collection); - } - - - @Override public List findAllByCondition(SysUser user) { - List depts = sysDeptData.findByDeptId(user.getDeptId()); - List ids = StreamUtils.toList(depts, SysDept::getId); - ids.add(user.getDeptId()); - PredicateBuilder predicateBuilder = 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())) - .and(StringUtils.isNotEmpty(user.getPhonenumber()), () -> tbSysUser.phonenumber.like(user.getPhonenumber())) - .and(ObjectUtil.isNotNull(user.getDeptId()), () -> tbSysUser.deptId.in(ids)); + return buildQuery(buildQueryCondition(user)); + } + + private List buildQuery(Predicate predicate) { List users = jpaQueryFactory.select(Projections.bean(TbSysUser.class, tbSysUser.id, tbSysUser.deptId, tbSysUser.nickName, tbSysUser.userName, tbSysUser.email, tbSysUser.avatar, tbSysUser.phonenumber, tbSysUser.sex, tbSysUser.status, tbSysUser.delFlag, tbSysUser.loginIp, tbSysUser.loginDate, tbSysUser.createBy, tbSysUser.createTime, tbSysUser.remark, tbSysDept.deptName, tbSysDept.leader)) .from(tbSysUser) .leftJoin(tbSysDept).on(tbSysUser.deptId.eq(tbSysDept.id)) - .where(predicateBuilder.build()).fetch(); + .where(predicate).fetch(); return MapstructUtils.convert(users, SysUser.class); } + private Predicate buildQueryCondition(SysUser user) { + List depts = sysDeptData.findByDeptId(user.getDeptId()); + List ids = StreamUtils.toList(depts, SysDept::getId); + ids.add(user.getDeptId()); + 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())) + .and(StringUtils.isNotEmpty(user.getPhonenumber()), () -> tbSysUser.phonenumber.like(user.getPhonenumber())) + .and(ObjectUtil.isNotNull(user.getDeptId()), () -> tbSysUser.deptId.in(ids)).build(); + } } diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysPostController.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysPostController.java index 8eed0393..1dedd62d 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysPostController.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysPostController.java @@ -2,9 +2,12 @@ package cc.iotkit.system.controller; import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; +import cc.iotkit.common.api.Request; import cc.iotkit.common.excel.utils.ExcelUtil; import cc.iotkit.common.log.annotation.Log; import cc.iotkit.common.log.enums.BusinessType; +import cc.iotkit.common.validate.EditGroup; +import cc.iotkit.common.validate.QueryGroup; import cc.iotkit.common.web.core.BaseController; import cc.iotkit.system.dto.bo.SysPostBo; import cc.iotkit.system.dto.vo.SysPostVo; @@ -40,8 +43,8 @@ public class SysPostController extends BaseController { @ApiOperation("获取岗位列表") @SaCheckPermission("system:post:list") @PostMapping("/list") - public Paging list(SysPostBo post, PageRequest query) { - return postService.selectPagePostList(post, query); + public Paging list(@RequestBody @Validated(QueryGroup.class) PageRequest query) { + return postService.selectPagePostList(query); } /** @@ -51,8 +54,8 @@ public class SysPostController extends BaseController { @Log(title = "岗位管理", businessType = BusinessType.EXPORT) @SaCheckPermission("system:post:export") @PostMapping("/export") - public void export(SysPostBo post, HttpServletResponse response) { - List list = postService.selectPostList(post); + public void export(@RequestBody @Validated(QueryGroup.class) Request post, HttpServletResponse response) { + List list = postService.selectPostList(post.getData()); ExcelUtil.exportExcel(list, "岗位数据", SysPostVo.class, response); } @@ -64,8 +67,8 @@ public class SysPostController extends BaseController { @ApiOperation("根据岗位编号获取详细信息") @SaCheckPermission("system:post:query") @PostMapping(value = "/{postId}") - public SysPostVo getInfo(@PathVariable Long postId) { - return postService.selectPostById(postId); + public SysPostVo getInfo(@PathVariable Request postId) { + return postService.selectPostById(postId.getData()); } /** @@ -75,13 +78,13 @@ public class SysPostController extends BaseController { @SaCheckPermission("system:post:add") @Log(title = "岗位管理", businessType = BusinessType.INSERT) @PostMapping - public void add(@Validated @RequestBody SysPostBo post) { - if (!postService.checkPostNameUnique(post)) { - fail("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); - } else if (!postService.checkPostCodeUnique(post)) { - fail("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + public void add(@RequestBody @Validated(EditGroup.class)Request post) { + if (!postService.checkPostNameUnique(post.getData())) { + fail("新增岗位'" + post.getData().getPostName() + "'失败,岗位名称已存在"); + } else if (!postService.checkPostCodeUnique(post.getData())) { + fail("新增岗位'" + post.getData().getPostName() + "'失败,岗位编码已存在"); } - postService.insertPost(post); + postService.insertPost(post.getData()); } /** @@ -91,13 +94,13 @@ public class SysPostController extends BaseController { @SaCheckPermission("system:post:edit") @Log(title = "岗位管理", businessType = BusinessType.UPDATE) @PostMapping - public void edit(@Validated @RequestBody SysPostBo post) { - if (!postService.checkPostNameUnique(post)) { - fail("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); - } else if (!postService.checkPostCodeUnique(post)) { - fail("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); + public void edit(@RequestBody @Validated(EditGroup.class) Request post) { + if (!postService.checkPostNameUnique(post.getData())) { + fail("修改岗位'" + post.getData().getPostName() + "'失败,岗位名称已存在"); + } else if (!postService.checkPostCodeUnique(post.getData())) { + fail("修改岗位'" + post.getData().getPostName() + "'失败,岗位编码已存在"); } - postService.updatePost(post); + postService.updatePost(post.getData()); } /** @@ -109,8 +112,8 @@ public class SysPostController extends BaseController { @SaCheckPermission("system:post:remove") @Log(title = "岗位管理", businessType = BusinessType.DELETE) @PostMapping("/{postIds}") - public void remove(@PathVariable Collection postIds) { - postService.deletePostByIds(postIds); + public void remove(@PathVariable @Validated(EditGroup.class) Request postIds) { + postService.deletePostByIds(postIds.getData()); } /** 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 26420140..931be8d7 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 @@ -6,7 +6,6 @@ import cc.iotkit.common.excel.utils.ExcelUtil; import cc.iotkit.common.log.annotation.Log; import cc.iotkit.common.log.enums.BusinessType; import cc.iotkit.common.web.core.BaseController; - import cc.iotkit.model.system.SysUserRole; import cc.iotkit.system.dto.bo.SysDeptBo; import cc.iotkit.system.dto.bo.SysRoleBo; @@ -14,10 +13,10 @@ import cc.iotkit.system.dto.bo.SysUserBo; import cc.iotkit.system.dto.vo.DeptTreeSelectVo; import cc.iotkit.system.dto.vo.SysRoleVo; import cc.iotkit.system.dto.vo.SysUserVo; -import cn.dev33.satoken.annotation.SaCheckPermission; import cc.iotkit.system.service.ISysDeptService; import cc.iotkit.system.service.ISysRoleService; import cc.iotkit.system.service.ISysUserService; +import cn.dev33.satoken.annotation.SaCheckPermission; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -45,8 +44,8 @@ public class SysRoleController extends BaseController { */ @SaCheckPermission("system:role:list") @GetMapping("/list") - public Paging list(SysRoleBo role, PageRequest query) { - return roleService.selectPageRoleList(role, query); + public Paging list(PageRequest query) { + return roleService.selectPageRoleList(query); } /** 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 690f3197..c4dab754 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 @@ -2,6 +2,7 @@ package cc.iotkit.system.controller; import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; +import cc.iotkit.common.api.Request; import cc.iotkit.common.excel.core.ExcelResult; import cc.iotkit.common.excel.utils.ExcelUtil; import cc.iotkit.common.log.annotation.Log; @@ -12,6 +13,7 @@ import cc.iotkit.common.undefined.LoginUser; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.StreamUtils; import cc.iotkit.common.utils.StringUtils; +import cc.iotkit.common.validate.EditGroup; import cc.iotkit.common.validate.QueryGroup; import cc.iotkit.common.web.core.BaseController; import cc.iotkit.system.dto.bo.SysDeptBo; @@ -65,8 +67,9 @@ public class SysUserController extends BaseController { @Log(title = "用户管理", businessType = BusinessType.EXPORT) @SaCheckPermission("system:user:export") @PostMapping("/export") - public void export(@RequestBody @Validated(QueryGroup.class) SysUserBo user, + public void export(@RequestBody @Validated(QueryGroup.class) Request req, HttpServletResponse response) { + SysUserBo user=req.getData(); List list = userService.selectUserList(user); List listVo = MapstructUtils.convert(list, SysUserExportVo.class); ExcelUtil.exportExcel(listVo, "用户数据", SysUserExportVo.class, response); @@ -147,7 +150,8 @@ public class SysUserController extends BaseController { @SaCheckPermission("system:user:add") @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping - public void add(@Validated @RequestBody SysUserBo user) { + public void add(@Validated(EditGroup.class) @RequestBody Request reqUser) { + SysUserBo user=reqUser.getData(); if (!userService.checkUserNameUnique(user)) { fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { @@ -171,7 +175,8 @@ public class SysUserController extends BaseController { @SaCheckPermission("system:user:edit") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping - public void edit(@Validated @RequestBody SysUserBo user) { + public void edit(@Validated(EditGroup.class) @RequestBody Request reqUser) { + SysUserBo user=reqUser.getData(); userService.checkUserAllowed(user); userService.checkUserDataScope(user.getId()); if (!userService.checkUserNameUnique(user)) { @@ -207,7 +212,8 @@ public class SysUserController extends BaseController { @SaCheckPermission("system:user:resetPwd") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping("/resetPwd") - public void resetPwd(@RequestBody SysUserBo user) { + 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())); @@ -221,7 +227,8 @@ public class SysUserController extends BaseController { @SaCheckPermission("system:user:edit") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus") - public void changeStatus(@RequestBody SysUserBo user) { + 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()); @@ -247,14 +254,15 @@ public class SysUserController extends BaseController { /** * 用户授权角色 * - * @param userId 用户Id + * @param reqUserId 用户Id * @param roleIds 角色ID串 */ @ApiOperation("用户授权角色") @SaCheckPermission("system:user:edit") @Log(title = "用户管理", businessType = BusinessType.GRANT) @PutMapping("/authRole") - public void insertAuthRole(Long userId, Long[] roleIds) { + public void insertAuthRole(Request reqUserId, Long[] roleIds) { + Long userId=reqUserId.getData(); userService.checkUserDataScope(userId); userService.insertUserAuth(userId, roleIds); } @@ -265,7 +273,8 @@ public class SysUserController extends BaseController { @ApiOperation("获取部门树列表") @SaCheckPermission("system:user:list") @GetMapping("/deptTree") - public List> deptTree(SysDeptBo dept) { + public List> deptTree(@RequestBody @Validated(QueryGroup.class) Request reqDept) { + SysDeptBo dept=reqDept.getData(); return deptService.selectDeptTreeList(dept); } diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysPostService.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysPostService.java index 8099a7a7..fe079774 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysPostService.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysPostService.java @@ -16,7 +16,7 @@ import java.util.List; public interface ISysPostService { - Paging selectPagePostList(SysPostBo post, PageRequest query); + Paging selectPagePostList(PageRequest query); /** * 查询岗位信息集合 diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysRoleService.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysRoleService.java index 9987ae48..7185fe59 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysRoleService.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysRoleService.java @@ -17,7 +17,7 @@ import java.util.Set; public interface ISysRoleService { - Paging selectPageRoleList(SysRoleBo role, PageRequest query); + Paging selectPageRoleList(PageRequest query); /** * 根据条件分页查询角色数据 diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysPostServiceImpl.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysPostServiceImpl.java index 48a18a8f..eb576ee7 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysPostServiceImpl.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysPostServiceImpl.java @@ -26,7 +26,7 @@ public class SysPostServiceImpl implements ISysPostService { private final ISysPostData sysPostData; @Override - public Paging selectPagePostList(SysPostBo post, PageRequest query) { + public Paging selectPagePostList(PageRequest query) { return sysPostData.findAll(query.to(SysPost.class)).to(SysPostVo.class); } diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java index 4caca080..6641ea42 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java @@ -45,8 +45,8 @@ public class SysRoleServiceImpl implements ISysRoleService { private final ISysRoleDeptData iSysRoleDeptData; @Override - public Paging selectPageRoleList(SysRoleBo role, PageRequest query) { - return new Paging<>(); + public Paging selectPageRoleList(PageRequest query) { + return iSysRoleData.findAll(query.to(SysRole.class)).to(SysRoleVo.class); } /**