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 list = channelService.selectSmChannelList(smChannel); return getDataTable(list); } /** * 查询全部充值渠道列表 */ @PreAuthorize("@ss.hasPermi('bst:channel:list')") @GetMapping("/listAll") public AjaxResult listAll() { List list = channelService.selectAllChannelNameList(); return success(list); } /** * 查询充值渠道列表 */ @PreAuthorize("@ss.hasPermi('bst:channel:listByIds')") @PostMapping("/listByIds") public AjaxResult listByIds(@RequestBody List ids) { List 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 list = channelService.selectSmChannelList(smChannel); ExcelUtil util = new ExcelUtil(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.selectSmChannelByChannelId(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.updateSmChannel(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.insertSmChannel(channel)); } /** * 删除充值渠道 */ @PreAuthorize("@ss.hasPermi('bst:channel:delete')") @Log(title = "充值渠道", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult delete(@PathVariable List ids) { return toAjax(channelService.logicDel(ids)); } }