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

import java.util.Date;

/**
 * @program: CostAccount
 * @description:
 * @author: Wang.YS
 * @create: 2024-06-25 11:03
 **/
@Repository
public class ComputeStandProjectGroupCostDetailRepository extends ServiceImpl<ComputeStandProjectGroupCostDetailMapper, ComputeStandProjectGroupCostDetail> {
    public void removeByComputeDate(String computeDate, SessionUserVO currentUser) {
        UpdateWrapper<ComputeStandProjectGroupCostDetail> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(ComputeStandProjectGroupCostDetail::getDelFlag, 0)
                .eq(ComputeStandProjectGroupCostDetail::getHospId, currentUser.getHospId())
                .eq(ComputeStandProjectGroupCostDetail::getComputeDate, computeDate)
                .set(ComputeStandProjectGroupCostDetail::getDeleteTime,new Date())
                .set(ComputeStandProjectGroupCostDetail::getDeleteUser,String.valueOf(currentUser.getId()))
                .set(ComputeStandProjectGroupCostDetail::getDelFlag, 1);
        this.update(updateWrapper);
    }
}
