Ver Fonte

增加没有集合的文章到集合中的API接口
微信登陆鉴权接口

king há 2 meses atrás
pai
commit
a9a11b5d06

+ 5 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -76,7 +76,7 @@ spring:
     # 密码
     password: fangzhen,7410
     # 连接超时时间
-    timeout: 10s
+    timeout: 30s
     lettuce:
       pool:
         # 连接池中的最小空闲连接
@@ -136,3 +136,7 @@ xss:
   excludes: /system/notice
   # 匹配链接
   urlPatterns: /system/*,/monitor/*,/tool/*
+
+wx-app:
+  appId: wx04df75135e207090
+  appSecret: bb6c56779af605c7d734900435f1bda5

+ 23 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -374,6 +374,28 @@ public class SysUser extends BaseEntity {
     }
 
 
+    /** unionId */
+    private String unionId;
+
+    /** openId */
+    private String openId;
+
+    public String getUnionId() {
+        return unionId;
+    }
+
+    public void setUnionId(String unionId) {
+        this.unionId = unionId;
+    }
+
+    public String getOpenId() {
+        return openId;
+    }
+
+    public void setOpenId(String openId) {
+        this.openId = openId;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
@@ -398,4 +420,5 @@ public class SysUser extends BaseEntity {
                 .append("dept", getDept())
                 .toString();
     }
+
 }

+ 42 - 22
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityArticleController.java

@@ -979,28 +979,6 @@ public class CommunityArticleController extends BaseController {
         return AjaxResult.success(communityCollection);
     }
 
-    /**
-     * 用户删除合集
-     *
-     * @param collectionId 合集id
-     * @return 是否成功
-     */
-    @ApiOperation("用户删除合集")
-    @DeleteMapping("/deleteCollection")
-    @Transactional
-    public AjaxResult deleteCollection(Long collectionId) {
-        if (Objects.isNull(collectionId)) {
-            return AjaxResult.error("参数异常!");
-        }
-        try {
-            communityCollectionService.deleteCollectionById(collectionId);
-        } catch (Exception e) {
-            System.out.println(e.getMessage());
-            throw new ProjectException();
-        }
-        return AjaxResult.success("删除成功!");
-    }
-
     /**
      * 更新合集信息
      *
@@ -1027,6 +1005,29 @@ public class CommunityArticleController extends BaseController {
     }
 
 
+    /**
+     * 用户删除合集
+     *
+     * @param collectionId 合集id
+     * @return 是否成功
+     */
+    @ApiOperation("用户删除合集")
+    @DeleteMapping("/deleteCollection")
+    @Transactional
+    public AjaxResult deleteCollection(Long collectionId) {
+        if (Objects.isNull(collectionId)) {
+            return AjaxResult.error("参数异常!");
+        }
+        try {
+            communityCollectionService.deleteCollectionById(collectionId);
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+            throw new ProjectException();
+        }
+        return AjaxResult.success("删除成功!");
+    }
+
+
     /**
      * 合集内新增文章
      *
@@ -1234,6 +1235,25 @@ public class CommunityArticleController extends BaseController {
         }
         return AjaxResult.success(communityUserPromptVo);
     }
+    @ApiOperation("个人未加入集合文章")
+    @GetMapping("/userNoCo")
+    @Anonymous
+    public AjaxResult userNoCo(@RequestParam(required = false) Long userId) {
+        int pageNum = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
+        int pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
+        int searchType = Convert.toInt(ServletUtils.getParameter("searchType"), 0);
+        List<CommunityArticleVo> communityArticleVos = null;
+        if (userId == null) {
+            userId = SecurityUtils.getUserId();
+        }
+        try {
+            communityArticleVos = communityArticleService.selectUserNoCo(userId, pageNum, pageSize, searchType);
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+            throw new ProjectException();
+        }
+        return AjaxResult.success(communityArticleVos);
+    }
 
     @ApiOperation("个人喜欢文章")
     @GetMapping("/userLike")

+ 7 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityCollection.java

@@ -49,6 +49,13 @@ public class CommunityCollection implements Serializable {
     @ApiModelProperty("合集简介")
     @Length(max= -1,message="编码长度不能超过-1")
     private String collectionProfile;
+    /**
+     * 合集标签
+     */
+    @Size(max= 255,message="编码长度不能超过255")
+    @ApiModelProperty("合集标签")
+    @Length(max= 255,message="编码长度不能超过255")
+    private String collectionTag;
     /**
     * 封面图片地址
     */

