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

用户信息源修改

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