package com.kcim.dao.repository;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kcim.common.util.UserContext;
import com.kcim.dao.mapper.ComputeStandShareParamDetailMapper;
import com.kcim.dao.model.ComputeStandShareParamDetail;
import com.kcim.vo.ComputeDateShareParamVo;
import com.kcim.vo.SessionUserVO;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @program: CostAccount
 * @description:
 * @author: Wang.YS
 * @create: 2024-06-27 15:14
 **/
@Repository
public class ComputeStandShareParamDetailRepository extends ServiceImpl<ComputeStandShareParamDetailMapper, ComputeStandShareParamDetail> {
    public List<ComputeDateShareParamVo> getByShareParamId(String computeDate, List<Integer> collect1) {
        return this.baseMapper.getByShareParamId( computeDate, UserContext.getHospId(),collect1);

    }

    public void removeByComputeDate(String computeDate, SessionUserVO currentUser) {
        UpdateWrapper<ComputeStandShareParamDetail> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(ComputeStandShareParamDetail::getDelFlag, 0)
                .eq(ComputeStandShareParamDetail::getHospId, currentUser.getHospId())
                .eq(ComputeStandShareParamDetail::getComputeDate, computeDate)
                .set(ComputeStandShareParamDetail::getDeleteTime,new Date())
                .set(ComputeStandShareParamDetail::getDeleteUser,String.valueOf(currentUser.getId()))
                .set(ComputeStandShareParamDetail::getDelFlag, 1);

        this.update(updateWrapper);
    }
}
