KKSU
2023-11-21 5b818c73e70ef4618681fd103ca593020431eeef
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
package cc.mrbird.febs.mall.controller;
 
import cc.mrbird.febs.common.annotation.ControllerEndpoint;
import cc.mrbird.febs.common.controller.BaseController;
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.common.enumerates.ProductEnum;
import cc.mrbird.febs.mall.dto.AdminMallProductNftDto;
import cc.mrbird.febs.mall.dto.AdminPickSellRecordDtoDto;
import cc.mrbird.febs.mall.dto.MallNewsInfoDto;
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.mapper.MallProductNftMapper;
import cc.mrbird.febs.mall.service.IMallNewsInfoService;
import cc.mrbird.febs.mall.vo.AdminMallProductNftVo;
import cc.mrbird.febs.mall.vo.AdminMallProductSellPickVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.management.Query;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
 
/**
 * @author wzy
 * @date 2022-05-13
 **/
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/admin/news")
public class AdminNewsInfoController extends BaseController {
 
    private final IMallNewsInfoService mallNewsInfoService;
    private final MallProductNftMapper mallProductNftMapper;
 
    /**
     * NFT预约产品
     */
    @GetMapping("getProductNFTList")
    public FebsResponse getProductNFTList(MallProductNft mallProductNft, QueryRequest request) {
        Map<String, Object> data = getDataTable(mallNewsInfoService.getProductNFTList(mallProductNft, request));
        return new FebsResponse().success().data(data);
    }
 
    /**
     * NFT预约产品-新增
     */
    @PostMapping("addProductNFT")
    @ControllerEndpoint(operation = "NFT预约产品-新增", exceptionMessage = "操作失败")
    public FebsResponse addProductNFT(@Valid AdminMallProductNftDto adminMallProductNftDto) {
        return mallNewsInfoService.addProductNFT(adminMallProductNftDto);
    }
 
    @PostMapping(value = "/upNFT/{id}")
    public FebsResponse upNFT(@PathVariable Long id) {
        MallProductNft mallProductNft = mallProductNftMapper.selectById(id);
        mallProductNft.setState(ProductEnum.PRODUCT_NFT_OPEN.getValue());
        mallProductNftMapper.updateById(mallProductNft);
        return new FebsResponse().success();
    }
 
    @PostMapping(value = "/unUpNFT/{id}")
    public FebsResponse unUpNFT(@PathVariable Long id) {
        MallProductNft mallProductNft = mallProductNftMapper.selectById(id);
        mallProductNft.setState(ProductEnum.PRODUCT_NFT_CLOSE.getValue());
        mallProductNftMapper.updateById(mallProductNft);
        return new FebsResponse().success();
    }
 
    /**
     * NFT预约产品-删除
     */
    @GetMapping("delNFT/{id}")
    @ControllerEndpoint(operation = " 新闻中心-删除", exceptionMessage = "操作失败")
    public FebsResponse delNFT(@NotNull(message = "{required}") @PathVariable Long id) {
        return mallNewsInfoService.delNFT(id);
    }
 
    /**
     * NFT预约产品-更新
     */
    @PostMapping("nftInfoUpdate")
    @ControllerEndpoint(operation = "NFT预约产品-更新", exceptionMessage = "操作失败")
    public FebsResponse nftInfoUpdate(@Valid MallProductNft mallProductNft) {
        return mallNewsInfoService.nftInfoUpdate(mallProductNft);
    }
 
    /**
     * 用户NFT预约列表
     */
    @GetMapping("getBuyList")
    public FebsResponse getBuyList(MallProductBuy mallProductBuy, QueryRequest request) {
        Map<String, Object> data = getDataTable(mallNewsInfoService.getBuyList(mallProductBuy, request));
        return new FebsResponse().success().data(data);
    }
 
    /**
     * 用户NFT提现列表
     */
    @GetMapping("getSellList")
    public FebsResponse getSellList(MallProductSell mallProductSell, QueryRequest request) {
        Map<String, Object> data = getDataTable(mallNewsInfoService.getSellList(mallProductSell, request));
        return new FebsResponse().success().data(data);
    }
 
    /**
     * 用户NFT提现-匹配提现用户列表
     * @return
     */
    @GetMapping(value = "findSellList")
    public FebsResponse findSellList() {
        List<AdminMallProductSellPickVo> categories = mallNewsInfoService.findSellList();
        return new FebsResponse().success().data(categories);
    }
 
    /**
     * 用户NFT提现-手动分配
     */
    @PostMapping("pickSellRecord")
    @ControllerEndpoint(operation = "用户NFT提现-手动分配", exceptionMessage = "操作失败")
    public FebsResponse pickSellRecord(@Valid AdminPickSellRecordDtoDto pickSellRecordDto) {
        return mallNewsInfoService.pickSellRecord(pickSellRecordDto);
    }
 
    /**
     * 新闻中心-列表
     * @param mallNewsInfo
     * @param request
     * @return
     */
    @GetMapping("getNewInfoList")
    public FebsResponse getNewInfoList(MallNewsInfo mallNewsInfo, QueryRequest request) {
        Map<String, Object> data = getDataTable(mallNewsInfoService.getNewInfoList(mallNewsInfo, request));
        return new FebsResponse().success().data(data);
    }
 
    /**
     * 新闻中心-新增
     */
    @PostMapping("addNewsInfo")
    @ControllerEndpoint(operation = " 新闻中心-新增", exceptionMessage = "操作失败")
    public FebsResponse addNewsInfo(@Valid MallNewsInfoDto mallNewsInfoDto) {
        return mallNewsInfoService.addNewsInfo(mallNewsInfoDto);
    }
 
    /**
     * 新闻中心-删除
     */
    @GetMapping("delNewsInfo/{id}")
    @ControllerEndpoint(operation = " 新闻中心-删除", exceptionMessage = "操作失败")
    public FebsResponse delNewsInfo(@NotNull(message = "{required}") @PathVariable Long id) {
        return mallNewsInfoService.delNewsInfo(id);
    }
 
    /**
     * 新闻中心-更新
     */
    @PostMapping("updateNewsInfo")
    @ControllerEndpoint(operation = "新闻中心-更新", exceptionMessage = "操作失败")
    public FebsResponse updateNewsInfo(@Valid MallNewsInfoDto mallNewsInfoDto) {
        return mallNewsInfoService.updateNewsInfo(mallNewsInfoDto);
    }
 
 
    @GetMapping("findNewsCategoryList")
    @ControllerEndpoint(operation = "新闻分类列表", exceptionMessage = "获取失败")
    public FebsResponse findNewsCategoryList(MallNewsCategory mallNewsCategory, QueryRequest request) {
        return new FebsResponse().success().data(getDataTable(mallNewsInfoService.findNewsCategoryInPage(mallNewsCategory, request)));
    }
 
    @PostMapping("addOrModifyNewsCategory")
    @ControllerEndpoint(operation = "新闻分类", exceptionMessage = "新增失败")
    public FebsResponse addOrModifyNewsCategory(MallNewsCategory mallNewsCategory) {
        mallNewsInfoService.addOrModifyNewsCategory(mallNewsCategory);
        return new FebsResponse().success().message("新增成功");
    }
 
    /**
     * 新闻分类-删除
     */
    @GetMapping("delNewsCategoryInfo/{id}")
    @ControllerEndpoint(operation = "新闻分类-删除", exceptionMessage = "操作失败")
    public FebsResponse delNewsCategoryInfo(@NotNull(message = "{required}") @PathVariable Long id) {
        return mallNewsInfoService.delNewsCategoryInfo(id);
    }
 
    @GetMapping(value = "findAllCategoryList")
    public FebsResponse findAllCategoryList() {
        List<MallNewsCategory> categories = mallNewsInfoService.findAllCategory();
        return new FebsResponse().success().data(categories);
    }
 
    @PostMapping(value = "/topNews/{id}")
    public FebsResponse topNews(@PathVariable Long id) {
        MallNewsInfo mallNewsInfo = new MallNewsInfo();
        mallNewsInfo.setIsTop(1);
        mallNewsInfo.setId(id);
        mallNewsInfoService.updateById(mallNewsInfo);
        return new FebsResponse().success();
    }
 
    @PostMapping(value = "/unTopNews/{id}")
    public FebsResponse unTopNews(@PathVariable Long id) {
        MallNewsInfo mallNewsInfo = new MallNewsInfo();
        mallNewsInfo.setIsTop(2);
        mallNewsInfo.setId(id);
        mallNewsInfoService.updateById(mallNewsInfo);
        return new FebsResponse().success();
    }
}