+ 5 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityArticleMapper.java

@@ -37,6 +37,11 @@ public interface CommunityArticleMapper extends BaseMapper<CommunityArticle> {
                                                         @Param("searchType") int searchType,
                                                         @Param("loginId") Long loginId);
 
+
+    List<CommunityArticleVo> selectUserNoCoArticles(
+            @Param("userId") Long userId
+    );
+
     /**
      * 获取该用户是否收藏该文章
      *

+ 7 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleServiceImpl.java

@@ -1592,6 +1592,13 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
         return communityUserPromptVos;
     }
 
+    // 修改service实现
+    @Override
+    public List<CommunityArticleVo> selectUserNoCo(Long userId, int pageNum, int pageSize, int searchType) {
+        //PageHelper.startPage(pageNum, pageSize);
+        return communityArticleMapper.selectUserNoCoArticles(userId);
+    }
+
     @Override
     public List<CommunityArticleVo> selectUserLike(Long userId, int pageNum, int pageSize, int searchType) {
         // 查询自己的通知列表

+ 2 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityCollectionServiceImpl.java

@@ -120,8 +120,10 @@ public class CommunityCollectionServiceImpl extends ServiceImpl<CommunityCollect
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String formattedUpdateTime = sdf.format(updateTime);
         collectionObject.put("collectioncreateby", communityCollection.getCreateBy());
+        collectionObject.put("collectionProfile", communityCollection.getCollectionProfile());
         collectionObject.put("updateTime", formattedUpdateTime);
         collectionObject.put("collectionImageUrl",communityCollection.getImages());
+        collectionObject.put("collectionTag",communityCollection.getCollectionTag());
         collectionObject.put("followNumber", communityCollectionUserMapper.selectList(new QueryWrapper<CommunityCollectionUser>().eq("collection_id", collectionId).and((wrapper) -> {
             wrapper.ne("is_delete", true)
                     .or()

+ 11 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/service/ICommunityArticleService.java

@@ -197,6 +197,17 @@ public interface ICommunityArticleService extends IService<CommunityArticle> {
      */
     List<CommunityUserPromptVo> selectCommunityUserPrompt(Long userId);
 
+    /**
+     *
+     * 个人未加入集合文章
+     *
+     * @param pageNum
+     * @param pageSize
+     * @param searchType
+     * @return
+     */
+    List<CommunityArticleVo> selectUserNoCo(Long userId,int pageNum, int pageSize, int searchType);
+
     /**
      *
      * 查询个人喜欢文章

+ 7 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/vo/CommunityCollectionVo.java

@@ -49,6 +49,13 @@ public class CommunityCollectionVo implements Serializable {
     @ApiModelProperty("合集简介")
     @Length(max= -1,message="编码长度不能超过-1")
     private String collectionProfile;
+    /**
+     * 合集标签
+     */
+    @Size(max= 255,message="编码长度不能超过255")
+    @ApiModelProperty("合集标签")
+    @Length(max= 255,message="编码长度不能超过255")
+    private String collectionTag;
     /**
     * 封面图片地址
     */

+ 27 - 0
ruoyi-generator/src/main/resources/mapper/community/ArticleMapper.xml

@@ -348,4 +348,31 @@
                  WHERE nick_name LIKE CONCAT( #{content}, '%') AND status = '0'
              ) AS A
     </select>
+
+    <!-- 查询用戶ID下沒有加入集合的文章列表 -->
+    <select id="selectUserNoCoArticles" resultMap="CommunityArticleVoResult">
+        SELECT
+        a.id as article_id,
+        a.user_id as article_user_id,
+        a.title as article_title,
+        a.is_comment as article_is_comment,
+        a.content as article_content,
+        a.page_views as pageViews,
+        a.create_by as article_create_by,
+        a.create_time as article_create_time,
+        a.update_by as article_update_by,
+        a.update_time as article_update_time,
+        a.address as address,
+        a.is_comment,
+        a.is_raffle,
+        a.is_download
+        FROM community_article a
+        WHERE a.create_by = #{userId}
+        AND NOT EXISTS (
+        SELECT 1
+        FROM community_collection_article c
+        WHERE c.article_id = a.id
+        )
+    </select>
+
 </mapper>

