electripper-v2/ruoyi-web/src/main/java/com/ruoyi/web/bst/ChannelController.java
2025-03-25 18:03:57 +08:00

145 lines
4.7 KiB
Java

package com.ruoyi.web.bst;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.ValidGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.bst.channel.domain.Channel;
import com.ruoyi.bst.channel.domain.ChannelQuery;
import com.ruoyi.bst.channel.domain.ChannelVO;
import com.ruoyi.bst.channel.domain.vo.ChannelNameVO;
import com.ruoyi.bst.channel.service.ChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 充值渠道Controller
*
* @author ruoyi
* @date 2024-04-15
*/
@RestController
@RequestMapping("/bst/channel")
public class ChannelController extends BaseController
{
@Autowired
private ChannelService channelService;
/**
* 查询充值渠道列表
*/
@PreAuthorize("@ss.hasPermi('bst:channel:list')")
@GetMapping("/list")
public TableDataInfo list(ChannelQuery smChannel)
{
startPage();
List<ChannelVO> list = channelService.selectChannelList(smChannel);
return getDataTable(list);
}
/**
* 查询全部充值渠道列表
*/
@PreAuthorize("@ss.hasPermi('bst:channel:list')")
@GetMapping("/listAll")
public AjaxResult listAll()
{
List<ChannelNameVO> list = channelService.selectAllChannelNameList();
return success(list);
}
/**
* 查询充值渠道列表
*/
@PreAuthorize("@ss.hasPermi('bst:channel:listByIds')")
@PostMapping("/listByIds")
public AjaxResult listByIds(@RequestBody List<Long> ids)
{
List<ChannelVO> list = channelService.selectByIds(ids);
return success(list);
}
/**
* 导出充值渠道列表
*/
@PreAuthorize("@ss.hasPermi('bst:channel:export')")
@Log(title = "充值渠道", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ChannelQuery smChannel)
{
List<ChannelVO> list = channelService.selectChannelList(smChannel);
ExcelUtil<ChannelVO> util = new ExcelUtil<ChannelVO>(ChannelVO.class);
util.exportExcel(response, list, "充值渠道数据");
}
/**
* 获取充值渠道详细信息
*/
@PreAuthorize("@ss.hasPermi('bst:channel:query')")
@GetMapping(value = "/{channelId}")
public AjaxResult getInfo(@PathVariable("channelId") Long channelId)
{
return success(channelService.selectChannelByChannelId(channelId));
}
/**
* 修改充值渠道
*/
@PreAuthorize("@ss.hasPermi('bst:channel:edit')")
@Log(title = "充值渠道", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) Channel form)
{
Channel channel = new Channel();
channel.setName(form.getName());
channel.setAppIds(form.getAppIds());
channel.setType(form.getType());
channel.setChannelId(form.getChannelId());
channel.setEnabled(form.getEnabled());
channel.setCostRate(form.getCostRate());
channel.setPicture(form.getPicture());
channel.setApiType(form.getApiType());
channel.setChannelConfig(form.getChannelConfig());
return toAjax(channelService.updateChannel(channel));
}
/**
* 新增充值渠道
*/
@PreAuthorize("@ss.hasPermi('bst:channel:add')")
@Log(title = "充值渠道", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) Channel form)
{
Channel channel = new Channel();
channel.setName(form.getName());
channel.setAppIds(form.getAppIds());
channel.setType(form.getType());
channel.setEnabled(form.getEnabled());
channel.setCostRate(form.getCostRate());
channel.setPicture(form.getPicture());
channel.setApiType(form.getApiType());
channel.setChannelConfig(form.getChannelConfig());
return toAjax(channelService.insertChannel(channel));
}
/**
* 删除充值渠道
*/
@PreAuthorize("@ss.hasPermi('bst:channel:delete')")
@Log(title = "充值渠道", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult delete(@PathVariable List<Long> ids) {
return toAjax(channelService.logicDel(ids));
}
}