瀏覽代碼

+ 点赞,收藏功能

chen.cheng 11 月之前
父節點
當前提交
f38cfa8aa4
共有 19 個文件被更改,包括 876 次插入49 次删除
  1. 28 4
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/cp/CpsContentInfoController.java
  2. 10 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/cp/CpsMeetingUsrController.java
  3. 94 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/cp/CpsUsrContentRelController.java
  4. 26 0
      ruoyi-common/src/main/java/com/ruoyi/common/enums/SysYesNo.java
  5. 38 13
      ruoyi-system/src/main/java/com/ruoyi/system/domain/CpsContentInfo.java
  6. 125 0
      ruoyi-system/src/main/java/com/ruoyi/system/domain/CpsUsrContentRel.java
  7. 19 9
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/CpsContentInfoMapper.java
  8. 5 0
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/CpsMeetingUsrMapper.java
  9. 63 0
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/CpsUsrContentRelMapper.java
  10. 16 8
      ruoyi-system/src/main/java/com/ruoyi/system/service/ICpsContentInfoService.java
  11. 2 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/ICpsMeetingUsrService.java
  12. 61 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/ICpsUsrContentRelService.java
  13. 98 12
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CpsContentInfoServiceImpl.java
  14. 6 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CpsMeetingUsrServiceImpl.java
  15. 96 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CpsUsrContentRelServiceImpl.java
  16. 27 2
      ruoyi-system/src/main/resources/mapper/cp/CpsContentInfoMapper.xml
  17. 14 0
      ruoyi-system/src/main/resources/mapper/cp/CpsMeetingUsrMapper.xml
  18. 148 0
      ruoyi-system/src/main/resources/mapper/cp/CpsUsrContentRelMapper.xml
  19. 0 1
      ruoyi-ui/src/views/cp/viewcfg/index.vue

+ 28 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/cp/CpsContentInfoController.java

@@ -8,10 +8,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.system.domain.CpsContentInfo;
-import com.ruoyi.system.domain.vo.WeChatVO;
-import com.ruoyi.system.rest.WechatService;
 import com.ruoyi.system.service.ICpsContentInfoService;
-import com.ruoyi.web.core.config.WeChatCfg;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -25,7 +22,6 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
-import java.util.Map;
 
 /**
  * 发布内容Controller
@@ -97,4 +93,32 @@ public class CpsContentInfoController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(cpsContentInfoService.deleteCpsContentInfoByIds(ids));
     }
+
+    @Log(title = "点赞内容", businessType = BusinessType.UPDATE)
+    @PostMapping("/{openId}/like")
+    public AjaxResult likeContent(@RequestBody CpsContentInfo cpsContentInfo, @PathVariable String openId) {
+        cpsContentInfoService.updateLikeContent(cpsContentInfo.getId(), openId);
+        return AjaxResult.success();
+    }
+
+    @Log(title = "点赞内容", businessType = BusinessType.UPDATE)
+    @PostMapping("/{openId}/unlike")
+    public AjaxResult unlikeContent(@RequestBody CpsContentInfo cpsContentInfo, @PathVariable String openId) {
+        cpsContentInfoService.updateDisLikeContent(cpsContentInfo.getId(), openId);
+        return AjaxResult.success();
+    }
+
+    @Log(title = "收藏内容", businessType = BusinessType.UPDATE)
+    @PostMapping("/{openId}/collect")
+    public AjaxResult collectContent(@RequestBody CpsContentInfo cpsContentInfo, @PathVariable String openId) {
+        cpsContentInfoService.updateCollectContent(cpsContentInfo.getId(), openId);
+        return AjaxResult.success();
+    }
+
+    @Log(title = "收藏内容", businessType = BusinessType.UPDATE)
+    @PostMapping("/{openId}/uncollect")
+    public AjaxResult uncollectContent(@RequestBody CpsContentInfo cpsContentInfo, @PathVariable String openId) {
+        cpsContentInfoService.updateDisCollectContent(cpsContentInfo.getId(), openId);
+        return AjaxResult.success();
+    }
 }

+ 10 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/cp/CpsMeetingUsrController.java

@@ -9,6 +9,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.web.service.TokenService;
+import com.ruoyi.system.domain.CpsContentInfo;
 import com.ruoyi.system.domain.CpsMeetingUsr;
 import com.ruoyi.system.rest.WechatService;
 import com.ruoyi.system.service.ICpsMeetingUsrService;
@@ -142,4 +143,13 @@ public class CpsMeetingUsrController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(cpsMeetingUsrService.deleteCpsMeetingUsrByIds(ids));
     }
+
+    @Log(title = "用户赞收藏信息", businessType = BusinessType.DELETE)
+    @GetMapping("/content/rel/{openId}")
+    @Anonymous
+    public TableDataInfo usrContentRel(CpsContentInfo cpsContentInfo, @PathVariable String openId) {
+        startPage();
+        List<CpsContentInfo> list = cpsMeetingUsrService.qryUsrCollectContent(openId, cpsContentInfo.getTitle());
+        return getDataTable(list);
+    }
 }

+ 94 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/cp/CpsUsrContentRelController.java

@@ -0,0 +1,94 @@
+package com.ruoyi.web.controller.cp;
+
+import com.ruoyi.common.annotation.Anonymous;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.system.domain.CpsUsrContentRel;
+import com.ruoyi.system.service.ICpsUsrContentRelService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 用户资讯信息Controller
+ *
+ * @author ruoyi
+ * @date 2024-08-22
+ */
+@RestController
+@CrossOrigin
+@Anonymous
+@RequestMapping("/cp/usrContentRel")
+public class CpsUsrContentRelController extends BaseController {
+    @Autowired
+    private ICpsUsrContentRelService cpsUsrContentRelService;
+
+    /**
+     * 查询用户资讯信息列表
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(CpsUsrContentRel cpsUsrContentRel) {
+        startPage();
+        List<CpsUsrContentRel> list = cpsUsrContentRelService.selectCpsUsrContentRelList(cpsUsrContentRel);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出用户资讯信息列表
+     */
+    @Log(title = "用户资讯信息", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, CpsUsrContentRel cpsUsrContentRel) {
+        List<CpsUsrContentRel> list = cpsUsrContentRelService.selectCpsUsrContentRelList(cpsUsrContentRel);
+        ExcelUtil<CpsUsrContentRel> util = new ExcelUtil<CpsUsrContentRel>(CpsUsrContentRel.class);
+        util.exportExcel(response, list, "用户资讯信息数据");
+    }
+
+    /**
+     * 获取用户资讯信息详细信息
+     */
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
+        return success(cpsUsrContentRelService.selectCpsUsrContentRelById(id));
+    }
+
+    @GetMapping(value = "/{openId}/{id}")
+    public AjaxResult getInfoByOpenId(@PathVariable("openId") String openId, @PathVariable("id") Long id) {
+        return success(cpsUsrContentRelService.selectCpsUsrContentRelList(new CpsUsrContentRel() {{
+            setOpenId(openId);
+            setContentId(id);
+        }}));
+    }
+
+    /**
+     * 修改用户资讯信息
+     */
+    @Log(title = "用户资讯信息", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody CpsUsrContentRel cpsUsrContentRel) {
+        return toAjax(cpsUsrContentRelService.updateCpsUsrContentRel(cpsUsrContentRel));
+    }
+
+    /**
+     * 删除用户资讯信息
+     */
+    @Log(title = "用户资讯信息", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        return toAjax(cpsUsrContentRelService.deleteCpsUsrContentRelByIds(ids));
+    }
+}

