Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cust-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李伟
cust-api
Commits
c57723b9
Commit
c57723b9
authored
Jan 21, 2025
by
liwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了评论点赞bug
parent
d7281c19
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
26 deletions
+32
-26
AppOpmArticleController.java
...ft/app/appArticle/controller/AppOpmArticleController.java
+3
-3
OpmArticleRepository.java
...rcisoft/business/opmArticle/dao/OpmArticleRepository.java
+3
-3
ArticleCommentVO.java
.../rcisoft/business/opmArticle/entity/ArticleCommentVO.java
+5
-4
LikeDTO.java
.../java/org/rcisoft/business/opmArticle/entity/LikeDTO.java
+5
-1
OpmArticleService.java
...cisoft/business/opmArticle/service/OpmArticleService.java
+2
-2
OpmArticleServiceImpl.java
...siness/opmArticle/service/impl/OpmArticleServiceImpl.java
+7
-6
OpmArticleMapper.xml
...es/mapper/business/opmArticle/mapper/OpmArticleMapper.xml
+7
-7
No files found.
src/main/java/org/rcisoft/app/appArticle/controller/AppOpmArticleController.java
View file @
c57723b9
...
@@ -85,12 +85,12 @@ public class AppOpmArticleController extends CyPaginationController<OpmArticle>
...
@@ -85,12 +85,12 @@ public class AppOpmArticleController extends CyPaginationController<OpmArticle>
@CyOpeLogAnno
(
title
=
"system-动态管理-评论点赞"
,
businessType
=
CyLogTypeEnum
.
QUERY
)
@CyOpeLogAnno
(
title
=
"system-动态管理-评论点赞"
,
businessType
=
CyLogTypeEnum
.
QUERY
)
@Operation
(
summary
=
"评论点赞"
,
description
=
"评论点赞"
)
@Operation
(
summary
=
"评论点赞"
,
description
=
"评论点赞"
)
@PostMapping
(
"/opmArticle/likeComment"
)
@PostMapping
(
"/opmArticle/likeComment"
)
public
CyResult
likeCommentAdd
(
Integer
articleId
,
String
praiseType
)
{
public
CyResult
likeCommentAdd
(
Integer
commentId
,
String
praiseType
)
{
CyPersistModel
data
=
opmArticleServiceImpl
.
likeCommentAdd
(
article
Id
,
praiseType
);
CyPersistModel
data
=
opmArticleServiceImpl
.
likeCommentAdd
(
comment
Id
,
praiseType
);
return
CyResultGenUtil
.
builder
(
data
,
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
article
Id
);
comment
Id
);
}
}
@PreAuthorize
(
"@cyPerm.hasPerm('app:article:detail')"
)
@PreAuthorize
(
"@cyPerm.hasPerm('app:article:detail')"
)
...
...
src/main/java/org/rcisoft/business/opmArticle/dao/OpmArticleRepository.java
View file @
c57723b9
...
@@ -45,19 +45,19 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
...
@@ -45,19 +45,19 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
int
likeAdd
(
@Param
(
"entity"
)
LikeDTO
likeDTO
);
int
likeAdd
(
@Param
(
"entity"
)
LikeDTO
likeDTO
);
//删除点赞记录
//删除点赞记录
int
likeDelete
(
@Param
(
"userId"
)
String
userId
,
@Param
(
"
articleId"
)
Integer
article
Id
);
int
likeDelete
(
@Param
(
"userId"
)
String
userId
,
@Param
(
"
commentId"
)
Integer
comment
Id
);
//动态点赞数+1
//动态点赞数+1
int
addLikeCount
(
Integer
articleId
);
int
addLikeCount
(
Integer
articleId
);
//评论点赞数+1
//评论点赞数+1
int
addCommentLikeCount
(
Integer
article
Id
);
int
addCommentLikeCount
(
Integer
comment
Id
);
//动态点赞数-1
//动态点赞数-1
int
reduceLikeCount
(
Integer
articleId
);
int
reduceLikeCount
(
Integer
articleId
);
//评论点赞数-1
//评论点赞数-1
int
reduceCommentLikeCount
(
Integer
article
Id
);
int
reduceCommentLikeCount
(
Integer
comment
Id
);
//动态表评论数+1
//动态表评论数+1
int
addArticleCommentCount
(
Integer
articleId
);
int
addArticleCommentCount
(
Integer
articleId
);
...
...
src/main/java/org/rcisoft/business/opmArticle/entity/ArticleCommentVO.java
View file @
c57723b9
...
@@ -80,12 +80,13 @@ public class ArticleCommentVO {
...
@@ -80,12 +80,13 @@ public class ArticleCommentVO {
private
Integer
commentedUserId
;
private
Integer
commentedUserId
;
/**
/**
*
子评论
*
是否点赞
*/
*/
private
List
<
ArticleCommentVO
>
childrenCommentList
;
private
String
isLike
;
/**
/**
*
是否点赞
*
子评论
*/
*/
private
String
isLike
;
private
List
<
ArticleCommentVO
>
childrenCommentList
;
}
}
src/main/java/org/rcisoft/business/opmArticle/entity/LikeDTO.java
View file @
c57723b9
...
@@ -5,10 +5,14 @@ import lombok.Data;
...
@@ -5,10 +5,14 @@ import lombok.Data;
@Data
@Data
public
class
LikeDTO
{
public
class
LikeDTO
{
Integer
businessId
;
Integer
businessId
;
//用户id
String
userId
;
String
userId
;
//动态id
Integer
articleId
;
Integer
articleId
;
//评论id
Integer
commentId
;
}
}
src/main/java/org/rcisoft/business/opmArticle/service/OpmArticleService.java
View file @
c57723b9
...
@@ -89,10 +89,10 @@ public interface OpmArticleService {
...
@@ -89,10 +89,10 @@ public interface OpmArticleService {
/**
/**
* 评论增加点赞数
* 评论增加点赞数
* @param
article
Id
* @param
comment
Id
* @return
* @return
*/
*/
CyPersistModel
likeCommentAdd
(
Integer
article
Id
,
String
praiseType
);
CyPersistModel
likeCommentAdd
(
Integer
comment
Id
,
String
praiseType
);
/**
/**
* 添加评论
* 添加评论
...
...
src/main/java/org/rcisoft/business/opmArticle/service/impl/OpmArticleServiceImpl.java
View file @
c57723b9
...
@@ -259,29 +259,30 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
...
@@ -259,29 +259,30 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
/**
/**
* 评论增加点赞数
* 评论增加点赞数
* @param articleId
* @param commentId
* @param praiseType 点赞类型 praise:点赞 cancel:取消点赞
* @return
* @return
*/
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
@Override
public
CyPersistModel
likeCommentAdd
(
Integer
article
Id
,
String
praiseType
){
public
CyPersistModel
likeCommentAdd
(
Integer
comment
Id
,
String
praiseType
){
int
line
=
0
;
int
line
=
0
;
if
(
praiseType
.
equals
(
"praise"
)){
if
(
praiseType
.
equals
(
"praise"
)){
//点赞
//点赞
//向点赞表增加一条数据
//向点赞表增加一条数据
LikeDTO
likeDTO
=
new
LikeDTO
();
LikeDTO
likeDTO
=
new
LikeDTO
();
likeDTO
.
setUserId
(
CyUserUtil
.
getAuthenBusinessId
());
likeDTO
.
setUserId
(
CyUserUtil
.
getAuthenBusinessId
());
likeDTO
.
set
ArticleId
(
article
Id
);
likeDTO
.
set
CommentId
(
comment
Id
);
//增加主表该动态的点赞数
//增加主表该动态的点赞数
baseMapper
.
addCommentLikeCount
(
article
Id
);
baseMapper
.
addCommentLikeCount
(
comment
Id
);
line
=
baseMapper
.
likeAdd
(
likeDTO
);
line
=
baseMapper
.
likeAdd
(
likeDTO
);
}
else
if
(
praiseType
.
equals
(
"cancel"
)){
}
else
if
(
praiseType
.
equals
(
"cancel"
)){
//取消点赞
//取消点赞
//删除点赞表中的数据
//删除点赞表中的数据
String
userId
=
CyUserUtil
.
getAuthenBusinessId
();
String
userId
=
CyUserUtil
.
getAuthenBusinessId
();
baseMapper
.
likeDelete
(
userId
,
article
Id
);
baseMapper
.
likeDelete
(
userId
,
comment
Id
);
//修改主表中该动态的点赞数
//修改主表中该动态的点赞数
line
=
baseMapper
.
reduceCommentLikeCount
(
article
Id
);
line
=
baseMapper
.
reduceCommentLikeCount
(
comment
Id
);
}
else
{
}
else
{
throw
new
CyServiceException
(
"点赞失败,请稍后再试"
);
throw
new
CyServiceException
(
"点赞失败,请稍后再试"
);
}
}
...
...
src/main/resources/mapper/business/opmArticle/mapper/OpmArticleMapper.xml
View file @
c57723b9
...
@@ -40,12 +40,12 @@
...
@@ -40,12 +40,12 @@
<update
id=
"reduceCommentLikeCount"
parameterType=
"java.lang.Integer"
>
<update
id=
"reduceCommentLikeCount"
parameterType=
"java.lang.Integer"
>
UPDATE opm_article_comment
UPDATE opm_article_comment
SET like_count = like_count - 1
SET like_count = like_count - 1
WHERE business_id = #{
article
Id};
WHERE business_id = #{
comment
Id};
</update>
</update>
<update
id=
"addCommentLikeCount"
parameterType=
"java.lang.Integer"
>
<update
id=
"addCommentLikeCount"
parameterType=
"java.lang.Integer"
>
UPDATE opm_article_comment
UPDATE opm_article_comment
SET like_count = like_count + 1
SET like_count = like_count + 1
WHERE business_id = #{
article
Id};
WHERE business_id = #{
comment
Id};
</update>
</update>
<select
id=
"queryOpmArticle"
resultMap=
"BaseResultMap"
>
<select
id=
"queryOpmArticle"
resultMap=
"BaseResultMap"
>
select opa.*,sot.topic_name as topic,mi.mem_code as memCode
select opa.*,sot.topic_name as topic,mi.mem_code as memCode
...
@@ -258,7 +258,7 @@
...
@@ -258,7 +258,7 @@
FROM opm_article_comment opc
FROM opm_article_comment opc
LEFT JOIN mem_info mi ON mi.user_id = opc.create_by
LEFT JOIN mem_info mi ON mi.user_id = opc.create_by
left join oss_info oi on oi.business_id = mi.avatar
left join oss_info oi on oi.business_id = mi.avatar
LEFT JOIN opm_article_like oal on oal.
article
_id = opc.business_id and oal.user_id = #{loginUserId}
LEFT JOIN opm_article_like oal on oal.
comment
_id = opc.business_id and oal.user_id = #{loginUserId}
WHERE 1 = 1
WHERE 1 = 1
AND opc.del_flag = '0'
AND opc.del_flag = '0'
AND opc.parent_id is null
AND opc.parent_id is null
...
@@ -287,7 +287,7 @@
...
@@ -287,7 +287,7 @@
LEFT JOIN mem_info mi ON mi.user_id = opc.create_by
LEFT JOIN mem_info mi ON mi.user_id = opc.create_by
LEFT JOIN oss_info oi on oi.business_id = mi.avatar
LEFT JOIN oss_info oi on oi.business_id = mi.avatar
LEFT JOIN mem_info mi2 ON mi2.user_id = opc.user_id
LEFT JOIN mem_info mi2 ON mi2.user_id = opc.user_id
LEFT JOIN opm_article_like oal on oal.
article
_id = opc.business_id and oal.user_id = #{loginUserId}
LEFT JOIN opm_article_like oal on oal.
comment
_id = opc.business_id and oal.user_id = #{loginUserId}
WHERE 1 = 1
WHERE 1 = 1
AND opc.del_flag = '0'
AND opc.del_flag = '0'
AND opc.article_id = #{articleId}
AND opc.article_id = #{articleId}
...
@@ -298,11 +298,11 @@
...
@@ -298,11 +298,11 @@
and del_flag = '0'
and del_flag = '0'
</delete>
</delete>
<delete
id=
"likeDelete"
parameterType=
"org.rcisoft.business.opmArticle.entity.OpmArticle"
>
<delete
id=
"likeDelete"
parameterType=
"org.rcisoft.business.opmArticle.entity.OpmArticle"
>
delete from opm_article_like where user_id = #{userId} and
article_id = #{article
Id}
delete from opm_article_like where user_id = #{userId} and
comment_id = #{comment
Id}
</delete>
</delete>
<insert
id=
"likeAdd"
parameterType=
"org.rcisoft.business.opmArticle.entity.OpmArticle"
>
<insert
id=
"likeAdd"
parameterType=
"org.rcisoft.business.opmArticle.entity.OpmArticle"
>
insert into opm_article_like (user_id, article_id,create_date)
insert into opm_article_like (user_id, article_id,c
omment_id,c
reate_date)
values (#{entity.userId}, #{entity.articleId},now())
values (#{entity.userId}, #{entity.articleId},
#{entity.commentId},
now())
</insert>
</insert>
<insert
id=
"addComment"
>
<insert
id=
"addComment"
>
INSERT INTO opm_article_comment
INSERT INTO opm_article_comment
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment