package com.hotent.surveyinfo.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hotent.base.manager.impl.BaseManagerImpl;
import com.hotent.surveyinfo.dao.CostSurveyFdTemplateHeadersDao;
import com.hotent.surveyinfo.dao.CostSurveyTemplateHeadersDao;
import com.hotent.surveyinfo.manager.CostSurveyFdTemplateHeadersManager;
import com.hotent.surveyinfo.manager.CostSurveyTemplateHeadersManager;
import com.hotent.surveyinfo.model.CostSurveyFdTemplateHeaders;
import com.hotent.surveyinfo.model.CostSurveyTemplateHeaders;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;


/**
 * 成本调查表头子表 服务实现类
 *
 * @company 山西清众科技股份有限公司
 * @author 超级管理员
 * @since 2025-09-19
 */
@Service
public class CostSurveyFdTemplateHeadersManagerImpl extends BaseManagerImpl<CostSurveyFdTemplateHeadersDao, CostSurveyFdTemplateHeaders> implements CostSurveyFdTemplateHeadersManager {

	@Override
	public CostSurveyFdTemplateHeaders getDetail(String id) {
		CostSurveyFdTemplateHeaders costSurveyTemplateHeaders = this.get(id);
    	

		return costSurveyTemplateHeaders;
	}
	@Override
	@Transactional
	public void createOrUpdate(CostSurveyFdTemplateHeaders costSurveyTemplateHeaders) {
		//新建或更新
		this.saveOrUpdate(costSurveyTemplateHeaders);
	}

	@Override
	@Transactional
	public void batchCreate(List<CostSurveyFdTemplateHeaders> costSurveyTemplateHeadersList) {
		if (costSurveyTemplateHeadersList != null && !costSurveyTemplateHeadersList.isEmpty()) {
			// 批量保存
			this.saveBatch(costSurveyTemplateHeadersList);
		}
	}

	@Override
	public List<CostSurveyFdTemplateHeaders> listBySurveyTemplateId(String surveyTemplateId) {
		return null;
	}

	@Override
	public List<CostSurveyFdTemplateHeaders> listVisibleBySurveyTemplateIdAndVersion(String surveyTemplateId, String versionId) {
		LambdaQueryWrapper<CostSurveyFdTemplateHeaders> wrapper = new LambdaQueryWrapper<>();
		wrapper.eq(CostSurveyFdTemplateHeaders::getSurveyTemplateId, surveyTemplateId);
		wrapper.eq(CostSurveyFdTemplateHeaders::getVersionId, versionId);
		wrapper.eq(CostSurveyFdTemplateHeaders::getShowVisible, "1");
		wrapper.orderByAsc(CostSurveyFdTemplateHeaders::getOrderNum);
		return this.list(wrapper);

	}
}
