提交 0ccf98d1 作者: 张小凤

GambitDao(update)

上级 28b9a5a4
......@@ -85,5 +85,11 @@ public class DynamicVO implements Serializable {
private List<ForumGambitDTO> forumGambitDTOList;
@ApiModelProperty(value = "转发数")
private Integer transpond;
@ApiModelProperty(value = "关注状态")
private Boolean status;
}
package com.mmc.csf.release.gambit.dto;
import com.mmc.csf.release.forum.vo.DynamicVO;
import com.mmc.csf.release.forum.vo.ForumReviewVO;
import com.mmc.csf.release.forum.vo.MediaVO;
import com.mmc.csf.release.forum.vo.UserBaseInfoVO;
import com.mmc.csf.release.model.group.Create;
import com.mmc.csf.release.model.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @Author small
* @Date 2023/9/26 15:32
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ForumDynamicGambitDTO {
@ApiModelProperty(value = "话题名称",example = "#深圳暴雨,#深圳大雨")
private List<String> gambitName;
@ApiModelProperty(value = "话题图标",example = "小程序给默认值")
@NotBlank(message = "话题图标不能为空",groups = {Create.class, Update.class})
private String gambitIcon;
@ApiModelProperty(value = "话题封面",example = "小程序给默认封面")
@NotBlank(message = "话题封面不能为空",groups = {Create.class,Update.class})
private String gambitCover;
@ApiModelProperty(value = "发布动态用户信息")
private UserBaseInfoVO userBaseInfo;
@ApiModelProperty(value = "用户id")
private Integer userAccountId;
@ApiModelProperty(value = "动态id")
private Integer id;
@ApiModelProperty(value = "动态描述")
private String description;
@ApiModelProperty(value = "位置信息")
private String location;
@ApiModelProperty(value = "纬度")
private BigDecimal lat;
@ApiModelProperty(value = "经度")
private BigDecimal lon;
@ApiModelProperty(value = "媒体资源")
private List<MediaVO> mediaVO;
@ApiModelProperty(value = "点赞数")
private Integer likesCount;
@ApiModelProperty(value = "评论数")
private Integer commentCount;
@ApiModelProperty(value = "是否点赞")
private Boolean likes;
@ApiModelProperty(value = "动态发布时间")
private Date dynamicPublishTime;
@ApiModelProperty(value = "评论信息")
private List<DynamicVO> commentAndReplyVO;
@ApiModelProperty("评论")
private ForumReviewVO forumReviewVO;
@ApiModelProperty(value = "话题列表")
private List<ForumGambitDTO> forumGambitDTOList;
@ApiModelProperty(value = "转发数")
private Integer transpond;
}
......@@ -2,6 +2,7 @@ package com.mmc.csf.release.controller;
import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.release.entity.forum.*;
import com.mmc.csf.release.gambit.dto.ForumDynamicGambitDTO;
import com.mmc.csf.release.gambit.dto.ForumGambitDTO;
import com.mmc.csf.release.gambit.qo.*;
import com.mmc.csf.release.gambit.vo.ForumGambitVO;
......@@ -126,7 +127,7 @@ public class GambitController extends BaseController{
@ApiOperation(value = "赞过")
@PostMapping("/liked")
public ResultBody<ForumDynamicGambitDO> liked(HttpServletRequest request, @RequestBody UserTopicDynamicsQO userTopicDynamicsQO){
public ResultBody<ForumDynamicGambitDTO> liked(HttpServletRequest request, @RequestBody UserTopicDynamicsQO userTopicDynamicsQO){
return ResultBody.success(gambitService.liked(userTopicDynamicsQO));
}
......@@ -146,7 +147,8 @@ public class GambitController extends BaseController{
@ApiOperation(value = "单个用户信息")
@GetMapping("/userMessage")
public ResultBody<ForumCountDO> userMessage(HttpServletRequest request, @ApiParam(value = "userAccountId") @RequestParam Integer userAccountId){
return gambitService.userMessage(userAccountId);
Integer userId = this.getUserLoginInfoFromRedis(request).getUserAccountId();
return gambitService.userMessage(userAccountId,userId);
}
......
......@@ -123,4 +123,8 @@ public interface GambitDao {
ForumReviewVO selectForumReviewMessage(Integer dynamicId);
int replyCount(ForumReviewDO forumReviewDO);
int selectCountAttention(Integer userId);
int selectCountAttentions(Integer userAccountId,Integer userId);
}
......@@ -38,6 +38,9 @@ public class ForumCountDO implements Serializable {
@ApiModelProperty(value = "修改时间")
private String updateTime;
@ApiModelProperty(value = "是否关注",example = "true表示已关注 null没有关注")
private Boolean status;
}
package com.mmc.csf.release.entity.forum;
import com.mmc.csf.release.entity.gambit.ForumGambitDO;
import com.mmc.csf.release.forum.vo.ForumReviewVO;
import com.mmc.csf.release.forum.vo.MediaVO;
import com.mmc.csf.release.gambit.dto.ForumDynamicGambitDTO;
import com.mmc.csf.release.gambit.dto.ForumGambitDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
......@@ -41,10 +45,30 @@ public class ForumDynamicGambitDO implements Serializable {
private List<ForumResourceDO> forumResourceDOList;
@ApiModelProperty("话题")
private List<ForumGambitDO> forumGambitDOList;
private List<ForumGambitDTO> forumGambitDOList;
@ApiModelProperty("评论")
private ForumReviewDO forumReviewDO;
private ForumReviewVO ForumReviewDO;
@ApiModelProperty(value = "媒体资源")
private List<MediaVO> mediaVO;
public ForumDynamicGambitDTO buildForumDynamicGambitDTO(){
return ForumDynamicGambitDTO.builder()
.description(this.description)
.userAccountId(this.userAccountId)
.likesCount(this.likesCount)
.commentCount(this.commentsCount)
.transpond(this.transpond)
.mediaVO(this.mediaVO)
.forumReviewVO(this.ForumReviewDO)
.forumGambitDTOList(this.forumGambitDOList)
.build();
}
......
......@@ -41,5 +41,5 @@ public interface GambitService {
PageResult myFansList(UserTopicDynamicsQO userTopicDynamicsQO);
ResultBody userMessage(Integer userAccountId);
ResultBody userMessage(Integer userAccountId,Integer userId);
}
......@@ -9,6 +9,7 @@ import com.mmc.csf.release.dao.gambit.GambitDao;
import com.mmc.csf.release.entity.forum.*;
import com.mmc.csf.release.entity.gambit.ForumAttentionDO;
import com.mmc.csf.release.entity.gambit.ForumGambitDO;
import com.mmc.csf.release.gambit.dto.ForumDynamicGambitDTO;
import com.mmc.csf.release.gambit.dto.ForumGambitDTO;
import com.mmc.csf.release.gambit.qo.*;
import com.mmc.csf.release.gambit.vo.ForumGambitVO;
......@@ -203,7 +204,8 @@ public class GambitServiceImpl implements GambitService {
userTopicDynamicsQO.buildCurrentPage();
int count = gambitDao.likedCount(userTopicDynamicsQO);
List<ForumDynamicGambitDO> forumDynamicGambitDOS = gambitDao.likedList(userTopicDynamicsQO);
return PageResult.buildPage(pageNo, userTopicDynamicsQO.getPageSize(),count,forumDynamicGambitDOS);
List<ForumDynamicGambitDTO> collect = forumDynamicGambitDOS.stream().map(ForumDynamicGambitDO::buildForumDynamicGambitDTO).collect(Collectors.toList());
return PageResult.buildPage(pageNo, userTopicDynamicsQO.getPageSize(),count,collect);
}
@Override
public PageResult myInterestList(UserTopicDynamicsQO userTopicDynamicsQO) {
......@@ -226,8 +228,12 @@ public class GambitServiceImpl implements GambitService {
}
@Override
public ResultBody userMessage(Integer userAccountId) {
public ResultBody userMessage(Integer userAccountId,Integer userId) {
ForumCountDO forumCountDO= gambitDao.userMessage(userAccountId);
int i = gambitDao.selectCountAttention(userId);
if (i!=0){
forumCountDO.setStatus(true);
}
return ResultBody.success(forumCountDO);
}
......
......@@ -134,7 +134,7 @@ public class DynamicServiceImpl implements DynamicService {
dynamicDao.insertforumGambit(forumGambitDO);
}
if (forumGambitDO1!=null){
forumDynamicDO.setId(forumGambitDO1.getId());
forumGambitDO.setId(forumGambitDO1.getId());
}
DynamicGambitDO dynamicGambitDO = new DynamicGambitDO(forumDynamicDO,forumGambitDO);
dynamicDao.insertDynamicGambit(dynamicGambitDO);
......@@ -404,7 +404,13 @@ public class DynamicServiceImpl implements DynamicService {
count=dynamicVOList.size();
}
for (DynamicVO dynamicVO : dynamicVOList) {
Integer userAccountId = dynamicVO.getUserAccountId();
int countAttention= gambitDao.selectCountAttentions(userAccountId,userId);
if (countAttention!=0){
dynamicVO.setStatus(true);
}
}
return PageResult.buildPage(pageNo, pageSize, count, dynamicVOList);
}
......
......@@ -54,11 +54,14 @@
<collection property="forumResourceDOList" ofType="com.mmc.csf.release.entity.forum.ForumResourceDO"
select="selectResourceList" column="{dynamicId=id}">
</collection>
<collection property="forumGambitDOList" ofType="com.mmc.csf.release.entity.gambit.ForumGambitDO"
select="selectGambitLists" column="{dynamicId=id}">
<collection property="forumGambitDOList" ofType="com.mmc.csf.release.gambit.dto.ForumGambitDTO"
select="selectGambitListsVO" column="{dynamicId=id}">
</collection>
<collection property="forumReviewDO" ofType="com.mmc.csf.release.entity.forum.ForumReviewDO"
select="selectForumReview" column="{dynamicId=id}">
<collection property="forumReviewDO" ofType="com.mmc.csf.release.forum.vo.ForumReviewVO"
select="selectForumReviewVO" column="{dynamicId=id}">
</collection>
<collection property="mediaVO" ofType="com.mmc.csf.release.forum.vo.MediaVO"
select="selectMediaVO" column="{dynamicId=id}">
</collection>
</resultMap>
......@@ -134,6 +137,26 @@
</select>
<select id="selectForumReviewVO" resultType="com.mmc.csf.release.forum.vo.ForumReviewVO">
SELECT
id,
content,
user_account_id,
like_count,
dynamic_id,
create_time,
update_time,
pid,
review_id
FROM
forum_review
WHERE
dynamic_id = #{dynamicId}
GROUP BY
id
LIMIT 0,1
</select>
<select id="selectForumReviewMessage" resultType="com.mmc.csf.release.forum.vo.ForumReviewVO">
SELECT
id,
......@@ -164,10 +187,23 @@
AND fr.review_id = #{id}
</select>
<select id="selectCountAttention" resultType="java.lang.Integer">
select count(*) from forum_attention where attention_user_account_id=#{userId}
</select>
<select id="selectCountAttentions" resultType="java.lang.Integer">
select count(*) from forum_attention where attention_user_account_id=#{userId} and user_account_id=#{userAccountId}
</select>
<select id="selectResourceList" resultType="com.mmc.csf.release.entity.forum.ForumResourceDO">
select dynamic_id,resource_url,create_time,update_time,`type` from forum_resource where dynamic_id=#{dynamicId}
</select>
<select id="selectMediaVO" resultType="com.mmc.csf.release.forum.vo.MediaVO">
select resource_url as url ,`type` from forum_resource where dynamic_id=#{dynamicId}
</select>
<select id="selectGambitLists" resultType="com.mmc.csf.release.entity.gambit.ForumGambitDO">
SELECT
fdg.dynamic_id,
......@@ -180,6 +216,17 @@
fdg.dynamic_id = #{dynamicId}
</select>
<select id="selectGambitListsVO" resultType="com.mmc.csf.release.gambit.dto.ForumGambitDTO">
SELECT
fdg.dynamic_id,
fdg.gambit_id,
fg.gambit_name
FROM
forum_dynamic_gambit fdg
LEFT JOIN forum_gambit fg ON fdg.gambit_id = fg.id
WHERE
fdg.dynamic_id = #{dynamicId}
</select>
<insert id="insertGambit" parameterType="com.mmc.csf.release.entity.gambit.ForumGambitDO" keyProperty="id" useGeneratedKeys="true">
insert into forum_gambit(gambit_name,gambit_icon,gambit_cover,gambit_property,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论