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);
|
}
|
|
|
}
|