Kaynağa Gözat

机构名称

hanqingsong 1 yıl önce
ebeveyn
işleme
b50c0f75b8

+ 13 - 2
src/main/java/com/chinaitop/depot/system/controller/UserInfoController.java

@@ -262,6 +262,8 @@ public class UserInfoController {
262 262
 			}
263 263
 		}*/
264 264
 		UserInfo userInfo = null;
265
+		// 机构名称
266
+		String orgName = null;
265 267
 		if(!userInfoService.validUsername(null,username)) {//用户名存在
266 268
 			/**************************限制单个用户的同时重复登录操作************************/
267 269
 			String sessionId = ObjectUtils.toString(redisUtil.get(username+"_sessinId"),"");
@@ -373,6 +375,9 @@ public class UserInfoController {
373 375
 				OrgInfo orgInfo = orgInfoService.findById(userInfo.getOrgId());
374 376
 				String orgInfoObject = mapper.writeValueAsString(orgInfo);
375 377
 				session.setAttribute("orgInfo", orgInfoObject);
378
+
379
+				// 登录日志保存机构名称
380
+				orgName = orgInfo.getOrgName();
376 381
 				// 当前用户所属的库信息及库编号
377 382
 				OrgInfo depotInfo = orgInfoService.getDepotInfo(orgInfo);
378 383
 				if(depotInfo!=null){
@@ -386,7 +391,8 @@ public class UserInfoController {
386 391
 			map.put("status", true);
387 392
 			map.put("userInfo", userInfo);
388 393
 			// 登录日志
389
-			userLoginLogService.saveData(request, userInfo, "1");
394
+			System.out.println(orgName);
395
+			userLoginLogService.saveData(request, userInfo, "1", orgName);
390 396
 		}
391 397
 		return map;
392 398
 	}
@@ -937,6 +943,8 @@ public class UserInfoController {
937 943
 		
938 944
 		Map<String, Object> map = new HashMap<String, Object>();
939 945
 		UserInfo userInfo = null;
946
+		// 登录日志
947
+		String orgName = null;
940 948
 		if(!userInfoService.validUsername(null,username)) {//用户名存在
941 949
 			/**************************限制单个用户的同时重复登录操作************************/
942 950
 			String sessionId = ObjectUtils.toString(redisUtil.get(username+"_sessinId"),"");
@@ -1027,6 +1035,9 @@ public class UserInfoController {
1027 1035
 				OrgInfo orgInfo = orgInfoService.findById(userInfo.getOrgId());
1028 1036
 				String orgInfoObject = mapper.writeValueAsString(orgInfo);
1029 1037
 				session.setAttribute("orgInfo", orgInfoObject);
1038
+
1039
+				// 登录日志
1040
+				orgName = orgInfo.getOrgName();
1030 1041
 				// 当前用户所属的库信息及库编号
1031 1042
 				OrgInfo depotInfo = orgInfoService.getDepotInfo(orgInfo);
1032 1043
 				if(depotInfo!=null){
@@ -1040,7 +1051,7 @@ public class UserInfoController {
1040 1051
 			map.put("status", true);
1041 1052
 			map.put("userInfo", userInfo);
1042 1053
             // 登录日志
1043
-            userLoginLogService.saveData(request, userInfo, "2");
1054
+            userLoginLogService.saveData(request, userInfo, "2", orgName);
1044 1055
 		}
1045 1056
 		return map;
1046 1057
 	}

+ 16 - 5
src/main/java/com/chinaitop/depot/system/mapper/UserLoginLogMapper.xml

@@ -11,6 +11,7 @@
11 11
     <result column="session_id" property="sessionId" jdbcType="VARCHAR" />
12 12
     <result column="login_type" property="loginType" jdbcType="VARCHAR" />
13 13
     <result column="org_id" property="orgId" jdbcType="INTEGER" />
14
+    <result column="org_name" property="orgName" jdbcType="VARCHAR" />
14 15
   </resultMap>
15 16
   <sql id="Example_Where_Clause" >
16 17
     <where >
@@ -71,7 +72,7 @@
71 72
     </where>
72 73
   </sql>
73 74
   <sql id="Base_Column_List" >
74
-    id, user_name, real_name, user_ip, in_login_time, out_login_time, session_id, login_type, org_id
75
+    id, user_name, real_name, user_ip, in_login_time, out_login_time, session_id, login_type, org_id, org_name
75 76
   </sql>
76 77
   <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.system.model.UserLoginLogExample" >
77 78
     select
@@ -96,10 +97,10 @@
96 97
   <insert id="insert" parameterType="com.chinaitop.depot.system.model.UserLoginLog" >
97 98
     insert into user_login_log (id, user_name, real_name, 
98 99
       user_ip, in_login_time, out_login_time, 
99
-      session_id, login_type,org_id)
100
+      session_id, login_type,org_id, org_name)
100 101
     values (#{id,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, #{realName,jdbcType=VARCHAR}, 
101 102
       #{userIp,jdbcType=VARCHAR}, #{inLoginTime,jdbcType=TIMESTAMP}, #{outLoginTime,jdbcType=TIMESTAMP}, 
102
-      #{sessionId,jdbcType=VARCHAR}, #{loginType,jdbcType=VARCHAR}, #{orgId,jdbcType=INTEGER})
103
+      #{sessionId,jdbcType=VARCHAR}, #{loginType,jdbcType=VARCHAR}, #{orgId,jdbcType=INTEGER}, #{orgName,jdbcType=VARCHAR})
103 104
   </insert>
104 105
   <insert id="insertSelective" parameterType="com.chinaitop.depot.system.model.UserLoginLog" >
105 106
     insert into user_login_log
@@ -131,6 +132,9 @@
131 132
       <if test="orgId != null" >
132 133
         org_id,
133 134
       </if>
135
+      <if test="orgName != null" >
136
+        org_name,
137
+      </if>
134 138
     </trim>
135 139
     <trim prefix="values (" suffix=")" suffixOverrides="," >
136 140
       <if test="id != null" >
@@ -160,6 +164,9 @@
160 164
       <if test="orgId != null" >
161 165
         #{orgId,jdbcType=INTEGER},
162 166
       </if>
167
+      <if test="orgName != null" >
168
+        #{orgName,jdbcType=VARCHAR},
169
+      </if>
163 170
     </trim>
164 171
   </insert>
165 172
   <select id="countByExample" parameterType="com.chinaitop.depot.system.model.UserLoginLogExample" resultType="java.lang.Integer" >
@@ -196,7 +203,10 @@
196 203
         login_type = #{record.loginType,jdbcType=VARCHAR},
197 204
       </if>
198 205
       <if test="record.orgId != null" >
199
-        org_id = #{record.orgId,jdbcType=VARCHAR},
206
+        org_id = #{record.orgId,jdbcType=INTEGER},
207
+      </if>
208
+      <if test="record.orgName != null" >
209
+        org_name = #{record.orgName,jdbcType=VARCHAR},
200 210
       </if>
201 211
     </set>
202 212
     <if test="_parameter != null" >
@@ -213,7 +223,8 @@
213 223
       out_login_time = #{record.outLoginTime,jdbcType=TIMESTAMP},
214 224
       session_id = #{record.sessionId,jdbcType=VARCHAR},
215 225
       login_type = #{record.loginType,jdbcType=VARCHAR},
216
-      org_id = #{record.orgId,jdbcType=INTEGER}
226
+      org_id = #{record.orgId,jdbcType=INTEGER},
227
+      org_name = #{record.orgName,jdbcType=VARCHAR}
217 228
     <if test="_parameter != null" >
218 229
       <include refid="Update_By_Example_Where_Clause" />
219 230
     </if>

+ 11 - 0
src/main/java/com/chinaitop/depot/system/model/UserLoginLog.java

@@ -34,6 +34,17 @@ public class UserLoginLog {
34 34
     // 库点id
35 35
     private Integer orgId;
36 36
 
37
+    // 机构名称
38
+    private String orgName;
39
+
40
+    public String getOrgName() {
41
+        return orgName;
42
+    }
43
+
44
+    public void setOrgName(String orgName) {
45
+        this.orgName = orgName;
46
+    }
47
+
37 48
     public Integer getOrgId() {
38 49
         return orgId;
39 50
     }

+ 1 - 1
src/main/java/com/chinaitop/depot/system/service/UserLoginLogService.java

@@ -16,7 +16,7 @@ import java.util.List;
16 16
 public interface UserLoginLogService {
17 17
 
18 18
     // 保存登录日志
19
-    void saveData(HttpServletRequest request, UserInfo userInfo, String loginType);
19
+    void saveData(HttpServletRequest request, UserInfo userInfo, String loginType, String orgName);
20 20
 
21 21
     // 更新登录日志
22 22
     void updateData(HttpServletRequest request);

+ 1 - 1
src/main/java/com/chinaitop/depot/system/service/impl/UserLoginLogServiceImpl.java

@@ -48,7 +48,7 @@ public class UserLoginLogServiceImpl implements UserLoginLogService {
48 48
 
49 49
     @Override
50 50
     @Transactional(rollbackFor = Exception.class)
51
-    public void saveData(HttpServletRequest request, UserInfo userInfo, String loginType) {
51
+    public void saveData(HttpServletRequest request, UserInfo userInfo, String loginType, String orgName) {
52 52
         // 查询是否登录成功
53 53
         if (redisUtil.hasKey(userInfo.getUsername() + CommonObject.sessionId)) {
54 54
             UserLoginLog log = new UserLoginLog();