Selaa lähdekoodia

用户删除功能优化,添加是否主库字段

admin 5 vuotta sitten
vanhempi
commit
f9fa99e52d

+ 2 - 0
src/main/java/com/chinaitop/depot/DepotSystemApplication.java

@@ -6,11 +6,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
6
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
8
 import org.springframework.cloud.openfeign.EnableFeignClients;
8
 import org.springframework.cloud.openfeign.EnableFeignClients;
9
+import org.springframework.transaction.annotation.EnableTransactionManagement;
9
 
10
 
10
 @EnableEurekaClient
11
 @EnableEurekaClient
11
 @EnableDiscoveryClient
12
 @EnableDiscoveryClient
12
 @SpringBootApplication
13
 @SpringBootApplication
13
 @EnableFeignClients
14
 @EnableFeignClients
15
+@EnableTransactionManagement
14
 @MapperScan(basePackages = {"com.chinaitop.depot.system.mapper"})
16
 @MapperScan(basePackages = {"com.chinaitop.depot.system.mapper"})
15
 public class DepotSystemApplication {
17
 public class DepotSystemApplication {
16
 
18
 

+ 6 - 4
src/main/java/com/chinaitop/depot/system/controller/UserInfoController.java

@@ -603,11 +603,13 @@ public class UserInfoController {
603
 	public Map<String, Object> remove(Integer userId) {
603
 	public Map<String, Object> remove(Integer userId) {
604
 		Map<String, Object> modelMap = new HashMap<>();
604
 		Map<String, Object> modelMap = new HashMap<>();
605
 		if (userId != null) {
605
 		if (userId != null) {
606
-			userInfoService.remove(userId);
607
-			userRoleService.deleteById(userId);//删除用户角色信息
608
-			userOrgService.deleteById(userId);//删除用户机构权限信息
606
+			try {
607
+				userInfoService.deleteAll(userId);
608
+				modelMap.put("status", "success");
609
+			} catch (Exception e) {
610
+				e.printStackTrace();
611
+			}
609
 		}
612
 		}
610
-		modelMap.put("status", "success");
611
 		return modelMap;
613
 		return modelMap;
612
 	}
614
 	}
613
 	
615
 	

+ 20 - 5
src/main/java/com/chinaitop/depot/system/mapper/OrgInfoMapper.xml

@@ -61,6 +61,7 @@
61
     <result column="frlxfs" property="frlxfs" jdbcType="VARCHAR" />
61
     <result column="frlxfs" property="frlxfs" jdbcType="VARCHAR" />
62
     <result column="yxgr" property="yxgr" jdbcType="DECIMAL" />
62
     <result column="yxgr" property="yxgr" jdbcType="DECIMAL" />
63
     <result column="kqbm" property="kqbm" jdbcType="VARCHAR" />
63
     <result column="kqbm" property="kqbm" jdbcType="VARCHAR" />
64
+    <result column="sfzk" property="sfzk" jdbcType="VARCHAR" />
64
   </resultMap>
65
   </resultMap>
65
   <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chinaitop.depot.system.model.OrgInfo">
66
   <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chinaitop.depot.system.model.OrgInfo">
66
     <result column="wjl" jdbcType="LONGVARCHAR" property="wjl" />
67
     <result column="wjl" jdbcType="LONGVARCHAR" property="wjl" />
@@ -132,7 +133,7 @@
132
     parent_id, status, del_flag, birds_eye, birds_Remote, brief_introduction, invoice_title, 
133
     parent_id, status, del_flag, birds_eye, birds_Remote, brief_introduction, invoice_title, 
133
     regist_number, bank_name, account_name, account_number,level_code,total_assets,corporate_capacity,
134
     regist_number, bank_name, account_name, account_number,level_code,total_assets,corporate_capacity,
134
     office_phone,registered_address,mail_box,official_website,house_number,tank_number,depot_property,
135
     office_phone,registered_address,mail_box,official_website,house_number,tank_number,depot_property,
135
-    updatetime,frlxfs,yxgr,kqbm
136
+    updatetime,frlxfs,yxgr,kqbm,sfzk
136
   </sql>
137
   </sql>
137
   <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.system.model.OrgInfoExample" >
138
   <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.system.model.OrgInfoExample" >
138
     select
139
     select
@@ -182,7 +183,7 @@
182
       regist_number, bank_name, account_name, 
183
       regist_number, bank_name, account_name, 
183
       account_number,total_assets,corporate_capacity,
184
       account_number,total_assets,corporate_capacity,
184
       office_phone,registered_address,mail_box,official_website,
185
       office_phone,registered_address,mail_box,official_website,
185
-      house_number,tank_number,depot_property,level_code,wjl,frlxfs,yxgr,kqbm)
186
+      house_number,tank_number,depot_property,level_code,wjl,frlxfs,yxgr,kqbm,sfzk)
186
     values (#{orgId,jdbcType=INTEGER}, #{orgName,jdbcType=VARCHAR}, #{shortName,jdbcType=VARCHAR}, 
187
     values (#{orgId,jdbcType=INTEGER}, #{orgName,jdbcType=VARCHAR}, #{shortName,jdbcType=VARCHAR}, 
187
       #{orgCode,jdbcType=VARCHAR}, #{orgClassId,jdbcType=INTEGER}, #{companyNature,jdbcType=INTEGER}, 
188
       #{orgCode,jdbcType=VARCHAR}, #{orgClassId,jdbcType=INTEGER}, #{companyNature,jdbcType=INTEGER}, 
188
       #{busiType,jdbcType=INTEGER}, #{address,jdbcType=VARCHAR}, #{contact,jdbcType=VARCHAR}, 
189
       #{busiType,jdbcType=INTEGER}, #{address,jdbcType=VARCHAR}, #{contact,jdbcType=VARCHAR}, 
@@ -202,7 +203,7 @@
202
       #{officePhone,jdbcType=VARCHAR}, #{registeredAddress,jdbcType=VARCHAR}, #{mailBox,jdbcType=VARCHAR}, 
203
       #{officePhone,jdbcType=VARCHAR}, #{registeredAddress,jdbcType=VARCHAR}, #{mailBox,jdbcType=VARCHAR}, 
203
       #{officialWebsite,jdbcType=VARCHAR}, #{houseNumber,jdbcType=INTEGER}, #{tankNumber,jdbcType=INTEGER}, 
204
       #{officialWebsite,jdbcType=VARCHAR}, #{houseNumber,jdbcType=INTEGER}, #{tankNumber,jdbcType=INTEGER}, 
204
       #{depotProperty,jdbcType=VARCHAR}, #{levelCode,jdbcType=VARCHAR}, #{wjl,jdbcType=LONGVARCHAR},
205
       #{depotProperty,jdbcType=VARCHAR}, #{levelCode,jdbcType=VARCHAR}, #{wjl,jdbcType=LONGVARCHAR},
205
-      #{frlxfs,jdbcType=VARCHAR}, #{yxgr,jdbcType=DECIMAL}, #{kqbm,jdbcType=VARCHAR})
206
+      #{frlxfs,jdbcType=VARCHAR}, #{yxgr,jdbcType=DECIMAL}, #{kqbm,jdbcType=VARCHAR}, #{sfzk,jdbcType=VARCHAR})
206
   </insert>
207
   </insert>
207
   <insert id="insertSelective" parameterType="com.chinaitop.depot.system.model.OrgInfo" useGeneratedKeys="true" keyProperty="orgId">
208
   <insert id="insertSelective" parameterType="com.chinaitop.depot.system.model.OrgInfo" useGeneratedKeys="true" keyProperty="orgId">
208
     insert into org_info
209
     insert into org_info
@@ -354,6 +355,9 @@
354
       <if test="kqbm != null">
355
       <if test="kqbm != null">
355
       	kqbm,
356
       	kqbm,
356
       </if>
357
       </if>
358
+      <if test="sfzk != null">
359
+        sfzk,
360
+      </if>
357
     </trim>
361
     </trim>
358
     <trim prefix="values (" suffix=")" suffixOverrides="," >
362
     <trim prefix="values (" suffix=")" suffixOverrides="," >
359
       <if test="orgId != null" >
363
       <if test="orgId != null" >
@@ -503,6 +507,9 @@
503
       <if test="kqbm != null">
507
       <if test="kqbm != null">
504
       	#{kqbm,jdbcType=VARCHAR},
508
       	#{kqbm,jdbcType=VARCHAR},
505
       </if>
509
       </if>
510
+      <if test="sfzk != null">
511
+        #{sfzk,jdbcType=VARCHAR},
512
+      </if>
506
     </trim>
513
     </trim>
507
   </insert>
514
   </insert>
508
   <select id="countByExample" parameterType="com.chinaitop.depot.system.model.OrgInfoExample" resultType="java.lang.Integer" >
515
   <select id="countByExample" parameterType="com.chinaitop.depot.system.model.OrgInfoExample" resultType="java.lang.Integer" >
@@ -664,6 +671,9 @@
664
       <if test="record.kqbm != null">
671
       <if test="record.kqbm != null">
665
       	kqbm = #{record.kqbm,jdbcType=VARCHAR},
672
       	kqbm = #{record.kqbm,jdbcType=VARCHAR},
666
       </if>
673
       </if>
674
+      <if test="record.sfzk != null">
675
+        sfzk = #{record.sfzk,jdbcType=VARCHAR},
676
+      </if>
667
     </set>
677
     </set>
668
     <if test="_parameter != null" >
678
     <if test="_parameter != null" >
669
       <include refid="Update_By_Example_Where_Clause" />
679
       <include refid="Update_By_Example_Where_Clause" />
@@ -719,7 +729,8 @@
719
       wjl = #{record.wjl,jdbcType=LONGVARCHAR},
729
       wjl = #{record.wjl,jdbcType=LONGVARCHAR},
720
       frlxfs = #{record.frlxfs,jdbcType=VARCHAR},
730
       frlxfs = #{record.frlxfs,jdbcType=VARCHAR},
721
       yxgr = #{record.yxgr,jdbcType=DECIMAL},
731
       yxgr = #{record.yxgr,jdbcType=DECIMAL},
722
-      kqbm = #{record.kqbm,jdbcType=VARCHAR}
732
+      kqbm = #{record.kqbm,jdbcType=VARCHAR},
733
+      sfzk = #{record.sfzk,jdbcType=VARCHAR}
723
     <if test="_parameter != null" >
734
     <if test="_parameter != null" >
724
       <include refid="Update_By_Example_Where_Clause" />
735
       <include refid="Update_By_Example_Where_Clause" />
725
     </if>
736
     </if>
@@ -901,6 +912,9 @@
901
       <if test="kqbm != null">
912
       <if test="kqbm != null">
902
       	kqbm = #{kqbm,jdbcType=VARCHAR},
913
       	kqbm = #{kqbm,jdbcType=VARCHAR},
903
       </if>
914
       </if>
915
+      <if test="sfzk !=null">
916
+        sfzk = #{sfzk,jdbcType=VARCHAR},
917
+      </if>
904
     </set>
918
     </set>
905
     where org_id = #{orgId,jdbcType=INTEGER}
919
     where org_id = #{orgId,jdbcType=INTEGER}
906
   </update>
920
   </update>
@@ -963,7 +977,8 @@
963
       wjl = #{wjl,jdbcType=LONGVARCHAR},
977
       wjl = #{wjl,jdbcType=LONGVARCHAR},
964
       frlxfs = #{frlxfs,jdbcType=VARCHAR},
978
       frlxfs = #{frlxfs,jdbcType=VARCHAR},
965
       yxgr = #{yxgr,jdbcType=DECIMAL},
979
       yxgr = #{yxgr,jdbcType=DECIMAL},
966
-      kqbm = #{kqbm,jdbcType=VARCHAR}
980
+      kqbm = #{kqbm,jdbcType=VARCHAR},
981
+      sfzk = #{sfzk,jdbcType=VARCHAR}
967
     where org_id = #{orgId,jdbcType=INTEGER}
982
     where org_id = #{orgId,jdbcType=INTEGER}
968
   </update>
983
   </update>
969
   <update id="updateOrgLevel" parameterType="map" statementType="CALLABLE" >
984
   <update id="updateOrgLevel" parameterType="map" statementType="CALLABLE" >

+ 22 - 0
src/main/java/com/chinaitop/depot/system/mapper/UserInfoMapper.java

@@ -45,4 +45,26 @@ public interface UserInfoMapper {
45
     List<UserInfo> queryAllByOrgClass(Map<Object, Object> map);
45
     List<UserInfo> queryAllByOrgClass(Map<Object, Object> map);
46
 
46
 
47
 	List<UserInfo> getUserInfoByRole(Integer orgId);
47
 	List<UserInfo> getUserInfoByRole(Integer orgId);
48
+
49
+	/**
50
+     * 查询当前用户对应的员工信息
51
+     * 
52
+     * @param userId 员工ID
53
+     * @return
54
+     */
55
+    List<Map<String, Object>> findKeeper(@Param("userId") Integer userId);
56
+
57
+    /**
58
+     * 删除当前用对应的员工信息
59
+     * 
60
+     * @param userId 员工ID
61
+     */
62
+	void deleteKeeperObj(@Param("userId") Integer userId);
63
+
64
+	/**
65
+	 * 删除当前用户对应的员工所保管的仓房信息
66
+	 * 
67
+	 * @param keepid 员工ID集合
68
+	 */
69
+	void deleteKeeperHouseObj(@Param("keepid") Integer keepid);
48
 }
70
 }

+ 12 - 0
src/main/java/com/chinaitop/depot/system/mapper/UserInfoMapper.xml

@@ -558,4 +558,16 @@
558
 	) 
558
 	) 
