package com.sptg.ad.biz.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.ad.api.dto.AdPushAppDto;
import com.sptg.ad.api.entity.AdPushApp;
import com.sptg.ad.api.feigns.AdPushAppFeign;
import com.sptg.ad.biz.service.AdPushAppServiceInterface;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.common.core.constant.OperationConstant;
import lombok.RequiredArgsConstructor;
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.RestController;

/**
 * title: AdTypeController
 * package: com.sptg.ad.biz.controller
 * description: 广告类型-控制器
 *
 *               
 *                 
 */
@RestController
@RequestMapping(value = "/ad/push/app")
@RequiredArgsConstructor
public class AdPushAppController implements AdPushAppFeign {

    private final AdPushAppServiceInterface adPushAppServiceInterface;

    @Override
    @PostMapping(value = "/showList")
    public ResultBean<Page<AdPushApp>> showList(@RequestBody AdPushAppDto dto) {
        return this.adPushAppServiceInterface.showList(dto);
    }

    @Override
    @PostMapping(value = "/addEntity")
    public ResultBean<Boolean> addEntity(@RequestBody AdPushApp adPushApp) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.adPushAppServiceInterface.insert(adPushApp));
    }

    @Override
    @PostMapping(value = "/updateIsEnable")
    public ResultBean<Boolean> updateIsEnable(@RequestBody AdPushAppDto dto) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.adPushAppServiceInterface.updateById(dto));
    }

    @Override
    @PostMapping(value = "/delete")
    public ResultBean<Boolean> delete(@RequestBody Long id) {
        AdPushApp adPushApp = new AdPushApp();
        adPushApp.setId(id);
        adPushApp.setStatus(OperationConstant.MINUS_ONE);
        return new ResultBean<>(ResultEnum.SUCCESS,this.adPushAppServiceInterface.updateById(adPushApp));
    }

    @Override
    @PostMapping(value = "/findById")
    public ResultBean<AdPushApp> findById(@RequestBody Long id) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.adPushAppServiceInterface.selectById(id));
    }

    @Override
    @PostMapping(value = "/editById")
    public ResultBean<Boolean> editById(@RequestBody AdPushApp adPushApp) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.adPushAppServiceInterface.updateById(adPushApp));
    }

    @Override
    @PostMapping(value = "/getList")
    public ResultBean<AdPushApp> getList(@RequestBody AdPushAppDto dto) {
        return this.adPushAppServiceInterface.getList(dto);
    }
}
