|
@@ -6,6 +6,7 @@ import cn.com.qmth.print.manage.enums.RoleMeta;
|
|
|
import cn.com.qmth.print.manage.service.PmSession;
|
|
|
import cn.com.qmth.print.manage.service.UserService;
|
|
|
import cn.com.qmth.print.manage.service.query.UserQuery;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.qmth.boot.api.annotation.Aac;
|
|
|
import com.qmth.boot.api.annotation.BOOL;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
@@ -93,15 +94,13 @@ public class UserController extends BaseController {
|
|
|
if (!RoleMeta.ADMIN.equals(requestUser.getRole())) {
|
|
|
throw new StatusException("只有管理员能重置密码");
|
|
|
}
|
|
|
-
|
|
|
- UserEntity db = userService.getById(userId);
|
|
|
- if (Objects.isNull(db)) {
|
|
|
- throw new StatusException("用户不存在");
|
|
|
- }
|
|
|
- db.setPassword(PmConstants.DEFAULT_PASSWORD);
|
|
|
- db.setPasswordCount(db.getPasswordCount() + 1);
|
|
|
- db.setUpdaterId(userId);
|
|
|
- db.setUpdateTime(new Date());
|
|
|
- userService.updateById(db);
|
|
|
+ UpdateWrapper<UserEntity> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.lambda()
|
|
|
+ .eq(UserEntity::getId, userId)
|
|
|
+ .set(UserEntity::getPassword, PmConstants.DEFAULT_PASSWORD)
|
|
|
+ .set(UserEntity::getPasswordCount, 0)
|
|
|
+ .set(UserEntity::getUpdaterId, userId)
|
|
|
+ .set(UserEntity::getUpdateTime, new Date());
|
|
|
+ userService.update(updateWrapper);
|
|
|
}
|
|
|
-}
|
|
|
+}
|