用户端更新个人秘密

hehai
mzh820631607 4 years ago
parent bc3b8dd9c9
commit 4fb4a33792
  1. 2
      src/main/java/com/msdw/tms/api/ClassTeachingApi.java
  2. 4
      src/main/java/com/msdw/tms/api/UserControllerApi.java
  3. 29
      src/main/java/com/msdw/tms/controller/UserController.java
  4. 2
      src/main/java/com/msdw/tms/entity/vo/UserEntityVo.java

@ -2,10 +2,8 @@ package com.msdw.tms.api;
import com.msdw.tms.common.utils.R; import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.ExperimentalTeachingEntity; import com.msdw.tms.entity.ExperimentalTeachingEntity;
import com.msdw.tms.entity.vo.ProjectRecordVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestParam;
@Api(value = "用户端班级实验", tags = "用户端班级实验信息") @Api(value = "用户端班级实验", tags = "用户端班级实验信息")
public interface ClassTeachingApi { public interface ClassTeachingApi {

@ -2,6 +2,7 @@ package com.msdw.tms.api;
import com.msdw.tms.common.utils.R; import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.UserEntity; import com.msdw.tms.entity.UserEntity;
import com.msdw.tms.entity.vo.UserEntityVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -14,4 +15,7 @@ public interface UserControllerApi {
@ApiOperation(value = "个人中心信息修改",notes = "个人中心信息修改") @ApiOperation(value = "个人中心信息修改",notes = "个人中心信息修改")
R update(UserEntity userEntity); R update(UserEntity userEntity);
@ApiOperation(value = "更新密码",notes = "更新密码")
R examinePassword(UserEntityVo entity);
} }

@ -1,5 +1,7 @@
package com.msdw.tms.controller; package com.msdw.tms.controller;
import cn.hutool.system.UserInfo;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.msdw.tms.api.UserControllerApi; import com.msdw.tms.api.UserControllerApi;
import com.msdw.tms.common.utils.PageUtils; import com.msdw.tms.common.utils.PageUtils;
import com.msdw.tms.common.utils.R; import com.msdw.tms.common.utils.R;
@ -7,6 +9,7 @@ import com.msdw.tms.entity.UserEntity;
import com.msdw.tms.entity.vo.UserEntityVo; import com.msdw.tms.entity.vo.UserEntityVo;
import com.msdw.tms.service.UserService; import com.msdw.tms.service.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays; import java.util.Arrays;
@ -78,6 +81,30 @@ public class UserController implements UserControllerApi {
return R.ok(); return R.ok();
} }
/**
* 校验密码
* @param entity 封装用户id和输入的原密码和新密码
* @return R 响应的状态信息
*/
@Override
@Transactional
@PostMapping("/examinePassword")
public R examinePassword(@RequestBody UserEntityVo entity){
Integer userid = entity.getUserid();//用户id
String password = entity.getPassword();//用户输入的当前密码
String newPassword = entity.getNewPassword();//获取用户输入的新密码
UserEntity byId = userService.getById(userid);//获取用户个人信息
UserEntity user = new UserEntity();//用于封装数据
if (password.equals(byId.getPassword())==true){
user.setUserid(userid).setPassword(newPassword);
boolean b = userService.updateById(user);
if (b==true){
return R.ok();
}else{return R.error("更新密码失败,请稍后重试");}
}else{
return R.error(403,"原密码错误,更新密码失败!!!");
}
}
} }

@ -35,5 +35,7 @@ public class UserEntityVo extends UserEntity implements Serializable {
private String professionalName; private String professionalName;
private List<UserEntity> user; private List<UserEntity> user;
//新密码
private String newPassword;
} }

Loading…
Cancel
Save