瀏覽代碼

新增事项收藏事项

conghelong 1 年之前
父節點
當前提交
de4409d02b

+ 74 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/matter/collectConller.java

@@ -0,0 +1,74 @@
+package com.ruoyi.web.controller.matter;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.sooka.jnb.matter.domin.Collect;
+import com.sooka.jnb.matter.domin.Matter;
+import com.sooka.jnb.matter.service.CollectService;
+
+import com.sooka.jnb.matter.service.MatterService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/system/collect")
+public class collectConller extends BaseController {
+
+    @Autowired
+    private CollectService collectService;
+
+    @Autowired
+    private MatterService matterService;
+
+
+    /**
+     * 是否展示
+     */
+    @GetMapping("list")
+    public TableDataInfo list( Matter matter)
+    {
+        List<Matter> list = matterService.selectSysrecommendVo(matter);
+        return getDataTable(list);
+    }
+
+    /**
+     * 收藏事项
+     */
+    @PostMapping("add")
+    public AjaxResult add(@RequestBody Collect collect)
+    {
+        return toAjax(collectService.insertcollect(collect));
+    }
+
+
+    /**
+     * 获取事项详细信息
+     */
+    @GetMapping(value = "/lists/{id}")
+    public AjaxResult getInfo(@PathVariable("id") String id)
+    {
+        return success(collectService.selectcollect(id));
+    }
+
+    /**
+     * 获取收藏详细信息
+     */
+    @GetMapping(value = "/collectlist/{id}")
+    public TableDataInfo collectlist(@PathVariable("id") String id)
+    {
+        List<Matter> list = matterService.collectlist(id);
+        return getDataTable(list);
+
+    }
+    /**
+     * 取消事项收藏
+     */
+    @DeleteMapping("/delete/{id}")
+    public AjaxResult remove(@PathVariable Long id)
+    {
+        return toAjax(collectService.deletecollect(id));
+    }
+}

+ 13 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/matter/matterConllter.java

@@ -5,6 +5,8 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.page.TableDataInfo;
 
 import com.sooka.jnb.department.domin.Department;
