package com.hotent.project.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hotent.constant.BaseConstant;
import com.hotent.project.dao.CostProjectTaskDraftDao;
import com.hotent.project.manager.CostProjectTaskDraftManager;
import com.hotent.project.model.CostProjectTaskDraft;
import com.hotent.base.manager.impl.BaseManagerImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 工作底稿表 服务实现类
 *
 * @company 山西清众科技股份有限公司
 * @author 超级管理员
 * @since 2025-01-27
 */
@Service
public class CostProjectTaskDraftManagerImpl extends BaseManagerImpl<CostProjectTaskDraftDao, CostProjectTaskDraft> implements CostProjectTaskDraftManager {


    @Override
    public CostProjectTaskDraft getByTaskId(String taskId) {
        LambdaQueryWrapper<CostProjectTaskDraft> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CostProjectTaskDraft::getTaskId, taskId)
                   .eq(CostProjectTaskDraft::getIsDeleted, BaseConstant.NORMAL_STATUS)
                   .last("LIMIT 1");

        return this.getOne(queryWrapper);
    }

    @Override
    @Transactional
    public void createOrUpdate(CostProjectTaskDraft costProjectTaskDraft) {
        //新建或更新
        this.saveOrUpdate(costProjectTaskDraft);
    }
}

