package cn.iocoder.yudao.module.crm.api.salesperformancesettlement;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crm.dal.dataobject.salesperformancesettlement.SalesPerformanceSettlementDO;
import cn.iocoder.yudao.module.crm.service.salesperformancesettlement.SalesPerformanceSettlementService;
import cn.iocoder.yudao.module.hrm.api.salesperformancesettlement.SalesPerformanceSettlementApi;
import cn.iocoder.yudao.module.hrm.api.salesperformancesettlement.dto.SalesPerformanceSettlementDTO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Flowable CRM Api 实现类
 */
@RestController
@Validated
public class SalesPerformanceSettlementApImpl implements SalesPerformanceSettlementApi {

    @Resource
    private SalesPerformanceSettlementService salesPerformanceSettlementService;


    @Override
    public CommonResult<Boolean> update(SalesPerformanceSettlementDTO salesPerformanceSettlementDTO) {
        salesPerformanceSettlementService.update(new SalesPerformanceSettlementDO().setSalesPerformanceId(salesPerformanceSettlementDTO.getSalesPerformanceId()),
                new LambdaQueryWrapper<SalesPerformanceSettlementDO>().eq(SalesPerformanceSettlementDO::getYear, salesPerformanceSettlementDTO.getYear())
                        .eq(SalesPerformanceSettlementDO::getMonth, salesPerformanceSettlementDTO.getMonth())
                        .eq(SalesPerformanceSettlementDO::getUserId, salesPerformanceSettlementDTO.getUserId()));
        return CommonResult.success(true);
    }
}
