|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.boot.core.collection.PageResult;
|
|
|
import com.qmth.boot.core.exception.StatusException;
|
|
|
+import com.qmth.exam.reserve.bean.Constants;
|
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
|
import com.qmth.exam.reserve.bean.user.UserReq;
|
|
|
import com.qmth.exam.reserve.bean.user.UserSaveReq;
|
|
@@ -55,7 +56,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|
|
|
|
|
if (req.getId() == null) {
|
|
|
userEntity.setEnable(Boolean.TRUE);
|
|
|
- userEntity.setPassword(DigestUtils.sha256Hex("123456").toUpperCase());
|
|
|
+ userEntity.setPassword(DigestUtils.sha256Hex(Constants.DEFAULT_PASSWORD).toUpperCase());
|
|
|
this.save(userEntity);
|
|
|
} else {
|
|
|
this.updateById(userEntity);
|
|
@@ -64,28 +65,25 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|
|
|
|
|
@Override
|
|
|
public void resetPassword(Long id) {
|
|
|
- UserEntity userEntity = getById(id);
|
|
|
- if (userEntity == null) {
|
|
|
- log.error("[重置密码] 找不到用户记录:id:{}", id);
|
|
|
- throw new StatusException("重置失败");
|
|
|
- }
|
|
|
-
|
|
|
LambdaUpdateWrapper<UserEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.set(UserEntity::getPassword, DigestUtils.sha256Hex("123456").toUpperCase()).eq(UserEntity::getId, id);
|
|
|
+ updateWrapper.set(UserEntity::getPassword, DigestUtils.sha256Hex(Constants.DEFAULT_PASSWORD).toUpperCase());
|
|
|
+ updateWrapper.set(UserEntity::getFirstLogin, true);
|
|
|
+ updateWrapper.set(UserEntity::getUpdateTime, System.currentTimeMillis());
|
|
|
+ updateWrapper.eq(UserEntity::getId, id);
|
|
|
+
|
|
|
this.update(updateWrapper);
|
|
|
+ log.warn("重置用户密码!userId:{}", id);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void enable(Long id, Boolean enable) {
|
|
|
- UserEntity userEntity = getById(id);
|
|
|
- if (userEntity == null) {
|
|
|
- log.error("[启用/禁用] 找不到用户记录:id:{}", id);
|
|
|
- throw new StatusException("启用/禁用失败");
|
|
|
- }
|
|
|
-
|
|
|
LambdaUpdateWrapper<UserEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.set(UserEntity::getEnable, enable).eq(UserEntity::getId, id);
|
|
|
+ updateWrapper.set(UserEntity::getEnable, enable);
|
|
|
+ updateWrapper.set(UserEntity::getUpdateTime, System.currentTimeMillis());
|
|
|
+ updateWrapper.eq(UserEntity::getId, id);
|
|
|
+
|
|
|
this.update(updateWrapper);
|
|
|
+ log.warn("更新用户状态!userId:{} enable:{}", id, enable);
|
|
|
}
|
|
|
|
|
|
private void checkUser(UserSaveReq req) {
|