diff --git a/src/main/java/com/msdw/tms/api/ClassTeachingApi.java b/src/main/java/com/msdw/tms/api/ClassTeachingApi.java index 2efe0bb..d93409b 100644 --- a/src/main/java/com/msdw/tms/api/ClassTeachingApi.java +++ b/src/main/java/com/msdw/tms/api/ClassTeachingApi.java @@ -2,10 +2,8 @@ package com.msdw.tms.api; import com.msdw.tms.common.utils.R; import com.msdw.tms.entity.ExperimentalTeachingEntity; -import com.msdw.tms.entity.vo.ProjectRecordVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.RequestParam; @Api(value = "用户端班级实验", tags = "用户端班级实验信息") public interface ClassTeachingApi { diff --git a/src/main/java/com/msdw/tms/api/UserControllerApi.java b/src/main/java/com/msdw/tms/api/UserControllerApi.java index 82a41ae..56c016a 100644 --- a/src/main/java/com/msdw/tms/api/UserControllerApi.java +++ b/src/main/java/com/msdw/tms/api/UserControllerApi.java @@ -2,6 +2,7 @@ package com.msdw.tms.api; import com.msdw.tms.common.utils.R; import com.msdw.tms.entity.UserEntity; +import com.msdw.tms.entity.vo.UserEntityVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -14,4 +15,7 @@ public interface UserControllerApi { @ApiOperation(value = "个人中心信息修改",notes = "个人中心信息修改") R update(UserEntity userEntity); + @ApiOperation(value = "更新密码",notes = "更新密码") + R examinePassword(UserEntityVo entity); + } diff --git a/src/main/java/com/msdw/tms/controller/UserController.java b/src/main/java/com/msdw/tms/controller/UserController.java index aff7cc1..7004e40 100644 --- a/src/main/java/com/msdw/tms/controller/UserController.java +++ b/src/main/java/com/msdw/tms/controller/UserController.java @@ -1,5 +1,7 @@ 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.common.utils.PageUtils; 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.service.UserService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.Arrays; @@ -78,6 +81,30 @@ public class UserController implements UserControllerApi { 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,"原密码错误,更新密码失败!!!"); + } + } } diff --git a/src/main/java/com/msdw/tms/entity/vo/UserEntityVo.java b/src/main/java/com/msdw/tms/entity/vo/UserEntityVo.java index fd3b76d..6b26c4a 100644 --- a/src/main/java/com/msdw/tms/entity/vo/UserEntityVo.java +++ b/src/main/java/com/msdw/tms/entity/vo/UserEntityVo.java @@ -35,5 +35,7 @@ public class UserEntityVo extends UserEntity implements Serializable { private String professionalName; private List user; + //新密码 + private String newPassword; }