package com.hotent.surveyinfo.manager.impl;

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

import java.util.Collections;
import java.util.List;
import javax.annotation.Resource;
import com.hotent.base.util.BeanUtils;


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

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

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

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

	@Override
	public List<CostSurveyTemplateHeaders> listBySurveyTemplateId(String surveyTemplateId) {
		return this.listBySurveyTemplateId(surveyTemplateId);
	}

	@Override
	public List<CostSurveyTemplateHeaders> listVisibleBySurveyTemplateIdAndVersion(String surveyTemplateId, String versionId) {
		QueryWrapper<CostSurveyTemplateHeaders> wrapper = new QueryWrapper<>();
		wrapper.eq("survey_template_id", surveyTemplateId)
				.eq("version_id", versionId)
				.eq("showVisible", "1")
				.orderByAsc("order_num");
		return this.list(wrapper);
	}
}