+ 26 - 0
ruoyi-common/src/main/java/com/ruoyi/common/enums/SysYesNo.java

@@ -0,0 +1,26 @@
+package com.ruoyi.common.enums;
+
+/**
+ * 用户状态
+ *
+ * @author ruoyi
+ */
+public enum SysYesNo {
+    YES("0", "是"), NO("1", "否");
+
+    private final String code;
+    private final String info;
+
+    SysYesNo(String code, String info) {
+        this.code = code;
+        this.info = info;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getInfo() {
+        return info;
+    }
+}

+ 38 - 13
ruoyi-system/src/main/java/com/ruoyi/system/domain/CpsContentInfo.java

@@ -1,13 +1,13 @@
 package com.ruoyi.system.domain;
 
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
 
 /**
  * 发布内容对象 cps_content_info
- * 
+ *
  * @author ruoyi
  * @date 2024-08-14
  */
@@ -33,53 +33,78 @@ public class CpsContentInfo extends BaseEntity
     /** 资讯类型 */
     @Excel(name = "资讯类型")
     private Integer contentType;
+    @Excel(name = "点赞数")
+    private Integer likeCnt;
+    @Excel(name = "收藏数")
+    private Integer collectedCnt;
+
 
-    public void setId(Long id) 
+    public void setId(Long id)
     {
         this.id = id;
     }
 
-    public Long getId() 
+    public Long getId()
     {
         return id;
     }
-    public void setTitle(String title) 
+
+    public void setTitle(String title)
     {
         this.title = title;
     }
 
-    public String getTitle() 
+    public String getTitle()
     {
         return title;
     }
-    public void setContent(String content) 
+
+    public void setContent(String content)
     {
         this.content = content;
     }
 
-    public String getContent() 
+    public String getContent()
     {
         return content;
     }
-    public void setThumbnail(String thumbnail) 
+
+    public void setThumbnail(String thumbnail)
     {
         this.thumbnail = thumbnail;
     }
 
-    public String getThumbnail() 
+    public String getThumbnail()
     {
         return thumbnail;
     }
-    public void setContentType(Integer contentType) 
+
+    public void setContentType(Integer contentType)
     {
         this.contentType = contentType;
     }
 
-    public Integer getContentType() 
+    public Integer getContentType()
     {
         return contentType;
     }
 
+    public Integer getLikeCnt() {
+        return likeCnt;
+    }
+
+    public void setLikeCnt(Integer likeCnt) {
+        this.likeCnt = likeCnt;
+    }
+
+    public Integer getCollectedCnt() {
+        return collectedCnt;
+    }
+
+    public void setCollectedCnt(Integer collectedCnt) {
+        this.collectedCnt = collectedCnt;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 125 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/CpsUsrContentRel.java

@@ -0,0 +1,125 @@
+package com.ruoyi.system.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 用户资讯信息对象 cps_usr_content_rel
+ * 
+ * @author ruoyi
+ * @date 2024-08-22
+ */
+public class CpsUsrContentRel extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键 */
+    private Long id;
+
+    /** openid */
+    @Excel(name = "openid")
+    private String openId;
+
+    /** 资讯主键 */
+    @Excel(name = "资讯主键")
+    private Long contentId;
+
+    /** 资讯主题 */
+    @Excel(name = "资讯主题")
+    private String contentTitle;
+
+    /** 资讯缩略图 */
+    @Excel(name = "资讯缩略图")
+    private String thumbnail;
+
+    /** 0收藏,1未收藏 */
+    @Excel(name = "0收藏,1未收藏")
+    private String collectFlag;
+
+    /** 0点赞,1未点赞 */
+    @Excel(name = "0点赞,1未点赞")
+    private String likeFlag;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setOpenId(String openId) 
+    {
+        this.openId = openId;
+    }
+
+    public String getOpenId() 
+    {
+        return openId;
+    }
+    public void setContentId(Long contentId) 
+    {
+        this.contentId = contentId;
+    }
+
+    public Long getContentId() 
+    {
+        return contentId;
+    }
+    public void setContentTitle(String contentTitle) 
+    {
+        this.contentTitle = contentTitle;
+    }
+
+    public String getContentTitle() 
+    {
+        return contentTitle;
+    }
+    public void setThumbnail(String thumbnail) 
+    {
+        this.thumbnail = thumbnail;
+    }
+
+    public String getThumbnail() 
+    {
+        return thumbnail;
+    }
+    public void setCollectFlag(String collectFlag) 
+    {
+        this.collectFlag = collectFlag;
+    }
+
+    public String getCollectFlag() 
+    {
+        return collectFlag;
+    }
+    public void setLikeFlag(String likeFlag) 
+    {
+        this.likeFlag = likeFlag;
+    }
+
+    public String getLikeFlag() 
+    {
+        return likeFlag;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("openId", getOpenId())
+            .append("contentId", getContentId())
+            .append("contentTitle", getContentTitle())
+            .append("thumbnail", getThumbnail())
+            .append("collectFlag", getCollectFlag())
+            .append("likeFlag", getLikeFlag())
+            .append("updateTime", getUpdateTime())
+            .append("createTime", getCreateTime())
+            .append("createBy", getCreateBy())
+            .append("updateBy", getUpdateBy())
+            .toString();
+    }
+}

+ 19 - 9
ruoyi-system/src/main/java/com/ruoyi/system/mapper/CpsContentInfoMapper.java

@@ -1,19 +1,20 @@
 package com.ruoyi.system.mapper;
 
-import java.util.List;
 import com.ruoyi.system.domain.CpsContentInfo;
 
+import java.util.List;
+
 /**
  * 发布内容Mapper接口
- * 
+ *
  * @author ruoyi
  * @date 2024-08-14
  */
-public interface CpsContentInfoMapper 
+public interface CpsContentInfoMapper
 {
     /**
      * 查询发布内容
-     * 
+     *
      * @param id 发布内容主键
      * @return 发布内容
      */
@@ -21,7 +22,7 @@ public interface CpsContentInfoMapper
 
     /**
      * 查询发布内容列表
-     * 
+     *
      * @param cpsContentInfo 发布内容
      * @return 发布内容集合
      */
@@ -29,7 +30,7 @@ public interface CpsContentInfoMapper
 
     /**
      * 新增发布内容
-     * 
+     *
      * @param cpsContentInfo 发布内容
      * @return 结果
      */
@@ -37,7 +38,7 @@ public interface CpsContentInfoMapper
 
     /**
      * 修改发布内容
-     * 
+     *
      * @param cpsContentInfo 发布内容
      * @return 结果
      */
@@ -45,7 +46,7 @@ public interface CpsContentInfoMapper
 
     /**
      * 删除发布内容
-     * 
+     *
      * @param id 发布内容主键
      * @return 结果
      */
@@ -53,9 +54,18 @@ public interface CpsContentInfoMapper
 
     /**
      * 批量删除发布内容
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
     public int deleteCpsContentInfoByIds(Long[] ids);
+
+    void updateCollectContent(Long id);
+
+    void updateDisCollectContent(Long id);
+
+    void updateLikeContent(Long id);
+
+    void updateDisLikeContent(Long id);
+
 }

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/CpsMeetingUsrMapper.java

@@ -1,6 +1,8 @@
 package com.ruoyi.system.mapper;
 
+import com.ruoyi.system.domain.CpsContentInfo;
 import com.ruoyi.system.domain.CpsMeetingUsr;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -64,4 +66,7 @@ public interface CpsMeetingUsrMapper {
     CpsMeetingUsr qryUsrByTel(String tel);
 
     int updateCpsMeetingUsrByTel(CpsMeetingUsr cpsMeetingUsr);
+
+    List<CpsContentInfo> qryUsrCollectContent(@Param("openId") String openId, @Param("keyword") String keyword);
+
 }

+ 63 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/CpsUsrContentRelMapper.java

@@ -0,0 +1,63 @@
+package com.ruoyi.system.mapper;
+
+import com.ruoyi.system.domain.CpsUsrContentRel;
+
+import java.util.List;
+
+/**
+ * 用户资讯信息Mapper接口
+ *
+ * @author ruoyi
+ * @date 2024-08-22
+ */
+public interface CpsUsrContentRelMapper {
+    /**
+     * 查询用户资讯信息
+     *
+     * @param id 用户资讯信息主键
+     * @return 用户资讯信息
+     */
+    public CpsUsrContentRel selectCpsUsrContentRelById(Long id);
+
+    /**
+     * 查询用户资讯信息列表
+     *
+     * @param cpsUsrContentRel 用户资讯信息
+     * @return 用户资讯信息集合
+     */
+    public List<CpsUsrContentRel> selectCpsUsrContentRelList(CpsUsrContentRel cpsUsrContentRel);
+
+    /**
+     * 新增用户资讯信息
+     *
+     * @param cpsUsrContentRel 用户资讯信息
+     * @return 结果
+     */
+    public int insertCpsUsrContentRel(CpsUsrContentRel cpsUsrContentRel);
+
+    /**
+     * 修改用户资讯信息
+     *
+     * @param cpsUsrContentRel 用户资讯信息
+     * @return 结果
+     */
+    public int updateCpsUsrContentRel(CpsUsrContentRel cpsUsrContentRel);
+
+    /**
+     * 删除用户资讯信息
+     *
+     * @param id 用户资讯信息主键
+     * @return 结果
+     */
+    public int deleteCpsUsrContentRelById(Long id);
+
+    /**
+     * 批量删除用户资讯信息
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteCpsUsrContentRelByIds(Long[] ids);
+
+    void insertOrUpdateCpsUsrContent(CpsUsrContentRel cpsUsrContentRel);
+}

+ 16 - 8
ruoyi-system/src/main/java/com/ruoyi/system/service/ICpsContentInfoService.java

@@ -5,15 +5,15 @@ import com.ruoyi.system.domain.CpsContentInfo;
 
 /**
  * 发布内容Service接口
- * 
+ *
  * @author ruoyi
  * @date 2024-08-14
  */
-public interface ICpsContentInfoService 
+public interface ICpsContentInfoService
 {
     /**
      * 查询发布内容
-     * 
+     *
      * @param id 发布内容主键
      * @return 发布内容
      */
@@ -21,7 +21,7 @@ public interface ICpsContentInfoService
 
     /**
      * 查询发布内容列表
-     * 
+     *
      * @param cpsContentInfo 发布内容
      * @return 发布内容集合
      */
@@ -29,7 +29,7 @@ public interface ICpsContentInfoService
 
     /**
      * 新增发布内容
-     * 
+     *
      * @param cpsContentInfo 发布内容
      * @return 结果
      */
@@ -37,7 +37,7 @@ public interface ICpsContentInfoService
 
     /**
      * 修改发布内容
-     * 
+     *
      * @param cpsContentInfo 发布内容
      * @return 结果
      */
@@ -45,7 +45,7 @@ public interface ICpsContentInfoService
 
     /**
      * 批量删除发布内容
-     * 
+     *
      * @param ids 需要删除的发布内容主键集合
      * @return 结果
      */
@@ -53,9 +53,17 @@ public interface ICpsContentInfoService
 
     /**
      * 删除发布内容信息
-     * 
+     *
      * @param id 发布内容主键
      * @return 结果
      */
     public int deleteCpsContentInfoById(Long id);
+
+    public void updateCollectContent(Long id,String openId);
+
+    void updateDisCollectContent(Long id, String openId);
+
+    void updateLikeContent(Long id,String openId);
+
+    void updateDisLikeContent(Long id,String openId);
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ICpsMeetingUsrService.java

@@ -1,6 +1,7 @@
 package com.ruoyi.system.service;
 
 import com.ruoyi.common.core.domain.model.WeChatUser;
+import com.ruoyi.system.domain.CpsContentInfo;
 import com.ruoyi.system.domain.CpsMeetingUsr;
 
 import java.util.List;
@@ -66,4 +67,5 @@ public interface ICpsMeetingUsrService {
 
     void usrRegister(CpsMeetingUsr user);
 
+    List<CpsContentInfo> qryUsrCollectContent(String openId,String keyword);
 }

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ICpsUsrContentRelService.java

@@ -0,0 +1,61 @@
+package com.ruoyi.system.service;
+
+import com.ruoyi.system.domain.CpsUsrContentRel;
+
+import java.util.List;
+
+/**
+ * 用户资讯信息Service接口
+ *
+ * @author ruoyi
+ * @date 2024-08-22
+ */
+public interface ICpsUsrContentRelService {
+    /**
+     * 查询用户资讯信息
+     *
+     * @param id 用户资讯信息主键
+     * @return 用户资讯信息
+     */
+    public CpsUsrContentRel selectCpsUsrContentRelById(Long id);
+
+    /**
+     * 查询用户资讯信息列表
+     *
+     * @param cpsUsrContentRel 用户资讯信息
+     * @return 用户资讯信息集合
+     */
+    public List<CpsUsrContentRel> selectCpsUsrContentRelList(CpsUsrContentRel cpsUsrContentRel);
+
+    /**
+     * 新增用户资讯信息
+     *
+     * @param cpsUsrContentRel 用户资讯信息
+     * @return 结果
+     */
+    public int insertCpsUsrContentRel(CpsUsrContentRel cpsUsrContentRel);
+
+    /**
+     * 修改用户资讯信息
+     *
+     * @param cpsUsrContentRel 用户资讯信息
+     * @return 结果
+     */
+    public int updateCpsUsrContentRel(CpsUsrContentRel cpsUsrContentRel);
+
+    /**
+     * 批量删除用户资讯信息
+     *
+     * @param ids 需要删除的用户资讯信息主键集合
+     * @return 结果
+     */
+    public int deleteCpsUsrContentRelByIds(Long[] ids);
+
+    /**
+     * 删除用户资讯信息信息
+     *
+     * @param id 用户资讯信息主键
+     * @return 结果
+     */
+    public int deleteCpsUsrContentRelById(Long id);
+}

+ 98 - 12
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CpsContentInfoServiceImpl.java

@@ -1,28 +1,38 @@
 package com.ruoyi.system.service.impl;
 
-import java.util.List;
+import com.ruoyi.common.enums.SysYesNo;
+import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import com.ruoyi.system.mapper.CpsContentInfoMapper;
 import com.ruoyi.system.domain.CpsContentInfo;
+import com.ruoyi.system.domain.CpsUsrContentRel;
+import com.ruoyi.system.mapper.CpsContentInfoMapper;
+import com.ruoyi.system.mapper.CpsUsrContentRelMapper;
 import com.ruoyi.system.service.ICpsContentInfoService;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
 
 /**
  * 发布内容Service业务层处理
- * 
+ *
  * @author ruoyi
  * @date 2024-08-14
  */
 @Service
-public class CpsContentInfoServiceImpl implements ICpsContentInfoService 
+public class CpsContentInfoServiceImpl implements ICpsContentInfoService
 {
     @Autowired
     private CpsContentInfoMapper cpsContentInfoMapper;
 
+    @Autowired
+    private CpsUsrContentRelMapper cpsUsrContentRelMapper;
+
     /**
      * 查询发布内容
-     * 
+     *
      * @param id 发布内容主键
      * @return 发布内容
      */
@@ -34,7 +44,7 @@ public class CpsContentInfoServiceImpl implements ICpsContentInfoService
 
     /**
      * 查询发布内容列表
-     * 
+     *
      * @param cpsContentInfo 发布内容
      * @return 发布内容
      */
@@ -46,7 +56,7 @@ public class CpsContentInfoServiceImpl implements ICpsContentInfoService
 
     /**
      * 新增发布内容
-     * 
+     *
      * @param cpsContentInfo 发布内容
      * @return 结果
      */
@@ -59,7 +69,7 @@ public class CpsContentInfoServiceImpl implements ICpsContentInfoService
 
     /**
      * 修改发布内容
-     * 
+     *
      * @param cpsContentInfo 发布内容
      * @return 结果
      */
@@ -72,7 +82,7 @@ public class CpsContentInfoServiceImpl implements ICpsContentInfoService
 
     /**
      * 批量删除发布内容
-     * 
+     *
      * @param ids 需要删除的发布内容主键
      * @return 结果
      */
@@ -84,7 +94,7 @@ public class CpsContentInfoServiceImpl implements ICpsContentInfoService
 
     /**
      * 删除发布内容信息
-     * 
+     *
      * @param id 发布内容主键
      * @return 结果
      */
@@ -93,4 +103,80 @@ public class CpsContentInfoServiceImpl implements ICpsContentInfoService
     {
         return cpsContentInfoMapper.deleteCpsContentInfoById(id);
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateCollectContent(Long id, String openId) {
+        CpsContentInfo cpsContentInfo = cpsContentInfoMapper.selectCpsContentInfoById(id);
+        if (ObjectUtils.isEmpty(cpsContentInfo)) {
+            throw new ServiceException("未找到该资讯");
+        }
+        cpsContentInfoMapper.updateCollectContent(id);
+        cpsUsrContentRelMapper.insertOrUpdateCpsUsrContent(new CpsUsrContentRel() {
+            {
+                setOpenId(openId);
+                setContentId(id);
+                setContentTitle(cpsContentInfo.getTitle());
+                setThumbnail(cpsContentInfo.getThumbnail());
+                setCollectFlag(SysYesNo.YES.getCode());
+            }
+        });
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateDisCollectContent(Long id, String openId) {
+        CpsContentInfo cpsContentInfo = cpsContentInfoMapper.selectCpsContentInfoById(id);
+        if (ObjectUtils.isEmpty(cpsContentInfo)) {
+            throw new ServiceException("未找到该资讯");
+        }
+        cpsContentInfoMapper.updateDisCollectContent(id);
+        cpsUsrContentRelMapper.insertOrUpdateCpsUsrContent(new CpsUsrContentRel() {
+            {
+                setOpenId(openId);
+                setContentId(id);
+                setContentTitle(cpsContentInfo.getTitle());
+                setThumbnail(cpsContentInfo.getThumbnail());
+                setCollectFlag(SysYesNo.NO.getCode());
+            }
+        });
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateLikeContent(Long id, String openId) {
+        CpsContentInfo cpsContentInfo = cpsContentInfoMapper.selectCpsContentInfoById(id);
+        if (ObjectUtils.isEmpty(cpsContentInfo)) {
+            throw new ServiceException("未找到该资讯");
+        }
+        cpsContentInfoMapper.updateLikeContent(id);
+        cpsUsrContentRelMapper.insertOrUpdateCpsUsrContent(new CpsUsrContentRel() {
+            {
+                setOpenId(openId);
+                setContentId(id);
+                setContentTitle(cpsContentInfo.getTitle());
+                setThumbnail(cpsContentInfo.getThumbnail());
+                setLikeFlag(SysYesNo.YES.getCode());
+            }
+        });
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateDisLikeContent(Long id, String openId) {
+        CpsContentInfo cpsContentInfo = cpsContentInfoMapper.selectCpsContentInfoById(id);
+        if (ObjectUtils.isEmpty(cpsContentInfo)) {
+            throw new ServiceException("未找到该资讯");
+        }
+        cpsContentInfoMapper.updateDisLikeContent(id);
+        cpsUsrContentRelMapper.insertOrUpdateCpsUsrContent(new CpsUsrContentRel() {
+            {
+                setOpenId(openId);
+                setContentId(id);
+                setContentTitle(cpsContentInfo.getTitle());
+                setThumbnail(cpsContentInfo.getThumbnail());
+                setLikeFlag(SysYesNo.NO.getCode());
+            }
+        });
+    }
 }

+ 6 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CpsMeetingUsrServiceImpl.java

@@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl;
 
 import com.ruoyi.common.core.domain.model.WeChatUser;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.system.domain.CpsContentInfo;
 import com.ruoyi.system.domain.CpsMeetingUsr;
 import com.ruoyi.system.mapper.CpsMeetingUsrMapper;
 import com.ruoyi.system.service.ICpsMeetingUsrService;
@@ -121,4 +122,9 @@ public class CpsMeetingUsrServiceImpl implements ICpsMeetingUsrService {
         }
         insertCpsMeetingUsr(user);
     }
+
+    @Override
+    public List<CpsContentInfo> qryUsrCollectContent(String openId, String keyword) {
+        return cpsMeetingUsrMapper.qryUsrCollectContent(openId, keyword);
+    }
 }

+ 96 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CpsUsrContentRelServiceImpl.java

@@ -0,0 +1,96 @@
+package com.ruoyi.system.service.impl;
+
+import java.util.List;
+import com.ruoyi.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.system.mapper.CpsUsrContentRelMapper;
+import com.ruoyi.system.domain.CpsUsrContentRel;
+import com.ruoyi.system.service.ICpsUsrContentRelService;
+
+/**
+ * 用户资讯信息Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2024-08-22
+ */
+@Service
+public class CpsUsrContentRelServiceImpl implements ICpsUsrContentRelService 
+{
+    @Autowired
+    private CpsUsrContentRelMapper cpsUsrContentRelMapper;
+
+    /**
+     * 查询用户资讯信息
+     * 
+     * @param id 用户资讯信息主键
+     * @return 用户资讯信息
+     */
+    @Override
+    public CpsUsrContentRel selectCpsUsrContentRelById(Long id)
+    {
+        return cpsUsrContentRelMapper.selectCpsUsrContentRelById(id);
+    }
+
+    /**
+     * 查询用户资讯信息列表
+     * 
+     * @param cpsUsrContentRel 用户资讯信息
+     * @return 用户资讯信息
+     */
+    @Override
+    public List<CpsUsrContentRel> selectCpsUsrContentRelList(CpsUsrContentRel cpsUsrContentRel)
+    {
+        return cpsUsrContentRelMapper.selectCpsUsrContentRelList(cpsUsrContentRel);
+    }
+
+    /**
+     * 新增用户资讯信息
+     * 
+     * @param cpsUsrContentRel 用户资讯信息
+     * @return 结果
+     */
+    @Override
+    public int insertCpsUsrContentRel(CpsUsrContentRel cpsUsrContentRel)
+    {
+        cpsUsrContentRel.setCreateTime(DateUtils.getNowDate());
+        return cpsUsrContentRelMapper.insertCpsUsrContentRel(cpsUsrContentRel);
+    }
+
+    /**
+     * 修改用户资讯信息
+     * 
+     * @param cpsUsrContentRel 用户资讯信息
+     * @return 结果
+     */
+    @Override
+    public int updateCpsUsrContentRel(CpsUsrContentRel cpsUsrContentRel)
+    {
+        cpsUsrContentRel.setUpdateTime(DateUtils.getNowDate());
+        return cpsUsrContentRelMapper.updateCpsUsrContentRel(cpsUsrContentRel);
+    }
+
+    /**
+     * 批量删除用户资讯信息
+     * 
+     * @param ids 需要删除的用户资讯信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteCpsUsrContentRelByIds(Long[] ids)
+    {
+        return cpsUsrContentRelMapper.deleteCpsUsrContentRelByIds(ids);
+    }
+
+    /**
+     * 删除用户资讯信息信息
+     * 
+     * @param id 用户资讯信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteCpsUsrContentRelById(Long id)
+    {
+        return cpsUsrContentRelMapper.deleteCpsUsrContentRelById(id);
+    }
+}

+ 27 - 2
ruoyi-system/src/main/resources/mapper/cp/CpsContentInfoMapper.xml

@@ -9,6 +9,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="title"    column="title"    />
         <result property="content"    column="content"    />
         <result property="thumbnail"    column="thumbnail"    />
+        <result property="likeCnt"    column="like_cnt"    />
+        <result property="collectedCnt"    column="collected_cnt"    />
         <result property="contentType"    column="content_type"    />
         <result property="updateTime"    column="update_time"    />
         <result property="createTime"    column="create_time"    />
@@ -17,11 +19,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectCpsContentInfoVo">
-        select id, title, content, thumbnail, content_type, update_time, create_time, create_by, update_by from cps_content_info
+        select id, title, content, thumbnail, content_type,like_cnt, collected_cnt, update_time, create_time, create_by, update_by from cps_content_info
     </sql>
 
     <select id="selectCpsContentInfoList" parameterType="com.ruoyi.system.domain.CpsContentInfo" resultMap="CpsContentInfoResult">
-        select id, title, thumbnail, content_type, update_time, create_time, create_by, update_by from cps_content_info
+        select id, title, thumbnail, content_type,like_cnt, collected_cnt, update_time, create_time, create_by, update_by from cps_content_info
         <where>
             <if test="title != null  and title != ''"> and title like concat('%', #{title}, '%')</if>
             <if test="content != null  and content != ''"> and content like concat('%', #{content}, '%')</if>
@@ -73,6 +75,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </trim>
         where id = #{id}
     </update>
+    <update id="updateCollectContent" parameterType="java.lang.Long">
+        update cps_content_info
+        set collected_cnt = collected_cnt + 1,
+            update_time   = now()
+        where id = #{id}
+    </update>
+    <update id="updateDisCollectContent" parameterType="java.lang.Long">
+        update cps_content_info
+        set collected_cnt = collected_cnt -1,
+            update_time   = now()
+        where id = #{id}
+    </update>
+    <update id="updateLikeContent" parameterType="java.lang.Long">
+        update cps_content_info
+        set like_cnt = like_cnt + 1, update_time = now()
+        where id = #{id}
+    </update>
+
+    <update id="updateDisLikeContent" parameterType="java.lang.Long">
+        update cps_content_info
+        set like_cnt = like_cnt -1, update_time = now()
+        where id = #{id}
+    </update>
 
     <delete id="deleteCpsContentInfoById" parameterType="Long">
         delete from cps_content_info where id = #{id}

+ 14 - 0
ruoyi-system/src/main/resources/mapper/cp/CpsMeetingUsrMapper.xml

@@ -147,4 +147,18 @@
         </trim>
         where tel = #{tel}
     </update>
+    <select id="qryUsrCollectContent" resultType="com.ruoyi.system.domain.CpsContentInfo">
+        SELECT content.content_type,
+        content.title,
+        content.thumbnail,
+        rel.update_time,
+        content.id
+        FROM cps_content_info content
+        INNER JOIN cps_usr_content_rel rel ON content.id = rel.content_id
+        WHERE rel.open_id = #{openId}
+        <if test="keyword !=null">
+            AND content.title LIKE CONCAT('%', #{keyword}, '%')
+        </if>
+        ORDER BY update_time DESC
+    </select>
 </mapper>

+ 148 - 0
ruoyi-system/src/main/resources/mapper/cp/CpsUsrContentRelMapper.xml

@@ -0,0 +1,148 @@
+<?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.ruoyi.system.mapper.CpsUsrContentRelMapper">
+
+    <resultMap type="com.ruoyi.system.domain.CpsUsrContentRel" id="CpsUsrContentRelResult">
+        <result property="id" column="id"/>
+        <result property="openId" column="open_id"/>
+        <result property="contentId" column="content_id"/>
+        <result property="contentTitle" column="content_title"/>
+        <result property="thumbnail" column="thumbnail"/>
+        <result property="collectFlag" column="collect_flag"/>
+        <result property="likeFlag" column="like_flag"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="createTime" column="create_time"/>
+        <result property="createBy" column="create_by"/>
+        <result property="updateBy" column="update_by"/>
+    </resultMap>
+
+    <sql id="selectCpsUsrContentRelVo">
+        select id,
+               open_id,
+               content_id,
+               content_title,
+               thumbnail,
+               collect_flag,
+               like_flag,
+               update_time,
+               create_time,
+               create_by,
+               update_by
+        from cps_usr_content_rel
+    </sql>
+
+    <select id="selectCpsUsrContentRelList" parameterType="com.ruoyi.system.domain.CpsUsrContentRel"
+            resultMap="CpsUsrContentRelResult">
+        <include refid="selectCpsUsrContentRelVo"/>
+        <where>
+            <if test="openId != null  and openId != ''">and open_id = #{openId}</if>
+            <if test="contentId != null ">and content_id = #{contentId}</if>
+            <if test="contentTitle != null  and contentTitle != ''">and content_title = #{contentTitle}</if>
+            <if test="thumbnail != null  and thumbnail != ''">and thumbnail = #{thumbnail}</if>
+            <if test="collectFlag != null  and collectFlag != ''">and collect_flag = #{collectFlag}</if>
+            <if test="likeFlag != null  and likeFlag != ''">and like_flag = #{likeFlag}</if>
+        </where>
+    </select>
+
+    <select id="selectCpsUsrContentRelById" parameterType="Long" resultMap="CpsUsrContentRelResult">
+        <include refid="selectCpsUsrContentRelVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertCpsUsrContentRel" parameterType="com.ruoyi.system.domain.CpsUsrContentRel">
+        insert into cps_usr_content_rel
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="openId != null">open_id,</if>
+            <if test="contentId != null">content_id,</if>
+            <if test="contentTitle != null">content_title,</if>
+            <if test="thumbnail != null">thumbnail,</if>
+            <if test="collectFlag != null">collect_flag,</if>
+            <if test="likeFlag != null">like_flag,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="updateBy != null">update_by,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="openId != null">#{openId},</if>
+            <if test="contentId != null">#{contentId},</if>
+            <if test="contentTitle != null">#{contentTitle},</if>
+            <if test="thumbnail != null">#{thumbnail},</if>
+            <if test="collectFlag != null">#{collectFlag},</if>
+            <if test="likeFlag != null">#{likeFlag},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+        </trim>
+    </insert>
+    <insert id="insertOrUpdateCpsUsrContent" parameterType="com.ruoyi.system.domain.CpsUsrContentRel">
+        insert into cps_usr_content_rel
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="openId != null">open_id,</if>
+            <if test="contentId != null">content_id,</if>
+            <if test="contentTitle != null">content_title,</if>
+            <if test="thumbnail != null">thumbnail,</if>
+            <if test="collectFlag != null">collect_flag,</if>
+            <if test="likeFlag != null">like_flag,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="updateBy != null">update_by,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="openId != null">#{openId},</if>
+            <if test="contentId != null">#{contentId},</if>
+            <if test="contentTitle != null">#{contentTitle},</if>
+            <if test="thumbnail != null">#{thumbnail},</if>
+            <if test="collectFlag != null">#{collectFlag},</if>
+            <if test="likeFlag != null">#{likeFlag},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+        </trim>
+        <trim prefix="ON DUPLICATE KEY UPDATE " suffixOverrides=",">
+            <if test="contentTitle != null">content_title = values(content_title),</if>
+            <if test="thumbnail != null">thumbnail = values(thumbnail),</if>
+            <if test="collectFlag != null">collect_flag = values(collect_flag),</if>
+            <if test="likeFlag != null">like_flag = values(like_flag),</if>
+            update_time = now()
+        </trim>
+    </insert>
+    <update id="updateCpsUsrContentRel" parameterType="com.ruoyi.system.domain.CpsUsrContentRel">
+        update cps_usr_content_rel
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="openId != null">open_id = #{openId},</if>
+            <if test="contentId != null">content_id = #{contentId},</if>
+            <if test="contentTitle != null">content_title = #{contentTitle},</if>
+            <if test="thumbnail != null">thumbnail = #{thumbnail},</if>
+            <if test="collectFlag != null">collect_flag = #{collectFlag},</if>
+            <if test="likeFlag != null">like_flag = #{likeFlag},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteCpsUsrContentRelById" parameterType="Long">
+        delete
+        from cps_usr_content_rel
+        where id = #{id}
+    </delete>
+
+    <delete id="deleteCpsUsrContentRelByIds" parameterType="String">
+        delete from cps_usr_content_rel where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 0 - 1
ruoyi-ui/src/views/cp/viewcfg/index.vue

@@ -222,7 +222,6 @@ export default {
   watch: {
     style: {
       handler(val) {
-        debugger
         this.form.style = JSON.stringify(val);
       },
       deep: true,