package com.kcim.dao.repository;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kcim.common.util.UserContext;
import com.kcim.dao.mapper.ComputeStandProjectCostDetailMapper;
import com.kcim.dao.model.ComputeStandProjectCostDetail;
import com.kcim.vo.ComputeProjectCostPageDto;
import com.kcim.vo.SessionUserVO;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @program: CostAccount
 * @description:
 * @author: Wang.YS
 * @create: 2024-06-25 11:03
 **/
@Repository
public class ComputeStandProjectCostDetailRepository extends ServiceImpl<ComputeStandProjectCostDetailMapper, ComputeStandProjectCostDetail> {
    public void removeByComputeDate(String computeDate, SessionUserVO currentUser) {
        UpdateWrapper<ComputeStandProjectCostDetail> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(ComputeStandProjectCostDetail::getDelFlag, 0)
                .eq(ComputeStandProjectCostDetail::getHospId, currentUser.getHospId())
                .eq(ComputeStandProjectCostDetail::getComputeDate, computeDate)
                .set(ComputeStandProjectCostDetail::getDeleteTime,new Date())
                .set(ComputeStandProjectCostDetail::getDeleteUser,String.valueOf(currentUser.getId()))
                .set(ComputeStandProjectCostDetail::getDelFlag, 1);
        this.update(updateWrapper);
    }

    public List<ComputeProjectCostPageDto> getByProjectCostId(String computeDate, List<Integer> collect1) {
        return this.baseMapper.getByProjectCostId( computeDate, UserContext.getHospId(),collect1);

    }
}