559
 	ORDER BY user_id 
559
 	ORDER BY user_id 
560
   </select>
560
   </select>
561
+  <!-- 查询当前用户对应的员工信息 -->
562
+  <select id="findKeeper" resultType="java.util.Map" parameterType="java.lang.Integer">
563
+	SELECT id FROM basic_keeper WHERE user_Id= ${userId}
564
+  </select>
565
+  <!-- 删除当前用户对应的员工信息 -->
566
+  <delete id="deleteKeeperObj" parameterType="java.lang.Integer">
567
+	delete FROM basic_keeper WHERE user_Id= ${userId}
568
+  </delete>
569
+  <!-- 删除当前用户对应的员工所保管的仓房信息 -->
570
+  <delete id="deleteKeeperHouseObj" parameterType="java.lang.Integer">
571
+	DELETE FROM basic_keeper_house WHERE keeper_id = ${keepid}
572
+  </delete>
561
 </mapper>
573
 </mapper>

+ 10 - 0
src/main/java/com/chinaitop/depot/system/model/OrgInfo.java

@@ -131,6 +131,8 @@ public class OrgInfo implements Serializable {
131
     
131
     
132
     private String kqbm;
132
     private String kqbm;
133
 
133
 
134
+    private String sfzk;
135
+
134
     public Integer getOrgId() {
136
     public Integer getOrgId() {
135
         return orgId;
137
         return orgId;
136
     }
138
     }
@@ -618,4 +620,12 @@ public class OrgInfo implements Serializable {
618
 	public void setKqbm(String kqbm) {
620
 	public void setKqbm(String kqbm) {
619
 		this.kqbm = kqbm == null ? null : kqbm.trim();
621
 		this.kqbm = kqbm == null ? null : kqbm.trim();
620
 	}
622
 	}
623
+
624
+	public String getSfzk() {
625
+		return sfzk;
626
+	}
627
+
628
+	public void setSfzk(String sfzk) {
629
+		this.sfzk = sfzk == null ? null : sfzk.trim();
630
+	}
621
 }
631
 }

+ 8 - 0
src/main/java/com/chinaitop/depot/system/service/UserInfoService.java

@@ -119,4 +119,12 @@ public interface UserInfoService {
119
 	List<UserInfo> queryAllByOrgClass(Map<Object, Object> map);
119
 	List<UserInfo> queryAllByOrgClass(Map<Object, Object> map);
120
 
120
 
121
 	List<UserInfo> getUserInfoByRole(Integer orgId);
121
 	List<UserInfo> getUserInfoByRole(Integer orgId);
122
+
123
+	/**
124
+	 * 删除当前用户数据和当前用户关联的部分数据
125
+	 * 
126
+	 * @param userId
127
+	 * @throws Exception
128
+	 */
129
+	void deleteAll(Integer userId) throws Exception;
122
 }
130
 }

+ 32 - 0
src/main/java/com/chinaitop/depot/system/service/impl/UserInfoServiceImpl.java

@@ -12,7 +12,10 @@ import com.chinaitop.depot.system.model.UserInfoExample.Criteria;
12
 import com.chinaitop.depot.system.model.UserRole;
12
 import com.chinaitop.depot.system.model.UserRole;
13
 import com.chinaitop.depot.system.model.UserRoleExample;
13
 import com.chinaitop.depot.system.model.UserRoleExample;
