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
6b661824
Commit
6b661824
authored
Mar 06, 2025
by
liwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增了app评论删除
parent
ee67f2c9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
143 additions
and
17 deletions
+143
-17
AppOpmArticleController.java
...ft/app/appArticle/controller/AppOpmArticleController.java
+14
-0
OpmArticleController.java
.../business/opmArticle/controller/OpmArticleController.java
+3
-3
OpmArticleRepository.java
...rcisoft/business/opmArticle/dao/OpmArticleRepository.java
+22
-1
ArticleCommentDTO.java
...rcisoft/business/opmArticle/entity/ArticleCommentDTO.java
+4
-1
OpmArticleService.java
...cisoft/business/opmArticle/service/OpmArticleService.java
+2
-2
OpmArticleServiceImpl.java
...siness/opmArticle/service/impl/OpmArticleServiceImpl.java
+54
-10
OpmArticleMapper.xml
...es/mapper/business/opmArticle/mapper/OpmArticleMapper.xml
+44
-0
No files found.
src/main/java/org/rcisoft/app/appArticle/controller/AppOpmArticleController.java
View file @
6b661824
...
...
@@ -144,4 +144,18 @@ public class AppOpmArticleController extends CyPaginationController<OpmArticle>
CyMessCons
.
MESSAGE_ALERT_ERROR
,
dto
);
}
/**
* 逻辑删除评论
*/
@PreAuthorize
(
"@cyPerm.hasPerm('app:opmArticle:delete')"
)
@DeleteMapping
(
"/deleteComment/{businessId:\\w+}"
)
public
CyResult
deleteComment
(
@PathVariable
String
businessId
,
@RequestBody
ArticleCommentDTO
dto
)
{
dto
.
setBusinessId
(
Integer
.
valueOf
(
businessId
));
CyPersistModel
data
=
opmArticleServiceImpl
.
removeComment
(
dto
,
"app"
);
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
businessId
);
}
}
src/main/java/org/rcisoft/business/opmArticle/controller/OpmArticleController.java
View file @
6b661824
...
...
@@ -146,9 +146,9 @@ public class OpmArticleController extends CyPaginationController<OpmArticle> {
*/
@PreAuthorize
(
"@cyPerm.hasPerm('cms:opmArticle:delete')"
)
@DeleteMapping
(
"/deleteComment/{businessId:\\w+}"
)
public
CyResult
deleteComment
(
@PathVariable
String
businessId
,
OpmArticle
opmArticle
)
{
opmArticle
.
setBusinessId
(
Integer
.
valueOf
(
businessId
));
CyPersistModel
data
=
opmArticleServiceImpl
.
removeComment
(
opmArticle
);
public
CyResult
deleteComment
(
@PathVariable
String
businessId
,
ArticleCommentDTO
dto
)
{
dto
.
setBusinessId
(
Integer
.
valueOf
(
businessId
));
CyPersistModel
data
=
opmArticleServiceImpl
.
removeComment
(
dto
,
"web"
);
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
...
...
src/main/java/org/rcisoft/business/opmArticle/dao/OpmArticleRepository.java
View file @
6b661824
...
...
@@ -50,7 +50,7 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
List
<
ArticleCommentVO
>
selectArticleChildrenComment
(
@Param
(
"articleId"
)
Integer
articleId
,
@Param
(
"parentId"
)
Integer
parentId
,
@Param
(
"loginUserId"
)
String
loginUserId
);
//删除评论
int
deleteComment
(
OpmArticle
opmArticle
);
int
deleteComment
(
ArticleCommentDTO
dto
);
//添加点赞记录
int
likeAdd
(
@Param
(
"entity"
)
LikeDTO
likeDTO
);
...
...
@@ -73,6 +73,12 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
//动态表评论数+1
int
addArticleCommentCount
(
Integer
articleId
);
//动态表评论数-1
int
reduceArticleCommentCount
(
Integer
articleId
);
//评论表评论数-1
int
reduceCommentCount
(
Integer
commentId
);
//评论表评论数+1
int
addCommentCount
(
Integer
commentId
);
...
...
@@ -84,5 +90,20 @@ public interface OpmArticleRepository extends CyBaseMapper<OpmArticle> {
//根据id查询评论信息
ArticleCommentDTO
findCommentById
(
Integer
businessId
);
//根据动态id查询动态评论
List
<
ArticleCommentVO
>
selectArticleCommentCount
(
@Param
(
"entity"
)
OpmArticle
article
);
//根据评论id查询子评论数量
Integer
selectArticleChildrenCommentCount
(
@Param
(
"entity"
)
ArticleCommentVO
article
);
//根据评论id修改动态的评论数量
int
updateCommentById
(
@Param
(
"entity"
)
ArticleCommentVO
commentVo
);
//根据id查询评论信息
ArticleCommentVO
selectCommentById
(
Integer
businessId
);
//根据动态id修改动态的评论数量
int
updateArticleCommentCountById
(
@Param
(
"entity"
)
OpmArticle
article
);
}
src/main/java/org/rcisoft/business/opmArticle/entity/ArticleCommentDTO.java
View file @
6b661824
...
...
@@ -7,7 +7,8 @@ import java.util.Date;
@Data
public
class
ArticleCommentDTO
{
//主键
private
Integer
businessId
;
//动态ID
private
Integer
articleId
;
//评论内容
...
...
@@ -30,4 +31,6 @@ public class ArticleCommentDTO {
private
String
remarks
;
//评论id
private
Integer
commentId
;
//删除标志
private
String
delFlag
;
}
src/main/java/org/rcisoft/business/opmArticle/service/OpmArticleService.java
View file @
6b661824
...
...
@@ -75,10 +75,10 @@ public interface OpmArticleService {
/**
* 逻辑删除 评论
* @param
opmArticle
* @param
dto
* @return
*/
CyPersistModel
removeComment
(
OpmArticle
opmArticl
e
);
CyPersistModel
removeComment
(
ArticleCommentDTO
dto
,
String
typ
e
);
/**
* 点赞增加点赞数
...
...
src/main/java/org/rcisoft/business/opmArticle/service/impl/OpmArticleServiceImpl.java
View file @
6b661824
...
...
@@ -273,9 +273,32 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
public
CyPersistModel
merge
(
OpmArticle
opmArticle
){
int
line
=
baseMapper
.
updateById
(
opmArticle
);
log
.
debug
(
CyUserUtil
.
getAuthenUsername
()+
"修改了ID为"
+
opmArticle
.
getBusinessId
()+
"的opmArticle管理信息"
);
return
new
CyPersistModel
(
line
);
//先查询该动态
QueryWrapper
<
OpmArticle
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
lambda
().
eq
(
OpmArticle:
:
getBusinessId
,
opmArticle
.
getBusinessId
());
List
<
OpmArticle
>
list
=
baseMapper
.
selectList
(
wrapper
);
if
(
list
.
size
()
>
0
){
OpmArticle
article
=
list
.
get
(
0
);
//查询该动态下的评论数
List
<
ArticleCommentVO
>
comment
=
baseMapper
.
selectArticleCommentCount
(
article
);
//修改动态
article
.
setCommentCount
(
comment
.
size
());
//修改评论数
article
.
setExamStatus
(
opmArticle
.
getExamStatus
());
//修改审核状态
int
line
=
baseMapper
.
updateById
(
article
);
//修改子表的评论数 给父级评论数+1
for
(
ArticleCommentVO
commentVo
:
comment
)
{
if
(
commentVo
.
getParentId
()
!=
null
){
//查询评论的子评论数量
Integer
commentCount
=
baseMapper
.
selectArticleChildrenCommentCount
(
commentVo
);
//修改评论的评论数量
commentVo
.
setCommentCount
(
commentCount
);
baseMapper
.
updateCommentById
(
commentVo
);
}
}
return
new
CyPersistModel
(
line
);
}
else
{
throw
new
CyServiceException
(
1001
,
"该动态已被用户删除!"
);
}
}
/**
...
...
@@ -466,17 +489,38 @@ public class OpmArticleServiceImpl extends ServiceImpl<OpmArticleRepository, Opm
/**
* 逻辑删除 评论
* @param
opmArticle
* @param
dto
* @return
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
public
CyPersistModel
removeComment
(
OpmArticle
opmArticle
){
opmArticle
.
setDeleted
();
int
line
=
baseMapper
.
deleteComment
(
opmArticle
);
log
.
debug
(
CyUserUtil
.
getAuthenUsername
()+
"逻辑删除了ID为"
+
opmArticle
.
getBusinessId
()+
"的opmArticleComment信息"
);
return
new
CyPersistModel
(
line
);
public
CyPersistModel
removeComment
(
ArticleCommentDTO
dto
,
String
type
){
if
(
type
.
equals
(
"app"
)){
//app端
//删除评论
int
line
=
baseMapper
.
deleteComment
(
dto
);
int
childrenCommentCount
=
0
;
if
(
dto
.
getParentId
()
!=
null
){
//删除的子评论 需要减掉父评论的数量
baseMapper
.
reduceCommentCount
(
dto
.
getParentId
());
}
else
{
//删除的是父评论 要查父评论下的子评论数量
ArticleCommentVO
vo
=
new
ArticleCommentVO
();
vo
.
setParentId
(
dto
.
getBusinessId
());
Integer
count
=
baseMapper
.
selectArticleChildrenCommentCount
(
vo
);
childrenCommentCount
=
count
;
}
OpmArticle
article
=
new
OpmArticle
();
article
.
setBusinessId
(
dto
.
getArticleId
());
article
.
setCommentCount
(
childrenCommentCount
+
1
);
baseMapper
.
updateArticleCommentCountById
(
article
);
return
new
CyPersistModel
(
1
);
}
else
{
//web端
dto
.
setDelFlag
(
"1"
);
int
line
=
baseMapper
.
deleteComment
(
dto
);
return
new
CyPersistModel
(
1
);
}
}
/**
...
...
src/main/resources/mapper/business/opmArticle/mapper/OpmArticleMapper.xml
View file @
6b661824
...
...
@@ -32,6 +32,11 @@
SET comment_count = comment_count + 1
WHERE business_id = #{articleId};
</update>
<update
id=
"reduceArticleCommentCount"
>
UPDATE opm_article
SET comment_count = comment_count - 1
WHERE business_id = #{articleId};
</update>
<update
id=
"addCommentCount"
>
UPDATE opm_article_comment
SET comment_count = comment_count + 1
...
...
@@ -47,6 +52,21 @@
SET like_count = like_count + 1
WHERE business_id = #{commentId};
</update>
<update
id=
"reduceCommentCount"
>
UPDATE opm_article_comment
SET comment_count = comment_count - 1
WHERE business_id = #{commentId};
</update>
<update
id=
"updateCommentById"
>
UPDATE opm_article_comment
SET comment_count = #{entity.commentCount}
WHERE business_id = #{entity.businessId};
</update>
<update
id=
"updateArticleCommentCountById"
>
UPDATE opm_article
SET comment_count = comment_count - #{entity.commentCount}
WHERE business_id = #{entity.businessId};
</update>
<select
id=
"queryOpmArticle"
resultMap=
"BaseResultMap"
>
select opa.*,sot.topic_name as topic,mi.mem_code as memCode
from opm_article opa
...
...
@@ -703,6 +723,30 @@
where 1=1
and business_id = #{businessId}
</select>
<select
id=
"selectArticleCommentCount"
resultType=
"org.rcisoft.business.opmArticle.entity.ArticleCommentVO"
>
SELECT *
from opm_article_comment
WHERE 1=1
and del_flag = '0'
and flag = '1'
and exam_status = '1'
and article_id = #{entity.businessId}
</select>
<select
id=
"selectArticleChildrenCommentCount"
resultType=
"java.lang.Integer"
>
SELECT count(*)
from opm_article_comment
WHERE 1=1
and del_flag = '0'
and flag = '1'
and parent_id = #{entity.parentId}
</select>
<select
id=
"selectCommentById"
resultType=
"org.rcisoft.business.opmArticle.entity.ArticleCommentVO"
>
select *
from opm_article_comment
where 1=1
and business_id = #{businessId}
</select>
<delete
id=
"deleteComment"
>
update opm_article_comment set del_flag = '1' where business_id = #{businessId}
and del_flag = '0'
...
...
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