Browse Source

日志查询修改
操作日志增加租户标识

wangli 4 years ago
parent
commit
489f4afd09

+ 4 - 0
user_center/src/main/java/com/huaxu/controller/LoginLogController.java

@@ -7,9 +7,11 @@ import com.huaxu.common.EasyExcelUtil;
 import com.huaxu.dto.LoginLogDto;
 import com.huaxu.dto.LoginLogDto;
 import com.huaxu.entity.LoginLogEntity;
 import com.huaxu.entity.LoginLogEntity;
 import com.huaxu.model.AjaxMessage;
 import com.huaxu.model.AjaxMessage;
+import com.huaxu.model.LoginUser;
 import com.huaxu.model.Pagination;
 import com.huaxu.model.Pagination;
 import com.huaxu.model.ResultStatus;
 import com.huaxu.model.ResultStatus;
 import com.huaxu.service.LoginLogService;
 import com.huaxu.service.LoginLogService;
+import com.huaxu.util.UserUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import io.swagger.annotations.ApiParam;
@@ -133,8 +135,10 @@ public class LoginLogController {
 
 
 
 
     ) {
     ) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
         SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
         SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
         LoginLogDto loginLogDto = new LoginLogDto();
         LoginLogDto loginLogDto = new LoginLogDto();
+        loginLogDto.setTenantId(loginUser.getTenantId());
         loginLogDto.setCondition(condition);
         loginLogDto.setCondition(condition);
         loginLogDto.setDepartmentId(departmentId);
         loginLogDto.setDepartmentId(departmentId);
         try {
         try {

+ 6 - 3
user_center/src/main/java/com/huaxu/controller/OperateLogController.java

@@ -7,10 +7,9 @@ import com.huaxu.common.EasyExcelUtil;
 import com.huaxu.dto.LoginLogDto;
 import com.huaxu.dto.LoginLogDto;
 import com.huaxu.dto.OperateLogDto;
 import com.huaxu.dto.OperateLogDto;
 import com.huaxu.entity.OperateLogEntity;
 import com.huaxu.entity.OperateLogEntity;
-import com.huaxu.model.AjaxMessage;
-import com.huaxu.model.Pagination;
-import com.huaxu.model.ResultStatus;
+import com.huaxu.model.*;
 import com.huaxu.service.OperateLogService;
 import com.huaxu.service.OperateLogService;
+import com.huaxu.util.UserUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import io.swagger.annotations.ApiParam;
@@ -131,10 +130,14 @@ public class OperateLogController {
 
 
 
 
     ) {
     ) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
         SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
         SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
         OperateLogDto operateLogDto = new OperateLogDto();
         OperateLogDto operateLogDto = new OperateLogDto();
+        operateLogDto.setTenantId(loginUser.getTenantId());
         operateLogDto.setCondition(condition);
         operateLogDto.setCondition(condition);
         operateLogDto.setDepartmentId(departmentId);
         operateLogDto.setDepartmentId(departmentId);
+
+        List<ProgramItem> programItemList = loginUser.getProgramItemList();
         try {
         try {
             if(StringUtils.isNotBlank(beginTime)){
             if(StringUtils.isNotBlank(beginTime)){
                 operateLogDto.setBeginTime(f.parse(beginTime));
                 operateLogDto.setBeginTime(f.parse(beginTime));

+ 4 - 0
user_center/src/main/java/com/huaxu/entity/LoginLogEntity.java

@@ -31,6 +31,10 @@ public class LoginLogEntity implements Serializable {
     @ApiModelProperty(value = "手机号")
     @ApiModelProperty(value = "手机号")
     private String phone;
     private String phone;
 
 
+    @ExcelIgnore
+    @ApiModelProperty(value = "租户标识")
+    private String tenantId;
+
     @ExcelIgnore
     @ExcelIgnore
     @ApiModelProperty(value = "公司id")
     @ApiModelProperty(value = "公司id")
     private Long companyId;
     private Long companyId;

+ 4 - 0
user_center/src/main/java/com/huaxu/entity/OperateLogEntity.java

@@ -28,6 +28,10 @@ public class OperateLogEntity implements Serializable {
     @ExcelProperty(value = {"操作日志","手机号"},index = 3)
     @ExcelProperty(value = {"操作日志","手机号"},index = 3)
     @ApiModelProperty(value = "手机号")
     @ApiModelProperty(value = "手机号")
     private String phone;
     private String phone;
+    @ExcelIgnore
+    @ApiModelProperty(value = "租户标识")
+    private String tenantId;
+
     @ExcelIgnore
     @ExcelIgnore
     @ApiModelProperty(value = "公司id")
     @ApiModelProperty(value = "公司id")
     private Integer companyId;
     private Integer companyId;

+ 11 - 11
user_center/src/main/java/com/huaxu/logAdvice/OperateLogAdvice.java

@@ -48,15 +48,15 @@ public class OperateLogAdvice {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
 
 
-        OperateLogEntity OperateLogs = new OperateLogEntity();
+        OperateLogEntity operateLog = new OperateLogEntity();
         LoginUser user = UserUtil.getCurrentUser();
         LoginUser user = UserUtil.getCurrentUser();
         if (user != null) {
         if (user != null) {
             // 设置当前登录用户
             // 设置当前登录用户
-            OperateLogs.setUserName(user.getUsername());
-            OperateLogs.setPhone(user.getPhoneNumber());
-            OperateLogs.setCompanyId(user.getCompanyId());
-            OperateLogs.setDepartmentId(user.getDepartmentId());
-
+            operateLog.setUserName(user.getUsername());
+            operateLog.setPhone(user.getPhoneNumber());
+            operateLog.setTenantId(user.getTenantId());
+            operateLog.setCompanyId(user.getCompanyId());
+            operateLog.setDepartmentId(user.getDepartmentId());
             MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
             MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
 
 
             String module = null;//ApiOperation注解的模块名
             String module = null;//ApiOperation注解的模块名
@@ -72,17 +72,17 @@ public class OperateLogAdvice {
                 Method method = methodSignature.getMethod();
                 Method method = methodSignature.getMethod();
                 module= method.getDeclaringClass().getName()+method.getName();
                 module= method.getDeclaringClass().getName()+method.getName();
             }
             }
-            OperateLogs.setOperateContent(module);
+            operateLog.setOperateContent(module);
 
 
             try {
             try {
                 return  joinPoint.proceed();
                 return  joinPoint.proceed();
             } catch (Exception e) {
             } catch (Exception e) {
-                OperateLogs.setOperateContent(OperateLogs.getOperateContent()+"__操作抛出异常");
+                operateLog.setOperateContent(operateLog.getOperateContent()+"__操作抛出异常");
                 throw e;
                 throw e;
             } finally {
             } finally {
-                if (OperateLogs.getUserName() != null) {
-                    OperateLogs.setCreateTime(new Date());
-                    operateLogMapper.insert(OperateLogs);
+                if (operateLog.getUserName() != null) {
+                    operateLog.setCreateTime(new Date());
+                    operateLogMapper.insert(operateLog);
                 }
                 }
             }
             }
         }else {
         }else {

+ 11 - 6
user_center/src/main/java/com/huaxu/service/MenuService.java

@@ -237,15 +237,20 @@ public class MenuService extends ServiceImpl<MenuMapper,MenuEntity> {
 		String userType = currentUser.getType();
 		String userType = currentUser.getType();
 		List<MenuEntity> menuEntities= new ArrayList<>();
 		List<MenuEntity> menuEntities= new ArrayList<>();
 		switch (userType) {
 		switch (userType) {
-			case "1"://超级管理员查询所有系统菜单
-				menuEntities = menuMapper.findAllFirstMenu();
-				break;
-			case "2"://普通用户按角色查询租户菜单
-				menuEntities = menuMapper.findUserFirstMenu(currentUser.getTenantId(),userId);
-				break;
+//			case "1"://超级管理员查询所有系统菜单
+//				menuEntities = menuMapper.findAllFirstMenu();
+//				break;
+//			case "2"://普通用户按角色查询租户菜单
+//				menuEntities = menuMapper.findUserFirstMenu(currentUser.getTenantId(),userId);
+//				break;
 			case "-999"://租户管理员查询租户菜单
 			case "-999"://租户管理员查询租户菜单
 				menuEntities = menuMapper.findTenantFirstMenu(currentUser.getTenantId());
 				menuEntities = menuMapper.findTenantFirstMenu(currentUser.getTenantId());
 				break;
 				break;
+			case "-9999"://超级管理员查询所有系统菜单
+				menuEntities = menuMapper.findAllFirstMenu();
+			default:	//其他租户用户暂时不区分类型
+				menuEntities = menuMapper.findUserFirstMenu(currentUser.getTenantId(),userId);
+				break;
 		}
 		}
 
 
 		return menuEntities;
 		return menuEntities;

+ 4 - 1
user_center/src/main/resources/mapper/LoginLogMapper.xml

@@ -150,6 +150,9 @@
             <if test="loginLogDto.id != null">
             <if test="loginLogDto.id != null">
                 and a.id = #{loginLogDto.id}
                 and a.id = #{loginLogDto.id}
             </if>
             </if>
+            <if test="loginLogDto.tenantId != null and loginLogDto.tenantId != ''">
+                and a.tenant_id = #{loginLogDto.tenantId}
+            </if>
             <if test="loginLogDto.condition != null and loginLogDto.condition != ''">
             <if test="loginLogDto.condition != null and loginLogDto.condition != ''">
                 and (a.name like concat('%', #{loginLogDto.condition},'%')
                 and (a.name like concat('%', #{loginLogDto.condition},'%')
                 or a.phone like concat('%', #{loginLogDto.condition},'%'))
                 or a.phone like concat('%', #{loginLogDto.condition},'%'))
@@ -164,7 +167,7 @@
                 and a.create_time >= #{loginLogDto.beginTime}
                 and a.create_time >= #{loginLogDto.beginTime}
             </if>
             </if>
             <if test="loginLogDto.endTime != null">
             <if test="loginLogDto.endTime != null">
-                and a.create_time &lt;= #{loginLogDto.endTime}
+                and a.create_time &lt;= DATE_ADD(#{loginLogDto.endTime},INTERVAL 1 DAY)
             </if>
             </if>
         </where>
         </where>
     </select>
     </select>

+ 5 - 3
user_center/src/main/resources/mapper/OperateLogMapper.xml

@@ -73,8 +73,7 @@
                 and a.create_time >= #{beginTime}
                 and a.create_time >= #{beginTime}
             </if>
             </if>
             <if test="endTime != null">
             <if test="endTime != null">
-                and a.create_time &lt;= #{endTime}
-            </if>
+                and a.create_time &lt;= #{endTime}            </if>
         </where>
         </where>
     </select>
     </select>
     <!--通过实体作为筛选条件查询-->
     <!--通过实体作为筛选条件查询-->
@@ -149,6 +148,9 @@
             <if test="operateLogDto.id != null">
             <if test="operateLogDto.id != null">
                 and a.id = #{operateLogDto.id}
                 and a.id = #{operateLogDto.id}
             </if>
             </if>
+            <if test="operateLogDto.tenantId != null and operateLogDto.tenantId != ''">
+                and a.tenant_id = #{operateLogDto.tenantId}
+            </if>
             <if test="operateLogDto.condition != null and operateLogDto.condition != ''">
             <if test="operateLogDto.condition != null and operateLogDto.condition != ''">
                 and (a.USER_NAME like concat('%', #{operateLogDto.condition},'%')
                 and (a.USER_NAME like concat('%', #{operateLogDto.condition},'%')
                 or a.phone like concat('%', #{operateLogDto.condition},'%'))
                 or a.phone like concat('%', #{operateLogDto.condition},'%'))
@@ -163,7 +165,7 @@
                 and a.create_time >= #{operateLogDto.beginTime}
                 and a.create_time >= #{operateLogDto.beginTime}
             </if>
             </if>
             <if test="operateLogDto.endTime != null">
             <if test="operateLogDto.endTime != null">
-                and a.create_time &lt;= #{operateLogDto.endTime}
+                and a.create_time &lt;=  DATE_ADD(#{operateLogDto.endTime},INTERVAL 1 DAY)
             </if>
             </if>
         </where>
         </where>
     </select>
     </select>