package com.ssm.manage.service.impl;

import com.ssm.core.service.impl.BaseServiceImpl;
import com.ssm.manage.dao.SsmDocPromotionProjectDao;
import com.ssm.manage.entity.DocPromotionProject;
import com.ssm.manage.entity.PromotionList;
import com.ssm.manage.query.DocPromotionRequest;
import com.ssm.manage.service.SsmDocPromotionProjectService;
import com.ssm.manage.service.SsmPromotionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class SsmDocPromotionProjectServiceImpl extends BaseServiceImpl<DocPromotionProject> implements SsmDocPromotionProjectService {
    @Autowired
    private SsmDocPromotionProjectDao dao;

    @Autowired
    private SsmPromotionService ssmPromotionService;

    @Override
    public SsmDocPromotionProjectDao getDao() {
        return dao;
    }

    @Override
    public List<DocPromotionProject> selectList(DocPromotionRequest docPromotionRequest) {
        PromotionList promotionList = new PromotionList();
        promotionList.setId(docPromotionRequest.getPromotionId());
        PromotionList promotionList1 = ssmPromotionService.selectByPrimaryKey(promotionList.getId());
        docPromotionRequest.setStoreId(promotionList1.getStoreId());
        DocPromotionProject docPromotionProject = new DocPromotionProject();
        BeanUtils.copyProperties(docPromotionRequest, docPromotionProject);
        List<DocPromotionProject> list = dao.select(docPromotionProject);
        return list;
    }
}
