diff --git a/TODOs.md b/TODOs.md
index 70eaa01..83aa2be 100644
--- a/TODOs.md
+++ b/TODOs.md
@@ -1,18 +1,28 @@
还要做的部分
-【想一想访客怎么处理】
+小程序提审要做的:
小程序首页密码修改
+订单发货小程序端显示发货详情
+
+体温上报添加一个按钮 可以删除当日填报
+
+小程序扫门禁码之后门禁开门(扫码 websocket 推到门禁端),小程序端显示开门成功
+
+项目部署到服务器
+
+
+
+
+
+
小程序端用户头像
大门 人员进出 后台管理(进出日志)
后台订单管理页
-订单发货小程序端显示
-
-小程序扫门禁码之后门禁开门(扫码 websocket 推到门禁端)
门禁端左侧提示文字修改
@@ -20,9 +30,6 @@
后台管理 按照id进行筛选
-体温上报添加一个按钮 可以删除当日填报
-
-项目部署到服务器
& 演示时快速创建账号
& 小程序提审(提审时隐藏小商店 调试按钮、上帝按钮)
& 发给老班看一看
diff --git a/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/controller/UserController.java b/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/controller/UserController.java
index 1f1fe3c..9d6b9c4 100644
--- a/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/controller/UserController.java
+++ b/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/controller/UserController.java
@@ -99,7 +99,7 @@ public class UserController {
user = new User();
user.setId(null);
user.setUsername(UUID.randomUUID().toString().replace("-", "").substring(0, 10));
- user.setPassword(UUID.randomUUID().toString());
+ user.setPassword("");
user.setRealname("微信用户" + user.getUsername().substring(0, 5));
user.setRoleId(3);
user.setPermission("1");
@@ -127,6 +127,34 @@ public class UserController {
return userService.getUserById(id);
}
+ /**
+ * 修改密码的接口
+ *
+ * @param oldpwd
+ * @param newpwd
+ * @return
+ */
+ @PostMapping("/updatePwd")
+ @ResponseBody
+ public Res updatePwd(@RequestParam("userId") Integer userId,
+ @RequestParam("oldpwd") String oldpwd,
+ @RequestParam("newpwd") String newpwd) {
+ if (newpwd == null || Objects.equals(newpwd, "")) {
+ return Res.error("新密码不能为空");
+ }
+ if (oldpwd == null) {
+ oldpwd = "";
+ }
+ // 调用Service层的方法,传入旧密码和新密码
+ boolean result = userService.updatePwd(userId, oldpwd, newpwd);
+ // 根据结果返回响应
+ if (result) {
+ return Res.success("修改成功");
+ } else {
+ return Res.error("旧密码不正确,修改失败");
+ }
+ }
+
/**
* 获取用户列表
*
diff --git a/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/dao/UserDao.java b/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/dao/UserDao.java
index f8f42c8..4343caa 100644
--- a/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/dao/UserDao.java
+++ b/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/dao/UserDao.java
@@ -3,6 +3,7 @@ package com.cxyxiaomo.epp.user.dao;
import com.cxyxiaomo.epp.common.pojo.User;
import com.cxyxiaomo.epp.common.vo.UserVO;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@@ -15,6 +16,8 @@ public interface UserDao {
public boolean updateUser(User user);
+ public boolean updatePwd(@Param("id") Integer id, @Param("password") String password);
+
public User getUserById(Integer id);
User getUserByUsername(String username);
diff --git a/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/service/UserService.java b/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/service/UserService.java
index 336b8a9..858e2c5 100644
--- a/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/service/UserService.java
+++ b/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/service/UserService.java
@@ -3,10 +3,12 @@ package com.cxyxiaomo.epp.user.service;
import com.cxyxiaomo.epp.common.pojo.User;
import com.cxyxiaomo.epp.common.vo.UserVO;
import com.cxyxiaomo.epp.user.dao.UserDao;
+import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
+import java.util.Objects;
@Service
public class UserService {
@@ -47,4 +49,30 @@ public class UserService {
public boolean deleteUser(Integer userId) {
return userDao.deleteUserById(userId);
}
+
+ /**
+ * 修改密码的方法
+ *
+ * @param oldpwd
+ * @param newpwd
+ * @return
+ */
+ public boolean updatePwd(Integer userId, String oldpwd, String newpwd) {
+ // 获取当前登录的用户信息
+ User user = userDao.getUserById(userId);
+ // 创建一个密码加密器
+ String oldpwdHash = DigestUtils.sha512Hex(oldpwd);
+ // 判断旧密码是否匹配 (或者是未设置密码的初始用户)
+ if (Objects.equals(oldpwdHash, user.getPassword()) ||
+ (Objects.equals(oldpwd, "") && Objects.equals(user.getPassword(), ""))) {
+ // 如果匹配,对新密码进行加密
+ String newpwdHash = DigestUtils.sha512Hex(newpwd);
+ // 调用mapper层的方法,更新数据库中的密码
+ userDao.updatePwd(user.getId(), newpwdHash);
+ return true;
+ } else {
+ // 如果不匹配,返回false
+ return false;
+ }
+ }
}
diff --git a/backend/microservice-provider-user-8001/src/main/resources/mybatis/mapper/UserMapper.xml b/backend/microservice-provider-user-8001/src/main/resources/mybatis/mapper/UserMapper.xml
index 48a17c5..7ea904d 100644
--- a/backend/microservice-provider-user-8001/src/main/resources/mybatis/mapper/UserMapper.xml
+++ b/backend/microservice-provider-user-8001/src/main/resources/mybatis/mapper/UserMapper.xml
@@ -48,6 +48,11 @@
WHERE id = #{id}
+
+ UPDATE user
+ SET `password` = #{password}
+ WHERE id = #{id}
+