Browse Source

事件收藏可视化接口

Memory_LG 4 weeks ago
parent
commit
1f85bd3a49

+ 1 - 1
event-ui/src/views/event/collect/index.vue

@@ -38,7 +38,7 @@
           <el-button size="mini" type="text" icon="el-icon-document" @click="handleEventLog(scope.row)"
                      v-hasPermi="['eventcatalogue:eventcatalogue:query']">事件日志
           </el-button>
-          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
+          <el-button size="mini" type="text" icon="el-icon-star-off" @click="handleDelete(scope.row)"
                     v-hasPermi="['system:collect:remove']">取消收藏
           </el-button>
         </template>

+ 12 - 1
event-ui/src/views/event/eventcatalogue/index.vue

@@ -85,6 +85,9 @@
           <el-button size="mini" type="text" icon="el-icon-document" @click="handleEventLog(scope.row)"
                      v-hasPermi="['eventcatalogue:eventcatalogue:query']">事件日志
           </el-button>
+          <el-button size="mini" type="text" icon="el-icon-star-on" @click="collectEvent(scope.row)"
+                     v-hasPermi="['system:collect:remove']">收藏事件
+          </el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -371,7 +374,8 @@
   import FileUpload from '@/views/components/FileUpload/index';
   import Supermap from '@/views/components/supermap';
   import {checkLat, checkLon} from "@/api/rules/rules";
-  import TcPlayer from '@/components/TcPlayer'; // 视频预览
+  import TcPlayer from '@/components/TcPlayer';
+  import {addCollect} from "@/api/event/collect/collect"; // 视频预览
    export default {
     name: "Eventcatalogue",
     components: {Deptselector, FileUpload, Supermap, TcPlayer},
@@ -822,6 +826,13 @@
           this.activities = res.data.eventlog;
           this.loading = false;
         });
+      },
+      /** 收藏事件 */
+      collectEvent(row){
+        let o = {eventCode: row.eventCode}
+        addCollect(o).then(res=>{
+          this.$modal.msgSuccess("收藏成功");
+        })
       }
     }
   };

+ 33 - 0
src/main/java/com/sooka/sponest/event/centereventteventcatalogue/controller/CenterEventViewController.java

@@ -3,7 +3,9 @@ package com.sooka.sponest.event.centereventteventcatalogue.controller;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.utils.SpringUtils;
 import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.core.utils.uuid.IdUtils;
 import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.core.web.page.TableDataInfo;
 import com.ruoyi.common.security.utils.SecurityUtils;
 import com.ruoyi.system.api.RemoteDeptService;
@@ -11,6 +13,8 @@ import com.sooka.sponest.event.centereventteventcatalogue.domain.bo.VisuForestCl
 import com.sooka.sponest.event.centereventteventcatalogue.domain.bo.VisuForestEventTodayEventListBO;
 import com.sooka.sponest.event.centereventteventcatalogue.domain.vo.VisuForestCloudMapVO;
 import com.sooka.sponest.event.centereventteventcatalogue.service.ICenterEventViewService;
