update:修改未写的分页函数
parent
03bab5d899
commit
031e01556c
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<Sy
|
|||
return TbSysLogininfor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<SysLogininfor> findAll(PageRequest<SysLogininfor> pageRequest) {
|
||||
return PageBuilder.toPaging(logininfoRepository.findAll(genPredicate(pageRequest.getData()), PageBuilder.toPageable(pageRequest)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysLogininfor> findByConditions(SysLogininfor data) {
|
||||
List<TbSysLogininfor> ret=jpaQueryFactory.selectFrom(tbSysLogininfor).where(genPredicate(data))
|
||||
|
@ -81,10 +84,4 @@ public class SysLogininfoDataImpl implements ISysLogininforData, IJPACommData<Sy
|
|||
logininfoRepository.deleteAll();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteByIds(Collection<Long> longs) {
|
||||
logininfoRepository.deleteAllByIdInBatch(longs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<SysOper
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<SysOperLog> findAll(PageRequest<SysOperLog> pageRequest) {
|
||||
return PageBuilder.toPaging(operLogRepository.findAll(buildQueryCondition(pageRequest.getData()), PageBuilder.toPageable(pageRequest)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll() {
|
||||
operLogRepository.deleteAll();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteByIds(Collection<Long> longs) {
|
||||
operLogRepository.deleteAllByIdInBatch(longs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysOperLog> findAllByCondition(SysOperLog data) {
|
||||
List<TbSysOperLog> ret=jpaQueryFactory.selectFrom(tbSysOperLog).where(PredicateBuilder.instance()
|
||||
List<TbSysOperLog> 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<SysPost, Long
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<SysPost> findAll() {
|
||||
return MapstructUtils.convert(postRepository.findAll(),SysPost.class);
|
||||
public Paging<SysPost> findAll(PageRequest<SysPost> pageRequest) {
|
||||
return PageBuilder.toPaging(postRepository.findAll(buildQueryCondition(pageRequest.getData()), PageBuilder.toPageable(pageRequest)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,10 +68,7 @@ public class SysPostDataImpl implements ISysPostData, IJPACommData<SysPost, Long
|
|||
|
||||
@Override
|
||||
public List<SysPost> selectPostList(SysPost post) {
|
||||
List<TbSysPost> 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<TbSysPost> 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<SysPost, Long
|
|||
return Objects.isNull(ret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SysPost findById(Long aLong) {
|
||||
return MapstructUtils.convert(postRepository.findById(aLong),SysPost.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysPost save(SysPost data) {
|
||||
postRepository.save(data.to(TbSysPost.class));
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(Collection<Long> 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<SysRole, Long
|
|||
return Integer.parseInt(execute + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<SysRole> findAll(PageRequest<SysRole> pageRequest) {
|
||||
return PageBuilder.toPaging(sysRoleRepository.findAll(buildQueryWrapper(pageRequest.getData()), PageBuilder.toPageable(pageRequest)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRole> selectRoleList(SysRole role) {
|
||||
return buildQueryTitle(buildQueryWrapper(role));
|
||||
|
|
|
@ -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<SysUser, Long
|
|||
return Objects.isNull(ret);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SysUser findById(Long aLong) {
|
||||
return MapstructUtils.convert(userRepository.findById(aLong),SysUser.class);
|
||||
public Paging<SysUser> findAll(PageRequest<SysUser> 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<Long> collection) {
|
||||
userRepository.deleteAllByIdInBatch(collection);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<SysUser> findAllByCondition(SysUser user) {
|
||||
List<SysDept> depts = sysDeptData.findByDeptId(user.getDeptId());
|
||||
List<Long> 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<SysUser> buildQuery(Predicate predicate) {
|
||||
List<TbSysUser> 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<SysDept> depts = sysDeptData.findByDeptId(user.getDeptId());
|
||||
List<Long> 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<SysPostVo> list(SysPostBo post, PageRequest<?> query) {
|
||||
return postService.selectPagePostList(post, query);
|
||||
public Paging<SysPostVo> list(@RequestBody @Validated(QueryGroup.class) PageRequest<SysPostBo> 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<SysPostVo> list = postService.selectPostList(post);
|
||||
public void export(@RequestBody @Validated(QueryGroup.class) Request<SysPostBo> post, HttpServletResponse response) {
|
||||
List<SysPostVo> 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<Long> 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<SysPostBo> 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<SysPostBo> 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<Collection> postIds) {
|
||||
postService.deletePostByIds(postIds.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<SysRoleVo> list(SysRoleBo role, PageRequest<?> query) {
|
||||
return roleService.selectPageRoleList(role, query);
|
||||
public Paging<SysRoleVo> list(PageRequest<SysRoleBo> query) {
|
||||
return roleService.selectPageRoleList(query);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<SysUserBo> req,
|
||||
HttpServletResponse response) {
|
||||
SysUserBo user=req.getData();
|
||||
List<SysUserVo> list = userService.selectUserList(user);
|
||||
List<SysUserExportVo> 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<SysUserBo> 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<SysUserBo> 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<SysUserBo> 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<SysUserBo> 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<Long> 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<Tree<Long>> deptTree(SysDeptBo dept) {
|
||||
public List<Tree<Long>> deptTree(@RequestBody @Validated(QueryGroup.class) Request<SysDeptBo> reqDept) {
|
||||
SysDeptBo dept=reqDept.getData();
|
||||
return deptService.selectDeptTreeList(dept);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.List;
|
|||
public interface ISysPostService {
|
||||
|
||||
|
||||
Paging<SysPostVo> selectPagePostList(SysPostBo post, PageRequest<?> query);
|
||||
Paging<SysPostVo> selectPagePostList(PageRequest<SysPostBo> query);
|
||||
|
||||
/**
|
||||
* 查询岗位信息集合
|
||||
|
|
|
@ -17,7 +17,7 @@ import java.util.Set;
|
|||
public interface ISysRoleService {
|
||||
|
||||
|
||||
Paging<SysRoleVo> selectPageRoleList(SysRoleBo role, PageRequest<?> query);
|
||||
Paging<SysRoleVo> selectPageRoleList(PageRequest<SysRoleBo> query);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
|
|
|
@ -26,7 +26,7 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||
private final ISysPostData sysPostData;
|
||||
|
||||
@Override
|
||||
public Paging<SysPostVo> selectPagePostList(SysPostBo post, PageRequest<?> query) {
|
||||
public Paging<SysPostVo> selectPagePostList(PageRequest<SysPostBo> query) {
|
||||
return sysPostData.findAll(query.to(SysPost.class)).to(SysPostVo.class);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
private final ISysRoleDeptData iSysRoleDeptData;
|
||||
|
||||
@Override
|
||||
public Paging<SysRoleVo> selectPageRoleList(SysRoleBo role, PageRequest<?> query) {
|
||||
return new Paging<>();
|
||||
public Paging<SysRoleVo> selectPageRoleList(PageRequest<SysRoleBo> query) {
|
||||
return iSysRoleData.findAll(query.to(SysRole.class)).to(SysRoleVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue