员工账号重复校验
This commit is contained in:
parent
7a305e8901
commit
436a38afa7
|
|
@ -104,27 +104,8 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public TbPlussShopStaffDto create(TbPlussShopStaff resources) {
|
public TbPlussShopStaffDto create(TbPlussShopStaff resources) {
|
||||||
if (org.apache.commons.lang3.StringUtils.isBlank(resources.getAccount())) {
|
checkStaffParams(resources);
|
||||||
throw new BadRequestException("员工账号为空");
|
|
||||||
}
|
|
||||||
if (userRepository.findByUsername(resources.getShopId()+"@"+resources.getAccount()) != null) {
|
|
||||||
throw new BadRequestException("员工账号已存在");
|
|
||||||
}
|
|
||||||
if (!PhoneUtil.validator(resources.getPhone())){
|
|
||||||
throw new BadRequestException("手机号格式有误");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pattern.matcher(resources.getCode()).find()) {
|
|
||||||
throw new BadRequestException("员工编号不能包含中文");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resources.getRoleId()==null) {
|
|
||||||
throw new BadRequestException("请选择角色");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resources.getMaxDiscountAmount().compareTo(new BigDecimal(100000000L)) > 0) {
|
|
||||||
throw new BadRequestException("最大优惠金额过大");
|
|
||||||
}
|
|
||||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||||
|
|
||||||
//添加收银系统后台账号
|
//添加收银系统后台账号
|
||||||
|
|
@ -172,9 +153,8 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
||||||
resources.setPassword(null);
|
resources.setPassword(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pattern.matcher(resources.getCode()).find()) {
|
checkStaffParams(resources);
|
||||||
throw new BadRequestException("员工编号不能包含中文");
|
|
||||||
}
|
|
||||||
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new);
|
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new);
|
||||||
User sysUser = userRepository.findByUsername(resources.getShopId()+"@"+tbPlussShopStaff.getAccount());
|
User sysUser = userRepository.findByUsername(resources.getShopId()+"@"+tbPlussShopStaff.getAccount());
|
||||||
if(!tbPlussShopStaff.getAccount().equals(resources.getAccount())){
|
if(!tbPlussShopStaff.getAccount().equals(resources.getAccount())){
|
||||||
|
|
@ -207,6 +187,33 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
||||||
Integer.valueOf(resources.getShopId()), resources.getId(), resources.getPermissions());
|
Integer.valueOf(resources.getShopId()), resources.getId(), resources.getPermissions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkStaffParams(TbPlussShopStaff resources) {
|
||||||
|
if (StringUtils.isBlank(resources.getAccount())) {
|
||||||
|
throw new BadRequestException("员工账号为空");
|
||||||
|
}
|
||||||
|
if (userRepository.findByUsername(resources.getShopId()+"@"+resources.getAccount()) != null) {
|
||||||
|
throw new BadRequestException("员工账号已存在");
|
||||||
|
}
|
||||||
|
if (!PhoneUtil.validator(resources.getPhone())){
|
||||||
|
throw new BadRequestException("手机号格式有误");
|
||||||
|
}
|
||||||
|
if (tbPlussShopStaffRepository.queryByAccount(resources.getAccount(),resources.getShopId()) != null) {
|
||||||
|
throw new BadRequestException("账号已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pattern.matcher(resources.getCode()).find()) {
|
||||||
|
throw new BadRequestException("员工编号不能包含中文");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resources.getRoleId()==null) {
|
||||||
|
throw new BadRequestException("请选择角色");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resources.getMaxDiscountAmount().compareTo(new BigDecimal(100000000L)) > 0) {
|
||||||
|
throw new BadRequestException("最大优惠金额过大");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateStatus(TbPlussShopStaff resources) {
|
public void updateStatus(TbPlussShopStaff resources) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue