package com.yc.ship.module.marketing.service.params;

import com.yc.ship.framework.common.util.object.BeanUtils;
import com.yc.ship.module.marketing.controller.app.params.vo.AppParamsSaveVo;
import com.yc.ship.module.marketing.dal.dataobject.params.MarketingParamsDO;
import com.yc.ship.module.marketing.dal.mysql.params.MarketingParamsMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 全民分销-保存小程序参数 Service 实现类
 *
 * @author luofieyun
 */
@Service
@Validated
public class MarketingParamsImpl implements MarketingParamsService {

    @Resource
    private MarketingParamsMapper marketingParamsMapper;
    @Override
    public Long createParams(AppParamsSaveVo createReqVO) {
        MarketingParamsDO marketingParamsDO = BeanUtils.toBean(createReqVO, MarketingParamsDO.class);
        marketingParamsMapper.insert(marketingParamsDO);
        return marketingParamsDO.getId();
    }

    @Override
    public String getParams(Long id) {
        MarketingParamsDO marketingParamsDO = marketingParamsMapper.selectById(id);
        if(marketingParamsDO != null) {
            return marketingParamsDO.getParams();
        }
        return null;
    }
}