|
@@ -41,19 +41,11 @@ public class SocialServiceImpl implements SocialServiceI {
|
41
|
41
|
@Override
|
42
|
42
|
@Transactional
|
43
|
43
|
public TpAnnouncement findAnnouncementDetail(Integer id, Integer communityId) {
|
44
|
|
- TpSocialView tpSocialView = new TpSocialView();
|
45
|
44
|
//TODO
|
46
|
|
- tpSocialView.setTaUserId(1);
|
47
|
|
- tpSocialView.setSocialType(Constant.ANNOUNCEMENT);
|
48
|
|
- tpSocialView.setCommunityId(communityId);
|
49
|
|
- tpSocialView.setUuid(id);
|
50
|
|
- Integer viewNum = tpSocialViewMapper.selectViewNum(tpSocialView);
|
51
|
|
-
|
52
|
|
- if (viewNum == 0){
|
53
|
|
- tpSocialView.setCreateDate(new Date());
|
54
|
|
- tpSocialViewMapper.insertSelective(tpSocialView);
|
55
|
|
- tpSocialView.setTaUserId(null);
|
56
|
|
- Integer allViewNum = tpSocialViewMapper.selectViewNum(tpSocialView);
|
|
45
|
+ Integer userId = 1;
|
|
46
|
+ //更新此用户的查看次数操作
|
|
47
|
+ Integer allViewNum = updateSocialView(userId,Constant.ANNOUNCEMENT,communityId,id);
|
|
48
|
+ if (null != allViewNum){
|
57
|
49
|
tpAnnouncementMapper.updateByPrimaryKeySelective(id, allViewNum);
|
58
|
50
|
}
|
59
|
51
|
return tpAnnouncementMapper.selectByPrimaryKey(id, communityId);
|
|
@@ -113,6 +105,43 @@ public class SocialServiceImpl implements SocialServiceI {
|
113
|
105
|
*/
|
114
|
106
|
@Override
|
115
|
107
|
public TpActivity findActivityDetail(Integer activityId, Integer communityId) {
|
|
108
|
+ //TODO
|
|
109
|
+ Integer userId = 1;
|
|
110
|
+ //更新查看次数
|
|
111
|
+ Integer allViewNum = updateSocialView(userId,Constant.ACTIVITY,communityId,activityId);
|
|
112
|
+ if (null != allViewNum){
|
|
113
|
+ TpActivity activity = new TpActivity();
|
|
114
|
+ activity.setId(activityId);
|
|
115
|
+ activity.setViewCount(allViewNum);
|
|
116
|
+ tpActivityMapper.updateByPrimaryKeySelective(activity);
|
|
117
|
+ }
|
|
118
|
+ return tpActivityMapper.selectByPrimaryKey(activityId,communityId);
|
|
119
|
+ }
|
|
120
|
+
|
|
121
|
+ /**
|
|
122
|
+ * 更新此用户的查看次数操作
|
|
123
|
+ * @param userId
|
|
124
|
+ * @param socialType
|
|
125
|
+ * @param communityId
|
|
126
|
+ * @param uuid
|
|
127
|
+ */
|
|
128
|
+ private Integer updateSocialView(Integer userId,String socialType,Integer communityId,Integer uuid) {
|
|
129
|
+ //检查是否查看过这个帖子
|
|
130
|
+ TpSocialView tpSocialView = new TpSocialView();
|
|
131
|
+ tpSocialView.setTaUserId(userId);
|
|
132
|
+ tpSocialView.setSocialType(socialType);
|
|
133
|
+ tpSocialView.setCommunityId(communityId);
|
|
134
|
+ tpSocialView.setUuid(uuid);
|
|
135
|
+ Integer viewNum = tpSocialViewMapper.selectViewNum(tpSocialView);
|
|
136
|
+
|
|
137
|
+ //查看过的话查看次数加一
|
|
138
|
+ if (viewNum == 0){
|
|
139
|
+ tpSocialView.setCreateDate(new Date());
|
|
140
|
+ tpSocialViewMapper.insertSelective(tpSocialView);
|
|
141
|
+ tpSocialView.setTaUserId(null);
|
|
142
|
+ Integer allViewNum = tpSocialViewMapper.selectViewNum(tpSocialView);
|
|
143
|
+ return allViewNum;
|
|
144
|
+ }
|
116
|
145
|
return null;
|
117
|
146
|
}
|
118
|
147
|
}
|