package com.sptg.ad.biz.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.ad.api.dto.AdContentDto;
import com.sptg.ad.api.entity.AdContent;
import com.sptg.ad.api.feigns.AdContentFeign;
import com.sptg.ad.biz.service.AdContentServiceInterface;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * title: AdContentController
 * package: com.sptg.ad.biz.controller
 * description: 广告类容-控制器
 *
 *               
 *                 
 */
@RestController
public class AdContentController implements AdContentFeign {

    private final AdContentServiceInterface adContentServiceInterface;

    /**
     * 功能描述:显示广告类容列表
     * @param
     * @return 
     *               
     *                       
     */
    @Override
    @PostMapping(value = "/showAdContentList")
    public ResultBean<Page<AdContent>> showAdContentList(@RequestBody AdContentDto adContentDto) {
        Page<AdContent> adContentPage = adContentServiceInterface.showAdContentList(adContentDto);
        return new ResultBean<>(ResultEnum.SUCCESS,adContentPage);
    }
    /**
     * 功能描述: 添加/修改
     * @param
     * @return
     *               
     *                       
     */
    @Override
    @PostMapping(value = "/addAdContent")
    public ResultBean<Boolean> addAdContent(@RequestBody AdContent adContent) {
        return this.adContentServiceInterface.addAdContent(adContent);
    }

    /**
     * 功能描述: 删除
     * @param
     * @return
     *               
     *                       
     */
    @Override
    @PostMapping(value = "/deleteAdContent")
    public ResultBean<Boolean> deleteAdContent(@RequestBody String ids) {
        return this.adContentServiceInterface.deleteAdContent(ids);
    }

    @Override
    @PostMapping(value = "/deleteAdContentList")
    public ResultBean<Boolean> deleteAdContentList(@RequestBody AdContentDto adContentDto) {
        return this.adContentServiceInterface.deleteAdContentList(adContentDto);
    }

    /**
     * 功能描述: 根据id查询广告
     * @param
     * @return
     *               
     *                       
     */
    @Override
    @PostMapping(value = "/findAdContentById")
    public AdContent findAdContentById(@RequestBody Long id) {
        return this.adContentServiceInterface.findAdContentById(id);
    }

    /**
     * 功能描述: 获取广告列表
     * @param  { adTitle：广告标题}
     * @return
     *               
     *                       
     */
    @Override
    @PostMapping(value = "/getList")
    public ResultBean<AdContent> getList(@RequestBody AdContentDto dto){
        return this.adContentServiceInterface.getList(dto);
    }

    @Autowired
    public AdContentController(
            AdContentServiceInterface adContentServiceInterface
    ){
        this.adContentServiceInterface = adContentServiceInterface;
    }
}
