Explorar o código

Merge branch 'system-zyj' of uskycloud/usky-cloud into system-165

James hai 1 ano
pai
achega
129ba5c79b

+ 12 - 1
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysLogininforServiceImpl.java

@@ -1,6 +1,7 @@
 package com.usky.system.service.impl;
 
 
+import com.usky.common.core.util.StringUtils;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.system.domain.SysLogininfor;
@@ -10,7 +11,10 @@ import com.usky.system.service.vo.SysLoginExportVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
+import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 
 
 /**
@@ -33,8 +37,15 @@ public class SysLogininforServiceImpl extends AbstractCrudService<SysLogininforM
     @Override
     public void insertLogininfor(SysLogininfor logininfor)
     {
-        logininfor.setDeptId(SecurityUtils.getLoginUser().getSysPerson().getDeptId().intValue());
+        if(Objects.isNull(SecurityUtils.getLoginUser())){
+
+        }else{
+            logininfor.setDeptId(SecurityUtils.getLoginUser().getSysPerson().getDeptId().intValue());
+        }
+
         logininfor.setTenantId(SecurityUtils.getTenantId());
+        Date now = new Date();
+        logininfor.setAccessTime(now);
         logininforMapper.insertLogininfor(logininfor);
     }
 

+ 11 - 1
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysOperLogServiceImpl.java

@@ -9,8 +9,11 @@ import com.usky.system.service.ISysOperLogService;
 import com.usky.system.service.vo.SysOperLogExportVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import sun.util.calendar.BaseCalendar;
 
+import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 操作日志 服务层处理
@@ -31,8 +34,15 @@ public class SysOperLogServiceImpl extends AbstractCrudService<SysOperLogMapper,
     @Override
     public void insertOperlog(SysOperLog operLog)
     {
-        operLog.setDeptId(SecurityUtils.getLoginUser().getSysPerson().getDeptId().intValue());
+        if(Objects.isNull(SecurityUtils.getLoginUser())){
+
+        }else{
+            operLog.setDeptId(SecurityUtils.getLoginUser().getSysPerson().getDeptId().intValue());
+        }
+
         operLog.setTenantId(SecurityUtils.getTenantId());
+        Date now = new Date();
+        operLog.setOperTime(now);
         operLogMapper.insertOperlog(operLog);
     }
 

+ 20 - 2
base-modules/service-system/service-system-biz/src/main/resources/mapper/system/SysLogininforMapper.xml

@@ -16,8 +16,26 @@
 	</resultMap>
 
 	<insert id="insertLogininfor" parameterType="com.usky.system.domain.SysLogininfor">
-		insert into sys_logininfor (user_name, status, ipaddr, msg, access_time, dept_id, tenant_id)
-		values (#{userName}, #{status}, #{ipaddr}, #{msg}, sysdate(), #{deptId}, #{tenantId})
+		insert into sys_logininfor
+		<trim prefix="(" suffix=")" suffixOverrides=",">
+			<if test="userName != null"> user_name, </if>
+			<if test="status != null"> status, </if>
+			<if test="ipaddr != null"> ipaddr, </if>
+			<if test="msg != null"> msg, </if>
+			<if test="accessTime != null"> access_time, </if>
+			<if test="deptId != null"> dept_id, </if>
+			<if test="tenantId != null"> tenant_id, </if>
+		</trim>
+		values
+		<trim prefix="(" suffix=")" suffixOverrides=",">
+			<if test="userName != null"> #{userName},</if>
+			<if test="status != null"> #{status},</if>
+			<if test="ipaddr != null"> #{ipaddr},</if>
+			<if test="msg != null"> #{msg},</if>
+			<if test="accessTime != null"> #{accessTime},</if>
+			<if test="deptId != null"> #{deptId},</if>
+			<if test="tenantId != null"> #{tenantId},</if>
+		</trim>
 	</insert>
 
 	<select id="selectLogininforList" parameterType="com.usky.system.domain.SysLogininfor" resultMap="SysLogininforResult">

+ 40 - 2
base-modules/service-system/service-system-biz/src/main/resources/mapper/system/SysOperLogMapper.xml

@@ -31,8 +31,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
     
 	<insert id="insertOperlog" parameterType="com.usky.system.domain.SysOperLog">
-		insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time, dept_id, tenant_id)
-        values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, sysdate(), #{deptId}, #{tenantId})
+		insert into sys_oper_log
+		<trim prefix="(" suffix=")" suffixOverrides=",">
+			<if test="title != null"> title, </if>
+			<if test="businessType != null"> business_type, </if>
+			<if test="method != null"> method, </if>
+			<if test="requestMethod != null"> request_method, </if>
+			<if test="operatorType != null"> operator_type, </if>
+			<if test="operName != null"> oper_name, </if>
+			<if test="deptName != null"> dept_name, </if>
+			<if test="operUrl != null"> oper_url, </if>
+			<if test="operIp != null"> oper_ip, </if>
+			<if test="operLocation != null"> oper_location, </if>
+			<if test="operParam != null"> oper_param, </if>
+			<if test="jsonResult != null"> json_result, </if>
+			<if test="status != null"> status, </if>
+			<if test="errorMsg != null"> error_msg, </if>
+			<if test="operTime != null"> oper_time, </if>
+			<if test="deptId != null"> dept_id, </if>
+			<if test="tenantId != null"> tenant_id, </if>
+		</trim>
+		values
+		<trim prefix="(" suffix=")" suffixOverrides=",">
+			<if test="title != null"> #{title},</if>
+			<if test="businessType != null"> #{businessType},</if>
+			<if test="method != null"> #{method},</if>
+			<if test="requestMethod != null"> #{requestMethod},</if>
+			<if test="operatorType != null"> #{operatorType},</if>
+			<if test="operName != null"> #{operName},</if>
+			<if test="deptName != null"> #{deptName},</if>
+			<if test="operUrl != null"> #{operUrl},</if>
+			<if test="operIp != null"> #{operIp},</if>
+			<if test="operLocation != null"> #{operLocation},</if>
+			<if test="operParam != null"> #{operParam},</if>
+			<if test="jsonResult != null"> #{jsonResult},</if>
+			<if test="status != null"> #{status},</if>
+			<if test="errorMsg != null"> #{errorMsg},</if>
+			<if test="operTime != null"> #{operTime},</if>
+			<if test="deptId != null"> #{deptId},</if>
+			<if test="tenantId != null"> #{tenantId},</if>
+		</trim>
 	</insert>
 	
 	<select id="selectOperLogList" parameterType="com.usky.system.domain.SysOperLog" resultMap="SysOperLogResult">