package com.pig4cloud.pig.marketing.service.impl;


import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pig4cloud.pig.admin.api.dto.SysPublicParamDTO;
import com.pig4cloud.pig.admin.api.feign.RemoteParamService;
import com.pig4cloud.pig.common.core.exception.BusinessException;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.core.util.ip.IPUtils;
import com.pig4cloud.pig.marketing.api.dto.app.MarketingAppsDomainDTO;
import com.pig4cloud.pig.marketing.api.dto.app.MarketingAppsIpDTO;
import com.pig4cloud.pig.marketing.api.dto.config.*;
import com.pig4cloud.pig.marketing.api.entity.*;
import com.pig4cloud.pig.marketing.api.util.DomainValidationUtil;
import com.pig4cloud.pig.marketing.api.vo.config.*;
import com.pig4cloud.pig.marketing.mapper.*;
import com.pig4cloud.pig.marketing.service.MarketingAppsService;
import com.pig4cloud.pig.marketing.service.MarketingConfigService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.*;

import static com.pig4cloud.pig.marketing.api.MarketingConfigConstants.*;


/**
 * @author: lwh
 * @date: 2025-07-16
 * @description: 营销全局配置服务
 */

@Service
@Slf4j
@AllArgsConstructor
public class MarketingConfigServiceImpl implements MarketingConfigService {

	private final MarketingConfigGroupMapper groupMapper;

	private final MarketingGroupDomainMapper groupDomainMapper;

	private final MarketingGroupIpMapper groupIpMapper;

	private final MarketingAppsIpMapper ipMapper;

	private final MarketingAppsDomainMapper domainMapper;

	private  final MarketingAppsService appsService;

	private final RemoteParamService remoteParamService;

	/**
	 * 添加分组
	 * @param reqDto 分组信息
	 * @return Boolean
	 */
	@Override
	public R addMarketingConfigGroup(AddMarketingGroupDTO reqDto) {
		// 先查询是否已存在
		MarketingConfigGroup group = groupMapper.selectOne(Wrappers.<MarketingConfigGroup>lambdaQuery()
				.eq(MarketingConfigGroup::getGroupName, reqDto.getGroupName())
				.eq(MarketingConfigGroup::getGroupType, reqDto.getGroupType())
		);
		if (group != null){
			return R.failed("分组名已存在");
		}
		MarketingConfigGroup marketingConfigGroup = new MarketingConfigGroup();
		BeanUtils.copyProperties(reqDto, marketingConfigGroup);
		return groupMapper.insert(marketingConfigGroup) > 0?R.ok():R.failed();
	}

	/**
	 * 删除分组
	 * @param reqDto 入参
	 * @return Boolean
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Boolean delMarketingConfigGroup(DelMarketingGroupDTO reqDto) {
		List<Long> ids = reqDto.getIds();
		for (Long id : reqDto.getIds()) {
			MarketingConfigGroup group = groupMapper.selectOne(Wrappers.<MarketingConfigGroup>lambdaQuery()
					.eq(MarketingConfigGroup::getId, id)
					.eq(MarketingConfigGroup::getGroupType, reqDto.getGroupType())
			);
			if (group == null){
				if (reqDto.getGroupType() == 1)
					throw new BusinessException("分组id:"+id+",IP分组不存在");
				else
					throw new BusinessException("分组id:"+id+",域名分组不存在");
			}
		}

		// 删除分组
		int delGroup = groupMapper.deleteByIds(ids);
		// 删除分组下域名或ip
		if (reqDto.getGroupType() == 1){
			// 删除IP
			groupIpMapper.delete(Wrappers.<MarketingGroupIp>lambdaQuery().in(MarketingGroupIp::getGroupId, ids));
			// 删除应用、全局配置关联的IP分组
			ipMapper.delete(Wrappers.<MarketingAppsIp>lambdaQuery().in(MarketingAppsIp::getGroupId, ids));
		}else if (reqDto.getGroupType() == 2){
			// 删除域名
			groupDomainMapper.delete(Wrappers.<MarketingGroupDomain>lambdaQuery().in(MarketingGroupDomain::getGroupId, ids));
			// 删除应用、全局配置关联的域名分组
			domainMapper.delete(Wrappers.<MarketingAppsDomain>lambdaQuery().in(MarketingAppsDomain::getGroupId, ids));
		}
		return delGroup > 0;
	}

	/**
	 * 根据ID查询分组详情
	 * @param id ID
	 * @return 分组详情
	 */
	@Override
	public R getMarketingGroupDetail(Long id) {
		MarketingConfigGroup group = groupMapper.selectById(id);
		if (group == null){
			throw new BusinessException("id:"+id+",分组不存在");
		}
		if (group.getGroupType().equals(1)){
			// IP类型
			GetMarketingIpGroupVO rspVO = new GetMarketingIpGroupVO();
			rspVO.setId(group.getId());
			rspVO.setGroupName(group.getGroupName());

			// 查询分组下IP列表
			List<MarketingGroupIp> ipList = groupIpMapper.selectList(Wrappers.<MarketingGroupIp>lambdaQuery().eq(MarketingGroupIp::getGroupId, group.getId()));
			ArrayList<MarketingGroupIpVO> ips = new ArrayList<>();
			for (MarketingGroupIp ip : ipList) {
				MarketingGroupIpVO ipVO = new MarketingGroupIpVO();
				BeanUtils.copyProperties(ip, ipVO);
				ips.add(ipVO);
			}
			rspVO.setIps(ips);
			return R.ok(rspVO);
		}else if (group.getGroupType().equals(2)){
			// 域名类型
			GetMarketingDomainGroupVO rspVO = new GetMarketingDomainGroupVO();
			rspVO.setId(group.getId());
			rspVO.setGroupName(group.getGroupName());

			// 查询分组下域名列表
			List<MarketingGroupDomain> domains = groupDomainMapper.selectList(Wrappers.<MarketingGroupDomain>lambdaQuery()
					.eq(MarketingGroupDomain::getGroupId, group.getId()));

			ArrayList<MarketingGroupDomainVO> domainVOS = new ArrayList<>();
			for (MarketingGroupDomain domain : domains) {
				MarketingGroupDomainVO domainVO = new MarketingGroupDomainVO();
				BeanUtils.copyProperties(domain, domainVO);
				domainVOS.add(domainVO);
			}
			rspVO.setDomains(domainVOS);
			return R.ok(rspVO);
		}
		return R.failed();
	}

	/**
	 * 修改分组域名
	 * @param reqDto 分组域名信息
	 * @return Boolean
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public R modMarketingGroupDomain(ModMarketingGroupDomainDTO reqDto) {
		//先查询分组是否存在
		MarketingConfigGroup group = groupMapper.selectOne(Wrappers.<MarketingConfigGroup>lambdaQuery()
				.eq(MarketingConfigGroup::getId, reqDto.getId())
				.eq(MarketingConfigGroup::getGroupType, 2)
		);

		if (group == null){
			throw new BusinessException("分组id:"+reqDto.getId()+",分组不存在");
		}

		// 在查询域名是否重复
		MarketingConfigGroup groupExist = groupMapper.selectOne(Wrappers.<MarketingConfigGroup>lambdaQuery()
				.eq(MarketingConfigGroup::getGroupType, "2")
				.eq(MarketingConfigGroup::getGroupName, reqDto.getGroupName()));
		if (groupExist != null && !groupExist.getId().equals(reqDto.getId())){
			return R.failed("分组名已存在");
		}
		// 更新分组信息
		group.setGroupName(reqDto.getGroupName());
		group.setRemark(reqDto.getRemark());
		groupMapper.updateById(group);

		// 删除域名
		groupDomainMapper.deleteByIds(reqDto.getDelList());

		// 更新域名信息
		List<MarketingGroupDomainDTO> domains = reqDto.getDomains();
		for (MarketingGroupDomainDTO domainDto : domains) {
			if (domainDto.getId() != null && (domainDto.getModify()==null || !domainDto.getModify())){
				continue;
			}


			// 域名格式校验
			if(!DomainValidationUtil.isValidDomain(domainDto.getDomain())){
				throw new BusinessException("域名格式不合法（支持字母、数字、下划线、横线、点）");
			}

			// 校验域名是否重复
			MarketingGroupDomain domainExist = groupDomainMapper.selectOne(Wrappers.<MarketingGroupDomain>lambdaQuery()
					.eq(MarketingGroupDomain::getDomain, domainDto.getDomain())
					.eq(MarketingGroupDomain::getGroupId, reqDto.getId())
			);
			if (domainExist != null && !domainExist.getId().equals(domainDto.getId())){
				return R.failed("域名:"+domainDto.getDomain()+"已存在");
			}

			// 新增、修改
			MarketingGroupDomain domain = new MarketingGroupDomain();
			BeanUtils.copyProperties(domainDto, domain);
			domain.setGroupId(reqDto.getId());
			if (domainDto.getId() == null){
				// 新增
				groupDomainMapper.insert(domain);
			} else if (domainDto.getModify() != null && domainDto.getModify()){
				// 修改
				groupDomainMapper.updateById(domain);
			}
		}
		return R.ok();
	}

	/**
	 * 获取域名分组列表
	 * @return 域名分组列表
	 */
	@Override
	public List<GetMarketingDomainGroupVO> getMarketingDomainGroupList() {
		List<MarketingConfigGroup> domainGroups = groupMapper.selectList(Wrappers.<MarketingConfigGroup>lambdaQuery().eq(MarketingConfigGroup::getGroupType, 2));

		ArrayList<GetMarketingDomainGroupVO> result = new ArrayList<>();
		for (MarketingConfigGroup domainGroup : domainGroups) {
			GetMarketingDomainGroupVO rspVO = new GetMarketingDomainGroupVO();
			rspVO.setId(domainGroup.getId());
			rspVO.setGroupName(domainGroup.getGroupName());

			// 查询分组下域名列表
			List<MarketingGroupDomain> domains = groupDomainMapper.selectList(Wrappers.<MarketingGroupDomain>lambdaQuery().eq(MarketingGroupDomain::getGroupId, domainGroup.getId()));
			ArrayList<MarketingGroupDomainVO> domainVOS = new ArrayList<>();
			for (MarketingGroupDomain domain : domains) {
				MarketingGroupDomainVO domainVO = new MarketingGroupDomainVO();
				BeanUtils.copyProperties(domain, domainVO);
				domainVOS.add(domainVO);
			}
			rspVO.setDomains(domainVOS);
			result.add(rspVO);
		}
		return result;
	}

	/**
	 * 修改分组IP
	 * @param reqDto 修改IP分组入参
	 * @return R
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public R modMarketingGroupIp(ModMarketingGroupIPDTO reqDto) {
		//先查询分组是否存在
		MarketingConfigGroup group = groupMapper.selectOne(Wrappers.<MarketingConfigGroup>lambdaQuery()
				.eq(MarketingConfigGroup::getId, reqDto.getId())
				.eq(MarketingConfigGroup::getGroupType, 1)
		);

		if (group == null){
			throw new BusinessException("分组id:"+reqDto.getId()+",分组不存在");
		}

		MarketingConfigGroup groupExist = groupMapper.selectOne(Wrappers.<MarketingConfigGroup>lambdaQuery()
				.eq(MarketingConfigGroup::getGroupType, "1")
				.eq(MarketingConfigGroup::getGroupName, reqDto.getGroupName())
		);
		if (groupExist != null && !groupExist.getId().equals(reqDto.getId())){
			return R.failed("分组名已存在");
		}

		// 更新分组信息
		 group.setGroupName(reqDto.getGroupName());
		 group.setRemark(reqDto.getRemark());
		 groupMapper.updateById(group);

		// 删除分组ip
		 groupIpMapper.deleteByIds(reqDto.getDelList());

		 // 更新IP信息
		List<MarketingGroupIPDTO> ips = reqDto.getIps();
		for (MarketingGroupIPDTO ipDto : ips) {
			if (ipDto.getId() != null && (ipDto.getModify()==null || !ipDto.getModify())){
				continue;
			}
			// 去除无用数据
			if (ipDto.getIpMode() == 1){
				ipDto.setEndIp(null);
			}

			// ip格式校验
			if (!IPUtils.isValidIp(ipDto.getStartIp())){
				throw new BusinessException("IP格式不合法（IPv4）");
			}
			if (ipDto.getIpMode() == 2){
				if (!IPUtils.isValidIp(ipDto.getEndIp())){
					throw new BusinessException("结束IP格式不合法（IPv4）");
				}
				if (!IPUtils.isEndIpGreater(ipDto.getStartIp(), ipDto.getEndIp())){
					throw new BusinessException("结束IP不能小于开始IP");
				}
			}

			// 校验是否重复
			Boolean isExist = groupIpMapper.checkIpConflict(ipDto.getIpMode(),ipDto.getStartIp(), ipDto.getEndIp(), ipDto.getId(), reqDto.getId());
			if (isExist){
				if (ipDto.getIpMode() == 1){
					throw new BusinessException("ip:"+ipDto.getStartIp()+"已存在");
				}
				String[] end = ipDto.getEndIp().split("\\.");
				throw new BusinessException("ip:"+ipDto.getStartIp()+"/"+end[3]+"已存在、或有重叠");
			}

			// 新增、修改
			MarketingGroupIp groupIp = new MarketingGroupIp();
			BeanUtils.copyProperties(ipDto, groupIp);
			groupIp.setGroupId(reqDto.getId());
			 if (ipDto.getId() == null){
				 // 新增
				 groupIpMapper.insert(groupIp);
			 }else if (ipDto.getModify() != null && ipDto.getModify()){
				 // 修改
				 groupIpMapper.updateById(groupIp);
			 }
		}
		return R.ok();
	}

	/**
	 * 获取ip分组列表
	 * @return ip分组列表
	 */
	@Override
	public List<GetMarketingIpGroupVO> getMarketingIpGroupList() {
		List<MarketingConfigGroup> ipGroups = groupMapper.selectList(Wrappers.<MarketingConfigGroup>lambdaQuery().eq(MarketingConfigGroup::getGroupType, 1));

		ArrayList<GetMarketingIpGroupVO> result = new ArrayList<>();
		for (MarketingConfigGroup ipGroup : ipGroups) {
			GetMarketingIpGroupVO rspVO = new GetMarketingIpGroupVO();
			rspVO.setId(ipGroup.getId());
			rspVO.setGroupName(ipGroup.getGroupName());

			// 查询分组下IP列表
			List<MarketingGroupIp> ipList = groupIpMapper.selectList(Wrappers.<MarketingGroupIp>lambdaQuery().eq(MarketingGroupIp::getGroupId, ipGroup.getId()));
			ArrayList<MarketingGroupIpVO> ips = new ArrayList<>();
			for (MarketingGroupIp ip : ipList) {
				MarketingGroupIpVO ipVO = new MarketingGroupIpVO();
				BeanUtils.copyProperties(ip, ipVO);
				ips.add(ipVO);
			}
			rspVO.setIps(ips);
			result.add(rspVO);
		}
		return result;
	}

	/**
	 * 获取IP集合
	 * @return IP集合
	 */
	@Override
	public List<GetMarketingConfigIpListVO> getMarketingConfigIpList() {
		List<GetMarketingConfigIpListVO> result = new ArrayList<>();
		List<MarketingAppsIp> ips = ipMapper.selectList(Wrappers.<MarketingAppsIp>lambdaQuery().eq(MarketingAppsIp::getConfig, true));
		ips.forEach(ip -> {
			GetMarketingConfigIpListVO ipVO = new GetMarketingConfigIpListVO();
			BeanUtils.copyProperties(ip, ipVO);

			if (ip.getGroupId() != null){
				MarketingConfigGroup group = groupMapper.selectById(ip.getGroupId());
				if (group != null)
					ipVO.setGroupName(group.getGroupName());
			}
			result.add(ipVO);
		});
		return result;
	}

	/**
	 * 添加IP集合
	 * @param reqDto 添加IP集合入参
	 * @return Boolean
	 */
	@Override
	public Boolean addMarketingConfigIpList(AddMarketingConfigIpListDTO reqDto) {

		// 去除无用数据
		if (reqDto.getSourceType() == 1){
			reqDto.setIpMode(null);
			reqDto.setStartIp(null);
			reqDto.setEndIp( null);

			// 查询分组是否存在
			MarketingConfigGroup group = groupMapper.selectOne(Wrappers.<MarketingConfigGroup>lambdaQuery()
					.eq(MarketingConfigGroup::getId, reqDto.getGroupId())
					.eq(MarketingConfigGroup::getGroupType, 1)
			);
			if (group == null){
				throw new BusinessException("分组ID:"+reqDto.getGroupId()+"不存在");
			}
		}else {
			reqDto.setGroupId(null);
			reqDto.setGroupName(null);
			if (reqDto.getIpMode() == 1){
				reqDto.setEndIp(null);
			}
		}
		// 校验IP是否存在
		MarketingAppsIpDTO ipDTO = new MarketingAppsIpDTO();
		BeanUtils.copyProperties(reqDto, ipDTO);
		if (appsService.checkIp(ipDTO,null, true)){
			if (reqDto.getSourceType() ==1){
				throw new BusinessException("分组ID:"+reqDto.getGroupId()+"已存在");
			}
			if (ipDTO.getIpMode() == 1) {
				throw new BusinessException("ip:" + ipDTO.getStartIp() + "已存在");
			}
			String[] end = ipDTO.getEndIp().split("\\.");
			throw new BusinessException("ip:" + ipDTO.getStartIp() + "/" + end[3] + "已存在");
		}
		MarketingAppsIp marketingAppsIp = new MarketingAppsIp();
		BeanUtils.copyProperties(reqDto, marketingAppsIp);
		marketingAppsIp.setConfig(true);
		int insert = ipMapper.insert(marketingAppsIp);
		return insert > 0;
	}

	/**
	 * 删除IP集合
	 * @param id id
	 * @return Boolean
	 */
	@Override
	public Boolean delMarketingConfigIpList(Long id) {
		MarketingAppsIp ip = ipMapper.selectOne(Wrappers.<MarketingAppsIp>lambdaQuery()
				.eq(MarketingAppsIp::getId, id)
				.eq(MarketingAppsIp::getConfig, true));
		if (ip == null) {
			throw new BusinessException("id: "+id+" ,IP不存在");
		}
		int delete = ipMapper.deleteById(id);
		return delete > 0;
	}

	/**
	 * 获取域名集合
	 * @return 域名集合
	 */
	@Override
	public List<GetMarketingConfigDomainListVO> getMarketingConfigDomainList() {
		List<GetMarketingConfigDomainListVO> result = new ArrayList<>();

		List<MarketingAppsDomain> domains = domainMapper.selectList(Wrappers.<MarketingAppsDomain>lambdaQuery().eq(MarketingAppsDomain::getConfig, true));
		domains.forEach(domain -> {
			GetMarketingConfigDomainListVO domainVO = new GetMarketingConfigDomainListVO();
			BeanUtils.copyProperties(domain, domainVO);
			if (domain.getGroupId() != null){
				MarketingConfigGroup group = groupMapper.selectById(domain.getGroupId());
				if (group != null)
					domainVO.setGroupName(group.getGroupName());
			}
			result.add(domainVO);
		});
		return result;
	}

	/**
	 * 添加域名集合
	 * @param reqDto 添加域名集合入参
	 * @return Boolean
	 */
	@Override
	public Boolean addMarketingConfigDomainList(AddMarketingConfigDomainListDTO reqDto) {

		if (reqDto.getSourceType() == 1){
			reqDto.setDomain(null);
			// 查询分组是否存在
			MarketingConfigGroup group = groupMapper.selectOne(Wrappers.<MarketingConfigGroup>lambdaQuery()
					.eq(MarketingConfigGroup::getId, reqDto.getGroupId())
					.eq(MarketingConfigGroup::getGroupType, 2)
			);
			if (group == null){
				throw new BusinessException("分组ID:"+reqDto.getGroupId()+"不存在");
			}
		}else {
			reqDto.setGroupId(null);
			reqDto.setGroupName(null);
		}
		// 校验域名是否存在
		MarketingAppsDomainDTO domainDTO = new MarketingAppsDomainDTO();
		BeanUtils.copyProperties(reqDto, domainDTO);
		if (appsService.checkDomain(domainDTO, null, true)){
			throw new BusinessException("域名:"+reqDto.getDomain()+"已存在");
		}

		MarketingAppsDomain domain = new MarketingAppsDomain();
		BeanUtils.copyProperties(reqDto, domain);
		domain.setConfig( true);
		int insert = domainMapper.insert(domain);
		return insert > 0;
	}

