package ctop.bytedance.ad.advertise.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import ctop.bytedance.ad.common.service.IMaterialInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * 头条智能投放账户配置信息表
 * @author jeecg-boot
 * @date   2021-04-20
 * @version V1.0
 */
@RestController
@RequestMapping("/bytedance/ad/advertiser/materialInfoController")
@Api(tags="视频素材")
@Slf4j
public class AdvertiserMaterialInfoController {
	@Autowired
	private IMaterialInfoService materialInfoService;



	@ApiOperation(value="素材下线", notes="素材下线")
	@GetMapping(value = "/updMaterialOfflineById")
	public Result updMaterialOfflineById(@RequestParam("id") String id,
								  		@RequestParam("offlineFlag") Integer offlineFlag) {
		try {
			List<String> listIds = Arrays.asList(id.split(","));
			if (listIds.size() > 8){
				return Result.errorMsg("已选视频素材最多支持8个。");
			}
			return materialInfoService.updMaterialOfflineById(listIds,offlineFlag);
		}catch (Exception e){
			log.error("素材下线异常",e);
			return Result.error("请求失败，请联系开发人员!");
		}
	}











}
