dcs 10 月之前
父节点
当前提交
07a8cc4cee

+ 5 - 1
virgo.api/src/main/java/com/bosshand/virgo/api/controller/LookRecordController.java

@@ -21,7 +21,7 @@ public class LookRecordController {
     @Autowired
     LookRecordService lookRecordService;
 
-    @OperationControllerLog(module = "运维管理", operation = "会议纪要-会议设置-会议类型-新增")
+    @OperationControllerLog(module = "房源管理", operation = "房源列表-带看记录-列表")
     @ApiOperation("获取")
     @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST)
     public Response list(@RequestBody LookRecord lookRecord, @PathVariable int currPage, @PathVariable int pageSize) {
@@ -33,6 +33,7 @@ public class LookRecordController {
         return Response.ok(result);
     }
 
+    @OperationControllerLog(module = "房源管理", operation = "房源列表-带看记录-新增")
     @ApiOperation("保存")
     @RequestMapping(value = "", method = RequestMethod.POST)
     public Response insert(@RequestBody LookRecord lookRecord) {
@@ -40,6 +41,7 @@ public class LookRecordController {
         return Response.ok();
     }
 
+    @OperationControllerLog(module = "房源管理", operation = "房源列表-带看记录-编辑")
     @ApiOperation("更新")
     @RequestMapping(value = "/update", method = RequestMethod.PUT)
     public Response update(@RequestBody LookRecord lookRecord) {
@@ -47,6 +49,7 @@ public class LookRecordController {
         return Response.ok();
     }
 
+    @OperationControllerLog(module = "房源管理", operation = "房源列表-带看记录-删除")
     @ApiOperation("删除")
     @RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
     public Response delete(@PathVariable long id) {
@@ -54,6 +57,7 @@ public class LookRecordController {
         return Response.ok();
     }
 
+    @OperationControllerLog(module = "房源管理", operation = "房源列表-带看记录-详情")
     @ApiOperation("详情")
     @RequestMapping(value = "/{id}", method = RequestMethod.GET)
     public Response get(@PathVariable long id) {

+ 6 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/controller/ProjectItemTargetRoomController.java

@@ -5,6 +5,7 @@ import com.bosshand.virgo.api.model.RoomCollection;
 import com.bosshand.virgo.api.model.Tag;
 import com.bosshand.virgo.api.service.ProjectItemTargetRoomService;
 import com.bosshand.virgo.api.service.RoomService;
+import com.bosshand.virgo.core.config.OperationControllerLog;
 import com.bosshand.virgo.core.response.Response;
 import com.bosshand.virgo.core.utils.ContextUtils;
 import com.bosshand.virgo.core.utils.StringUtil;
@@ -43,6 +44,7 @@ public class ProjectItemTargetRoomController {
         return Response.ok(projectItemTargetRoomService.queryKeyWord(keyWord));
     }
 
+    @OperationControllerLog(module = "房源管理", operation = "房源列表")
     @ApiOperation("获取")
     @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST)
     public Response list(@RequestBody ProjectItemTargetRoom projectItemTargetRoom, @PathVariable int currPage, @PathVariable int pageSize) {
@@ -77,6 +79,7 @@ public class ProjectItemTargetRoomController {
         return Response.ok(result);
     }
 
+    @OperationControllerLog(module = "房源管理", operation = "房源新增")
     @ApiOperation("新增")
     @RequestMapping(value = "", method = RequestMethod.POST)
     public Response insert(@RequestBody ProjectItemTargetRoom projectItemTargetRoom) {
@@ -84,6 +87,7 @@ public class ProjectItemTargetRoomController {
         return Response.ok();
     }
 
+    @OperationControllerLog(module = "房源管理", operation = "房源删除")
     @ApiOperation("删除")
     @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
     public Response delete(@PathVariable long id) {
@@ -91,6 +95,7 @@ public class ProjectItemTargetRoomController {
         return Response.ok();
     }
 
+    @OperationControllerLog(module = "房源管理", operation = "房源编辑")
     @ApiOperation("修改")
     @RequestMapping(value = "", method = RequestMethod.PUT)
     public Response update(@RequestBody ProjectItemTargetRoom projectItemTargetRoom) {
@@ -98,6 +103,7 @@ public class ProjectItemTargetRoomController {
         return Response.ok();
     }
 
+    @OperationControllerLog(module = "房源管理", operation = "房源详情")
     @ApiOperation("详情")
     @RequestMapping(value = "/{id}", method = RequestMethod.GET)
     public Response get(@PathVariable long id) {

+ 12 - 3
virgo.core/src/main/java/com/bosshand/virgo/core/config/OperationLogAspect.java

@@ -2,6 +2,7 @@ package com.bosshand.virgo.core.config;
 
 import cn.hutool.json.JSONUtil;
 import com.bosshand.virgo.core.model.OperationLog;
+import com.bosshand.virgo.core.model.UserContext;
 import com.bosshand.virgo.core.response.Response;
 import com.bosshand.virgo.core.service.OperationLogService;
 import com.bosshand.virgo.core.utils.ContextUtils;
@@ -48,8 +49,6 @@ public class OperationLogAspect {
         logger.info("进入日志切面前置通知!");
     }
 
-    //使用这个方法先注释前面三个方法,留before方法就行
-
     /**
      * 通知包裹了目标方法,在目标方法调用之前和之后执行自定义的行为
      * ProceedingJoinPoint切入点可以获取切入点方法上的名字、参数、注解和对象
@@ -71,8 +70,18 @@ public class OperationLogAspect {
         //得到url
         String url = request.getRequestURL().toString();
         //写入操作日志
-        long userId = ContextUtils.getCurrentUser().getId();
+
+        UserContext userContext = ContextUtils.getUserContext();
+
+        long userId = userContext.getUserId();
+
+        long organizationId = userContext.getOrganizationId();
+
+        long projectId = userContext.getProjectId();
+
         OperationLog operationLog = new OperationLog();
+        operationLog.setOrganizationId(organizationId);
+        operationLog.setProjectId(projectId);
         operationLog.setUserId(userId);
         operationLog.setUrl(url);
         operationLog.setData(requestJson);

+ 27 - 1
virgo.core/src/main/java/com/bosshand/virgo/core/model/OperationLog.java

@@ -11,9 +11,19 @@ public class OperationLog {
 
     private long id;
 
-    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date date;
 
+    /**
+     * 组织id
+     */
+    private long organizationId;
+
+    /**
+     * 项目id
+     */
+    private long projectId;
+
     /**
      * 用户id
      */
@@ -55,6 +65,22 @@ public class OperationLog {
         this.date = date;
     }
 
+    public long getOrganizationId() {
+        return organizationId;
+    }
+
+    public void setOrganizationId(long organizationId) {
+        this.organizationId = organizationId;
+    }
+
+    public long getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(long projectId) {
+        this.projectId = projectId;
+    }
+
     public long getUserId() {
         return userId;
     }

+ 10 - 4
virgo.core/src/main/resources/mapper/OperationLogMapper.xml

@@ -7,6 +7,8 @@
     <resultMap type="com.bosshand.virgo.core.model.OperationLog" id="result">
         <id column="id" property="id"/>
         <result column="date" property="date"/>
+        <result column="organizationId" property="organizationId"/>
+        <result column="projectId" property="projectId"/>
         <result column="userId" property="userId"/>
         <result column="url" property="url"/>
         <result column="module" property="module"/>
@@ -15,8 +17,8 @@
     </resultMap>
 
     <insert id="insert" parameterType="com.bosshand.virgo.core.model.OperationLog" useGeneratedKeys="true" keyProperty="id">
-        INSERT INTO operation_log(`date`, `userId`, `url`, `module`, `operation`, `data`)
-        VALUES (now(), #{userId}, #{url}, #{module}, #{operation}, #{data})
+        INSERT INTO operation_log(`date`, `organizationId`, `projectId`, `userId`, `url`, `module`, `operation`, `data`)
+        VALUES (now(), #{organizationId}, #{projectId}, #{userId}, #{url}, #{module}, #{operation}, #{data})
     </insert>
 
     <select id="get" resultMap="result">
@@ -26,6 +28,8 @@
     <select id="getTotalCount" parameterType="com.bosshand.virgo.core.model.OperationLog" resultType="Integer">
         SELECT count(*) FROM operation_log
         <where>
+            <if test="organizationId!=0">and organizationId=#{organizationId}</if>
+            <if test="projectId!=0">and projectId=#{projectId}</if>
             <if test="userId!=0">and userId=#{userId}</if>
         </where>
     </select>
@@ -33,9 +37,11 @@
     <select id="getLimit" resultMap="result">
         SELECT * FROM operation_log
         <where>
-            <if test="userId!=0">and a.userId=#{p.userId}</if>
+            <if test="p.organizationId!=0">and organizationId=#{p.organizationId}</if>
+            <if test="p.projectId!=0">and projectId=#{p.projectId}</if>
+            <if test="p.userId!=0">and userId=#{p.userId}</if>
         </where>
-        order by a.date desc
+        order by date desc
         limit #{currIndex} , #{pageSize}
     </select>