package com.kcim.dao.repository;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.kcim.dao.mapper.ComputeProjectGroupCostDetailMapper;
import com.kcim.dao.model.ComputeProjectGroupCostDetail;
import com.kcim.service.impl.BaseBatchServiceImpl;
import com.kcim.vo.SessionUserVO;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * @program: CostAccount
 * @description:
 * @author: Wang.YS
 * @create: 2024-01-19 15:58
 **/
@Repository
public class ComputeProjectGroupCostDetailRepository extends BaseBatchServiceImpl<ComputeProjectGroupCostDetailMapper, ComputeProjectGroupCostDetail> {
    public void removeByComputeDate(String computeDate, SessionUserVO currentUser) {

        UpdateWrapper<ComputeProjectGroupCostDetail> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(ComputeProjectGroupCostDetail::getDelFlag, 0)
                .eq(ComputeProjectGroupCostDetail::getHospId, currentUser.getHospId())
                .eq(ComputeProjectGroupCostDetail::getComputeDate, computeDate)
                .set(ComputeProjectGroupCostDetail::getDeleteTime,new Date())
                .set(ComputeProjectGroupCostDetail::getDeleteUser,String.valueOf(currentUser.getId()))
                .set(ComputeProjectGroupCostDetail::getDelFlag, 1);
        this.update(updateWrapper);
    }
}
