fix:修复去重bug

V0.5.x
tangfudong 2023-06-13 18:07:27 +08:00
parent eb1e8fa0aa
commit e9cdaa031b
2 changed files with 6 additions and 4 deletions

View File

@ -163,7 +163,8 @@ public class SysRoleDataImpl implements ISysRoleData, IJPACommData<SysRole, Long
}
private List<SysRole> buildQueryTitle(Predicate predicate) {
return jpaQueryFactory.select(Projections.fields(SysRole.class, tbSysRole.id, tbSysRole.roleName,
return jpaQueryFactory.selectDistinct(tbSysRole.id)
.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))
.from(tbSysRole)
@ -176,6 +177,7 @@ 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()))

View File

@ -19,7 +19,6 @@ import cc.iotkit.system.dto.vo.SysUserVo;
import cc.iotkit.system.service.ISysUserService;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
@ -150,12 +149,13 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
@Override
public int insertUser(SysUserBo user) {
// 新增用户信息
int rows=sysUserData.save(user.to(SysUser.class))!=null?1:0;
SysUser newUser=sysUserData.save(user.to(SysUser.class));
user.setId(newUser.getId());
// 新增用户岗位关联
insertUserPost(user,false);
// 新增用户与角色管理
insertUserRole(user, false);
return rows;
return newUser!=null?1:0;
}
/**