+ 6 - 2
ruoyi-generator/src/main/resources/mapper/community/CommunityCollectionMapper.xml

@@ -4,12 +4,13 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.generator.mapper.community.CommunityCollectionMapper">
     <select id="selectUserCollection" resultType="com.ruoyi.generator.vo.CommunityCollectionVo">
-        select id,user_id,collection_name,collection_profile,images,is_delete,articleCount,pageViews,create_by,update_by,create_time,update_time,isFollow  from (
+        select id,user_id,collection_name,collection_profile,images,collection_tag,is_delete,articleCount,pageViews,create_by,update_by,create_time,update_time,isFollow  from (
         SELECT a.id,
         a.user_id,
         a.collection_name,
         a.collection_profile,
         a.images,
+        a.collection_tag,
         a.is_delete,
         COUNT(b.article_id) AS articleCount,
         a.heat AS pageViews,
@@ -31,6 +32,7 @@
         a.collection_name,
         a.collection_profile,
         a.images,
+        a.collection_tag,
         a.is_delete,
         a.create_by,
         a.update_by,
@@ -44,6 +46,7 @@
         a.collection_name,
         a.collection_profile,
         a.images,
+        a.collection_tag,
         a.is_delete,
         COUNT(b.article_id) AS articleCount,
         a.heat AS pageViews,
@@ -66,6 +69,7 @@
         a.collection_name,
         a.collection_profile,
         a.images,
+        a.collection_tag,
         a.is_delete,
         a.create_by,
         a.update_by,
@@ -84,7 +88,7 @@
 
 
     <select id="selectCollectById" resultType="com.ruoyi.generator.vo.CommunityCollectionVo">
-        select a.id,a.collection_name,a.collection_profile,a.images
+        select a.id,a.collection_name,a.collection_profile,a.images,a.collection_tag
         from `ruoyi-community`.community_collection a
                  left join `ruoyi-community`.community_collection_article b on a.id = b.collection_id
         where b.article_id = #{articleId} and (b.is_delete is null or b.is_delete != '1')

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java

@@ -53,6 +53,13 @@ public interface SysUserMapper extends BaseMapper<SysUser>
      */
     public SysUser selectUserById(Long userId);
 
+    /**
+     * 根据openId查询用户信息
+     * @param openId
+     * @return
+     */
+    public SysUser selectWxUserByOpenId(String openId);
+
     /**
      * 新增用户信息
      * 

+ 9 - 1
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -22,6 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="createTime"   column="create_time"  />
         <result property="updateBy"     column="update_by"    />
         <result property="updateTime"   column="update_time"  />
+		<result property="openId"       column="open_id"  />
         <result property="remark"       column="remark"       />
 		<result property="isSex" 		column="is_Sex"/>
         <association property="dept"    javaType="SysDept"         resultMap="deptResult" />
@@ -85,7 +86,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<!-- 数据范围过滤 -->
 		${params.dataScope}
 	</select>
-	
+
+	<select id="selectWxUserByOpenId" parameterType="String" resultMap="SysUserResult">
+		<include refid="selectUserVo" />
+		where u.open_id = #{openId} and u.del_flag = '0'
+	</select>
+
 	<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
 	    select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
 	    from sys_user u
@@ -156,6 +162,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="password != null and password != ''">password,</if>
  			<if test="status != null and status != ''">status,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
+			<if test="openId != null and openId != ''">open_id,</if>
  			<if test="remark != null and remark != ''">remark,</if>
  			create_time
  		)values(
@@ -170,6 +177,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="password != null and password != ''">#{password},</if>
  			<if test="status != null and status != ''">#{status},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
+			<if test="openId != null and openId != ''">#{openId},</if>
  			<if test="remark != null and remark != ''">#{remark},</if>
  			sysdate()
  		)