package com.hotent.project.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hotent.baseInfo.manager.AuditedUnitManager;
import com.hotent.baseInfo.model.AuditedUnit;
import com.hotent.constant.BaseConstant;
import com.hotent.project.dao.CostProjectTaskPreliminaryOpinionDao;
import com.hotent.project.manager.CostProjectTaskManager;
import com.hotent.project.manager.CostProjectTaskPreliminaryOpinionManager;
import com.hotent.project.model.CostProjectTask;
import com.hotent.project.model.CostProjectTaskPreliminaryOpinion;
import com.hotent.base.manager.impl.BaseManagerImpl;
import com.hotent.uc.api.model.IUser;
import com.hotent.uc.util.ContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 成本审核意见表 服务实现类（包含初步意见、反馈意见、结论意见）
 *
 * @company 山西清众科技股份有限公司
 * @author 超级管理员
 * @since 2025-01-27
 */
@Service
public class CostProjectTaskPreliminaryOpinionManagerImpl extends BaseManagerImpl<CostProjectTaskPreliminaryOpinionDao, CostProjectTaskPreliminaryOpinion> implements CostProjectTaskPreliminaryOpinionManager {

    @Autowired
    private AuditedUnitManager auditedUnitManager;

    @Autowired
    private CostProjectTaskManager costProjectTaskManager;

    @Override
    public CostProjectTaskPreliminaryOpinion getDetail(String id) {
        CostProjectTaskPreliminaryOpinion opinion = this.get(id);
        return opinion;
    }

    @Override
    public CostProjectTaskPreliminaryOpinion getByTaskId(String taskId) {
        LambdaQueryWrapper<CostProjectTaskPreliminaryOpinion> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CostProjectTaskPreliminaryOpinion::getTaskId, taskId);
        queryWrapper.last("limit 1");
        CostProjectTaskPreliminaryOpinion one = this.getOne(queryWrapper);
        return one;
    }

    @Override
    @Transactional
    public void createOrUpdate(CostProjectTaskPreliminaryOpinion opinion) {
        this.saveOrUpdate(opinion);
    }
}

