/*
* Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved.
*
*/
package net.northking.cctp.platform.api.comlibrary.service;

import net.northking.cctp.common.db.annotation.DatabaseReadOnly;

import net.northking.cctp.platform.db.service.CpComponentParamterService;
import net.northking.cctp.platform.db.entity.CpComponentParamter;

import net.northking.cctp.platform.dto.comlibrary.CpComponentParamterDetailDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 组件参数服务实现类
 *
 * @author maven-cctp-plugin
 * @since 1.0
 */

@Service
@ConditionalOnMissingBean(name = "CpComponentParamterApiServiceImpl")
public class CpComponentParamterApiServiceImpl implements CpComponentParamterApiService
{
  /**
   * 日志
   */
  private final static Logger logger = LoggerFactory.getLogger(CpComponentParamterApiServiceImpl.class);

  @Autowired
  private CpComponentParamterService cpComponentParamterService;

  @Override
  @DatabaseReadOnly
  public List<CpComponentParamterDetailDto> getParameters(String comId)
  {
    List<CpComponentParamterDetailDto> result = new ArrayList<>();
    CpComponentParamter example = new CpComponentParamter();
    example.setComId(comId);
    List<CpComponentParamter> entitys = this.cpComponentParamterService.query(example);
    for (CpComponentParamter entity : entitys) {
      CpComponentParamterDetailDto dto = new CpComponentParamterDetailDto();
      BeanUtils.copyProperties(entity, dto);
      result.add(dto);
    }
    return result;
  }

}
