Commit f78d54de authored by 刘基明's avatar 刘基明

用户信息源修改

parent 32ee590d
...@@ -2,6 +2,7 @@ package com.tanpu.community.controller; ...@@ -2,6 +2,7 @@ package com.tanpu.community.controller;
import com.tanpu.common.api.CommonResp; import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.community.api.beans.qo.ThemeQo; import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.theme.*; import com.tanpu.community.api.beans.req.theme.*;
import com.tanpu.community.manager.ThemeManager; import com.tanpu.community.manager.ThemeManager;
...@@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
@RestController @RestController
...@@ -20,13 +22,14 @@ public class ThemeController { ...@@ -20,13 +22,14 @@ public class ThemeController {
@Autowired @Autowired
private ThemeManager themeManager; private ThemeManager themeManager;
@Resource
private UserHolder userHolder;
@ApiOperation("发表主题") @ApiOperation("发表主题")
@PostMapping(value = "/publish") @PostMapping(value = "/publish")
@ResponseBody @ResponseBody
public CommonResp<Void> publishTheme(@Validated @RequestBody CreateThemeReq req) { public CommonResp<Void> publishTheme(@Validated @RequestBody CreateThemeReq req) {
String userId = "liujm"; String userId = userHolder.getUserId();
themeManager.publishTheme(req, userId); themeManager.publishTheme(req, userId);
return CommonResp.success(); return CommonResp.success();
} }
...@@ -36,7 +39,7 @@ public class ThemeController { ...@@ -36,7 +39,7 @@ public class ThemeController {
@PostMapping(value = "/list") @PostMapping(value = "/list")
@ResponseBody @ResponseBody
public CommonResp<List<ThemeQo>> selectInterestList(@Validated @RequestBody ThemeListReq req) { public CommonResp<List<ThemeQo>> selectInterestList(@Validated @RequestBody ThemeListReq req) {
String userId = "liujm"; String userId = userHolder.getUserId();
List<ThemeQo> result = themeManager.queryThemes(req, userId); List<ThemeQo> result = themeManager.queryThemes(req, userId);
return CommonResp.success(result); return CommonResp.success(result);
} }
...@@ -46,7 +49,7 @@ public class ThemeController { ...@@ -46,7 +49,7 @@ public class ThemeController {
@GetMapping(value = "/detail") @GetMapping(value = "/detail")
@ResponseBody @ResponseBody
public CommonResp<ThemeQo> getThemeMainText(@RequestParam String themeId) { public CommonResp<ThemeQo> getThemeMainText(@RequestParam String themeId) {
String userId = "liujm"; String userId = userHolder.getUserId();
ThemeQo themeQo = themeManager.getDetail(themeId, userId); ThemeQo themeQo = themeManager.getDetail(themeId, userId);
return CommonResp.success(themeQo); return CommonResp.success(themeQo);
} }
...@@ -55,7 +58,7 @@ public class ThemeController { ...@@ -55,7 +58,7 @@ public class ThemeController {
@PostMapping(value = "/forward") @PostMapping(value = "/forward")
@ResponseBody @ResponseBody
public CommonResp forwardTheme(@Validated @RequestBody ForwardThemeReq forwardThemeReq) { public CommonResp forwardTheme(@Validated @RequestBody ForwardThemeReq forwardThemeReq) {
String userId = "liujm"; String userId = userHolder.getUserId();
themeManager.forward(forwardThemeReq, userId); themeManager.forward(forwardThemeReq, userId);
return CommonResp.success(); return CommonResp.success();
} }
...@@ -64,8 +67,8 @@ public class ThemeController { ...@@ -64,8 +67,8 @@ public class ThemeController {
@PostMapping(value = "/like") @PostMapping(value = "/like")
@ResponseBody @ResponseBody
public CommonResp<Void> likeOnTheme(@RequestBody LikeThemeReq req) { public CommonResp<Void> likeOnTheme(@RequestBody LikeThemeReq req) {
String user = "liujm"; String userId = userHolder.getUserId();
themeManager.like(req, user); themeManager.like(req, userId);
return CommonResp.success(); return CommonResp.success();
} }
...@@ -73,7 +76,7 @@ public class ThemeController { ...@@ -73,7 +76,7 @@ public class ThemeController {
@GetMapping(value = "/delete") @GetMapping(value = "/delete")
@ResponseBody @ResponseBody
public CommonResp<Void> delete(@RequestParam(value = "themeId") String themeId) { public CommonResp<Void> delete(@RequestParam(value = "themeId") String themeId) {
String userId = "liujm"; String userId = userHolder.getUserId();
themeManager.delete(themeId); themeManager.delete(themeId);
return CommonResp.success(); return CommonResp.success();
} }
...@@ -82,8 +85,8 @@ public class ThemeController { ...@@ -82,8 +85,8 @@ public class ThemeController {
@PostMapping(value = "/collect") @PostMapping(value = "/collect")
@ResponseBody @ResponseBody
public CommonResp<Void> bookTheme(@RequestBody CollectThemeReq req) { public CommonResp<Void> bookTheme(@RequestBody CollectThemeReq req) {
String user = "liujm"; String userId = userHolder.getUserId();
themeManager.collect(req, user); themeManager.collect(req, userId);
return CommonResp.success(); return CommonResp.success();
} }
...@@ -106,8 +109,7 @@ public class ThemeController { ...@@ -106,8 +109,7 @@ public class ThemeController {
@GetMapping(value = "/block") @GetMapping(value = "/block")
@ResponseBody @ResponseBody
public CommonResp concealTheme(String themeId) { public CommonResp concealTheme(String themeId) {
String user = "liujm"; String userId = userHolder.getUserId();
// themeManager.blockContent(themeId,user);
return CommonResp.success(); return CommonResp.success();
} }
......
...@@ -221,7 +221,9 @@ public class ThemeManager { ...@@ -221,7 +221,9 @@ public class ThemeManager {
//是否关注作者 //是否关注作者
String authorId = themeQo.getAuthorId(); String authorId = themeQo.getAuthorId();
Set<String> fansSet = new HashSet<>(followRelService.queryFansByFollowerId(userId)); Set<String> fansSet = new HashSet<>(followRelService.queryFansByFollowerId(userId));
themeQo.setFollow(fansSet.contains(authorId)); if (fansSet!=null){
themeQo.setFollow(fansSet.contains(authorId));
}
//是否点赞 //是否点赞
CollectionEntity likeEntity = collectionService.getNotDeleteTargetCollection(themeId, userId, CollectionTypeEnum.LIKE_THEME); CollectionEntity likeEntity = collectionService.getNotDeleteTargetCollection(themeId, userId, CollectionTypeEnum.LIKE_THEME);
themeQo.setHasLiked(likeEntity!=null); themeQo.setHasLiked(likeEntity!=null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment