xuekang
2024-05-13 15a0280ae9e7db96fdf0744c722d214d2cb5a0e5
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
package com.nuvole.four.controller.pc;
 
import com.github.pagehelper.PageHelper;
import com.nuvole.common.domain.emnu.CommonResultEmnu;
import com.nuvole.common.domain.result.CommonResult;
import com.nuvole.common.domain.result.PageBean;
import com.nuvole.four.controller.BaseController;
import com.nuvole.four.domain.ChannelInfo;
import com.nuvole.four.domain.dto.ChannelInfoDto;
import com.nuvole.four.service.ChannelInfoService;
import com.nuvole.util.CommonUtil;
import com.nuvole.util.PageUtils;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * @Desc: 通道信息维护Controller
 * @Author: dqh
 * @Date: 2024-04-09
 **/
@Api(value = "通道信息维护", tags = "通道信息维护")
@Slf4j
@RestController
@CrossOrigin
@RequestMapping(value = "/v1/four/pc/channel")
public class ChannelInfoController extends BaseController {
    @Autowired
    private ChannelInfoService channelInfoService;
 
    /**
     * 方法描述:查询通道列表
     *
     * @date  2024-04-11 14:42
     **/
    @ApiOperation(value = "查询通道信息列表", notes = "查询通道信息列表")
    @GetMapping("/getChannelInfoList")
    public CommonResult<PageBean<ChannelInfo>> getChannelInfoList(
            @ApiParam(name = "channelName", value = "通道名称") String channelName,
            @ApiParam(name = "status", value = "状态;0=启用,1=禁用") Integer status,
            @ApiParam(name = "pageNumber", value = "页码", defaultValue = "1", required = true) Integer pageNumber,
            @ApiParam(name = "pageSize", value = "条数", defaultValue = "10", required = true) Integer pageSize,
            @ApiParam(name = "sortName", value = "排序名称") String sortName,
            @ApiParam(name = "sortOrder", value = "排序方式") String sortOrder
    ) {
        if (StringUtils.isNotBlank(sortName) && StringUtils.isNotBlank(sortOrder)) {
            PageHelper.orderBy(PageUtils.orderParser(sortName, sortOrder));
        } else {
            PageHelper.orderBy("create_time desc");
        }
        PageHelper.startPage(pageNumber, pageSize);
        ChannelInfo channelInfo = new ChannelInfo();
        channelInfo.setChannelName(channelName);
        channelInfo.setStatus(status);
 
        List<ChannelInfoDto> list = channelInfoService.getPageList(channelInfo);
        CommonResult result = new CommonResult<>(new PageBean(list));
        CommonResult result1 = new CommonResult<>();
        BeanUtils.copyProperties(result, result1);
        result = result1;
        return result;
 
    }
 
    /**
     * 方法描述:查询通道列表
     *
     * @date  2024-04-11 14:42
     **/
    @ApiOperation(value = "查询所有通道信息列表", notes = "查询所有通道信息列表")
    @GetMapping("/getAllList")
    public CommonResult<List<ChannelInfo>> getAllChannelInfoList(
            @ApiParam(name = "channelName", value = "通道名称") String channelName,
            @ApiParam(name = "status", value = "状态;0=启用,1=禁用") Integer status,
            @ApiParam(name = "sortName", value = "排序名称") String sortName,
            @ApiParam(name = "sortOrder", value = "排序方式") String sortOrder
    ) {
        if (StringUtils.isNotBlank(sortName) && StringUtils.isNotBlank(sortOrder)) {
            PageHelper.orderBy(PageUtils.orderParser(sortName, sortOrder));
        } else {
            PageHelper.orderBy("create_time desc");
        }
        ChannelInfo channelInfo = new ChannelInfo();
        channelInfo.setChannelName(channelName);
        channelInfo.setStatus(status);
        List<ChannelInfo> list = channelInfoService.getList(channelInfo);
        return new CommonResult<>(list);
 
    }
 
    /**
     * 方法描述:新增通道
     *
     * @date  2024-04-11 14:42
     **/
    @ApiOperation(value = "添加", notes = "添加")
    @ApiImplicitParams({ @ApiImplicitParam(name = "ChannelInfo") })
    @PostMapping("/save")
    public CommonResult<Integer> save() {
        ChannelInfo channelInfo = CommonUtil.getObjFromReq(ChannelInfo.class);
        channelInfoService.saveChannelInfo(channelInfo);
        return new CommonResult(CommonResultEmnu.OK);
    }
 
    /**
     * 方法描述: 修改通道
     *
     * @date  2024-04-11 14:41
     **/
    @ApiOperation(value = "编辑", notes = "编辑")
    @ApiImplicitParams({ @ApiImplicitParam(name = "ChannelInfo") })
    @PostMapping("/upd")
    public CommonResult<Integer> upd() {
        ChannelInfo channelInfo = CommonUtil.getObjFromReq(ChannelInfo.class);
        channelInfoService.updateChannelInfo(channelInfo);
        return new CommonResult(CommonResultEmnu.OK);
    }
 
    /**
     * 方法描述:根据ID查询通道详情
     *
     * @date  2024-04-11 14:42
     **/
    @ApiOperation(value = "查询通道信息详情", notes = "查询通道信息详情")
    @GetMapping("/getDetail")
    public CommonResult<ChannelInfo> getChannelInfoDetail(
            @ApiParam(name = "id", value = "通道ID") Long id)
    {
        ChannelInfo dtoList = channelInfoService.getChannelInfo(id);
        return new CommonResult<>(dtoList);
    }
 
    /**
     * 方法描述:根据code查询通道详情
     *
     * @date 2024-04-11 14:42
     **/
    @ApiOperation(value = "根据code查询通道详情", notes = "根据code查询通道详情")
    @GetMapping("/getDetailByCode")
    public CommonResult<ChannelInfo> getDetailByCode(@ApiParam(name = "channelCode", value = "通道code") String channelCode) {
        ChannelInfo dtoList = channelInfoService.getDetailByCode(channelCode);
        return new CommonResult(dtoList);
    }
 
 
}