package com.sptg.ad.biz.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.ad.api.dto.AdAdsenseDto;
import com.sptg.ad.api.dto.AdMaterialDto;
import com.sptg.ad.api.entity.AdAdsense;
import com.sptg.ad.api.entity.AdContent;
import com.sptg.ad.api.entity.AdMaterial;
import com.sptg.ad.api.feigns.AdAdsenseFeign;
import com.sptg.ad.api.feigns.AdMaterialFeign;
import com.sptg.ad.biz.service.AdAdsenseServiceInterface;
import com.sptg.ad.biz.service.AdMaterialServiceInterface;
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: AdMaterialController
 * package: com.sptg.ad.biz.controller
 * description: 广告素材-控制器
 *
 *
 *
 */
@RestController
public class AdMaterialController implements AdMaterialFeign {

    private final AdMaterialServiceInterface adMaterialServiceInterface;
    @Autowired
    public AdMaterialController(AdMaterialServiceInterface adMaterialServiceInterface){
        this.adMaterialServiceInterface = adMaterialServiceInterface;
    }
    @Override
    @PostMapping("/showAdMaterialList")
    public ResultBean<Page<AdMaterial>> showAdMaterialList(@RequestBody AdMaterialDto adMaterialDto) {
        Page<AdMaterial> adMaterialPage = adMaterialServiceInterface.showAdMaterialList(adMaterialDto);
        return new ResultBean<>(ResultEnum.SUCCESS,adMaterialPage);
    }

    @Override
    @PostMapping("/addAdMaterial")
    public ResultBean<Boolean> addAdMaterial(@RequestBody AdMaterial adMaterial) {
        return this.adMaterialServiceInterface.addAdMaterial(adMaterial);
    }

    @Override
    @PostMapping("/deleteAdMaterial")
    public ResultBean<Boolean> deleteAdMaterial(@RequestBody String ids) {
        return this.adMaterialServiceInterface.deleteAdMaterial(ids);
    }
    @Override
    @PostMapping(value = "/findAdMaterialById")
    public AdMaterial findAdMaterialById(@RequestBody Long id) {
        return this.adMaterialServiceInterface.findAdMaterialById(id);
    }

    @Override
    public ResultBean<Boolean> deleteAdMaterialList(@RequestBody  AdMaterialDto adMaterialDto) {
        return this.adMaterialServiceInterface.deleteAdMaterialList(adMaterialDto);
    }
}
