From 08f1b1f1804a8bd833d42f257908d80e88387b55 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期五, 14 三月 2025 11:27:47 +0800
Subject: [PATCH] 3.5增加登录验证、修改密码、人员列表调整

---
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/SystemUserServiceImpl.java |   39 ++++++++++++++++++++++++++++++++++-----
 1 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/SystemUserServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/SystemUserServiceImpl.java
index 4ae36d2..cbde55b 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/SystemUserServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/SystemUserServiceImpl.java
@@ -3,10 +3,14 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.panzhihua.common.exceptions.ServiceException;
+import com.panzhihua.common.model.vos.R;
+import com.panzhihua.common.model.vos.sangeshenbian.SystemUserVo;
 import com.panzhihua.common.utlis.StringUtils;
 import com.panzhihua.sangeshenbian.dao.SystemUserMapper;
 import com.panzhihua.sangeshenbian.model.entity.SystemUser;
 import com.panzhihua.sangeshenbian.model.vo.RegionVO;
+import com.panzhihua.sangeshenbian.model.vo.UpdatePasswordDTO;
 import com.panzhihua.sangeshenbian.service.ISystemUserService;
 import com.panzhihua.sangeshenbian.warpper.SystemUserList;
 import com.panzhihua.sangeshenbian.warpper.SystemUserListVo;
@@ -42,7 +46,7 @@
 	 * @return
 	 */
 	@Override
-	public Optional<SystemUser> getSystemUserByPhone(String phone) {
+	public Optional<SystemUser> getSystemUserAdminByPhone(String phone) {
 		if (StringUtils.isBlank(phone)) {
 			return Optional.empty();
 		}
@@ -50,10 +54,16 @@
 				.eq(SystemUser::getPhone, phone).ne(SystemUser::getStatus, 3)
 				.eq(SystemUser::getIsAdmin, 1).last("LIMIT 1").oneOpt();
 	}
-	
-	
-	
-	
+
+	@Override
+	public Optional<SystemUser> getSystemUserByPhone(String phone) {
+		if (StringUtils.isBlank(phone)) {
+			return Optional.empty();
+		}
+		return this.lambdaQuery()
+				.eq(SystemUser::getPhone, phone).ne(SystemUser::getStatus, 3).last("LIMIT 1").oneOpt();
+	}
+
 	/**
 	 * 获取行政区划数据
 	 *
@@ -88,4 +98,23 @@
 	public List<RegionVO> getCommunity(String streetId) {
 		return this.baseMapper.getCommunity(streetId);
 	}
+
+	/**
+	 * 修改密码
+	 * @param dto
+	 * @param systemUserVo
+	 */
+	@Override
+	public void updatePassword(UpdatePasswordDTO dto, SystemUserVo systemUserVo) {
+		if (systemUserVo == null) {
+			throw new ServiceException("用户不存在");
+		}
+		if (systemUserVo.getPassword().equals(dto.getNewPassword())) {
+			throw new ServiceException("新密码不能与旧密码相同");
+		}
+		if (!systemUserVo.getPassword().equals(dto.getOldPassword())) {
+			throw new ServiceException("旧密码错误");
+		}
+		this.lambdaUpdate().set(SystemUser::getPassword, dto.getNewPassword()).eq(SystemUser::getId, systemUserVo.getId()).update();
+	}
 }

--
Gitblit v1.7.1