提交 a4c7188c 作者: 张小凤

DynamicMapper.xml(update)

上级 7b8efe9d
...@@ -32,6 +32,9 @@ public class UserTopicDynamicsQO { ...@@ -32,6 +32,9 @@ public class UserTopicDynamicsQO {
@ApiModelProperty(value = "用户id",example = "1") @ApiModelProperty(value = "用户id",example = "1")
private Integer userAccountId; private Integer userAccountId;
@ApiModelProperty(value = "token用户id",hidden = true)
private Integer userId;
/** /**
* 初始化起始查询行并返回当前页 * 初始化起始查询行并返回当前页
......
...@@ -135,12 +135,16 @@ public class GambitController extends BaseController{ ...@@ -135,12 +135,16 @@ public class GambitController extends BaseController{
@ApiOperation(value = "我的关注") @ApiOperation(value = "我的关注")
@PostMapping("/myInterestList") @PostMapping("/myInterestList")
public ResultBody<MyAttentionDO> myInterestList(HttpServletRequest request, @RequestBody UserTopicDynamicsQO userTopicDynamicsQO){ public ResultBody<MyAttentionDO> myInterestList(HttpServletRequest request, @RequestBody UserTopicDynamicsQO userTopicDynamicsQO){
Integer userId = this.getUserLoginInfoFromRedis(request).getUserAccountId();
userTopicDynamicsQO.setUserId(userId);
return ResultBody.success(gambitService.myInterestList(userTopicDynamicsQO)); return ResultBody.success(gambitService.myInterestList(userTopicDynamicsQO));
} }
@ApiOperation(value = "我的粉丝") @ApiOperation(value = "我的粉丝")
@PostMapping("/myFansList") @PostMapping("/myFansList")
public ResultBody<MyFansDO> myFansList(HttpServletRequest request, @RequestBody UserTopicDynamicsQO userTopicDynamicsQO){ public ResultBody<MyFansDO> myFansList(HttpServletRequest request, @RequestBody UserTopicDynamicsQO userTopicDynamicsQO){
Integer userId = this.getUserLoginInfoFromRedis(request).getUserAccountId();
userTopicDynamicsQO.setUserId(userId);
return ResultBody.success(gambitService.myFansList(userTopicDynamicsQO)); return ResultBody.success(gambitService.myFansList(userTopicDynamicsQO));
} }
......
...@@ -183,6 +183,8 @@ public interface DynamicDao { ...@@ -183,6 +183,8 @@ public interface DynamicDao {
List<ForumGambitDO> selectGambit(Integer id); List<ForumGambitDO> selectGambit(Integer id);
List<ForumGambitDO> selectGambitBack(Integer id);
void insertforumFirstLevelReview(ForumFirstLevelReviewDO forumFirstLevelReviewDO); void insertforumFirstLevelReview(ForumFirstLevelReviewDO forumFirstLevelReviewDO);
......
...@@ -84,6 +84,8 @@ public interface GambitDao { ...@@ -84,6 +84,8 @@ public interface GambitDao {
void updateAttentionExchange(Integer userAccountId, Integer attentionUserAccountId); void updateAttentionExchange(Integer userAccountId, Integer attentionUserAccountId);
void updateAttentionExchanges(Integer userAccountId, Integer attentionUserAccountId,Integer userAccountId1, Integer attentionUserAccountId1);
ForumAttentionDO selectAttentionMessage(Integer userAccountId, Integer attentionUserAccountId); ForumAttentionDO selectAttentionMessage(Integer userAccountId, Integer attentionUserAccountId);
List<ForumDynamicGambitDO> appGambitList(TopicDynamicsQO topicDynamicsQO); List<ForumDynamicGambitDO> appGambitList(TopicDynamicsQO topicDynamicsQO);
...@@ -108,11 +110,19 @@ public interface GambitDao { ...@@ -108,11 +110,19 @@ public interface GambitDao {
List<ForumDynamicGambitDO> likedList(UserTopicDynamicsQO userTopicDynamicsQO); List<ForumDynamicGambitDO> likedList(UserTopicDynamicsQO userTopicDynamicsQO);
int myInterestListCount(UserTopicDynamicsQO userTopicDynamicsQO); List<MyAttentionDO> myInterestListCount(UserTopicDynamicsQO userTopicDynamicsQO);
List<MyAttentionDO> myInterestListCounts(UserTopicDynamicsQO userTopicDynamicsQO);
List<MyAttentionDO> myInterestList(UserTopicDynamicsQO userTopicDynamicsQO); List<MyAttentionDO> myInterestList(UserTopicDynamicsQO userTopicDynamicsQO);
int myFansListCount(UserTopicDynamicsQO userTopicDynamicsQO); List<MyAttentionDO> myInterestLists(UserTopicDynamicsQO userTopicDynamicsQO);
ForumCountDO selectUserCount(Integer userAccountId);
List<MyFansDO> myFansListCount(UserTopicDynamicsQO userTopicDynamicsQO);
List<MyFansDO> myFansListCounts(UserTopicDynamicsQO userTopicDynamicsQO);
List<MyFansDO> myFansList(UserTopicDynamicsQO userTopicDynamicsQO); List<MyFansDO> myFansList(UserTopicDynamicsQO userTopicDynamicsQO);
...@@ -137,4 +147,6 @@ public interface GambitDao { ...@@ -137,4 +147,6 @@ public interface GambitDao {
List<DynamicGambitDO> selectDynamicGambit(Integer dynamicId); List<DynamicGambitDO> selectDynamicGambit(Integer dynamicId);
void updateGambits(Integer gambitId); void updateGambits(Integer gambitId);
List<MyFansDO> myFansLists(UserTopicDynamicsQO userTopicDynamicsQO);
} }
...@@ -34,6 +34,9 @@ public class MyAttentionDO implements Serializable { ...@@ -34,6 +34,9 @@ public class MyAttentionDO implements Serializable {
private UserAccountVO userAccountVO; private UserAccountVO userAccountVO;
@ApiModelProperty(value = "前端忽略此字段",hidden = true)
private Integer attentionUserAccountId;
......
...@@ -34,6 +34,8 @@ public class MyFansDO implements Serializable { ...@@ -34,6 +34,8 @@ public class MyFansDO implements Serializable {
private UserAccountVO userAccountVO; private UserAccountVO userAccountVO;
@ApiModelProperty(value = "前端忽略此字段",hidden = true)
private Integer attentionUserAccountId;
......
...@@ -30,9 +30,7 @@ import org.springframework.stereotype.Service; ...@@ -30,9 +30,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -177,7 +175,9 @@ public class GambitServiceImpl implements GambitService { ...@@ -177,7 +175,9 @@ public class GambitServiceImpl implements GambitService {
gambitDao.forumCountFansNO(userAccountId); gambitDao.forumCountFansNO(userAccountId);
gambitDao.forumCountAttentionNO(attentionUserAccountId); gambitDao.forumCountAttentionNO(attentionUserAccountId);
}else{ }else{
gambitDao.updateAttentionExchange(attentionUserAccountId,userAccountId); Integer userAccountId1=attentionUserAccountId;
Integer attentionUserAccountId1=userAccountId;
gambitDao.updateAttentionExchanges(userAccountId,attentionUserAccountId,userAccountId1,attentionUserAccountId1);
gambitDao.forumCountFansNO(userAccountId); gambitDao.forumCountFansNO(userAccountId);
gambitDao.forumCountAttentionNO(attentionUserAccountId); gambitDao.forumCountAttentionNO(attentionUserAccountId);
} }
...@@ -284,9 +284,53 @@ public class GambitServiceImpl implements GambitService { ...@@ -284,9 +284,53 @@ public class GambitServiceImpl implements GambitService {
Integer pageNo = userTopicDynamicsQO.getPageNo(); Integer pageNo = userTopicDynamicsQO.getPageNo();
userTopicDynamicsQO.buildCurrentPage(); userTopicDynamicsQO.buildCurrentPage();
int count = gambitDao.myInterestListCount(userTopicDynamicsQO); Integer userId = userTopicDynamicsQO.getUserId();
List<MyAttentionDO> myAttentionDOS = gambitDao.myInterestList(userTopicDynamicsQO); Integer userAccountId1 = userTopicDynamicsQO.getUserAccountId();
if (userAccountId1==null){
userTopicDynamicsQO.setUserAccountId(userId);
}
ArrayList<MyAttentionDO> listCount = new ArrayList<>();
List<MyAttentionDO> myAttentionDOSCount=null;
int count =0;
myAttentionDOSCount=gambitDao.myInterestListCount(userTopicDynamicsQO);
if (myAttentionDOSCount.size()!=0){
for (MyAttentionDO myAttentionDO : myAttentionDOSCount) {
listCount.add(myAttentionDO);
}
}
myAttentionDOSCount=gambitDao.myInterestListCounts(userTopicDynamicsQO);
if (myAttentionDOSCount.size()!=0){
for (MyAttentionDO myAttentionDO : myAttentionDOSCount) {
listCount.add(myAttentionDO);
}
}
ArrayList<MyAttentionDO> collectCount = listCount.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MyAttentionDO::getId))), ArrayList::new));
count=collectCount.size();
ArrayList<MyAttentionDO> list = new ArrayList<>();
List<MyAttentionDO> myAttentionDOS =null;
myAttentionDOS= gambitDao.myInterestList(userTopicDynamicsQO);
if (myAttentionDOS.size()!=0){
for (MyAttentionDO myAttentionDO : myAttentionDOS) {
list.add(myAttentionDO);
}
}
myAttentionDOS= gambitDao.myInterestLists(userTopicDynamicsQO);
if (myAttentionDOS.size()!=0){
for (MyAttentionDO myAttentionDO : myAttentionDOS) {
list.add(myAttentionDO);
}
}
ArrayList<MyAttentionDO> collect = list.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MyAttentionDO::getId))), ArrayList::new));
myAttentionDOS=collect;
for (MyAttentionDO myAttentionDO : myAttentionDOS) { for (MyAttentionDO myAttentionDO : myAttentionDOS) {
if (userTopicDynamicsQO.getUserAccountId().equals(myAttentionDO.getUserAccountId())){
myAttentionDO.setUserAccountId(myAttentionDO.getAttentionUserAccountId());
ForumCountDO forumCountDO = gambitDao.selectUserCount(myAttentionDO.getUserAccountId());
myAttentionDO.setCountDO(forumCountDO);
}
Integer userAccountId = myAttentionDO.getUserAccountId(); Integer userAccountId = myAttentionDO.getUserAccountId();
UserAccountVO info = info(userAccountId); UserAccountVO info = info(userAccountId);
myAttentionDO.setUserAccountVO(info); myAttentionDO.setUserAccountVO(info);
...@@ -298,14 +342,59 @@ public class GambitServiceImpl implements GambitService { ...@@ -298,14 +342,59 @@ public class GambitServiceImpl implements GambitService {
public PageResult myFansList(UserTopicDynamicsQO userTopicDynamicsQO) { public PageResult myFansList(UserTopicDynamicsQO userTopicDynamicsQO) {
Integer pageNo = userTopicDynamicsQO.getPageNo(); Integer pageNo = userTopicDynamicsQO.getPageNo();
userTopicDynamicsQO.buildCurrentPage(); userTopicDynamicsQO.buildCurrentPage();
int count = gambitDao.myFansListCount(userTopicDynamicsQO); Integer userId = userTopicDynamicsQO.getUserId();
List<MyFansDO> myAttentionDOS = gambitDao.myFansList(userTopicDynamicsQO); Integer userAccountId1 = userTopicDynamicsQO.getUserAccountId();
for (MyFansDO myAttentionDO : myAttentionDOS) { if (userAccountId1==null){
userTopicDynamicsQO.setUserAccountId(userId);
}
List<MyFansDO> listCount =new ArrayList<>();
List<MyFansDO> myFansDOSCount=null;
int allCount =0;
myFansDOSCount = gambitDao.myFansListCount(userTopicDynamicsQO);
if (myFansDOSCount.size()!=0){
for (MyFansDO myFansDO : myFansDOSCount) {
listCount.add(myFansDO);
}
}
myFansDOSCount = gambitDao.myFansListCounts(userTopicDynamicsQO);
if (myFansDOSCount.size()!=0){
for (MyFansDO myFansDO : myFansDOSCount) {
listCount.add(myFansDO);
}
}
ArrayList<MyFansDO> collectCount = listCount.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MyFansDO::getId))), ArrayList::new));
int count =collectCount.size();
List<MyFansDO> list =new ArrayList<>();
List<MyFansDO> myFansDOS=null;
myFansDOS=gambitDao.myFansList(userTopicDynamicsQO);
if (myFansDOS.size()!=0){
for (MyFansDO myFansDO : myFansDOS) {
list.add(myFansDO);
}
}
myFansDOS=gambitDao.myFansLists(userTopicDynamicsQO);
if (myFansDOS.size()!=0){
for (MyFansDO myFansDO : myFansDOS) {
list.add(myFansDO);
}
}
ArrayList<MyFansDO> collect = list.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MyFansDO::getId))), ArrayList::new));
myFansDOS=collect;
for (MyFansDO myAttentionDO : myFansDOS) {
if (userTopicDynamicsQO.getUserAccountId().equals(myAttentionDO.getUserAccountId())){
myAttentionDO.setUserAccountId(myAttentionDO.getAttentionUserAccountId());
ForumCountDO forumCountDO = gambitDao.selectUserCount(myAttentionDO.getUserAccountId());
myAttentionDO.setCountDO(forumCountDO);
}
Integer userAccountId = myAttentionDO.getUserAccountId(); Integer userAccountId = myAttentionDO.getUserAccountId();
UserAccountVO info = info(userAccountId); UserAccountVO info = info(userAccountId);
myAttentionDO.setUserAccountVO(info); myAttentionDO.setUserAccountVO(info);
} }
return PageResult.buildPage(pageNo, userTopicDynamicsQO.getPageSize(),count,myAttentionDOS); return PageResult.buildPage(pageNo, userTopicDynamicsQO.getPageSize(),count,myFansDOS);
} }
......
...@@ -79,7 +79,7 @@ public class BackstageForumServiceImpl implements BackstageForumService { ...@@ -79,7 +79,7 @@ public class BackstageForumServiceImpl implements BackstageForumService {
for (ForumDynamicDO forumDynamicDO : dynamicList) { for (ForumDynamicDO forumDynamicDO : dynamicList) {
Integer id = forumDynamicDO.getDynamicId(); Integer id = forumDynamicDO.getDynamicId();
ArrayList<String> list = new ArrayList<>(); ArrayList<String> list = new ArrayList<>();
List<ForumGambitDO> gambitDOS = dynamicDao.selectGambit(id); List<ForumGambitDO> gambitDOS = dynamicDao.selectGambitBack(id);
for (ForumGambitDO gambitDO : gambitDOS) { for (ForumGambitDO gambitDO : gambitDOS) {
list.add(gambitDO.getGambitName()); list.add(gambitDO.getGambitName());
} }
......
...@@ -248,6 +248,24 @@ ...@@ -248,6 +248,24 @@
AND fdg.dynamic_id = #{id} AND fdg.dynamic_id = #{id}
</select> </select>
<select id="selectGambitBack" resultType="com.mmc.csf.release.entity.gambit.ForumGambitDO">
SELECT DISTINCT
gf.id,
gf.gambit_name,
gf.gambit_icon,
gf.gambit_cover,
gf.post_count,
gf.gambit_property,
gf.user_account_id,
gf.discussion_count
FROM
forum_dynamic_gambit fdg
INNER JOIN forum_gambit gf
WHERE
fdg.gambit_id = gf.id
AND fdg.dynamic_id = #{id}
</select>
<select id="selectGambitDTO" resultType="com.mmc.csf.release.gambit.dto.ForumGambitDTO"> <select id="selectGambitDTO" resultType="com.mmc.csf.release.gambit.dto.ForumGambitDTO">
SELECT DISTINCT SELECT DISTINCT
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="userAccountId" column="user_account_id" /> <result property="userAccountId" column="user_account_id" />
<result property="mutualAttention" column="mutual_attention"/> <result property="mutualAttention" column="mutual_attention"/>
<result property="attentionUserAccountId" column="attention_user_account_id"/>
<collection property="dynamicCount" ofType="java.lang.Integer" <collection property="dynamicCount" ofType="java.lang.Integer"
select="selectCountUser" column="{userAccountId=user_account_id}"> select="selectCountUser" column="{userAccountId=user_account_id}">
</collection> </collection>
...@@ -80,10 +81,12 @@ ...@@ -80,10 +81,12 @@
</collection> </collection>
</resultMap> </resultMap>
<resultMap id="myFansListMap" type="com.mmc.csf.release.entity.forum.MyFansDO"> <resultMap id="myFansListMap" type="com.mmc.csf.release.entity.forum.MyFansDO">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="userAccountId" column="attention_user_account_id" /> <result property="userAccountId" column="user_account_id" />
<result property="mutualAttention" column="mutual_attention"/> <result property="mutualAttention" column="mutual_attention"/>
<result property="attentionUserAccountId" column="attention_user_account_id"/>
<collection property="dynamicCount" ofType="java.lang.Integer" <collection property="dynamicCount" ofType="java.lang.Integer"
select="selectCountUser" column="{userAccountId=user_account_id}"> select="selectCountUser" column="{userAccountId=user_account_id}">
</collection> </collection>
...@@ -560,6 +563,14 @@ ...@@ -560,6 +563,14 @@
where user_account_id=#{userAccountId} and attention_user_account_id=#{attentionUserAccountId} where user_account_id=#{userAccountId} and attention_user_account_id=#{attentionUserAccountId}
</update> </update>
<update id="updateAttentionExchanges">
update forum_attention set user_account_id=#{userAccountId1} ,
attention_user_account_id=#{attentionUserAccountId1},
mutual_attention=false,
update_time=NOW()
where user_account_id=#{attentionUserAccountId} and attention_user_account_id=#{userAccountId}
</update>
<select id="appGambitList" resultMap="appGambitListMap"> <select id="appGambitList" resultMap="appGambitListMap">
SELECT DISTINCT SELECT DISTINCT
fd.id, fd.id,
...@@ -651,10 +662,16 @@ ...@@ -651,10 +662,16 @@
limit #{pageNo}, #{pageSize} limit #{pageNo}, #{pageSize}
</select> </select>
<select id="myInterestListCount" resultType="java.lang.Integer"> <select id="myInterestListCount" resultMap="myInterestListMap">
select count(*) from forum_attention where attention_user_account_id=#{userAccountId} select attention_user_account_id,mutual_attention,id,user_account_id from forum_attention where attention_user_account_id=#{userAccountId}
</select>
<select id="myInterestListCounts" resultMap="myInterestListMap">
select attention_user_account_id,mutual_attention,id,user_account_id from forum_attention where attention_user_account_id=#{userAccountId} or user_account_id=#{userAccountId} and mutual_attention=1
</select> </select>
<select id="myInterestList" resultMap="myInterestListMap"> <select id="myInterestList" resultMap="myInterestListMap">
select attention_user_account_id,mutual_attention,id,user_account_id from forum_attention where attention_user_account_id=#{userAccountId} select attention_user_account_id,mutual_attention,id,user_account_id from forum_attention where attention_user_account_id=#{userAccountId}
ORDER BY ORDER BY
...@@ -662,8 +679,20 @@ ...@@ -662,8 +679,20 @@
limit #{pageNo}, #{pageSize} limit #{pageNo}, #{pageSize}
</select> </select>
<select id="myFansListCount" resultType="java.lang.Integer"> <select id="myInterestLists" resultMap="myInterestListMap">
select count(*) from forum_attention where attention_user_account_id=#{userAccountId} select attention_user_account_id,mutual_attention,id,user_account_id from forum_attention where attention_user_account_id=#{userAccountId} or user_account_id=#{userAccountId} and mutual_attention=1
ORDER BY
create_time DESC
limit #{pageNo}, #{pageSize}
</select>
<select id="myFansListCount" resultMap="myFansListMap">
select user_account_id,mutual_attention,id,attention_user_account_id from forum_attention where user_account_id=#{userAccountId}
</select>
<select id="myFansListCounts" resultMap="myFansListMap">
select user_account_id,mutual_attention,id,attention_user_account_id from forum_attention where
user_account_id=#{userAccountId} or attention_user_account_id=#{userAccountId} and mutual_attention=1
</select> </select>
<select id="myFansList" resultMap="myFansListMap"> <select id="myFansList" resultMap="myFansListMap">
...@@ -673,6 +702,14 @@ ...@@ -673,6 +702,14 @@
limit #{pageNo}, #{pageSize} limit #{pageNo}, #{pageSize}
</select> </select>
<select id="myFansLists" resultMap="myFansListMap">
select user_account_id,mutual_attention,id,attention_user_account_id from forum_attention where
user_account_id=#{userAccountId} or attention_user_account_id=#{userAccountId} and mutual_attention=1
ORDER BY
create_time DESC
limit #{pageNo}, #{pageSize}
</select>
<select id="userMessage" resultType="com.mmc.csf.release.entity.forum.ForumCountDO"> <select id="userMessage" resultType="com.mmc.csf.release.entity.forum.ForumCountDO">
select id,user_account_id,like_count,fans_count,attention_count,create_time,update_time select id,user_account_id,like_count,fans_count,attention_count,create_time,update_time
from forum_count where user_account_id=#{userAccountId} from forum_count where user_account_id=#{userAccountId}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论