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.ComputePatientProjectGroupCostDetailMapper;
import com.kcim.dao.model.ComputePatientProjectGroupCostDetail;
import com.kcim.vo.SessionUserVO;
import org.springframework.stereotype.Repository;

import java.util.Date;

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

        this.update(updateWrapper);
    }
}
