package com.ytpm.controller;

import com.ytpm.advertise.param.ChannelAppParam;
import com.ytpm.agent.param.ChannelListParam;
import com.ytpm.agent.param.ChannelParam;
import com.ytpm.agent.view.AgentChannelView;
import com.ytpm.general.Result;
import com.ytpm.general.ResultTable;
import com.ytpm.service.ChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "广告渠道管理模块")
@RestController
@RequestMapping("/channel")
public class AgentChannelController {

    @Resource
    private ChannelService channelService;

    /**
     * 获取广告渠道列表
     */
    @ApiOperation("获取广告渠道列表")
    @PostMapping("/list")
    public ResultTable<AgentChannelView> list(@RequestBody ChannelListParam param) {
        return channelService.channelList(param);
    }

    /**
     * 新增广告渠道
     */
    @ApiOperation("新增广告渠道")
    @PostMapping("/addOne")
    public Result<?> addOne(@RequestBody ChannelParam param){
        return channelService.addOne(param);
    }

    /**
     * 修改广告渠道
     */
    @ApiOperation("修改广告渠道")
    @PostMapping("/updateOne")
    public Result<?> updateOne(@RequestBody ChannelParam param){
        return channelService.updateOne(param);
    }

    /**
     * 删除广告渠道
     */
    @ApiOperation("删除广告渠道")
    @GetMapping("/deleteOne")
    public Result<?> deleteOne(@RequestParam("channelId")String channelId){
        return channelService.deleteOne(channelId);
    }

    /**
     * 过滤指定app已经关联过的渠道
     */
    @ApiOperation("过滤指定app已经关联过的渠道")
    @PostMapping("/relativeChannel")
    public ResultTable<AgentChannelView>  relativeChannel(@RequestBody ChannelAppParam param){
        return channelService.relativeChannel(param);
    }
}
