You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
5.2 KiB
138 lines
5.2 KiB
package com.zc.business.controller;
|
|
|
|
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.enums.BusinessType;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.zc.business.domain.DcPublishingChannels;
|
|
import com.zc.business.enums.UniversalEnum;
|
|
import com.zc.business.service.IDcPublishingChannelsService;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 发布渠道Controller
|
|
*
|
|
* @author ruoyi
|
|
* @date 2024-04-19
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/business/channels")
|
|
public class DcPublishingChannelsController extends BaseController
|
|
{
|
|
@Autowired
|
|
private IDcPublishingChannelsService dcPublishingChannelsService;
|
|
|
|
/**
|
|
* 查询发布渠道列表
|
|
*/
|
|
//@PreAuthorize("@ss.hasPermi('business:channels:list')")
|
|
@PostMapping("/list")
|
|
public TableDataInfo list(@RequestBody DcPublishingChannels dcPublishingChannels)
|
|
{
|
|
startPage();
|
|
List<DcPublishingChannels> list = dcPublishingChannelsService.selectDcPublishingChannelsList(dcPublishingChannels);
|
|
return getDataTable(list);
|
|
}
|
|
|
|
/**
|
|
* 导出发布渠道列表
|
|
*/
|
|
//@PreAuthorize("@ss.hasPermi('business:channels:export')")
|
|
@Log(title = "发布渠道", businessType = BusinessType.EXPORT)
|
|
@PostMapping("/export")
|
|
public void export(HttpServletResponse response, DcPublishingChannels dcPublishingChannels)
|
|
{
|
|
List<DcPublishingChannels> list = dcPublishingChannelsService.selectDcPublishingChannelsList(dcPublishingChannels);
|
|
ExcelUtil<DcPublishingChannels> util = new ExcelUtil<>(DcPublishingChannels.class);
|
|
util.exportExcel(response, list, UniversalEnum.RELEASE_CHANNEL_DATA.getValue());
|
|
}
|
|
|
|
/**
|
|
* 获取发布渠道详细信息
|
|
*/
|
|
// @PreAuthorize("@ss.hasPermi('business:channels:query')")
|
|
@GetMapping(value = "/{id}")
|
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
{
|
|
return AjaxResult.success(dcPublishingChannelsService.selectDcPublishingChannelsById(id));
|
|
}
|
|
|
|
/**
|
|
* 新增发布渠道
|
|
*/
|
|
//@PreAuthorize("@ss.hasPermi('business:channels:add')")
|
|
@Log(title = "发布渠道", businessType = BusinessType.INSERT)
|
|
@PostMapping
|
|
public AjaxResult add(@RequestBody DcPublishingChannels dcPublishingChannels)
|
|
{
|
|
if (dcPublishingChannels.getDataCategory()==null){
|
|
return AjaxResult.error(UniversalEnum.PARAMETER_ERROR.getValue());
|
|
}
|
|
List<DcPublishingChannels> channelsList = dcPublishingChannelsService.
|
|
selectChannelsDataCategory(dcPublishingChannels.getDataCategory());
|
|
if (channelsList!=null&&channelsList.size()>UniversalEnum.ZERO.getNumber()){
|
|
return AjaxResult.error(UniversalEnum.THE_EVENT_TYPE_ALREADY_EXISTS.getValue());
|
|
}
|
|
return toAjax(dcPublishingChannelsService.insertDcPublishingChannels(dcPublishingChannels));
|
|
}
|
|
|
|
/**
|
|
* 修改发布渠道
|
|
*/
|
|
// @PreAuthorize("@ss.hasPermi('business:channels:edit')")
|
|
@Log(title = "发布渠道", businessType = BusinessType.UPDATE)
|
|
@PutMapping
|
|
public AjaxResult edit(@RequestBody DcPublishingChannels dcPublishingChannels)
|
|
{
|
|
|
|
return toAjax(dcPublishingChannelsService.updateDcPublishingChannels(dcPublishingChannels));
|
|
}
|
|
|
|
/**
|
|
* 删除发布渠道
|
|
*/
|
|
//@PreAuthorize("@ss.hasPermi('business:channels:remove')")
|
|
@Log(title = "发布渠道", businessType = BusinessType.DELETE)
|
|
@DeleteMapping("/{ids}")
|
|
public AjaxResult remove(@PathVariable Long[] ids)
|
|
{
|
|
return toAjax(dcPublishingChannelsService.deleteDcPublishingChannelsByIds(ids));
|
|
}
|
|
/**
|
|
* 修改启用停用
|
|
*/
|
|
@PostMapping("/updateEnabled")
|
|
public AjaxResult updateEnabled(@RequestBody DcPublishingChannels dcPublishingChannels)
|
|
{
|
|
Integer enabled = dcPublishingChannels.getEnabled();//状态
|
|
if (enabled==null){
|
|
return AjaxResult.error(UniversalEnum.PARAMETER_ERROR.getValue());
|
|
}
|
|
if (enabled==UniversalEnum.TWO.getNumber()){ //启用状态,修改启用时间
|
|
dcPublishingChannels.setEnableDate(DateUtils.getNowDate());
|
|
}
|
|
return toAjax(dcPublishingChannelsService.updateEnabled(dcPublishingChannels));
|
|
}
|
|
//事件调度处置事件推送发布渠道
|
|
@PostMapping("/eventPublishChannels")
|
|
public AjaxResult eventPublishChannels(@RequestBody HashMap map)
|
|
{
|
|
if (map==null||map.size()==UniversalEnum.ZERO.getNumber()){
|
|
return AjaxResult.error(UniversalEnum.PARAMETER_ERROR.getValue());
|
|
}
|
|
String eventId = map.get("eventId").toString();
|
|
if (StringUtils.isBlank(eventId)){
|
|
return AjaxResult.error(UniversalEnum.PARAMETER_ERROR.getValue());
|
|
}
|
|
return AjaxResult.success(dcPublishingChannelsService.eventPublishChannels(eventId));
|
|
}
|
|
}
|
|
|