角色模板 添加重名问题
以及 修改权限报错问题
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
package com.czg.account.dto;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class RoleTemplateDTO {
|
||||
private Integer id;
|
||||
|
||||
@@ -273,8 +273,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
}
|
||||
long roleCount;
|
||||
if (role.getShopId() == null) {
|
||||
roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).ne(SysRole::getId, roleEditDTO.getId())
|
||||
.isNull(SysRole::getShopId).count();
|
||||
roleCount = 0;
|
||||
} else {
|
||||
roleCount = queryChain().eq(SysRole::getName, roleEditDTO.getName()).ne(SysRole::getId, roleEditDTO.getId())
|
||||
.eq(SysRole::getShopId, StpKit.USER.getShopId()).count();
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import com.czg.account.dto.RoleTemplateDTO;
|
||||
import com.czg.account.entity.SysRole;
|
||||
import com.czg.account.service.SysRoleService;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.account.mapper.SysRoleTemplateMapper;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
@@ -34,6 +35,10 @@ public class SysRoleTemplateServiceImpl extends ServiceImpl<SysRoleTemplateMappe
|
||||
SysRoleTemplate roleTemplate = BeanUtil.copyProperties(dto, SysRoleTemplate.class, "roleIdList");
|
||||
roleTemplate.setOpUser(StpKit.USER.getAccount());
|
||||
if (roleTemplate.getPid() != null) {
|
||||
boolean exists = exists(query().eq(SysRoleTemplate::getPid, roleTemplate.getPid()).eq(SysRoleTemplate::getName, roleTemplate.getName()));
|
||||
if (exists) {
|
||||
throw new CzgException("添加失败,该模板下已存在同名角色");
|
||||
}
|
||||
SysRole sysRole = new SysRole().setName(roleTemplate.getName()).setCreateUserId(StpKit.USER.getShopId());
|
||||
roleService.save(sysRole);
|
||||
roleTemplate.setRoleId(sysRole.getId());
|
||||
@@ -80,6 +85,10 @@ public class SysRoleTemplateServiceImpl extends ServiceImpl<SysRoleTemplateMappe
|
||||
@Override
|
||||
public Boolean editInfo(RoleTemplateDTO dto) {
|
||||
SysRoleTemplate roleTemplate = BeanUtil.copyProperties(dto, SysRoleTemplate.class);
|
||||
boolean exists = exists(query().eq(SysRoleTemplate::getPid, roleTemplate.getPid()).eq(SysRoleTemplate::getName, roleTemplate.getName()).ne(SysRoleTemplate::getId, roleTemplate.getId()));
|
||||
if (exists) {
|
||||
throw new CzgException("添加失败,已存在同名模板");
|
||||
}
|
||||
roleTemplate.setOpUser(StpKit.USER.getAccount());
|
||||
roleTemplate.setOpSysUserId(StpKit.USER.getLoginIdAsLong());
|
||||
return updateById(roleTemplate);
|
||||
|
||||
Reference in New Issue
Block a user