|
@@ -10,6 +10,7 @@ import shop.alien.entity.result.R;
|
|
|
import shop.alien.entity.store.LifeSys;
|
|
import shop.alien.entity.store.LifeSys;
|
|
|
import shop.alien.entity.store.UserLoginInfo;
|
|
import shop.alien.entity.store.UserLoginInfo;
|
|
|
import shop.alien.entity.store.dto.SystemUserAddDto;
|
|
import shop.alien.entity.store.dto.SystemUserAddDto;
|
|
|
|
|
+import shop.alien.entity.store.dto.SystemUserStatusDto;
|
|
|
import shop.alien.entity.store.vo.SystemLoginVo;
|
|
import shop.alien.entity.store.vo.SystemLoginVo;
|
|
|
import shop.alien.store.config.BaseRedisService;
|
|
import shop.alien.store.config.BaseRedisService;
|
|
|
import shop.alien.mapper.LifeSysMapper;
|
|
import shop.alien.mapper.LifeSysMapper;
|
|
@@ -185,6 +186,54 @@ public class SystemServiceImpl implements SystemService {
|
|
|
return R.fail("新增账号失败,请稍后重试");
|
|
return R.fail("新增账号失败,请稍后重试");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R<LifeSys> updateUserStatus(SystemUserStatusDto statusDto) {
|
|
|
|
|
+ // 校验用户ID
|
|
|
|
|
+ if (statusDto.getUserId() == null) {
|
|
|
|
|
+ return R.fail("用户ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 校验状态值
|
|
|
|
|
+ if (statusDto.getStatus() == null) {
|
|
|
|
|
+ return R.fail("状态值不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (statusDto.getStatus() != 0 && statusDto.getStatus() != 1) {
|
|
|
|
|
+ return R.fail("状态值只能是0(禁用)或1(启用)");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询用户是否存在
|
|
|
|
|
+ LifeSys lifeSys = lifeSysMapper.selectById(statusDto.getUserId());
|
|
|
|
|
+ if (lifeSys == null) {
|
|
|
|
|
+ return R.fail("用户不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 更新用户状态
|
|
|
|
|
+ lifeSys.setStatus(statusDto.getStatus());
|
|
|
|
|
+
|
|
|
|
|
+ // 如果提供了备注,也更新备注
|
|
|
|
|
+ if (StringUtils.hasText(statusDto.getRemark())) {
|
|
|
|
|
+ String currentRemark = lifeSys.getRemark();
|
|
|
|
|
+ String newRemark = statusDto.getRemark();
|
|
|
|
|
+ // 如果已有备注,追加新备注
|
|
|
|
|
+ if (StringUtils.hasText(currentRemark)) {
|
|
|
|
|
+ lifeSys.setRemark(currentRemark + " | " + newRemark);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ lifeSys.setRemark(newRemark);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 执行更新
|
|
|
|
|
+ int result = lifeSysMapper.updateById(lifeSys);
|
|
|
|
|
+ if (result > 0) {
|
|
|
|
|
+ // 清除密码信息,避免返回到前端
|
|
|
|
|
+ lifeSys.setUserPassword(null);
|
|
|
|
|
+ String statusText = statusDto.getStatus() == 1 ? "启用" : "禁用";
|
|
|
|
|
+ return R.data(lifeSys, "账号" + statusText + "成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.fail("修改状态失败,请稍后重试");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static String encryptToMD5(String input) {
|
|
public static String encryptToMD5(String input) {
|
|
|
try {
|
|
try {
|
|
|
// 获取 MD5 算法的 MessageDigest 实例
|
|
// 获取 MD5 算法的 MessageDigest 实例
|