package com.sptg.gateway.controller.ad;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.ad.api.constant.AdSecurityToken;
import com.sptg.ad.api.dto.AdPushDeviceDetailsDto;
import com.sptg.ad.api.entity.AdPushDeviceDetails;
import com.sptg.ad.api.feigns.AdPushDeviceDetailsFeign;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.security.annotation.Security;
import com.sptg.common.security.enums.DataFormatEnum;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * title: AdPushDeviceDetailsController
 * package: com.sptg.gateway.controller.ad
 * description: 广告任务发布到设备详情
 *
 *               
 *                 
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/ad/device")
public class AdPushDeviceDetailsController {

    private final AdPushDeviceDetailsFeign adPushDeviceDetailsFeign;

    /**
     * 功能描述:广告发布页面
     * @param
     * @return
     *               
     *                      
     */
    @GetMapping("/details/view")
    @Security(token = AdSecurityToken.AD_PUSH_MONITORING_DETAIL,format = DataFormatEnum.JSON)
    public ModelAndView index(Long taskId){
        ModelAndView modelAndView = new ModelAndView("ad/ad-push-device-details");
        modelAndView.addObject("taskId", taskId);
        return modelAndView;
    }

    @PostMapping(value = "/details/showAdPushDeviceDetails")
    @Security(token = AdSecurityToken.AD_PUSH_MONITORING_DETAIL,format = DataFormatEnum.JSON)
    public ResultBean<Page<AdPushDeviceDetails>> showAdPushDeviceDetails(AdPushDeviceDetailsDto adPushDeviceDetailsDto,Page<AdPushDeviceDetails> page){
        adPushDeviceDetailsDto.setPage(page);
        return this.adPushDeviceDetailsFeign.showAdPushDeviceDetails(adPushDeviceDetailsDto);
    }
}
