Commit 631e5bc5 authored by liwei's avatar liwei

修改了活动查询和活动详情接口,以及评论接口

parent 6e45121b
......@@ -4,6 +4,8 @@ package org.rcisoft.app.appArticle.controller;
/*固定导入*/
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.rcisoft.business.opmArticle.entity.OpmArticle;
import org.rcisoft.business.opmArticle.service.OpmArticleService;
import org.rcisoft.core.anno.CyOpeLogAnno;
......@@ -48,11 +50,24 @@ public class AppOpmArticleController extends CyPaginationController<OpmArticle>
@CyOpeLogAnno(title = "system-动态管理-动态点赞", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="动态点赞", description="动态点赞")
@PostMapping("/opmArticle/like")
public CyResult likeAdd(String articleId, String praiseType) {
public CyResult likeAdd(Integer articleId, String praiseType) {
CyPersistModel data = opmArticleServiceImpl.likeAdd(articleId,praiseType);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
articleId);
}
@PreAuthorize("@cyPerm.hasPerm('app:article:detail')")
@CyOpeLogAnno(title = "system-opmArticle管理管理-查询opmArticle管理", businessType = CyLogTypeEnum.QUERY)
@Operation(summary="查询单一opmArticle管理", description="查询单一opmArticle管理")
@Parameters({@Parameter(name = "businessId", description = "businessId", required = true)})
@GetMapping("/open/opmArticle/detail/{businessId:\\w+}")
public CyResult detail(@PathVariable String businessId) {
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
opmArticleServiceImpl.findById(businessId));
}
}
......@@ -49,6 +49,8 @@ public class OpmArticleController extends CyPaginationController<OpmArticle> {
CyMessCons.MESSAGE_ALERT_ERROR,
opmArticle);
}
@PreAuthorize("@cyPerm.hasPerm('cms:opmArticle:delete')")
@CyOpeLogAnno(title = "system-opmArticle管理管理-删除opmArticle管理", businessType = CyLogTypeEnum.DELETE)
@Operation(summary="逻辑删除opmArticle管理", description="逻辑删除opmArticle管理")
......@@ -157,11 +159,23 @@ public class OpmArticleController extends CyPaginationController<OpmArticle> {
*/
@PreAuthorize("@cyPerm.hasPerm('cms:opmArticle:add')")
@PostMapping("/like")
public CyResult likeAdd(String articleId,String praiseType) {
public CyResult likeAdd(Integer articleId,String praiseType) {
CyPersistModel data = opmArticleServiceImpl.likeAdd(articleId,praiseType);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
articleId);
}
@PreAuthorize("@cyPerm.hasPerm('cms:opmArticle:add')")
@CyOpeLogAnno(title = "system-opmArticle管理管理-新增opmArticle管理", businessType = CyLogTypeEnum.INSERT)
@Operation(summary="添加opmArticle管理", description="添加opmArticle管理")
@PostMapping(value = "/comment")
public CyResult comment(@Valid @RequestBody OpmArticle opmArticle, BindingResult bindingResult) {
CyPersistModel data = opmArticleServiceImpl.addComment(opmArticle);
return CyResultGenUtil.builder(data,
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
opmArticle);
}
}
......@@ -28,7 +28,7 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
IPage<OpmArticle> queryOpmArticlePaged(CyPageInfo cyPageInfo, @Param("entity") OpmArticle opmArticle);
OpmArticle selectByIdWithUrl(String articleId);
OpmArticle selectByIdWithUrl(@Param("articleId") String articleId,@Param("loginUserId") String loginUserId);
List<ArticleCommentVO> SelectArticleComment(Integer businessId);
......@@ -38,12 +38,18 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
int likeAdd(@Param("entity") LikeDTO likeDTO);
//删除点赞记录
int likeDelete(@Param("userId") String userId,@Param("articleId") String articleId);
int likeDelete(@Param("userId") String userId,@Param("articleId") Integer articleId);
//点赞数+1
int addLikeCount(String articleId);
int addLikeCount(Integer articleId);
//点赞数-1
int reduceLikeCount(String articleId);
int reduceLikeCount(Integer articleId);
//评论数+1
int addCommentCount(Integer articleId);
//添加动态评论
int addComment(@Param("entity") OpmArticle opmArticle);
}
......@@ -34,6 +34,11 @@ public class ArticleCommentVO {
*/
String avatarUrl;
/**
* 用户头像ID
*/
Integer avatarId;
/**
* 会员昵称
*/
......
......@@ -10,5 +10,5 @@ public class LikeDTO {
String userId;
String articleId;
Integer articleId;
}
......@@ -184,6 +184,22 @@ public class OpmArticle extends CyIdIncreEntity<OpmArticle> {
@TableField(exist = false)
private String loginUserId;
/**
* 评论内容
*/
@TableField(exist = false)
private String commentContent;
/**
* 动态ID
*/
@TableField(exist = false)
private Integer articleId;
/**
* 评论父级ID
*/
@TableField(exist = false)
private Integer parentId;
}
......@@ -84,6 +84,13 @@ public interface OpmArticleService {
* @param articleId
* @return
*/
CyPersistModel likeAdd(String articleId,String praiseType);
CyPersistModel likeAdd(Integer articleId,String praiseType);
/**
* 添加评论
* @param opmArticle
* @return
*/
CyPersistModel addComment(OpmArticle opmArticle);
}
......@@ -28,6 +28,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
......@@ -136,8 +137,9 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
*/
@Override
public OpmArticle findById(String articleId){
String loginUserId = CyUserUtil.getAuthenBusinessId();
//根据动态id 查询动态详情
OpmArticle opmArticle = baseMapper.selectByIdWithUrl(articleId);
OpmArticle opmArticle = baseMapper.selectByIdWithUrl(articleId,loginUserId);
//查询该动态的评论
List<ArticleCommentVO> list = baseMapper.SelectArticleComment(opmArticle.getBusinessId());
list.forEach(item -> {
......@@ -213,7 +215,7 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public CyPersistModel likeAdd(String articleId,String praiseType){
public CyPersistModel likeAdd(Integer articleId,String praiseType){
int line = 0;
if (praiseType.equals("praise")){
//点赞
......@@ -237,4 +239,21 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
return new CyPersistModel(line);
}
/**
* 添加评论
* @param opmArticle
* @return
*/
@Override
public CyPersistModel addComment(OpmArticle opmArticle) {
opmArticle.setUserId(CyUserUtil.getAuthenBusinessId());
opmArticle.setCreateDate(new Date());
opmArticle.setUpdateDate(new Date());
opmArticle.setCreateBy(CyUserUtil.getAuthenBusinessId());
opmArticle.setUpdateBy(CyUserUtil.getAuthenBusinessId());
int line = baseMapper.addComment(opmArticle);
//修改主表的评论数
baseMapper.addCommentCount(opmArticle.getArticleId());
return new CyPersistModel(line);
}
}
......@@ -27,8 +27,11 @@
SET like_count = like_count - 1
WHERE business_id = #{articleId};
</update>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
<update id="addCommentCount">
UPDATE opm_article
SET comment_count = comment_count + 1
WHERE business_id = #{articleId};
</update>
<select id="queryOpmArticle" resultMap="BaseResultMap">
select opa.*,sot.topic_name as topic,mi.mem_code as memCode
from opm_article opa
......@@ -181,25 +184,30 @@
mi.mem_residence_city AS memResidenceCity,
mi.mem_career AS memCareer,
mi.mem_nick_name AS memNickName,
mi.avatar AS avatarId,
oi.url AS memAvatar,
CASE
WHEN oal.business_id IS NOT NULL THEN 1 ELSE 0
END AS isLike,
GROUP_CONCAT( DISTINCT pic_urls.url ORDER BY pic_urls.url SEPARATOR ',' ) AS url
FROM
opm_article opa
LEFT JOIN mem_info mi ON mi.user_id = opa.create_by
LEFT JOIN (
SELECT
opm_article.business_id,
CAST( JSON_UNQUOTE( JSON_EXTRACT( picture_id, CONCAT( '$.id[', jt_ids.idx - 1, ']' ))) AS UNSIGNED ) AS picture_id
FROM
opm_article,
JSON_TABLE (
JSON_EXTRACT( opm_article.picture_id, '$.id' ),
'$[*]' COLUMNS ( idx FOR ORDINALITY )) AS jt_ids
WHERE
opm_article.del_flag = '0'
) AS pic_ids ON opa.business_id = pic_ids.business_id
LEFT JOIN oss_info pic_urls ON pic_ids.picture_id = pic_urls.business_id
LEFT JOIN oss_info oi ON oi.business_id = mi.avatar
LEFT JOIN mem_info mi ON mi.user_id = opa.create_by
LEFT JOIN (
SELECT
opm_article.business_id,
CAST( JSON_UNQUOTE( JSON_EXTRACT( picture_id, CONCAT( '$.id[', jt_ids.idx - 1, ']' ))) AS UNSIGNED ) AS picture_id
FROM
opm_article,
JSON_TABLE (
JSON_EXTRACT( opm_article.picture_id, '$.id' ),
'$[*]' COLUMNS ( idx FOR ORDINALITY )) AS jt_ids
WHERE
opm_article.del_flag = '0'
) AS pic_ids ON opa.business_id = pic_ids.business_id
LEFT JOIN oss_info pic_urls ON pic_ids.picture_id = pic_urls.business_id
LEFT JOIN oss_info oi ON oi.business_id = mi.avatar
LEFT JOIN opm_article_like oal on oal.article_id = opa.business_id and oal.user_id = #{loginUserId}
WHERE
1 = 1
AND opa.del_flag = '0'
......@@ -218,6 +226,7 @@
opc.reply_count,
mi.mem_code as memCode,
mi.mem_nick_name as memNickName,
mi.avatar as avatarId,
oi.url as avatarUrl
FROM opm_article_comment opc
LEFT JOIN mem_info mi ON mi.user_id = opc.create_by
......@@ -237,4 +246,15 @@
insert into opm_article_like (user_id, article_id,create_date)
values (#{entity.userId}, #{entity.articleId},now())
</insert>
<insert id="addComment">
INSERT INTO opm_article_comment
(
create_by, create_date, update_by, update_date, content, parent_id, article_id, user_id
)
VALUES
(
#{entity.createBy}, #{entity.createDate},#{entity.updateBy},#{entity.updateDate},
#{entity.commentContent},#{entity.parentId},#{entity.articleId},#{entity.userId}
)
</insert>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment