package cn.com.ctop.kuaishou.modules.batch.service.impl;

import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaignTemplate;
import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignTemplateMapper;
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignTemplateService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 快手-创建广告计划模板
 * @Author: jeecg-boot
 * @Date: 2019-08-06
 * @Version: V1.0
 */
@Service
public class KuaiShouCampaignTemplateServiceImpl extends ServiceImpl<KuaiShouCampaignTemplateMapper, KuaiShouCampaignTemplate> implements IKuaiShouCampaignTemplateService {

    @Autowired
    private KuaiShouCampaignTemplateMapper campaignTemplateMapper;

    /**
     * 创建广告创意模板
     *
     * @param template
     * @return
     */
    @Override
    public Map<String, Object> insertTemplate(KuaiShouCampaignTemplate template) {
        Map<String, Object> resultMap = new HashMap<>();
        try {
            template.setDayBudget(template.getDayBudget() * 1000);
            campaignTemplateMapper.insert(template);


            resultMap.put("success", true);
            resultMap.put("message", "创建广告创意成功");
            resultMap.put("code", 0);
        } catch (Exception e) {
            resultMap.put("success", false);
            resultMap.put("message", "创建广告创意失败");
            resultMap.put("code", -1);
        }
        return resultMap;
    }
}
