package cn.iocoder.yudao.module.crm.service.salesperformanceassessment;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.salesperformanceassessment.vo.SalesPerformanceAssessmentPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.salesperformanceassessment.vo.SalesPerformanceAssessmentSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.salesperformanceassessment.SalesPerformanceAssessmentDO;
import cn.iocoder.yudao.module.crm.dal.mysql.salesperformanceassessment.SalesPerformanceAssessmentMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 绩效考核设置 Service 实现类
 *
 * @author 艾楷
 */
@Service
@Validated
public class SalesPerformanceAssessmentServiceImpl extends ServiceImpl<SalesPerformanceAssessmentMapper, SalesPerformanceAssessmentDO> implements SalesPerformanceAssessmentService {

    @Resource
    private SalesPerformanceAssessmentMapper salesPerformanceAssessmentMapper;

    @Override
    public Long createSalesPerformanceAssessment(SalesPerformanceAssessmentSaveReqVO createReqVO) {
        // 插入
        SalesPerformanceAssessmentDO salesPerformanceAssessment = BeanUtils.toBean(createReqVO, SalesPerformanceAssessmentDO.class);
        salesPerformanceAssessmentMapper.insert(salesPerformanceAssessment);
        // 返回
        return salesPerformanceAssessment.getId();
    }

    @Override
    public void updateSalesPerformanceAssessment(SalesPerformanceAssessmentSaveReqVO updateReqVO) {
        // 更新
        SalesPerformanceAssessmentDO updateObj = BeanUtils.toBean(updateReqVO, SalesPerformanceAssessmentDO.class);
        salesPerformanceAssessmentMapper.updateById(updateObj);
    }

    @Override
    public void deleteSalesPerformanceAssessment(Long id) {
        // 删除
        salesPerformanceAssessmentMapper.deleteById(id);
    }

    @Override
    public SalesPerformanceAssessmentDO getSalesPerformanceAssessment(Long id) {
        return salesPerformanceAssessmentMapper.selectById(id);
    }

    @Override
    public PageResult<SalesPerformanceAssessmentDO> getSalesPerformanceAssessmentPage(SalesPerformanceAssessmentPageReqVO pageReqVO) {
        return salesPerformanceAssessmentMapper.selectPage(pageReqVO);
    }

}
