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

        this.update(updateWrapper);
    }
}