+import com.sooka.jnb.department.service.DepartmentService;
+import com.sooka.jnb.matter.domin.Collect;
 import com.sooka.jnb.matter.domin.Matter;
 import com.sooka.jnb.matter.service.MatterService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,6 +26,8 @@ public class matterConllter extends BaseController {
     @Autowired
     private MatterService matterService;
 
+    @Autowired
+    private DepartmentService departmentService;
         /**
          * 查询事项列表
          */
@@ -42,6 +46,15 @@ public class matterConllter extends BaseController {
     {
         return success(matterService.selectSysMatterVo(matter));
     }
+
+    /**
+     * 查询事项列表
+     */
+    @GetMapping("/listdept")
+    public AjaxResult listdept(Department department)
+    {
+        return success(departmentService.selectSysDeptVo(department));
+    }
         /**
          * 获取事项详细信息
          */

+ 21 - 0
sooka-jnb/src/main/java/com/sooka/jnb/matter/domin/Collect.java

@@ -0,0 +1,21 @@
+package com.sooka.jnb.matter.domin;
+
+import com.ruoyi.common.core.domain.BaseEntity;
+import lombok.Data;
+
+
+@Data
+
+
+public class Collect  extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+
+    //id
+    private Integer id;
+    //用户id
+    private  String  userId;
+    //事项id
+    private  String  matterId;
+
+}

+ 6 - 0
sooka-jnb/src/main/java/com/sooka/jnb/matter/domin/Matter.java

@@ -26,6 +26,12 @@ public class Matter extends BaseEntity {
         private  String examine;
         //内容
         private  String content;
+
+        //内容
+        private  String userId;
+
+        //内容
+        private  String matterId;
     }
 
 

+ 29 - 0
sooka-jnb/src/main/java/com/sooka/jnb/matter/mapper/CollectMapper.java

@@ -0,0 +1,29 @@
+package com.sooka.jnb.matter.mapper;
+
+import com.sooka.jnb.matter.domin.Collect;
+import com.sooka.jnb.matter.domin.Matter;
+
+import java.util.List;
+
+public interface CollectMapper {
+    /**
+     * 收藏事项
+     */
+    int insertcollect(Collect collect);
+
+
+    /**
+     * 获取收藏事项详细信息
+     */
+    Collect selectcollect(String id);
+
+    /**
+     * 获取事项详细信息
+     */
+    List<Matter> collectlist(String id);
+
+    /**
+     * 取消事项收藏
+     */
+    int deletecollect(Long id);
+}

+ 10 - 0
sooka-jnb/src/main/java/com/sooka/jnb/matter/mapper/MatterMapper.java

@@ -23,6 +23,11 @@ public interface MatterMapper {
         List<Matter> selectSysMatterVo(Matter matter);
 
         /**
+         * 查询推荐事项列表
+         */
+        List<Matter> selectSysrecommendVo(Matter matter);
+
+        /**
          * 新增事项
          */
         int insertSysMatter(Matter matter);
@@ -38,6 +43,11 @@ public interface MatterMapper {
         int examine(Matter matter);
 
         /**
+         * 获取事项详细信息
+         */
+        List<Matter> collectlist(String id);
+
+        /**
          * 删除事项
          */
         int deleteSysMatterByDeptId(Long id);

+ 26 - 0
sooka-jnb/src/main/java/com/sooka/jnb/matter/service/CollectService.java

@@ -0,0 +1,26 @@
+package com.sooka.jnb.matter.service;
+
+import com.sooka.jnb.matter.domin.Collect;
+import com.sooka.jnb.matter.domin.Matter;
+
+import java.util.List;
+
+
+public interface CollectService {
+
+    /**
+     * 收藏事项
+     */
+    int insertcollect(Collect collect);
+
+    /**
+     * 获取收藏事项详细信息
+     */
+    Collect selectcollect(String id);
+
+
+    /**
+     * 取消事项收藏
+     */
+    int deletecollect(Long id);
+}

+ 9 - 0
sooka-jnb/src/main/java/com/sooka/jnb/matter/service/MatterService.java

@@ -19,6 +19,15 @@ public interface MatterService
      List<Matter> selectSysMatterVo(Matter matter);
 
     /**
+     * 查询推荐事项列表
+     */
+    List<Matter> selectSysrecommendVo(Matter matter);
+    /**
+     * 获取收藏详细信息
+     */
+    List<Matter> collectlist(String id);
+
+    /**
      * 新增事项
      */
     int insertSysMatter(Matter matter);

+ 50 - 0
sooka-jnb/src/main/java/com/sooka/jnb/matter/service/impl/CollectServicempl.java

@@ -0,0 +1,50 @@
+package com.sooka.jnb.matter.service.impl;
+
+
+import com.sooka.jnb.matter.domin.Collect;
+
+import com.sooka.jnb.matter.domin.Matter;
+import com.sooka.jnb.matter.mapper.CollectMapper;
+import com.sooka.jnb.matter.mapper.MatterMapper;
+import com.sooka.jnb.matter.service.CollectService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class CollectServicempl  implements CollectService {
+
+    @Resource
+    private CollectMapper collectMapper;
+
+    @Resource
+    private MatterMapper matterMapper;
+    /**
+     * 收藏事项
+     */
+    @Override
+    public int insertcollect(Collect collect) {
+        return collectMapper.insertcollect( collect);
+    }
+
+    /**
+     * 获取收藏事项详细信息
+     */
+    @Override
+    public Collect selectcollect(String id)
+    {
+        return collectMapper.selectcollect(id);
+    }
+
+
+    /**
+     * 取消事项收藏
+     */
+    @Override
+    public int deletecollect(Long id)
+    {
+        return collectMapper.deletecollect(id);
+    }
+
+}

+ 17 - 0
sooka-jnb/src/main/java/com/sooka/jnb/matter/service/impl/MatterServicempl.java

@@ -36,6 +36,23 @@ public class MatterServicempl implements MatterService
     }
 
     /**
+     * 查询推荐事项列表
+     */
+    @Override
+    public List<Matter> selectSysrecommendVo(Matter matter)
+    {
+        return matterMapper.selectSysrecommendVo(matter);
+    }
+    /**
+     * 获取事项详细信息
+     */
+    @Override
+    public List<Matter> collectlist(String id)
+    {
+        return matterMapper.collectlist(id);
+    }
+
+    /**
      * 新增事项
      */
     @Override

+ 35 - 0
sooka-jnb/src/main/resources/mapper/matter/collectMapper.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sooka.jnb.matter.mapper.CollectMapper">
+
+    <resultMap type="com.sooka.jnb.matter.domin.Collect" id="CollectResult">
+        <result property="id"    column="id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="matterId"    column="matter_id"    />
+    </resultMap>
+
+    <insert id="insertcollect">
+       INSERT INTO
+           jnb_list_user_favorites (user_id, matter_id)
+        VALUE (#{userId},#{matterId} )
+    </insert>
+
+
+    <select id="selectcollect"  resultMap="CollectResult">
+       select  user_id, matter_id  from jnb_list_user_favorites
+        where user_id = #{id}
+    </select>
+
+    <select id="collectlist"  resultMap="CollectResult">
+		SELECT * FROM jnb_list_of_matters
+        WHERE id IN (
+        SELECT matter_id FROM jnb_list_user_favorites
+        WHERE user_id = #{id})
+    </select>
+
+    <delete id="deletecollect" parameterType="Long">
+        delete from jnb_list_user_favorites where matter_id = #{id}
+    </delete>
+</mapper>

+ 16 - 0
sooka-jnb/src/main/resources/mapper/matter/matterMapper.xml

@@ -27,12 +27,21 @@
             <if test="examine != null and examine !=''">
                 AND examine LIKE '%' #{examine} '%'
             </if>
+            <if test="department != null and department !=''">
+                AND department = #{department}
+            </if>
             <if test="type != null and type !=''">
                 AND type = #{type}
             </if>
         </where>
     </select>
 
+    <select id="selectSysrecommendVo"  resultMap="MatterResult">
+        select  id,title, type, department,operation,address,phone,picture,examine ,content from jnb_list_of_matters
+        where operation=0
+    </select>
+
+
     <select id="selectSysMatterById"  resultMap="MatterResult">
        select  id ,title, type, department,operation,address,phone,picture,examine,content from jnb_list_of_matters
         where id = #{id}
@@ -59,6 +68,13 @@
         where id = #{id}
     </update>
 
+    <select id="collectlist"  resultMap="MatterResult">
+		SELECT * FROM jnb_list_of_matters
+        WHERE id IN (
+        SELECT matter_id FROM jnb_list_user_favorites
+        WHERE user_id = #{id})
+    </select>
+
     <update id="examine" parameterType="SysDept">
         update jnb_list_of_matters
         <trim prefix="SET" suffixOverrides=",">