package com.sptg.ad.biz.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.ad.api.dto.AdTypeDto;
import com.sptg.ad.api.entity.AdType;
import com.sptg.ad.api.feigns.AdTypeFeign;
import com.sptg.ad.biz.service.AdTypeServiceInterface;
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.*;

import java.util.List;

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

    private final AdTypeServiceInterface adTypeServiceInterface;


    /**
     * 查询广告类型列表(分页)
     * @param
     * @return 分页查询结果
     *               
     *                      
     */
    @Override
    @PostMapping(value = "/showAdTypeList")
    public ResultBean<Page<AdType>> showAdTypeList(@RequestBody AdTypeDto adTypeDto){
       Page<AdType> adTypePage = adTypeServiceInterface.showAdTypeList(adTypeDto);
       return new ResultBean<>(ResultEnum.SUCCESS,adTypePage);
    }

    @Override
    @PostMapping(value = "/addAdType")
    public ResultBean<Boolean> addAdType(@RequestBody AdType adType) {
        return this.adTypeServiceInterface.addAdType(adType);
    }

    @Override
    @PostMapping(value = "/deleteAdType")
    public ResultBean<Boolean> deleteAdType(@RequestBody String ids) {
        return this.adTypeServiceInterface.deleteAdType(ids);
    }

    @Override
    @PostMapping(value = "/getAdTypeList")
    public ResultBean<AdType> getAdTypeList(@RequestBody Long rootOrgId) {
        return this.adTypeServiceInterface.getAdTypeList(rootOrgId);
    }

    @Override
    @PostMapping(value = "/checkAdTypeName")
    public ResultBean<Boolean> checkAdTypeName(@RequestBody AdType adType) {
        return this.adTypeServiceInterface.checkAdTypeName(adType);
    }

    @Override
    @PostMapping(value = "/getAdTypeById")
    public AdType getAdTypeById(@RequestBody Long id) {
        return this.adTypeServiceInterface.getAdTypeById(id);
    }

    @Override
    @PostMapping(value = "/getAdTypeCount")
    public Integer getAdTypeCount(@RequestBody AdTypeDto adTypeDto) {
        return this.adTypeServiceInterface.getAdTypeCount(adTypeDto);
    }

    public AdTypeController(AdTypeServiceInterface adTypeServiceInterface){
        this.adTypeServiceInterface = adTypeServiceInterface;
    }
}
