ThemeController.java 3.82 KB
package com.tanpu.community.controller;


import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.req.theme.ForwardThemeReq;
import com.tanpu.community.api.beans.qo.MainTextQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.req.CreateThemeReq;
import com.tanpu.community.api.beans.req.theme.ThemeListByTopicReq;
import com.tanpu.community.api.beans.req.theme.ThemeListReq;
import com.tanpu.community.manager.ThemeManager;
import com.tanpu.community.service.FollowRelService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping(value = "/api/theme")
public class ThemeController {

    @Autowired
    private ThemeManager themeManager;

    @Autowired
    private FollowRelService followRelService;

    @ApiOperation("发表主题")
    @PostMapping(value = "/publish")
    @ResponseBody
    public CommonResp<Void> publishTheme(@Validated @RequestBody CreateThemeReq req) {
        String userId = "liujm";
        themeManager.publishTheme(req, userId);
        return CommonResp.success();
    }



    @ApiOperation("圈子首页-推荐/关注")
    @GetMapping(value = "/list")
    @ResponseBody
    public List<ThemeQo> selectInterestList(@RequestBody ThemeListReq req) {
        String userId = "liujm";
        if (req.getType()==1){
            return themeManager.selectHotThemes(req,userId);
        }else {
            return themeManager.selectInterestThemes(req,userId);
        }
    }


    @ApiOperation("话题详情页-最新/最热")
    @GetMapping(value = "/listByTopic")
    @ResponseBody
    public CommonResp<List<ThemeQo>> getThemeMainText(@RequestBody ThemeListByTopicReq req) {
        String userId = "liujm";
        List<ThemeQo> result= themeManager.queryByTopic(req,userId);
        return CommonResp.success(result);
    }


    @ApiOperation("主题正文")
    @GetMapping(value = "/detail")
    @ResponseBody
    public CommonResp<MainTextQo> getThemeMainText(@RequestParam String topicId) {
        String userId = "liujm";
        MainTextQo mainTextQo = themeManager.getMainText(topicId,userId);
        return CommonResp.success(mainTextQo);
    }

    @ApiOperation("转发主题")
    @PostMapping(value = "/forward")
    @ResponseBody
    public CommonResp forwardTheme(@Validated @RequestBody ForwardThemeReq forwardThemeReq) {
        String userId = "liujm";
        themeManager.forward(forwardThemeReq, userId);
        return CommonResp.success();
    }


    @ApiOperation("点赞主题")
    @GetMapping(value = "/like")
    @ResponseBody
    public CommonResp likeOnTheme(@RequestParam String themeId) {
        String user = "liujm";
        themeManager.like(themeId, user);
        return CommonResp.success();
    }

    @ApiOperation("分享主题")
    @GetMapping(value = "/share")
    @ResponseBody
    public CommonResp shareTheme(String themeId) {
        return CommonResp.success();
    }

    @ApiOperation("收藏主题")
    @GetMapping(value = "/collect")
    @ResponseBody
    public CommonResp bookTheme(String themeId) {
        String user = "liujm";
//        themeManager.book(themeId,user);
        return CommonResp.success();
    }

    @ApiOperation("举报主题")
    @GetMapping(value = "/report")
    @ResponseBody
    public CommonResp complaintTheme(@RequestParam String themeId) {

        return CommonResp.failed("功能暂未开放");
    }

    @ApiOperation("屏蔽")
    @GetMapping(value = "/block")
    @ResponseBody
    public CommonResp concealTheme(String themeId) {
        String user = "liujm";
//        themeManager.blockContent(themeId,user);
        return CommonResp.success();
    }

}