+import com.sooka.sponest.event.centereventteventcollect.domain.CentereventTEventCollect;
+import com.sooka.sponest.event.centereventteventcollect.service.ICentereventTEventCollectService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.ArrayUtils;
@@ -37,6 +41,9 @@ public class CenterEventViewController extends BaseController {
     @Autowired
     private ICenterEventViewService centerEventViewService;
 
+    @Autowired
+    private ICentereventTEventCollectService centereventTEventCollectService;
+
     @ApiOperation("事件状态、来源统计")
     @PostMapping("/selectTodayEvents")
     public R<VisuForestCloudTodayEventsBO> selectTodayEvents(@RequestBody VisuForestCloudMapVO visuForestCloudMapVO) {
@@ -166,4 +173,30 @@ public class CenterEventViewController extends BaseController {
     public R getHousingConstructionEventList(@RequestBody VisuForestCloudMapVO visuForestCloudMapVO) {
         return R.ok(centerEventViewService.getHousingConstructionEventList(visuForestCloudMapVO));
     }
+
+
+    @GetMapping("/getCollectList")
+    public TableDataInfo getCollectList(CentereventTEventCollect centereventTEventCollect){
+        startPage();
+        List<CentereventTEventCollect> list = centereventTEventCollectService.selectCentereventTEventCollectList(centereventTEventCollect);
+        return getDataTable(list);
+    }
+
+    @PostMapping("/addCollect")
+    public AjaxResult addCollect(@RequestBody CentereventTEventCollect centereventTEventCollect){
+        centereventTEventCollect.setId(IdUtils.simpleUUID());
+        centereventTEventCollect.setSort("0");
+        if(StringUtils.isBlank(centereventTEventCollect.getUserId())){
+            centereventTEventCollect.setUserId(SecurityUtils.getUserId().toString());
+        }
+        if(centereventTEventCollectService.isCollect(centereventTEventCollect)){
+            return AjaxResult.error("您已收藏该事件");
+        }
+        return toAjax(centereventTEventCollectService.insertCentereventTEventCollect(centereventTEventCollect));
+    }
+
+    @PostMapping("/deleteCollect")
+    public AjaxResult deleteCollect(@RequestBody CentereventTEventCollect centereventTEventCollect){
+        return toAjax(centereventTEventCollectService.deleteCentereventTEventCollectById(centereventTEventCollect.getId()));
+    }
 }

+ 5 - 0
src/main/java/com/sooka/sponest/event/centereventteventcollect/controller/CentereventTEventCollectController.java

@@ -5,6 +5,7 @@ import java.io.IOException;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.core.utils.uuid.IdUtils;
 import com.ruoyi.common.security.utils.SecurityUtils;
 import com.sooka.sponest.event.centereventteventcollect.domain.CentereventTEventCollect;
 import com.sooka.sponest.event.centereventteventcollect.service.ICentereventTEventCollectService;
@@ -76,10 +77,14 @@ public class CentereventTEventCollectController extends BaseController {
     @Log(title = "事件收藏", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody CentereventTEventCollect centereventTEventCollect) {
+        centereventTEventCollect.setId(IdUtils.simpleUUID());
         centereventTEventCollect.setSort("0");
         if(StringUtils.isBlank(centereventTEventCollect.getUserId())){
             centereventTEventCollect.setUserId(SecurityUtils.getUserId().toString());
         }
+        if(centereventTEventCollectService.isCollect(centereventTEventCollect)){
+            return AjaxResult.error("您已收藏该事件");
+        }
         return toAjax(centereventTEventCollectService.insertCentereventTEventCollect(centereventTEventCollect));
     }
 

+ 2 - 0
src/main/java/com/sooka/sponest/event/centereventteventcollect/mapper/CentereventTEventCollectMapper.java

@@ -59,4 +59,6 @@ public interface CentereventTEventCollectMapper {
      * @return 结果
      */
     public int deleteCentereventTEventCollectByIds(String[] ids);
+
+    int isCollect(CentereventTEventCollect centereventTEventCollect);
 }

+ 2 - 0
src/main/java/com/sooka/sponest/event/centereventteventcollect/service/ICentereventTEventCollectService.java

@@ -59,4 +59,6 @@ public interface ICentereventTEventCollectService {
      * @return 结果
      */
     public int deleteCentereventTEventCollectById(String id);
+
+    boolean isCollect(CentereventTEventCollect centereventTEventCollect);
 }

+ 10 - 0
src/main/java/com/sooka/sponest/event/centereventteventcollect/service/impl/CentereventTEventCollectServiceImpl.java

@@ -2,7 +2,10 @@ package com.sooka.sponest.event.centereventteventcollect.service.impl;
 
 import java.util.List;
 
+import com.alibaba.nacos.common.utils.UuidUtils;
+import com.ruoyi.common.core.text.UUID;
 import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.core.utils.uuid.IdUtils;
 import com.ruoyi.common.security.utils.SecurityUtils;
 import com.sooka.sponest.event.centereventteventcollect.domain.CentereventTEventCollect;
 import com.sooka.sponest.event.centereventteventcollect.mapper.CentereventTEventCollectMapper;
@@ -89,4 +92,11 @@ public class CentereventTEventCollectServiceImpl implements ICentereventTEventCo
     public int deleteCentereventTEventCollectById(String id) {
         return centereventTEventCollectMapper.deleteCentereventTEventCollectById(id);
     }
+
+    @Override
+    public boolean isCollect(CentereventTEventCollect centereventTEventCollect) {
+        int collect = centereventTEventCollectMapper.isCollect(centereventTEventCollect);
+        System.out.println("collect = " + collect);
+        return collect > 0;
+    }
 }

+ 12 - 5
src/main/resources/mapper/centereventteventcollect/CentereventTEventCollectMapper.xml

@@ -97,11 +97,7 @@
         where id = #{id}
     </update>
 
-    <delete id="deleteCentereventTEventCollectById" parameterType="String">
-        delete
-        from centerevent_t_event_collect
-        where id = #{id}
-    </delete>-->
+    -->
     <insert id="insertCentereventTEventCollect" parameterType="CentereventTEventCollect">
         insert into centerevent_t_event_collect
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -123,4 +119,15 @@
             #{id}
         </foreach>
     </delete>
+
+    <select id="isCollect" parameterType="CentereventTEventCollect" resultType="int">
+        select count(1) from centerevent_t_event_collect
+        where event_code = #{eventCode} and user_id = #{userId}
+    </select>
+
+    <delete id="deleteCentereventTEventCollectById" parameterType="String">
+        delete
+        from centerevent_t_event_collect
+        where id = #{id}
+    </delete>
 </mapper>