From e1357ea1af1a473dc9fa93be458fd1578885630c Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 05 十二月 2023 17:29:52 +0800
Subject: [PATCH] 1、用户增加所属片区外键ID; 2、修改重置密码的方法名;

---
 pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserCtrl.java |   23 ++++++-----
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaUser.java            |   14 +++++++
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml                      |   43 +++++++++++++++------
 pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java   |    6 +-
 4 files changed, 60 insertions(+), 26 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaUser.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaUser.java
index bb7bf2a..73270a4 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaUser.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaUser.java
@@ -55,6 +55,12 @@
     @Schema(description = "瀹炰綋id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
     public Long id;
 
+
+    @Schema(description = "鎵�灞炵墖鍖篒D", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
+    @JSONField(serializeUsing= ObjectWriterImplToString.class)
+    @TableField(value = "blockId")
+    public Long blockId ;
+
     /**
      * 鐢ㄦ埛濮撳悕
      */
@@ -120,6 +126,14 @@
     /**
      * 鐢ㄦ埛鎵�灞炶鑹睮d
      */
+    @Schema(hidden = true)
     @TableField(exist = false)
     public String[] roleIds ;
+
+    /**
+     * 鎵�灞炵墖鍖哄悕绉�
+     */
+    @Schema(description = "鎵�灞炵墖鍖哄悕绉帮紝琛ㄥ崟涓嶇敤濉啓", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
+    @TableField(exist = false)
+    public String blockName ;
 }
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml
index e2c99bc..4aa5498 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml
@@ -7,6 +7,7 @@
         <!--@mbg.generated-->
         <!--@Table ba_user-->
         <id property="id" column="id" />
+        <result property="blockId" column="blockId"/>
         <result property="name" column="name"/>
         <result property="phone" column="phone"/>
         <result property="password" column="password"/>
@@ -29,6 +30,7 @@
 
     <resultMap id="loginResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaUser">
         <id property="id" column="id" />
+        <result property="blockId" column="blockId"/>
         <result property="name" column="name"/>
         <result property="phone" column="phone"/>
         <result property="orgTag" column="orgTag"/>
@@ -40,15 +42,15 @@
     </resultMap>
 
     <sql id="Base_Column_List">
-        id, name, phone, password, orgTag, supperAdmin, disabled, deleted
+        id, blockId, name, phone, password, orgTag, supperAdmin, disabled, deleted
     </sql>
 
     <sql id="part_Column_List">
-        id, name, phone, disabled
+        ${alias}.id, ${alias}.name, ${alias}.phone, ${alias}.disabled
     </sql>
 
     <sql id="Login_Column_List">
-        id, name, phone, orgTag, supperAdmin
+        id, blockId, name, phone, orgTag, supperAdmin
     </sql>
 
     <select id="login" resultMap="loginResultMap" >
@@ -61,7 +63,8 @@
     <select id="selectTotal" parameterType="java.util.Map" resultType="java.lang.Long">
         select
         count(*)
-        from ba_user where supperAdmin!=1 and deleted!=1
+        from ba_user
+        where supperAdmin!=1 and deleted!=1
         <trim prefix="and" suffixOverrides="and">
             <if test="name != null">
                 name like concat('%', #{name}, '%') and
@@ -73,14 +76,19 @@
     </select>
     <select id="selectSome" parameterType="java.util.Map" resultMap="someResultMap">
         select
-        <include refid="part_Column_List" />
-        from ba_user where supperAdmin!=1 and deleted!=1
+        <include refid="part_Column_List" >
+            <property name="alias" value="bu"/>
+        </include>,
+        bb.`name` blockName
+        from ba_user bu
+        left join ba_block bb on bu.blockId = bb.id
+        where bu.supperAdmin!=1 and bu.deleted!=1
         <trim prefix="and" suffixOverrides="and">
             <if test="name != null">
-                name like concat('%', #{name}, '%') and
+                bu.name like concat('%', #{name}, '%') and
             </if>
             <if test="phone != null">
-                phone = #{phone,jdbcType=VARCHAR}
+                bu.phone = #{phone,jdbcType=VARCHAR}
             </if>
         </trim>
         order by id DESC
@@ -93,6 +101,7 @@
     <insert id="putin" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser">
         insert into ba_user (<include refid="Base_Column_List" />)
         values (#{id,jdbcType=BIGINT},
+        #{blockId,jdbcType=BIGINT},
         #{name,jdbcType=VARCHAR},
         #{phone,jdbcType=VARCHAR},
         #{password,jdbcType=VARCHAR},
@@ -108,7 +117,10 @@
             <if test="id != null">
                 id,
             </if>
-            <if test="name != null">
+            <if test="blockId != null">
+                blockId,
+            </if>
+           <if test="name != null">
                 `name`,
             </if>
             <if test="phone != null">
@@ -134,7 +146,10 @@
             <if test="id != null">
                 #{id,jdbcType=BIGINT},
             </if>
-            <if test="name != null">
+            <if test="blockId != null">
+                #{blockId,jdbcType=BIGINT},
+            </if>
+           <if test="name != null">
                 #{name,jdbcType=VARCHAR},
             </if>
             <if test="phone != null">
@@ -161,7 +176,10 @@
     <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser">
         update ba_user
         <set>
-            <if test="name != null">
+            <if test="blockId != null">
+                blockId = #{blockId,jdbcType=BIGINT},
+            </if>
+           <if test="name != null">
                 `name` = #{name,jdbcType=VARCHAR},
             </if>
             <if test="phone != null">
@@ -181,7 +199,8 @@
     </update>
     <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser">
         update ba_user
-        set `name` = #{name,jdbcType=VARCHAR},
+        set blockId = #{blockId,jdbcType=BIGINT},
+        `name` = #{name,jdbcType=VARCHAR},
         phone = #{phone,jdbcType=VARCHAR},
         password = #{password,jdbcType=VARCHAR},
         disabled = #{disabled,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT},
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserCtrl.java
index 3bfc625..dec9d8a 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserCtrl.java
@@ -115,7 +115,6 @@
         }
         po.id = null;
         int count;
-        int count1;
         try {
             po.disabled = Disabled.NO;//榛樿涓嶇鐢�
             po.deleted = Deleted.NO;//榛樿涓嶅垹闄�
@@ -130,12 +129,12 @@
                 po.password = MD5.encrypt(defaultPassword);
             }
             count = this.sv.save(po);
-            count1 = this.sv.setRoles(String.valueOf(po.id), po.roleIds);
+            this.sv.setRoles(po.id, po.roleIds);
         } catch (Exception e) {
             log.error("淇濆瓨鐢ㄦ埛寮傚父", e);
             return BaseResponseUtils.buildException(e.getMessage());
         }
-        if (count <= 0 || count1 <= 0) {
+        if (count <= 0) {
             return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
         } else {
             return BaseResponseUtils.buildSuccess(true);
@@ -171,6 +170,7 @@
             po.deleted = null;//璁剧疆涓簄ull锛屼笉鍋氭洿鏂�
             po.orgTag = null;//璁剧疆涓簄ull锛屼笉鍋氭洿鏂�
             count = this.sv.update(po);
+            this.sv.setRoles(po.id, po.roleIds);
         } catch (Exception e) {
             log.error("淇濆瓨鐢ㄦ埛寮傚父", e);
             return BaseResponseUtils.buildException(e.getMessage());
@@ -250,7 +250,7 @@
      * @param id 鐢ㄦ埛ID
      * @return 鏄惁鎴愬姛
      */
-    @Operation(summary = "閲嶇疆瀵嗙爜", description = "鎻愪氦鐢ㄦ埛ID")
+    @Operation(summary = "閲嶇疆瀵嗙爜涓洪粯璁ゅ瘑鐮�", description = "鎻愪氦鐢ㄦ埛ID")
     @ApiResponses(value = {
             @ApiResponse(
                     responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
@@ -259,9 +259,9 @@
                             schema = @Schema(implementation = Boolean.class))}
             )
     })
-    @GetMapping(path = "resetPassword", consumes = MediaType.TEXT_PLAIN_VALUE)
+    @GetMapping(path = "resetPasswordByDefault", consumes = MediaType.TEXT_PLAIN_VALUE)
     @SsoAop("-1")//@SsoAop(power = "-1")
-    public BaseResponse<Boolean> resetPassword(@Parameter(description = "瀹炰綋id", required = true) String id) throws Exception {
+    public BaseResponse<Boolean> resetPasswordByDefault(@Parameter(description = "瀹炰綋id", required = true) String id) throws Exception {
         if (id == null) {
             return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖");
         }
@@ -292,7 +292,7 @@
      * @param id 鐢ㄦ埛ID
      * @return 鏄惁鎴愬姛
      */
-    @Operation(summary = "閲嶇疆瀵嗙爜", description = "鎻愪氦鐢ㄦ埛ID")
+    @Operation(summary = "閲嶇疆瀵嗙爜涓洪殢鏈烘暟瀛楀姞瀛楁瘝", description = "鎻愪氦鐢ㄦ埛ID")
     @ApiResponses(value = {
             @ApiResponse(
                     responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
@@ -301,9 +301,9 @@
                             schema = @Schema(implementation = Boolean.class))}
             )
     })
-    @GetMapping(path = "resetPassword1", consumes = MediaType.TEXT_PLAIN_VALUE)
+    @GetMapping(path = "resetPasswordByRandom", consumes = MediaType.TEXT_PLAIN_VALUE)
     @SsoAop("-1")//@SsoAop(power = "-1")
-    public BaseResponse<String> resetPassword1(@Parameter(description = "瀹炰綋id", required = true) String id) throws Exception {
+    public BaseResponse<String> resetPasswordByRandom(@Parameter(description = "瀹炰綋id", required = true) String id) throws Exception {
         if (id == null) {
             return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖");
         }
@@ -331,11 +331,12 @@
 
 
     /**
+     * 2023-12-05 鍦� save鍜寀pdate鏂规硶涓繘琛屼簡瑙掕壊璁剧疆鍏宠仈锛屾湰鏂规硶搴熷純
      * 璁剧疆鐢ㄦ埛瑙掕壊
      *
      * @param id 鐢ㄦ埛ID
      * @return 鏄惁鎴愬姛
-     */
+
     @Operation(summary = "璁剧疆鐢ㄦ埛瑙掕壊", description = "鎻愪氦鐢ㄦ埛ID锛屽強鎵�閫夋嫨鐨勮鑹睮D闆嗗悎锛堟暟缁勶級")
     @ApiResponses(value = {
             @ApiResponse(
@@ -365,7 +366,7 @@
         }
         return BaseResponseUtils.buildSuccess(true);
     }
-
+     */
 
     /**
      * 鍒犻櫎鐢ㄦ埛
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
index 79c975b..0c900bd 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
@@ -119,12 +119,12 @@
      * @param roleIds 閫夋嫨鐨勮鑹瞚d闆嗗悎
      * @return 鎻掑叆鐢ㄦ埛涓庤鑹插叧鑱旇褰曟暟閲�
      */
-    public int setRoles(String userId, String[] roleIds) {
-        this.urDao.deleteByUserId(Long.parseLong(userId));
+    public int setRoles(Long userId, String[] roleIds) {
+        this.urDao.deleteByUserId(userId);
         int count = 0;
         if (roleIds != null && roleIds.length > 0) {
             for (String roleId : roleIds) {
-                count += this.urDao.insertSelective(new BaUserRole(Long.parseLong(userId), Long.parseLong(roleId)));
+                count += this.urDao.insertSelective(new BaUserRole(userId, Long.parseLong(roleId)));
             }
         }
         return count;

--
Gitblit v1.8.0