| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 查询资讯分页信息(角色权限)附带点赞评论数 |
| | | * @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 |
| | |
| | | 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)); |
| | | } |
| | | } |
| | |
| | | * 发布状态 0:未发布 1:已发布 |
| | | */ |
| | | private String publish; |
| | | |
| | | /** |
| | | * 开启评论区 0:关闭 1:开启 |
| | | */ |
| | | private String iscomment; |
| | | } |
| | |
| | | * @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); |
| | | } |
| | |
| | | </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> |
| | |
| | | * @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); |
| | | } |
| | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | |
| | | private String keyword; |
| | | |
| | | /** |
| | | * 角色id |
| | | * 角色名称 |
| | | */ |
| | | private String rolename; |
| | | |
| | | /** |
| | | * 角色id |
| | | */ |
| | | private String userid; |
| | | |
| | | /** |
| | | * 点赞总数 |
| | | */ |
| | | private String count; |
| | | |
| | | /** |
| | | * 是否点赞 |
| | | */ |
| | | private String islikes; |
| | | |
| | | /** |
| | | * 评论总数 |
| | | */ |
| | | private String comments; |
| | | |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | */ |
| | | @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") |
| | |
| | | @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)); |
| | | } |
| | | |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * 实体类 |
| | |
| | | @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; |
| | | |
| | | |
| | | } |
| | |
| | | * 自定义分页 |
| | | * |
| | | * @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); |
| | | } |
| | |
| | | <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>=#{comment.startTime} |
| | | </if> |
| | | <if test="comment.endTime!=null and comment.endTime!=''"> |
| | | and time<=#{comment.endTime} |
| | | </if> |
| | | ORDER BY isexamine ASC,topping DESC,time DESC |
| | | </select> |
| | | |
| | | |
| | |
| | | * @return |
| | | */ |
| | | IPage<CommentVO> selectSurveyPage(IPage<CommentVO> page, CommentVO comment); |
| | | |
| | | IPage<CommentVO> articlepage(IPage<CommentVO> page, CommentVO comment); |
| | | } |
| | |
| | | return page.setRecords(baseMapper.selectSurveyPage(page, comment)); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<CommentVO> articlepage(IPage<CommentVO> page, CommentVO comment) { |
| | | return page.setRecords(baseMapper.articlepage(page, comment)); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | 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; |
| | | |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | @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)); |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * 实体类 |
| | |
| | | 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; |
| | | |
| | | |
| | | } |
| | |
| | | */ |
| | | List<LikesVO> selectLikesPage(IPage page, LikesVO likes); |
| | | |
| | | Boolean removelikes(Likes likes); |
| | | |
| | | } |
| | |
| | | <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> |
| | |
| | | */ |
| | | IPage<LikesVO> selectLikesPage(IPage<LikesVO> page, LikesVO likes); |
| | | |
| | | Boolean removelikes(Likes likes); |
| | | |
| | | } |
| | |
| | | |
| | | 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; |
| | |
| | | return page.setRecords(baseMapper.selectLikesPage(page, likes)); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean removelikes(Likes likes) { |
| | | return baseMapper.removelikes(likes); |
| | | } |
| | | |
| | | } |
| | |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class LikesVO extends Likes { |
| | | |
| | | @ApiModelProperty(value = "通知类型名") |
| | | private String categoryName; |
| | | |
| | | @ApiModelProperty(value = "租户编号") |
| | | private String tenantId; |
| | | |
| | | } |