mirror of https://gitee.com/stylefeng/roses
管理员账号的一些修改
parent
e6251043b0
commit
44dcfcdd50
|
@ -51,17 +51,22 @@ public class DateValueValidator implements ConstraintValidator<DateValue, String
|
|||
@Override
|
||||
public boolean isValid(String dateValue, ConstraintValidatorContext context) {
|
||||
|
||||
// 如果是必填的
|
||||
if (required && StrUtil.isEmpty(dateValue)) {
|
||||
return false;
|
||||
if (StrUtil.isEmpty(dateValue)) {
|
||||
// 校验是不是必填
|
||||
if (required) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
// 校验日期格式
|
||||
DateUtil.parse(dateValue, format);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// 校验格式
|
||||
DateUtil.parse(dateValue, format);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package cn.stylefeng.roses.kernel.validator.api.validators.phone;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 校验手机号码格式
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/10/31 14:53
|
||||
*/
|
||||
@Documented
|
||||
@Constraint(validatedBy = PhoneValueValidator.class)
|
||||
@Target({ElementType.FIELD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface PhoneValue {
|
||||
|
||||
String message() default "手机号码格式不正确";
|
||||
|
||||
Class[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
|
||||
/**
|
||||
* 是否必填
|
||||
* <p>
|
||||
* 如果必填,在校验的时候本字段没值就会报错
|
||||
*/
|
||||
boolean required() default true;
|
||||
|
||||
@Target({ElementType.FIELD, ElementType.PARAMETER})
|
||||
@Retention(RUNTIME)
|
||||
@Documented
|
||||
@interface List {
|
||||
PhoneValue[] value();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.stylefeng.roses.kernel.validator.api.validators.phone;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
/**
|
||||
* 校验手机号是否为11位
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/10/31 14:53
|
||||
*/
|
||||
public class PhoneValueValidator implements ConstraintValidator<PhoneValue, String> {
|
||||
|
||||
private Boolean required;
|
||||
|
||||
@Override
|
||||
public void initialize(PhoneValue constraintAnnotation) {
|
||||
this.required = constraintAnnotation.required();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(String phoneValue, ConstraintValidatorContext context) {
|
||||
|
||||
if (StrUtil.isEmpty(phoneValue)) {
|
||||
if (required) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return phoneValue.length() == 11;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package cn.stylefeng.roses.kernel.system.api;
|
||||
|
||||
/**
|
||||
* 职位api
|
||||
*
|
||||
* @author linjinfeng
|
||||
* @date 2021/3/24 17:20
|
||||
*/
|
||||
public interface PositionServiceApi {
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package cn.stylefeng.roses.kernel.system.api.pojo.organization;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 系统职位表
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/11/04 11:05
|
||||
*/
|
||||
@Data
|
||||
public class HrPositionDTO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long positionId;
|
||||
|
||||
/**
|
||||
* 职位名称
|
||||
*/
|
||||
private String positionName;
|
||||
|
||||
/**
|
||||
* 职位编码
|
||||
*/
|
||||
private String positionCode;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private BigDecimal positionSort;
|
||||
|
||||
/**
|
||||
* 状态:1-启用,2-禁用
|
||||
*/
|
||||
private Integer statusFlag;
|
||||
|
||||
/**
|
||||
* 职位备注
|
||||
*/
|
||||
private String positionRemark;
|
||||
|
||||
/**
|
||||
* 删除标记:Y-已删除,N-未删除
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
}
|
|
@ -26,6 +26,7 @@ package cn.stylefeng.roses.kernel.system.api.pojo.user.request;
|
|||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import cn.stylefeng.roses.kernel.validator.api.validators.date.DateValue;
|
||||
import cn.stylefeng.roses.kernel.validator.api.validators.phone.PhoneValue;
|
||||
import cn.stylefeng.roses.kernel.validator.api.validators.status.StatusValue;
|
||||
import cn.stylefeng.roses.kernel.validator.api.validators.unique.TableUniqueValue;
|
||||
import lombok.Data;
|
||||
|
@ -34,7 +35,6 @@ import lombok.EqualsAndHashCode;
|
|||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -86,7 +86,6 @@ public class SysUserRequest extends BaseRequest {
|
|||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@NotBlank(message = "姓名不能为空", groups = {add.class, edit.class, updateInfo.class})
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
|
@ -98,7 +97,7 @@ public class SysUserRequest extends BaseRequest {
|
|||
/**
|
||||
* 生日
|
||||
*/
|
||||
@DateValue(message = "生日格式不正确", groups = {add.class, edit.class})
|
||||
@DateValue(required = false, message = "生日格式不正确", groups = {add.class, edit.class})
|
||||
private String birthday;
|
||||
|
||||
/**
|
||||
|
@ -116,8 +115,7 @@ public class SysUserRequest extends BaseRequest {
|
|||
/**
|
||||
* 手机
|
||||
*/
|
||||
@NotNull(message = "手机号码不能为空", groups = {add.class, edit.class, reg.class})
|
||||
@Size(min = 11, max = 11, message = "手机号码格式错误,不是11位", groups = {add.class, edit.class, reg.class})
|
||||
@PhoneValue(required = false, message = "手机号码格式错误", groups = {add.class, edit.class, reg.class})
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
|
@ -146,7 +144,6 @@ public class SysUserRequest extends BaseRequest {
|
|||
/**
|
||||
* 用户所属机构的职务
|
||||
*/
|
||||
@NotNull(message = "用户职务不能为空", groups = {add.class, edit.class})
|
||||
private Long positionId;
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,8 +25,9 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.organization.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrPosition;
|
||||
import cn.stylefeng.roses.kernel.system.api.PositionServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrPositionRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.organization.entity.HrPosition;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -37,7 +38,7 @@ import java.util.List;
|
|||
* @author chenjinlong
|
||||
* @date 2020/11/04 11:07
|
||||
*/
|
||||
public interface HrPositionService extends IService<HrPosition> {
|
||||
public interface HrPositionService extends IService<HrPosition>, PositionServiceApi {
|
||||
|
||||
/**
|
||||
* 添加职位
|
||||
|
|
|
@ -17,9 +17,11 @@
|
|||
suser.tel as tel,
|
||||
suser.status_flag as statusFlag,
|
||||
suorg.org_id as orgId,
|
||||
suorg.position_id as positionId
|
||||
suorg.position_id as positionId,
|
||||
hpos.position_name as positionName
|
||||
from sys_user suser
|
||||
left join sys_user_org suorg on suser.user_id = suorg.user_id
|
||||
left join hr_position hpos on suorg.position_id = hpos.position_id
|
||||
<where>
|
||||
<if test="sysUserRequest.realName != null and sysUserRequest.realName != ''">
|
||||
and suser.real_name like concat('%',#{sysUserRequest.realName},'%')
|
||||
|
@ -55,9 +57,11 @@
|
|||
suser.tel as tel,
|
||||
suser.status_flag as statusFlag,
|
||||
suorg.org_id as orgId,
|
||||
suorg.position_id as positionId
|
||||
suorg.position_id as positionId,
|
||||
hpos.position_name as positionName
|
||||
from sys_user suser
|
||||
left join sys_user_org suorg on suser.user_id = suorg.user_id
|
||||
left join hr_position hpos on suorg.position_id = hpos.position_id
|
||||
<where>
|
||||
<if test="sysUserRequest.realName != null and sysUserRequest.realName != ''">
|
||||
and suser.real_name like concat('%',#{sysUserRequest.realName},'%')
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.user.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.system.api.UserOrgServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserOrg;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.UserOrgRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserOrg;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -53,7 +53,17 @@ public interface SysUserOrgService extends IService<SysUserOrg>, UserOrgServiceA
|
|||
*
|
||||
* @param userId 用户id
|
||||
* @param orgId 机构id
|
||||
* @param positionId 部门id
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/26 12:52
|
||||
*/
|
||||
void add(Long userId, Long orgId);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param orgId 机构id
|
||||
* @param positionId 职位id
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/26 12:52
|
||||
*/
|
||||
|
@ -91,7 +101,17 @@ public interface SysUserOrgService extends IService<SysUserOrg>, UserOrgServiceA
|
|||
*
|
||||
* @param userId 用户id
|
||||
* @param orgId 机构id
|
||||
* @param positionId 部门id
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/26 12:52
|
||||
*/
|
||||
void edit(Long userId, Long orgId);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param orgId 机构id
|
||||
* @param positionId 职位id
|
||||
* @author chenjinlong
|
||||
* @date 2021/1/26 12:52
|
||||
*/
|
||||
|
|
|
@ -72,6 +72,14 @@ public class SysUserOrgServiceServiceImpl extends ServiceImpl<SysUserOrgMapper,
|
|||
this.save(sysUserOrg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Long userId, Long orgId) {
|
||||
SysUserOrg sysUserOrg = new SysUserOrg();
|
||||
sysUserOrg.setUserId(userId);
|
||||
sysUserOrg.setOrgId(orgId);
|
||||
this.save(sysUserOrg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Long userId, Long orgId, Long positionId) {
|
||||
SysUserOrg sysUserOrg = new SysUserOrg();
|
||||
|
@ -101,6 +109,17 @@ public class SysUserOrgServiceServiceImpl extends ServiceImpl<SysUserOrgMapper,
|
|||
this.updateById(sysUserOrg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void edit(Long userId, Long orgId) {
|
||||
|
||||
// 删除已有绑定的组织机构
|
||||
this.delByUserId(userId);
|
||||
|
||||
// 新增组织机构绑定
|
||||
this.add(userId, orgId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void edit(Long userId, Long orgId, Long positionId) {
|
||||
|
|
|
@ -169,7 +169,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
this.save(sysUser);
|
||||
|
||||
// 更新用户员工信息
|
||||
sysUserOrgService.add(sysUser.getUserId(), sysUserRequest.getOrgId(), sysUserRequest.getPositionId());
|
||||
if (null == sysUserRequest.getPositionId()) {
|
||||
sysUserOrgService.add(sysUser.getUserId(), sysUserRequest.getOrgId());
|
||||
}else {
|
||||
sysUserOrgService.add(sysUser.getUserId(), sysUserRequest.getOrgId(), sysUserRequest.getPositionId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -229,7 +233,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
Long sysUserId = sysUser.getUserId();
|
||||
|
||||
// 更新用户员工信息
|
||||
sysUserOrgService.edit(sysUserId, sysUserRequest.getOrgId(), sysUserRequest.getPositionId());
|
||||
if (null == sysUserRequest.getPositionId()) {
|
||||
sysUserOrgService.edit(sysUser.getUserId(), sysUserRequest.getOrgId());
|
||||
}else {
|
||||
sysUserOrgService.edit(sysUser.getUserId(), sysUserRequest.getOrgId(), sysUserRequest.getPositionId());
|
||||
}
|
||||
|
||||
// 清除缓存中的用户信息
|
||||
sysUserCacheOperatorApi.remove(String.valueOf(sysUserId));
|
||||
|
|
Loading…
Reference in New Issue