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.AdContentDto;
import com.sptg.ad.api.entity.AdAdsense;
import com.sptg.ad.api.entity.AdContent;
import com.sptg.ad.api.feigns.AdAdsenseFeign;
import com.sptg.ad.api.feigns.AdContentFeign;
import com.sptg.ad.biz.service.AdAdsenseServiceInterface;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

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

    private final AdAdsenseServiceInterface adAdsenseServiceInterface;
    @Autowired
    public AdAdsenseController(AdAdsenseServiceInterface adAdsenseServiceInterface){
        this.adAdsenseServiceInterface = adAdsenseServiceInterface;
    }
    @Override
    @PostMapping("/showAdAdsenseList")
    public ResultBean<Page<AdAdsense>> showAdAdsenseList(@RequestBody AdAdsenseDto adAdsenseDto) {
        Page<AdAdsense> adAdsensePage = adAdsenseServiceInterface.showAdAdsenseList(adAdsenseDto);
        return new ResultBean<>(ResultEnum.SUCCESS,adAdsensePage);
    }

    @Override
    @PostMapping("/addAdAdsense")
    public ResultBean<Boolean> addAdAdsense(@RequestBody AdAdsense adAdsense) {
        return this.adAdsenseServiceInterface.addAdAdsense(adAdsense);
    }

    @Override
    @PostMapping("/deleteAdAdsense")
    public ResultBean<Boolean> deleteAdAdsense(@RequestBody String ids) {
        return this.adAdsenseServiceInterface.deleteAdAdsense(ids);
    }

    @Override
    public AdAdsense findAdsenseById(@RequestBody Long id) {
        return this.adAdsenseServiceInterface.findAdAdsenseById(id);
    }

    @Override
    public ResultBean<Boolean> deleteAdsenseList(@RequestBody AdAdsenseDto adAdsenseDto) {
        return this.adAdsenseServiceInterface.deleteAdsenseList(adAdsenseDto);
    }

    @Override
    public ResultBean<Boolean> updateAdsenseStatus(@RequestParam("id") Long id, @RequestParam("adsenseStatus") String adsenseStatus) {
        return this.adAdsenseServiceInterface.updateAdsenseStatus(id,adsenseStatus);
    }
    @Override
    public ResultBean<Integer> getAllAdsenseCount() {
        return this.adAdsenseServiceInterface.getAllAdsenseCount();
    }
}
