洪城义警-正式版后台
zengh
2021-10-09 86b6fcd12634fbb08a2bd8a2cf44205f7e1d2067
点赞评论相关提交
21 files modified
329 ■■■■■ changed files
src/main/java/org/springblade/modules/article/controller/ArticleController.java 30 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/entity/Article.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/mapper/ArticleMapper.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/mapper/ArticleMapper.xml 50 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/service/ArticleService.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/service/impl/ArticleServiceImpl.java 20 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/vo/ArticleVo.java 23 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/comment/controller/CommentController.java 23 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/comment/entity/Comment.java 19 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/comment/mapper/CommentMapper.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/comment/mapper/CommentMapper.xml 56 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/comment/service/ICommentService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/comment/service/impl/CommentServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/comment/vo/CommentVO.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/likes/controller/LikesController.java 16 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/likes/entity/Likes.java 20 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/likes/mapper/LikesMapper.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/likes/mapper/LikesMapper.xml 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/likes/service/ILikesService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/likes/service/impl/LikesServiceImpl.java 6 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/likes/vo/LikesVO.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/article/controller/ArticleController.java
@@ -65,6 +65,22 @@
    }
    /**
     *
     * 查询资讯分页信息(角色权限)附带点赞评论数
     * @param response
     * @param article 资讯对象
     * @param query 查询参数
     * @return
     */
    @GetMapping("/pageLikes")
    public R<IPage<Article>> pageLikes(HttpServletResponse response, ArticleVo article, Query query){
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
        response.setHeader("Access-Control-Allow-Credentials","true");
        return R.data(articleService.pageLikes(Condition.getPage(query),article));
    }
    /**
     * 资讯详情
     * @param article 资讯查询对象
     * @param response
@@ -130,4 +146,18 @@
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return R.status(articleService.removeByIds(Func.toLongList(ids)));
    }
    /**
     * 批量修改评论区状态
     */
    @PostMapping("/upcomment")
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids,String type) {
        String[] split = ids.split(",");
        String strArrays = "";
        for (int i = 0; i < split.length; i++) {
            strArrays += "'" + split[i] + "',";
        }
        String code = strArrays.substring(0, strArrays.length() - 1);
        return R.status(articleService.upcomment(code,type));
    }
}
src/main/java/org/springblade/modules/article/entity/Article.java
@@ -91,4 +91,9 @@
     * 发布状态 0:未发布 1:已发布
     */
    private String publish;
    /**
     * 开启评论区 0:关闭 1:开启
     */
    private String iscomment;
}
src/main/java/org/springblade/modules/article/mapper/ArticleMapper.java
@@ -29,4 +29,14 @@
     * @return
     */
    List<Article> pageDate(IPage<Article> page, @Param("article") ArticleVo article);
    /**
     * 查询资讯分页信息(角色权限)附带评论点赞数量
     * @param page
     * @param article 资讯对象
     * @return
     */
    List<Article> pageLikes(IPage<Article> page, @Param("article") ArticleVo article);
    Boolean upcomment(String ids,String type);
}
src/main/java/org/springblade/modules/article/mapper/ArticleMapper.xml
@@ -44,4 +44,54 @@
        </if>
        order by create_time desc
    </select>
    <!--查询资讯分页列表信息-->
    <select id="pageLikes" resultType="org.springblade.modules.article.vo.ArticleVo">
        SELECT
        *
        FROM
        sys_article art
        LEFT JOIN (
        SELECT
        a.likes_article,
        COUNT( * ) AS count,
        b.islikes
        FROM
        sys_likes a
        LEFT JOIN ( SELECT likes_article, COUNT( * ) AS islikes FROM sys_likes WHERE 1 = 1
        <if test="article.userid!=null and article.userid!=''">
            and likes_user = #{article.userid}
        </if>
        GROUP BY likes_article ) b ON a.likes_article = b.likes_article
        GROUP BY
        likes_article,
        b.islikes
        ) likes ON art.id = likes.likes_article
        LEFT JOIN (
        SELECT
        article,
        COUNT(*) as comments
        FROM
        sys_comment
        GROUP BY article
        ) com on com.article = art.id
        WHERE
        1 = 1
        <if test="article.articleType!=null and article.articleType!=''">
            and article_type LIKE CONCAT ('%', #{article.articleType},'%')
        </if>
        <if test="article.keyword!=null and article.keyword!=''">
            AND CONCAT(title,source_name)
            LIKE CONCAT ('%', #{article.keyword},'%')
        </if>
        <if test="(article.rolename==null and article.rolename=='') or (article.rolename!='administrator' and article.rolename!='policeAdmin')">
            AND publish = 1
        </if>
        order by create_time desc
    </select>
    <update id="upcomment">
        update sys_article set iscomment = #{type}
        where id in(${ids})
    </update>
</mapper>
src/main/java/org/springblade/modules/article/service/ArticleService.java
@@ -26,4 +26,14 @@
     * @return
     */
    IPage<Article> pageDate(IPage<Article> page, ArticleVo article);
    /**
     * 查询资讯分页信息(角色权限)附带评论点赞数
     * @param page
     * @param article 资讯对象
     * @return
     */
    IPage<Article> pageLikes(IPage<Article> page, ArticleVo article);
    Boolean upcomment(String ids,String type);
}
src/main/java/org/springblade/modules/article/service/impl/ArticleServiceImpl.java
@@ -38,4 +38,24 @@
    public IPage<Article> pageDate(IPage<Article> page, ArticleVo article) {
        return page.setRecords(baseMapper.pageDate(page,article));
    }
    /**
     * 查询资讯分页信息(角色权限)附带评论点赞数
     * @param page
     * @param article 资讯对象
     * @return
     */
    @Override
    public IPage<Article> pageLikes(IPage<Article> page, ArticleVo article) {
        return page.setRecords(baseMapper.pageLikes(page,article));
    }
    /**
     * 批量更新
     * @return
     */
    @Override
    public Boolean upcomment(String ids,String type) {
        return baseMapper.upcomment(ids,type);
    }
}
src/main/java/org/springblade/modules/article/vo/ArticleVo.java
@@ -24,7 +24,28 @@
    private String keyword;
    /**
     * 角色id
     * 角色名称
     */
    private String rolename;
    /**
     * 角色id
     */
    private String userid;
    /**
     * 点赞总数
     */
    private String count;
    /**
     * 是否点赞
     */
    private String islikes;
    /**
     * 评论总数
     */
    private String comments;
}
src/main/java/org/springblade/modules/comment/controller/CommentController.java
@@ -34,6 +34,7 @@
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Date;
/**
 *  控制器
@@ -84,6 +85,17 @@
    }
    /**
     * 自定义分页
     */
    @GetMapping("/articlepage")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入survey")
    public R<IPage<CommentVO>> articlepage(CommentVO comment, Query query) {
        IPage<CommentVO> pages = commentService.articlepage(Condition.getPage(query), comment);
        return R.data(pages);
    }
    /**
     * 新增
     */
    @PostMapping("/save")
