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.ComputePatientProjectCostDetailMapper;
import com.kcim.dao.model.ComputePatientProjectCostDetail;
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 17:06
 **/
@Repository
public class ComputePatientProjectCostDetailRepository extends ServiceImpl<ComputePatientProjectCostDetailMapper, ComputePatientProjectCostDetail> {
    public void removeByComputeDate(String computeDate, SessionUserVO currentUser) {
        UpdateWrapper<ComputePatientProjectCostDetail> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(ComputePatientProjectCostDetail::getDelFlag, 0)
                .eq(ComputePatientProjectCostDetail::getHospId, currentUser.getHospId())
                .eq(ComputePatientProjectCostDetail::getComputeDate, computeDate)
                .set(ComputePatientProjectCostDetail::getDeleteTime,new Date())
                .set(ComputePatientProjectCostDetail::getDeleteUser,String.valueOf(currentUser.getId()))
                .set(ComputePatientProjectCostDetail::getDelFlag, 1);

        this.update(updateWrapper);
    }

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

    }
}
