2 Commits
test ... gyj

Author SHA1 Message Date
GYJ
33b0c2bb10 员工账号重复校验 2024-11-22 10:10:52 +08:00
GYJ
d7ba8509d5 员工账号重复校验 2024-11-21 14:30:28 +08:00

View File

@@ -104,27 +104,8 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
@Override
@Transactional(rollbackFor = Exception.class)
public TbPlussShopStaffDto create(TbPlussShopStaff resources) {
if (org.apache.commons.lang3.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("手机号格式有误");
}
checkStaffParams(resources);
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());
//添加收银系统后台账号
@@ -175,6 +156,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
if (pattern.matcher(resources.getCode()).find()) {
throw new BadRequestException("员工编号不能包含中文");
}
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new);
User sysUser = userRepository.findByUsername(resources.getShopId()+"@"+tbPlussShopStaff.getAccount());
if(!tbPlussShopStaff.getAccount().equals(resources.getAccount())){
@@ -207,6 +189,33 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
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
@Transactional(rollbackFor = Exception.class)
public void updateStatus(TbPlussShopStaff resources) {