创建用户账号和密码的长度限制
This commit is contained in:
parent
1f753ffa37
commit
a0a4789424
@ -85,6 +85,8 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
//上级部门为本租户顶级部门
|
//上级部门为本租户顶级部门
|
||||||
DeptRespDTO parentDept = deptApi.getDeptByParentId(0L);
|
DeptRespDTO parentDept = deptApi.getDeptByParentId(0L);
|
||||||
deptRespDTO.setParentId(parentDept.getId());
|
deptRespDTO.setParentId(parentDept.getId());
|
||||||
|
//所属企业ID为新增的企业ID
|
||||||
|
deptRespDTO.setCorpId(companyRespVO.getId());
|
||||||
Long deptId = deptApi.saveDept(deptRespDTO);
|
Long deptId = deptApi.saveDept(deptRespDTO);
|
||||||
/*3.新增企业管理员用户信息并配置角色*/
|
/*3.新增企业管理员用户信息并配置角色*/
|
||||||
UserDTO userDTO = new UserDTO();
|
UserDTO userDTO = new UserDTO();
|
||||||
|
@ -15,6 +15,10 @@ public class DeptRespDTO {
|
|||||||
* 部门编号
|
* 部门编号
|
||||||
*/
|
*/
|
||||||
private Long id;
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 所属企业ID
|
||||||
|
*/
|
||||||
|
private String corpId;
|
||||||
/**
|
/**
|
||||||
* 部门名称
|
* 部门名称
|
||||||
*/
|
*/
|
||||||
|
@ -24,7 +24,7 @@ public class AuthLoginReqVO {
|
|||||||
@Schema(description = "账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma")
|
@Schema(description = "账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma")
|
||||||
@NotEmpty(message = "登录账号不能为空")
|
@NotEmpty(message = "登录账号不能为空")
|
||||||
@Length(min = 4, max = 16, message = "账号长度为 4-16 位")
|
@Length(min = 4, max = 16, message = "账号长度为 4-16 位")
|
||||||
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
// @Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao")
|
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao")
|
||||||
|
@ -12,6 +12,9 @@ public class DeptRespVO {
|
|||||||
@Schema(description = "部门编号", example = "1024")
|
@Schema(description = "部门编号", example = "1024")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "所属企业ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||||
|
private String corpId;
|
||||||
|
|
||||||
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@ public class DeptSaveReqVO {
|
|||||||
@Schema(description = "部门编号", example = "1024")
|
@Schema(description = "部门编号", example = "1024")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "所属企业 ID", example = "1024")
|
||||||
|
private String corpId;
|
||||||
|
|
||||||
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||||
@NotBlank(message = "部门名称不能为空")
|
@NotBlank(message = "部门名称不能为空")
|
||||||
@Size(max = 30, message = "部门名称长度不能超过 30 个字符")
|
@Size(max = 30, message = "部门名称长度不能超过 30 个字符")
|
||||||
|
@ -28,6 +28,10 @@ public class DeptDO extends TenantBaseDO {
|
|||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 所属企业ID,可能为null
|
||||||
|
*/
|
||||||
|
private String corpId;
|
||||||
/**
|
/**
|
||||||
* 部门名称
|
* 部门名称
|
||||||
*/
|
*/
|
||||||
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
|
|||||||
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
|
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -49,7 +50,13 @@ public class DeptServiceImpl implements DeptService {
|
|||||||
createReqVO.setAncestors(validateParentDept(null, createReqVO.getParentId()));
|
createReqVO.setAncestors(validateParentDept(null, createReqVO.getParentId()));
|
||||||
// 校验部门名的唯一性
|
// 校验部门名的唯一性
|
||||||
validateDeptNameUnique(null, createReqVO.getParentId(), createReqVO.getName());
|
validateDeptNameUnique(null, createReqVO.getParentId(), createReqVO.getName());
|
||||||
|
if(StringUtils.isEmpty(createReqVO.getCorpId()) && !DeptDO.PARENT_ID_ROOT.equals(createReqVO.getParentId())){
|
||||||
|
//没有传企业ID,且不是最顶级部门,自动取上一节点的企业ID(如果有的话)
|
||||||
|
DeptDO parentDept = this.getDept(createReqVO.getParentId());
|
||||||
|
if(StringUtils.isNotEmpty(parentDept.getCorpId())){
|
||||||
|
createReqVO.setCorpId(parentDept.getCorpId());
|
||||||
|
}
|
||||||
|
}
|
||||||
// 插入部门
|
// 插入部门
|
||||||
DeptDO dept = BeanUtils.toBean(createReqVO, DeptDO.class);
|
DeptDO dept = BeanUtils.toBean(createReqVO, DeptDO.class);
|
||||||
deptMapper.insert(dept);
|
deptMapper.insert(dept);
|
||||||
|
Loading…
Reference in New Issue
Block a user