	/**
	 * 删除域名集合
	 * @param id id
	 * @return Boolean
	 */
	@Override
	public Boolean delMarketingConfigDomainList(Long id) {
		// 判断是否存在
		MarketingAppsDomain domain = domainMapper.selectOne(Wrappers.<MarketingAppsDomain>lambdaQuery()
				.eq(MarketingAppsDomain::getId, id)
				.eq(MarketingAppsDomain::getConfig, true));
		if (domain == null){
			throw new BusinessException("id:"+id+",域名不存在");
		}
		int delete = domainMapper.deleteById(id);
		return delete > 0;
	}

	/**
	 * 查询全局配置信息
	 * @return 全局配置信息
	 */
	@Override
	public GetMarketingGlobalConfigVO getMarketingGlobalConfig() {
		GetMarketingGlobalConfigVO res = new GetMarketingGlobalConfigVO();
		R<ArrayList<SysPublicParamDTO>> ParamDTO = remoteParamService.getParamList(Arrays.asList(TRIGGER_MODE, TRIGGER_RULE, TRIGGER_NUM, PROMPT_MSG, URL));
		ParamDTO.getData().forEach(item -> {
			switch (item.getPublicKey()) {
				case TRIGGER_MODE:
					res.setTriggerMode(Integer.valueOf(item.getPublicValue()));
					break;
				case TRIGGER_RULE:
					res.setTriggerRule(Integer.valueOf(item.getPublicValue()));
					break;
				case TRIGGER_NUM:
					res.setTriggerNum(item.getPublicValue());
					break;
				case PROMPT_MSG:
					res.setPromptMsg(item.getPublicValue());
					break;
				case URL:
					res.setUrl(item.getPublicValue());
					break;
			}
		});
		return res;
	}

	/**
	 * 修改全局配置
	 * @param reDto 全局配置信息
	 * @return Boolean
	 */
	@Override
	public Boolean setMarketingGlobalConfig(GetMarketingGlobalConfigVO reDto) {
		List<SysPublicParamDTO> sysParamList = new ArrayList<>();
		SysPublicParamDTO sysParam = new SysPublicParamDTO();
		if (reDto.getTriggerMode() != null){
			sysParam.setPublicKey(TRIGGER_MODE);
			sysParam.setPublicValue(reDto.getTriggerMode().toString());
			sysParamList.add(sysParam);
		}
		if (reDto.getTriggerRule() != null){
			sysParam = new SysPublicParamDTO();
			sysParam.setPublicKey(TRIGGER_RULE);
			sysParam.setPublicValue(reDto.getTriggerRule().toString());
			sysParamList.add(sysParam);
		}
		if (StringUtils.isNotBlank(reDto.getTriggerNum())){
			BigDecimal bigDecimal = new BigDecimal(reDto.getTriggerNum());
			if (bigDecimal.compareTo(BigDecimal.ZERO) < 0){
				throw new BusinessException("触发频率不能小于0");
			}
			if (bigDecimal.compareTo(new BigDecimal("10000")) > 0) {
				throw new BusinessException("触发频率不能大于10000");
			}
			sysParam = new SysPublicParamDTO();
			sysParam.setPublicKey(TRIGGER_NUM);
			sysParam.setPublicValue(reDto.getTriggerNum());
			sysParamList.add(sysParam);
		}
		if (StringUtils.isNotBlank(reDto.getPromptMsg())){
			sysParam = new SysPublicParamDTO();
			sysParam.setPublicKey(PROMPT_MSG);
			sysParam.setPublicValue(reDto.getPromptMsg());
			sysParamList.add(sysParam);
		}
		if (StringUtils.isNotBlank(reDto.getUrl())){
			sysParam = new SysPublicParamDTO();
			sysParam.setPublicKey(URL);
			sysParam.setPublicValue(reDto.getUrl());
			sysParamList.add(sysParam);
		}
		remoteParamService.setByKey(sysParamList);
		return null;
	}

//	@Override
//	public Boolean getMarketingConfig(AddMarketingConfigDomainListDTO reqDto) {
//		// 判断域名表中是否重复
//		// 判断分组中是否重复
//
//		MarketingAppsDomain domain = new MarketingAppsDomain();
//		BeanUtils.copyProperties(reqDto, domain);
//		domain.setConfig( true);
//		int insert = domainMapper.insert(domain);
//		return insert > 0;
//	}
}