14
 import com.chinaitop.depot.system.service.UserInfoService;
14
 import com.chinaitop.depot.system.service.UserInfoService;
15
+import com.chinaitop.depot.system.service.UserOrgService;
16
+
15
 import org.springframework.stereotype.Service;
17
 import org.springframework.stereotype.Service;
18
+import org.springframework.transaction.annotation.Transactional;
16
 
19
 
17
 import javax.annotation.Resource;
20
 import javax.annotation.Resource;
18
 
21
 
@@ -38,6 +41,9 @@ public class UserInfoServiceImpl implements UserInfoService {
38
 	@Resource
41
 	@Resource
39
 	private RoleInfoMapper roleInfoMapper;
42
 	private RoleInfoMapper roleInfoMapper;
40
 
43
 
44
+	@Resource
45
+	private UserOrgService userOrgService;
46
+
41
 	@Override
47
 	@Override
42
 	public UserInfo valid(String UserInfoName, String password) {
48
 	public UserInfo valid(String UserInfoName, String password) {
43
 		// 获取MD5加密后的字符串
49
 		// 获取MD5加密后的字符串
@@ -281,4 +287,30 @@ public class UserInfoServiceImpl implements UserInfoService {
281
 		return UserInfoMapper.getUserInfoByRole(orgId);
287
 		return UserInfoMapper.getUserInfoByRole(orgId);
282
 	}
288
 	}
283
 
289
 
290
+	@Override
291
+	@Transactional
292
+	public void deleteAll(Integer userId) throws Exception {
293
+
294
+		UserInfoMapper.deleteByPrimaryKey(userId);//删除当前人
295
+		userRoleMapper.deleteById(userId);//删除用户角色信息
296
+		userOrgService.deleteById(userId);//删除用户机构权限信息
297
+
298
+		//删除用对应的员工信息
299
+		/* 查询当前用户对应的员工信息ID */
300
+		List<Map<String, Object>> list = UserInfoMapper.findKeeper(userId);
301
+
302
+		if (null != list && list.size() > 0) {
303
+			/* 删除当前用户对应的员工所保管的仓房信息 */
304
+			//Map<String, Object> map = null;
305
+			for (Map<String, Object> map : list) {
306
+				Integer id = Integer.parseInt(map.get("id")+"");
307
+				UserInfoMapper.deleteKeeperHouseObj(id);
308
+			}
309
+
310
+			/* 删除当前用户对应的员工信息 */
311
+			UserInfoMapper.deleteKeeperObj(userId);
312
+		}
313
+
314
+	}
315
+
284
 }
316
 }