package com.kcim.dao.repository;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kcim.dao.mapper.ComputeStandPatientProjectCostDetailMapper;
import com.kcim.dao.model.ComputeStandPatientProjectCostDetail;
import com.kcim.vo.SessionUserVO;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * @program: CostAccount
 * @description:
 * @author: Wang.YS
 * @create: 2024-06-27 20:44
 **/
@Repository
public class ComputeStandPatientProjectCostDetailRepository extends ServiceImpl<ComputeStandPatientProjectCostDetailMapper, ComputeStandPatientProjectCostDetail> {
    public void removeByComputeDate(String computeDate, SessionUserVO currentUser) {
        UpdateWrapper<ComputeStandPatientProjectCostDetail> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(ComputeStandPatientProjectCostDetail::getDelFlag, 0)
                .eq(ComputeStandPatientProjectCostDetail::getHospId, currentUser.getHospId())
                .eq(ComputeStandPatientProjectCostDetail::getComputeDate, computeDate)
                .set(ComputeStandPatientProjectCostDetail::getDeleteTime,new Date())
                .set(ComputeStandPatientProjectCostDetail::getDeleteUser,String.valueOf(currentUser.getId()))
                .set(ComputeStandPatientProjectCostDetail::getDelFlag, 1);

        this.update(updateWrapper);
    }
}
