Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
safe-campus-bbs
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
万成波
safe-campus-bbs
Commits
ec025c69
Commit
ec025c69
authored
Sep 04, 2025
by
万成波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化动态
parent
a98f658f
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
243 additions
and
228 deletions
+243
-228
safe-campus-moment/src/main/java/com/tangguo/domain/BbsMoment.java
...us-moment/src/main/java/com/tangguo/domain/BbsMoment.java
+6
-16
safe-campus-moment/src/main/java/com/tangguo/domain/BbsMomentAttachment.java
...src/main/java/com/tangguo/domain/BbsMomentAttachment.java
+0
-5
safe-campus-moment/src/main/java/com/tangguo/domain/bo/CreateMomentBO.java
...t/src/main/java/com/tangguo/domain/bo/CreateMomentBO.java
+3
-18
safe-campus-moment/src/main/java/com/tangguo/domain/dto/BbsMomentListDTO.java
...rc/main/java/com/tangguo/domain/dto/BbsMomentListDTO.java
+0
-83
safe-campus-moment/src/main/java/com/tangguo/domain/vo/BbsMomentListVO.java
.../src/main/java/com/tangguo/domain/vo/BbsMomentListVO.java
+47
-6
safe-campus-moment/src/main/java/com/tangguo/mapper/BbsMomentMapper.java
...ent/src/main/java/com/tangguo/mapper/BbsMomentMapper.java
+3
-3
safe-campus-moment/src/main/java/com/tangguo/service/IBbsMomentAttachmentService.java
...java/com/tangguo/service/IBbsMomentAttachmentService.java
+12
-3
safe-campus-moment/src/main/java/com/tangguo/service/IBbsMomentVoteOptionService.java
...java/com/tangguo/service/IBbsMomentVoteOptionService.java
+12
-2
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentAttachmentServiceImpl.java
.../tangguo/service/impl/BbsMomentAttachmentServiceImpl.java
+28
-9
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentServiceImpl.java
...n/java/com/tangguo/service/impl/BbsMomentServiceImpl.java
+90
-67
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentVoteOptionServiceImpl.java
.../tangguo/service/impl/BbsMomentVoteOptionServiceImpl.java
+40
-14
safe-campus-moment/src/main/resources/mapper/BbsMomentMapper.xml
...mpus-moment/src/main/resources/mapper/BbsMomentMapper.xml
+2
-2
No files found.
safe-campus-moment/src/main/java/com/tangguo/domain/BbsMoment.java
View file @
ec025c69
...
@@ -51,14 +51,14 @@ public class BbsMoment extends BaseEntity {
...
@@ -51,14 +51,14 @@ public class BbsMoment extends BaseEntity {
@ApiModelProperty
(
"动态类型:IMAGE 图片动态、VIDEO 视频动态、URL 链接动态"
)
@ApiModelProperty
(
"动态类型:IMAGE 图片动态、VIDEO 视频动态、URL 链接动态"
)
private
String
type
;
private
String
type
;
/** 话题名称(
|
号分割) */
/** 话题名称(
逗
号分割) */
@Excel
(
name
=
"话题名称"
,
readConverterExp
=
"
|
号分割"
)
@Excel
(
name
=
"话题名称"
,
readConverterExp
=
"
逗
号分割"
)
@ApiModelProperty
(
"话题名称(
|
分割)"
)
@ApiModelProperty
(
"话题名称(
逗号
分割)"
)
private
String
topicNames
;
private
String
topicNames
;
/** 话题Ids(
|
号分割) */
/** 话题Ids(
逗
号分割) */
@Excel
(
name
=
"话题Ids"
,
readConverterExp
=
"
|
分割"
)
@Excel
(
name
=
"话题Ids"
,
readConverterExp
=
"
逗号
分割"
)
@ApiModelProperty
(
"话题Ids(
|
分割)"
)
@ApiModelProperty
(
"话题Ids(
逗号
分割)"
)
private
String
topicIds
;
private
String
topicIds
;
/** 外部链接地址 */
/** 外部链接地址 */
...
@@ -66,11 +66,6 @@ public class BbsMoment extends BaseEntity {
...
@@ -66,11 +66,6 @@ public class BbsMoment extends BaseEntity {
@ApiModelProperty
(
"外部链接地址"
)
@ApiModelProperty
(
"外部链接地址"
)
private
String
linkUrl
;
private
String
linkUrl
;
/** 附件地址(|号分割) */
@Excel
(
name
=
"附件地址(|分割)"
)
@ApiModelProperty
(
"附件地址(|分割)"
)
private
String
attachmentUrls
;
/** 是否开启评论:0 否、1 是 */
/** 是否开启评论:0 否、1 是 */
@Excel
(
name
=
"是否开启评论:0 否、1 是"
)
@Excel
(
name
=
"是否开启评论:0 否、1 是"
)
@ApiModelProperty
(
"是否开启评论:0 否、1 是"
)
@ApiModelProperty
(
"是否开启评论:0 否、1 是"
)
...
@@ -108,11 +103,6 @@ public class BbsMoment extends BaseEntity {
...
@@ -108,11 +103,6 @@ public class BbsMoment extends BaseEntity {
@ApiModelProperty
(
"投票结束时间"
)
@ApiModelProperty
(
"投票结束时间"
)
private
Date
voteEndTime
;
private
Date
voteEndTime
;
/** 投票选项JSON */
@Excel
(
name
=
"投票选项JSON"
)
@ApiModelProperty
(
"投票选项JSON"
)
private
String
voteOptions
;
/** 动态点赞人数 */
/** 动态点赞人数 */
@Excel
(
name
=
"动态点赞人数"
)
@Excel
(
name
=
"动态点赞人数"
)
@ApiModelProperty
(
"动态点赞人数"
)
@ApiModelProperty
(
"动态点赞人数"
)
...
...
safe-campus-moment/src/main/java/com/tangguo/domain/BbsMomentAttachment.java
View file @
ec025c69
...
@@ -57,9 +57,4 @@ public class BbsMomentAttachment extends BaseEntity {
...
@@ -57,9 +57,4 @@ public class BbsMomentAttachment extends BaseEntity {
@ApiModelProperty
(
"附件预览地址"
)
@ApiModelProperty
(
"附件预览地址"
)
private
String
url
;
private
String
url
;
/** 文件扩展名:PNG、JPG、MP4 */
@Excel
(
name
=
"文件扩展名:PNG、JPG、MP4"
)
@ApiModelProperty
(
"文件扩展名:PNG、JPG、MP4"
)
private
String
fileExt
;
}
}
safe-campus-moment/src/main/java/com/tangguo/domain/bo/CreateMomentBO.java
View file @
ec025c69
...
@@ -28,9 +28,6 @@ public class CreateMomentBO {
...
@@ -28,9 +28,6 @@ public class CreateMomentBO {
/** 外部链接地址 */
/** 外部链接地址 */
private
String
linkUrl
;
private
String
linkUrl
;
/** 动态附件地址 */
private
List
<
String
>
attachmentUrls
;
/** 是否开启评论:0 否、1 是 */
/** 是否开启评论:0 否、1 是 */
private
Integer
isEnableComment
;
private
Integer
isEnableComment
;
...
@@ -46,6 +43,9 @@ public class CreateMomentBO {
...
@@ -46,6 +43,9 @@ public class CreateMomentBO {
/** 投票选项类型:TEXT 文字、IMAGE 图片 */
/** 投票选项类型:TEXT 文字、IMAGE 图片 */
private
String
voteOptionType
;
private
String
voteOptionType
;
/** 动态附件 */
private
List
<
Attachment
>
attachments
;
/** 动态投票选项 */
/** 动态投票选项 */
private
List
<
VoteOption
>
voteOptions
;
private
List
<
VoteOption
>
voteOptions
;
...
@@ -59,15 +59,9 @@ public class CreateMomentBO {
...
@@ -59,15 +59,9 @@ public class CreateMomentBO {
/** 附件名称 */
/** 附件名称 */
private
String
name
;
private
String
name
;
/** 附件类型:图片 IMAGE、视频 VIDEO */
private
String
type
;
/** 附件预览地址 */
/** 附件预览地址 */
private
String
url
;
private
String
url
;
/** 文件扩展名:PNG、JPG、MP4 */
private
String
fileExt
;
}
}
/**
/**
...
@@ -76,21 +70,12 @@ public class CreateMomentBO {
...
@@ -76,21 +70,12 @@ public class CreateMomentBO {
@Data
@Data
public
static
class
VoteOption
{
public
static
class
VoteOption
{
/** 选项类型:TEXT 文字、IMAGE 图片 */
private
String
type
;
/** 选项名称 */
/** 选项名称 */
private
String
name
;
private
String
name
;
/** 选项编码 */
private
String
code
;
/** 图片地址 */
/** 图片地址 */
private
String
imageUrl
;
private
String
imageUrl
;
/** 排序值 */
private
Integer
sort
;
}
}
}
}
safe-campus-moment/src/main/java/com/tangguo/domain/dto/BbsMomentListDTO.java
deleted
100644 → 0
View file @
a98f658f
package
com
.
tangguo
.
domain
.
dto
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
java.util.Date
;
/**
*
*
* @author 谈笑
* @createTime 2025-09-03 15:42:59 星期三
*/
@Data
public
class
BbsMomentListDTO
{
/**
* 发布时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
createTime
;
/** 动态Id */
private
Long
id
;
/** 发布人用户名 */
private
String
userName
;
/** 动态内容 */
private
String
content
;
/** 动态类型:IMAGE 图片动态、VIDEO 视频动态、URL 链接动态 */
private
String
type
;
/** 话题名称 */
private
String
topicNames
;
/** 话题Ids */
private
String
topicIds
;
/** 外部链接地址 */
private
String
linkUrl
;
/** 附件地址 */
private
String
attachmentUrls
;
/** 是否开启评论:0 否、1 是 */
private
Integer
isEnableComment
;
/** 是否精选评论:0 否、1 是 */
private
Integer
isEnableFeaturedComment
;
/** 是否开启投票:0 否、1 是 */
private
Integer
isEnableVote
;
/** 投票标题 */
private
String
voteTitle
;
/** 投票选项类型:TEXT 文字、IMAGE 图片 */
private
String
voteOptionType
;
/** 投票选项JSON */
private
String
voteOptions
;
/** 动态点赞人数 */
private
Integer
likeCount
;
/** 动态评论人数 */
private
Integer
commentCount
;
/** 动态投票人数 */
private
Integer
voteCount
;
/** 当前是否点赞:0 未点赞、1 已点赞 */
private
Integer
isLike
;
/** 当前是否投票:0 未投票、1 已投票 */
private
Integer
isVote
;
/** 是否本人动态:0 否、1 是 */
private
Integer
isSelf
;
}
safe-campus-moment/src/main/java/com/tangguo/domain/vo/BbsMomentListVO.java
View file @
ec025c69
...
@@ -40,9 +40,6 @@ public class BbsMomentListVO {
...
@@ -40,9 +40,6 @@ public class BbsMomentListVO {
/** 外部链接地址 */
/** 外部链接地址 */
private
String
linkUrl
;
private
String
linkUrl
;
/** 附件地址 */
private
List
<
String
>
attachmentUrls
;
/** 是否开启评论:0 否、1 是 */
/** 是否开启评论:0 否、1 是 */
private
Integer
isEnableComment
;
private
Integer
isEnableComment
;
...
@@ -58,9 +55,6 @@ public class BbsMomentListVO {
...
@@ -58,9 +55,6 @@ public class BbsMomentListVO {
/** 投票选项类型:TEXT 文字、IMAGE 图片 */
/** 投票选项类型:TEXT 文字、IMAGE 图片 */
private
String
voteOptionType
;
private
String
voteOptionType
;
/** 投票选项JSON */
private
String
voteOptions
;
/** 动态点赞人数 */
/** 动态点赞人数 */
private
Integer
likeCount
;
private
Integer
likeCount
;
...
@@ -79,4 +73,51 @@ public class BbsMomentListVO {
...
@@ -79,4 +73,51 @@ public class BbsMomentListVO {
/** 是否本人动态:0 否、1 是 */
/** 是否本人动态:0 否、1 是 */
private
Integer
isSelf
;
private
Integer
isSelf
;
/** 动态附件 */
private
List
<
Attachment
>
attachments
;
/** 动态投票选项 */
private
List
<
VoteOption
>
voteOptions
;
/**
* 动态附件
*/
@Data
public
static
class
Attachment
{
/** 附件名称 */
private
String
name
;
/** 附件预览地址 */
private
String
url
;
}
/**
* 动态投票选项
*/
@Data
public
static
class
VoteOption
{
/** 选项类型:TEXT 文字、IMAGE 图片 */
private
String
type
;
/** 选项名称 */
private
String
name
;
/** 选项编码 */
private
String
code
;
/** 图片地址 */
private
String
imageUrl
;
/** 排序值 */
private
Integer
sort
;
/** 投票人数 */
private
Integer
voteCount
;
}
}
}
safe-campus-moment/src/main/java/com/tangguo/mapper/BbsMomentMapper.java
View file @
ec025c69
...
@@ -2,7 +2,7 @@ package com.tangguo.mapper;
...
@@ -2,7 +2,7 @@ package com.tangguo.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.tangguo.domain.BbsMoment
;
import
com.tangguo.domain.BbsMoment
;
import
com.tangguo.domain.
dto.BbsMomentListDT
O
;
import
com.tangguo.domain.
vo.BbsMomentListV
O
;
import
com.tangguo.domain.vo.BbsUserMomentCountVO
;
import
com.tangguo.domain.vo.BbsUserMomentCountVO
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -22,9 +22,9 @@ public interface BbsMomentMapper extends BaseMapper<BbsMoment> {
...
@@ -22,9 +22,9 @@ public interface BbsMomentMapper extends BaseMapper<BbsMoment> {
BbsUserMomentCountVO
selectUserMomentCount
(
@Param
(
"userName"
)
String
userName
);
BbsUserMomentCountVO
selectUserMomentCount
(
@Param
(
"userName"
)
String
userName
);
List
<
BbsMomentList
DT
O
>
selectUserMoments
(
@Param
(
"userName"
)
String
userName
,
@Param
(
"content"
)
String
content
);
List
<
BbsMomentList
V
O
>
selectUserMoments
(
@Param
(
"userName"
)
String
userName
,
@Param
(
"content"
)
String
content
);
List
<
BbsMomentList
DT
O
>
selectMoments
(
@Param
(
"userName"
)
String
userName
,
@Param
(
"content"
)
String
content
);
List
<
BbsMomentList
V
O
>
selectMoments
(
@Param
(
"userName"
)
String
userName
,
@Param
(
"content"
)
String
content
);
}
}
safe-campus-moment/src/main/java/com/tangguo/service/IBbsMomentAttachmentService.java
View file @
ec025c69
package
com
.
tangguo
.
service
;
package
com
.
tangguo
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.tangguo.domain.BbsMoment
;
import
com.tangguo.domain.BbsMomentAttachment
;
import
com.tangguo.domain.BbsMomentAttachment
;
import
com.tangguo.domain.bo.CreateMomentBO
;
import
com.tangguo.domain.bo.CreateMomentBO
;
...
@@ -23,14 +24,22 @@ public interface IBbsMomentAttachmentService extends IService<BbsMomentAttachmen
...
@@ -23,14 +24,22 @@ public interface IBbsMomentAttachmentService extends IService<BbsMomentAttachmen
List
<
BbsMomentAttachment
>
getAttachments
(
Long
momentId
);
List
<
BbsMomentAttachment
>
getAttachments
(
Long
momentId
);
/**
* 查询动态附件
*
* @param momentIds 动态Ids
* @return 附件
*/
List
<
BbsMomentAttachment
>
getAttachments
(
List
<
Long
>
momentIds
);
/**
/**
* 添加动态附件
* 添加动态附件
*
*
* @param userName 用户名
* @param moment 动态
* @param momentId 动态Id
* @param attachments 动态附件
* @param attachments 动态附件
*/
*/
void
addAttachments
(
String
userName
,
Long
momentId
,
List
<
CreateMomentBO
.
Attachment
>
attachments
);
void
addAttachments
(
BbsMoment
moment
,
List
<
CreateMomentBO
.
Attachment
>
attachments
);
/**
/**
...
...
safe-campus-moment/src/main/java/com/tangguo/service/IBbsMomentVoteOptionService.java
View file @
ec025c69
package
com
.
tangguo
.
service
;
package
com
.
tangguo
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.tangguo.domain.BbsMoment
;
import
com.tangguo.domain.BbsMomentVoteOption
;
import
com.tangguo.domain.BbsMomentVoteOption
;
import
com.tangguo.domain.bo.CreateMomentBO
;
import
com.tangguo.domain.bo.CreateMomentBO
;
...
@@ -23,13 +24,22 @@ public interface IBbsMomentVoteOptionService extends IService<BbsMomentVoteOptio
...
@@ -23,13 +24,22 @@ public interface IBbsMomentVoteOptionService extends IService<BbsMomentVoteOptio
List
<
BbsMomentVoteOption
>
getVoteOptions
(
Long
momentId
);
List
<
BbsMomentVoteOption
>
getVoteOptions
(
Long
momentId
);
/**
* 查询动态投票选项
*
* @param momentIds 动态Ids
* @return 投票选项
*/
List
<
BbsMomentVoteOption
>
getVoteOptions
(
List
<
Long
>
momentIds
);
/**
/**
* 添加动态投票选项
* 添加动态投票选项
*
*
* @param moment
Id 动态Id
* @param moment
动态
* @param voteOptions 投票选项
* @param voteOptions 投票选项
*/
*/
void
addVoteOptions
(
Long
momentId
,
List
<
CreateMomentBO
.
VoteOption
>
voteOptions
);
void
addVoteOptions
(
BbsMoment
moment
,
List
<
CreateMomentBO
.
VoteOption
>
voteOptions
);
/**
/**
...
...
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentAttachmentServiceImpl.java
View file @
ec025c69
...
@@ -3,6 +3,7 @@ package com.tangguo.service.impl;
...
@@ -3,6 +3,7 @@ package com.tangguo.service.impl;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.tangguo.domain.BbsMoment
;
import
com.tangguo.domain.BbsMomentAttachment
;
import
com.tangguo.domain.BbsMomentAttachment
;
import
com.tangguo.domain.bo.CreateMomentBO
;
import
com.tangguo.domain.bo.CreateMomentBO
;
import
com.tangguo.mapper.BbsMomentAttachmentMapper
;
import
com.tangguo.mapper.BbsMomentAttachmentMapper
;
...
@@ -36,31 +37,48 @@ public class BbsMomentAttachmentServiceImpl extends ServiceImpl<BbsMomentAttachm
...
@@ -36,31 +37,48 @@ public class BbsMomentAttachmentServiceImpl extends ServiceImpl<BbsMomentAttachm
@Override
@Override
public
List
<
BbsMomentAttachment
>
getAttachments
(
Long
momentId
)
{
public
List
<
BbsMomentAttachment
>
getAttachments
(
Long
momentId
)
{
return
this
.
list
(
return
this
.
list
(
Wrappers
.
lambdaQuery
(
BbsMomentAttachment
.
class
).
eq
(
BbsMomentAttachment:
:
getMomentId
,
momentId
)
Wrappers
.
lambdaQuery
(
BbsMomentAttachment
.
class
)
.
eq
(
BbsMomentAttachment:
:
getMomentId
,
momentId
)
);
);
}
}
/**
* 查询动态附件
*
* @param momentIds 动态Ids
* @return 附件
*/
@Override
public
List
<
BbsMomentAttachment
>
getAttachments
(
List
<
Long
>
momentIds
)
{
List
<
BbsMomentAttachment
>
dbAttachments
=
new
ArrayList
<>(
9
);
if
(
CollUtil
.
isNotEmpty
(
momentIds
))
{
dbAttachments
=
this
.
list
(
Wrappers
.
lambdaQuery
(
BbsMomentAttachment
.
class
).
in
(
BbsMomentAttachment:
:
getMomentId
,
momentIds
)
);
}
return
dbAttachments
;
}
/**
/**
* 添加动态附件
* 添加动态附件
*
*
* @param userName 用户名
* @param moment 动态
* @param momentId 动态Id
* @param attachments 动态附件
* @param attachments 动态附件
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
void
addAttachments
(
String
userName
,
Long
momentId
,
List
<
CreateMomentBO
.
Attachment
>
attachments
)
{
public
void
addAttachments
(
BbsMoment
moment
,
List
<
CreateMomentBO
.
Attachment
>
attachments
)
{
if
(
CollUtil
.
isNotEmpty
(
attachments
))
{
if
(
CollUtil
.
isNotEmpty
(
attachments
))
{
List
<
BbsMomentAttachment
>
newAttachments
=
new
ArrayList
<>(
attachments
.
size
());
List
<
BbsMomentAttachment
>
newAttachments
=
new
ArrayList
<>(
attachments
.
size
());
for
(
CreateMomentBO
.
Attachment
attachment
:
attachments
)
{
for
(
CreateMomentBO
.
Attachment
attachment
:
attachments
)
{
BbsMomentAttachment
newAttachment
=
new
BbsMomentAttachment
();
BbsMomentAttachment
newAttachment
=
new
BbsMomentAttachment
();
newAttachment
.
setMomentId
(
moment
Id
);
newAttachment
.
setMomentId
(
moment
.
getId
()
);
newAttachment
.
setUserName
(
userName
);
newAttachment
.
setUserName
(
moment
.
getUserName
()
);
newAttachment
.
setName
(
attachment
.
getName
());
newAttachment
.
setName
(
attachment
.
getName
());
newAttachment
.
setType
(
attach
ment
.
getType
());
newAttachment
.
setType
(
mo
ment
.
getType
());
newAttachment
.
setUrl
(
attachment
.
getUrl
());
newAttachment
.
setUrl
(
attachment
.
getUrl
());
newAttachment
.
setFileExt
(
attachment
.
getFileExt
());
newAttachments
.
add
(
newAttachment
);
newAttachments
.
add
(
newAttachment
);
}
}
this
.
saveBatch
(
newAttachments
);
this
.
saveBatch
(
newAttachments
);
...
@@ -76,7 +94,8 @@ public class BbsMomentAttachmentServiceImpl extends ServiceImpl<BbsMomentAttachm
...
@@ -76,7 +94,8 @@ public class BbsMomentAttachmentServiceImpl extends ServiceImpl<BbsMomentAttachm
@Override
@Override
public
void
deleteAttachments
(
Long
momentId
)
{
public
void
deleteAttachments
(
Long
momentId
)
{
this
.
remove
(
this
.
remove
(
Wrappers
.
lambdaQuery
(
BbsMomentAttachment
.
class
).
eq
(
BbsMomentAttachment:
:
getMomentId
,
momentId
)
Wrappers
.
lambdaQuery
(
BbsMomentAttachment
.
class
)
.
eq
(
BbsMomentAttachment:
:
getMomentId
,
momentId
)
);
);
}
}
...
...
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentServiceImpl.java
View file @
ec025c69
This diff is collapsed.
Click to expand it.
safe-campus-moment/src/main/java/com/tangguo/service/impl/BbsMomentVoteOptionServiceImpl.java
View file @
ec025c69
...
@@ -3,8 +3,10 @@ package com.tangguo.service.impl;
...
@@ -3,8 +3,10 @@ package com.tangguo.service.impl;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.tangguo.domain.BbsMoment
;
import
com.tangguo.domain.BbsMomentVoteOption
;
import
com.tangguo.domain.BbsMomentVoteOption
;
import
com.tangguo.domain.bo.CreateMomentBO
;
import
com.tangguo.domain.bo.CreateMomentBO
;
import
com.tangguo.enums.VoteOptionType
;
import
com.tangguo.mapper.BbsMomentVoteOptionMapper
;
import
com.tangguo.mapper.BbsMomentVoteOptionMapper
;
import
com.tangguo.service.IBbsMomentVoteOptionService
;
import
com.tangguo.service.IBbsMomentVoteOptionService
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -36,33 +38,57 @@ public class BbsMomentVoteOptionServiceImpl extends ServiceImpl<BbsMomentVoteOpt
...
@@ -36,33 +38,57 @@ public class BbsMomentVoteOptionServiceImpl extends ServiceImpl<BbsMomentVoteOpt
@Override
@Override
public
List
<
BbsMomentVoteOption
>
getVoteOptions
(
Long
momentId
)
{
public
List
<
BbsMomentVoteOption
>
getVoteOptions
(
Long
momentId
)
{
return
this
.
list
(
return
this
.
list
(
Wrappers
.
lambdaQuery
(
BbsMomentVoteOption
.
class
).
eq
(
BbsMomentVoteOption:
:
getMomentId
,
momentId
)
Wrappers
.
lambdaQuery
(
BbsMomentVoteOption
.
class
)
.
eq
(
BbsMomentVoteOption:
:
getMomentId
,
momentId
)
);
);
}
}
/**
* 查询动态投票选项
*
* @param momentIds 动态Ids
* @return 投票选项
*/
@Override
public
List
<
BbsMomentVoteOption
>
getVoteOptions
(
List
<
Long
>
momentIds
)
{
List
<
BbsMomentVoteOption
>
dbOptions
=
new
ArrayList
<>(
2
);
if
(
CollUtil
.
isNotEmpty
(
momentIds
))
{
dbOptions
=
this
.
list
(
Wrappers
.
lambdaQuery
(
BbsMomentVoteOption
.
class
).
in
(
BbsMomentVoteOption:
:
getMomentId
,
momentIds
)
);
}
return
dbOptions
;
}
/**
/**
* 添加动态投票选项
* 添加动态投票选项
*
*
* @param moment
Id 动态Id
* @param moment
动态
* @param voteOptions 投票选项
* @param voteOptions 投票选项
*/
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
void
addVoteOptions
(
Long
momentId
,
List
<
CreateMomentBO
.
VoteOption
>
voteOptions
)
{
public
void
addVoteOptions
(
BbsMoment
moment
,
List
<
CreateMomentBO
.
VoteOption
>
voteOptions
)
{
if
(
CollUtil
.
isNotEmpty
(
voteOptions
))
{
if
(
CollUtil
.
isNotEmpty
(
voteOptions
))
{
List
<
BbsMomentVoteOption
>
newVoteOptions
=
new
ArrayList
<>(
voteOptions
.
size
());
List
<
BbsMomentVoteOption
>
newOptions
=
new
ArrayList
<>(
voteOptions
.
size
());
for
(
CreateMomentBO
.
VoteOption
voteOption
:
voteOptions
)
{
for
(
int
i
=
0
;
i
<
voteOptions
.
size
();
i
++)
{
BbsMomentVoteOption
newVoteOption
=
new
BbsMomentVoteOption
();
CreateMomentBO
.
VoteOption
option
=
voteOptions
.
get
(
i
);
newVoteOption
.
setMomentId
(
momentId
);
BbsMomentVoteOption
newOption
=
new
BbsMomentVoteOption
();
newVoteOption
.
setType
(
voteOption
.
getType
());
newOption
.
setMomentId
(
moment
.
getId
());
newVoteOption
.
setName
(
voteOption
.
getName
());
VoteOptionType
optionType
=
VoteOptionType
.
getVoteOptionType
(
moment
.
getVoteOptionType
());
newVoteOption
.
setCode
(
voteOption
.
getCode
());
newOption
.
setType
(
optionType
.
name
());
newVoteOption
.
setImageUrl
(
voteOption
.
getImageUrl
());
newOption
.
setName
(
option
.
getName
());
newVoteOption
.
setSort
(
voteOption
.
getSort
());
int
optionIndex
=
i
+
1
;
newVoteOptions
.
add
(
newVoteOption
);
newOption
.
setCode
(
String
.
valueOf
(
optionIndex
));
newOption
.
setSort
(
optionIndex
);
if
(
VoteOptionType
.
IMAGE
==
optionType
)
{
newOption
.
setImageUrl
(
option
.
getImageUrl
());
}
newOptions
.
add
(
newOption
);
}
}
this
.
saveBatch
(
new
Vote
Options
);
this
.
saveBatch
(
newOptions
);
}
}
}
}
...
...
safe-campus-moment/src/main/resources/mapper/BbsMomentMapper.xml
View file @
ec025c69
...
@@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
</select>
<select
id=
"selectUserMoments"
resultType=
"com.tangguo.domain.
dto.BbsMomentListDT
O"
>
<select
id=
"selectUserMoments"
resultType=
"com.tangguo.domain.
vo.BbsMomentListV
O"
>
SELECT
SELECT
m.*,
m.*,
IF(l.id IS NOT NULL AND l.like_status = 1, 1, 0) AS is_like,
IF(l.id IS NOT NULL AND l.like_status = 1, 1, 0) AS is_like,
...
@@ -75,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -75,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
</select>
<select
id=
"selectMoments"
resultType=
"com.tangguo.domain.
dto.BbsMomentListDT
O"
>
<select
id=
"selectMoments"
resultType=
"com.tangguo.domain.
vo.BbsMomentListV
O"
>
SELECT
SELECT
m.*,
m.*,
IF(l.id IS NOT NULL AND l.like_status = 1, 1, 0) AS is_like,
IF(l.id IS NOT NULL AND l.like_status = 1, 1, 0) AS is_like,
...
...
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