package com.hotent.project.manager.impl;

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

import java.util.List;

/**
 * 核增核减记录表 服务实现类
 *
 * @company 山西清众科技股份有限公司
 * @author 超级管理员
 * @since 2025-01-27
 */
@Service
public class CostProjectTaskAdjustmentRecordManagerImpl extends BaseManagerImpl<CostProjectTaskAdjustmentRecordDao, CostProjectTaskAdjustmentRecord> implements CostProjectTaskAdjustmentRecordManager {

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

    @Override
    public List<CostProjectTaskAdjustmentRecord> listByTaskId(String taskId) {
        LambdaQueryWrapper<CostProjectTaskAdjustmentRecord> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(CostProjectTaskAdjustmentRecord::getTaskId, taskId)
                   .orderByAsc(CostProjectTaskAdjustmentRecord::getOrderNum);

        return this.list(queryWrapper);
    }

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

