44323
2024-02-22 aa8ff2d61669d0779fdacdba76e26388587b435d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package com.stylefeng.guns.modular.api;
 
import com.stylefeng.guns.modular.system.model.AppUser;
import com.stylefeng.guns.modular.system.model.EncyclopedicKnowledge;
import com.stylefeng.guns.modular.system.model.SysDataType;
import com.stylefeng.guns.modular.system.service.IAppUserService;
import com.stylefeng.guns.modular.system.service.IEncyclopedicKnowledgeService;
import com.stylefeng.guns.modular.system.service.ISysDataTypeService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.warpper.req.SearchHouseResourceReq;
import com.stylefeng.guns.modular.system.warpper.req.SearchIntermediaryReq;
import com.stylefeng.guns.modular.system.warpper.res.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * @author zhibing.pu
 * @Date 2023/11/23 15:19
 */
@RestController
@RequestMapping("")
public class EncyclopedicKnowledgeController {
 
    @Autowired
    private IEncyclopedicKnowledgeService encyclopedicKnowledgeService;
 
    @Autowired
    private ISysDataTypeService sysDataTypeService;
    @Autowired
    private IAppUserService appUserService;
 
 
    @ResponseBody
    @GetMapping("/base/encyclopedicKnowledge/getEncyclopedicKnowledgeType")
    @ApiOperation(value = "获取类别", tags = {"知识百科"})
    public ResultUtil<List<SysDataType>> getEncyclopedicKnowledgeType(){
        List<SysDataType> sysDataType = sysDataTypeService.getSysDataType(1);
        List<SysDataType> res = new ArrayList<>();
        // 如果当前类别下 没有内容就不展示了
        for (SysDataType dataType : sysDataType) {
            List<EncyclopedicKnowledgeRes> list = encyclopedicKnowledgeService.getEncyclopedicKnowledgeList(dataType.getId());
            if (list.size()!=0) res.add(dataType);
        }
        return ResultUtil.success(res);
    }
 
 
 
    @ResponseBody
    @GetMapping("/base/encyclopedicKnowledge/getEncyclopedicKnowledgeList")
    @ApiOperation(value = "获取列表数据", tags = {"知识百科"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "typeId", value = "类别id", required = true),
    })
    public ResultUtil<List<EncyclopedicKnowledgeRes>> getEncyclopedicKnowledgeList(Integer typeId){
        List<EncyclopedicKnowledgeRes> encyclopedicKnowledgeList = encyclopedicKnowledgeService.getEncyclopedicKnowledgeList(typeId);
        return ResultUtil.success(encyclopedicKnowledgeList);
    }
 
 
    @ResponseBody
    @PostMapping("/base/encyclopedicKnowledge/getEncyclopedicKnowledgeInfo")
    @ApiOperation(value = "获取详情", tags = {"知识百科"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "数据id", required = true),
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = false, paramType = "header")
    })
    public ResultUtil<EncyclopedicKnowledgeInfoRes> getEncyclopedicKnowledgeInfo(Integer id){
 
        EncyclopedicKnowledgeInfoRes encyclopedicKnowledgeInfo = encyclopedicKnowledgeService.getEncyclopedicKnowledgeInfo(id);
        return ResultUtil.success(encyclopedicKnowledgeInfo);
    }
 
 
    @ResponseBody
    @PostMapping("/base/encyclopedicKnowledge/upvoteEncyclopedicKnowledge")
    @ApiOperation(value = "点赞/取消点赞", tags = {"知识百科"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "数据id", required = true),
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil upvoteEncyclopedicKnowledge(Integer id){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        return encyclopedicKnowledgeService.upvoteEncyclopedicKnowledge(id);
    }
 
 
 
 
}