@@ -109,7 +121,16 @@
    @PostMapping("/submit")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增或修改", notes = "传入survey")
    public R submit(@Valid Comment comment) {
    public R submit(@Valid @RequestBody Comment comment) {
        if (null==comment.getTime()){
            comment.setTime(new Date());
        }
        if (comment.getTopping()== null || comment.getIsexamine().equals("")){
            comment.setTopping("0");
        }
        if (comment.getIsexamine() == null || comment.getIsexamine().equals("")){
            comment.setIsexamine("0");
        }
        return R.status(commentService.saveOrUpdate(comment));
    }
src/main/java/org/springblade/modules/comment/entity/Comment.java
@@ -19,11 +19,13 @@
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * 实体类
@@ -41,8 +43,21 @@
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    @ApiModelProperty(value = "人员名称")
    private String name;
    @ApiModelProperty(value = "评论文章id")
    private String article;
    @ApiModelProperty(value = "评论内容")
    private String content;
    @ApiModelProperty(value = "评论人id")
    private String userId;
    @ApiModelProperty(value = "回复人id(文章或人)")
    private String reply;
    @ApiModelProperty(value = "时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date time;
    @ApiModelProperty(value = "是否置顶")
    private String topping;
    @ApiModelProperty(value = "是否审核")
    private String isexamine;
}
src/main/java/org/springblade/modules/comment/mapper/CommentMapper.java
@@ -35,8 +35,10 @@
     * 自定义分页
     *
     * @param page
     * @param ulikes
     * @param comment
     * @return
     */
    List<CommentVO> selectSurveyPage(IPage page, CommentVO ulikes);
    List<CommentVO> selectSurveyPage(IPage page, CommentVO comment);
    List<CommentVO> articlepage(IPage page, CommentVO comment);
}
src/main/java/org/springblade/modules/comment/mapper/CommentMapper.xml
@@ -3,16 +3,60 @@
<mapper namespace="org.springblade.modules.comment.mapper.CommentMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="ulikesResultMap" type="org.springblade.modules.comment.entity.Comment">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="identityCard" property="identityCard"/>
        <result column="ticketCode" property="ticketCode"/>
    <resultMap id="ulikesResultMap" type="org.springblade.modules.comment.vo.CommentVO">
    </resultMap>
    <select id="selectSurveyPage" resultMap="ulikesResultMap">
        select * from sys_ulikes
        SELECT
            com.*,
            user.real_name as name
        FROM
            sys_comment com
            LEFT JOIN blade_user user ON com.user_id = user.id
        where 1=1 and isexamine = 1
        <if test="comment.article!=null and comment.article!=''">
            and article = #{comment.article}
        </if>
            ORDER BY topping DESC,time DESC
    </select>
    <select id="articlepage" resultMap="ulikesResultMap">
        SELECT
        com.*,
        user.real_name AS name,
        art.title,
        art.source_name
        FROM
        sys_comment com
        LEFT JOIN blade_user user ON com.user_id = user.id
        LEFT JOIN sys_article art on art.id = com.article
        WHERE
        1 =1
        <if test="comment.topping!=null and comment.topping!=''">
            and topping = #{comment.topping}
        </if>
        <if test="comment.isexamine!=null and comment.isexamine!=''">
            and isexamine = #{comment.isexamine}
        </if>
        <if test="comment.sourceName!=null and comment.sourceName!=''">
            and source_name LIKE CONCAT ('%', #{comment.sourceName},'%')
        </if>
        <if test="comment.title!=null and comment.title!=''">
            and title LIKE CONCAT ('%', #{comment.title},'%')
        </if>
        <if test="comment.name!=null and comment.name!=''">
            and name LIKE CONCAT ('%', #{comment.name},'%')
        </if>
        <if test="comment.startTime!=null and comment.startTime!=''">
            and time&gt;=#{comment.startTime}
        </if>
        <if test="comment.endTime!=null and comment.endTime!=''">
            and time&lt;=#{comment.endTime}
        </if>
            ORDER BY isexamine ASC,topping DESC,time DESC
    </select>
src/main/java/org/springblade/modules/comment/service/ICommentService.java
@@ -37,4 +37,6 @@
     * @return
     */
    IPage<CommentVO> selectSurveyPage(IPage<CommentVO> page, CommentVO comment);
    IPage<CommentVO> articlepage(IPage<CommentVO> page, CommentVO comment);
}
src/main/java/org/springblade/modules/comment/service/impl/CommentServiceImpl.java
@@ -38,5 +38,10 @@
        return page.setRecords(baseMapper.selectSurveyPage(page, comment));
    }
    @Override
    public IPage<CommentVO> articlepage(IPage<CommentVO> page, CommentVO comment) {
        return page.setRecords(baseMapper.articlepage(page, comment));
    }
}
src/main/java/org/springblade/modules/comment/vo/CommentVO.java
@@ -33,4 +33,18 @@
public class CommentVO extends Comment {
    private static final long serialVersionUID = 1L;
    private String name;
    private String title;
    private String sourceName;
    /**
     * 开始时间
     */
    private String startTime;
    /**
     * 结束时间
     */
    private String endTime;
}
src/main/java/org/springblade/modules/likes/controller/LikesController.java
@@ -35,6 +35,7 @@
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Date;
import java.util.Map;
/**
@@ -119,6 +120,9 @@
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增或修改", notes = "传入likes")
    public R submit(@RequestBody Likes likes) {
        if (null==likes.getTime()){
            likes.setTime(new Date());
        }
        return R.status(likesService.saveOrUpdate(likes));
    }
@@ -133,4 +137,16 @@
        return R.status(temp);
    }
    /**
     * 删除指定点赞记录
     */
    @PostMapping("/removelikes")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "逻辑删除", notes = "传入likes")
    public R removelikes(@ApiParam(value = "主键集合") @RequestBody Likes likes) {
        boolean temp = likesService.removelikes(likes);
        return R.status(temp);
    }
}
src/main/java/org/springblade/modules/likes/entity/Likes.java
@@ -19,10 +19,13 @@
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.joda.time.DateTime;
import java.io.Serializable;
import java.util.Date;
/**
 * 实体类
@@ -39,10 +42,21 @@
    private Integer id;
    /**
     * 内容
     * 点赞文章id
     */
    @ApiModelProperty(value = "内容")
    private String content;
    @ApiModelProperty(value = "点赞文章id")
    private String likesArticle;
    /**
     * 点赞文章id
     */
    @ApiModelProperty(value = "点赞人id")
    private String likesUser;
    /**
     * 点赞文章id
     */
    @ApiModelProperty(value = "点赞时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date time;
}
src/main/java/org/springblade/modules/likes/mapper/LikesMapper.java
@@ -39,4 +39,6 @@
     */
    List<LikesVO> selectLikesPage(IPage page, LikesVO likes);
    Boolean removelikes(Likes likes);
}
src/main/java/org/springblade/modules/likes/mapper/LikesMapper.xml
@@ -11,4 +11,8 @@
    <select id="selectLikesPage" resultMap="likesVOResultMap">
        select * from sys_likes
    </select>
    <delete id="removelikes">
        delete from sys_likes where likes_article=#{likesArticle} AND likes_user =#{likesUser}
    </delete>
</mapper>
src/main/java/org/springblade/modules/likes/service/ILikesService.java
@@ -36,4 +36,6 @@
     */
    IPage<LikesVO> selectLikesPage(IPage<LikesVO> page, LikesVO likes);
    Boolean removelikes(Likes likes);
}
src/main/java/org/springblade/modules/likes/service/impl/LikesServiceImpl.java
@@ -18,7 +18,6 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.likes.entity.Likes;
import org.springblade.modules.likes.mapper.LikesMapper;
import org.springblade.modules.likes.service.ILikesService;
@@ -38,4 +37,9 @@
        return page.setRecords(baseMapper.selectLikesPage(page, likes));
    }
    @Override
    public Boolean removelikes(Likes likes) {
        return baseMapper.removelikes(likes);
    }
}
src/main/java/org/springblade/modules/likes/vo/LikesVO.java
@@ -14,10 +14,4 @@
@EqualsAndHashCode(callSuper = true)
public class LikesVO extends Likes {
    @ApiModelProperty(value = "通知类型名")
    private String categoryName;
    @ApiModelProperty(value = "租户编号")
    private String tenantId;
}