员工账号修改接口

This commit is contained in:
张松
2025-02-27 11:12:50 +08:00
parent eda74e2609
commit 9c2c35c5cf
2 changed files with 4 additions and 6 deletions

View File

@@ -29,7 +29,6 @@ public class ShopStaffEditDTO {
/** /**
* 登录账号 * 登录账号
*/ */
@NotEmpty(message = "账号不为空")
private String accountName; private String accountName;
/** /**
* 登录密码 * 登录密码
@@ -38,12 +37,10 @@ public class ShopStaffEditDTO {
/** /**
* 手机号 * 手机号
*/ */
@NotEmpty(message = "手机号不为空")
private String phone; private String phone;
/** /**
* 员工编号 * 员工编号
*/ */
@NotEmpty(message = "编号不为空")
private String code; private String code;
/** /**
* 优惠类型 1 折扣 0 金额 * 优惠类型 1 折扣 0 金额

View File

@@ -65,16 +65,16 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
sysUsersRolesService.updateRole(shopStaff.getId(), shopStaffEditDTO.getRoleId()); sysUsersRolesService.updateRole(shopStaff.getId(), shopStaffEditDTO.getRoleId());
} }
if (!"*******".equals(shopStaffEditDTO.getAccountPwd())) { if (StrUtil.isNotBlank(shopStaffEditDTO.getAccountPwd()) && !"*******".equals(shopStaffEditDTO.getAccountPwd())) {
sysUserService.updateSysUserPwd(shopStaff.getId(), shopStaffEditDTO.getAccountPwd()); sysUserService.updateSysUserPwd(shopStaff.getId(), shopStaffEditDTO.getAccountPwd());
} }
SysUser sysUser = sysUserService.getById(sysUserId); SysUser sysUser = sysUserService.getById(sysUserId);
if (!shopStaffEditDTO.getPhone().equals(sysUser.getPhone())) { if (StrUtil.isNotBlank(shopStaffEditDTO.getPhone()) && !shopStaffEditDTO.getPhone().equals(sysUser.getPhone())) {
sysUser.setPhone(shopStaffEditDTO.getPhone()); sysUser.setPhone(shopStaffEditDTO.getPhone());
} }
if (!shopStaffEditDTO.getAccountName().equals(sysUser.getAccount())) { if (StrUtil.isNotBlank(shopStaffEditDTO.getAccountName()) && !shopStaffEditDTO.getAccountName().equals(sysUser.getAccount())) {
long count = sysUserService.count(new QueryWrapper().eq(SysUser::getAccount, shopStaffEditDTO.getAccountName())); long count = sysUserService.count(new QueryWrapper().eq(SysUser::getAccount, shopStaffEditDTO.getAccountName()));
if (count > 0) { if (count > 0) {
throw new ApiNotPrintException("此账户名已存在"); throw new ApiNotPrintException("此账户名已存在");
@@ -84,6 +84,7 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
sysUserService.updateById(sysUser); sysUserService.updateById(sysUser);
shopStaffEditDTO.setCode(StrUtil.isBlank(shopStaffEditDTO.getCode()) ? null : shopStaffEditDTO.getCode());
BeanUtil.copyProperties(shopStaffEditDTO, shopStaff); BeanUtil.copyProperties(shopStaffEditDTO, shopStaff);
updateById(shopStaff); updateById(shopStaff);