'use strict';

const { Controller } = require('ee-core');
const Log = require('ee-core/log');
const Services = require('ee-core/services');
const path = require('path');
const fs = require('fs');
const { generatePhotoDetail, getLogoList, addLogo,deleteLogo } = require('../api/generate');

const errData = {
  msg :'请求失败，请联系管理员',
  code:999
}

/**
 * 设置控制器
 * @class
 */
class GenerateController extends Controller {

  constructor(ctx) {
    super(ctx);
    this.configPath = path.join(__dirname, '..', 'config', 'app.config.json');
  }

  /**
   * 获取设备配置列表
   */
  async generatePhotoDetail(args) {
    try {
      const result = await generatePhotoDetail(args);
      if(result.data)  return result.data
      return errData;
    } catch (error) {
      Log.error('主图详情生成失败:', error);
      return errData;
    }
  }
  /**
   * 获取LOGO列表
   */
  async addLogo(args) {
    try {
      const result = await addLogo(args);
      if(result.data)  return result.data
      return errData;
    } catch (error) {
      Log.error('添加LOGO失败:', error);
      return errData;
    }
  }
  /**
   * 获取LOGO列表
   */
  async getLogoList(args) {
    try {
      const result = await getLogoList(args);
      if(result.data)  return result.data
      return errData;
    } catch (error) {
      Log.error('获取LOGO列表失败:', error);
      return errData;
    }
  }

  /**
   * 获取LOGO列表
   */
  async deleteLogo(args) {
    try {
      const result = await deleteLogo(args);
      if(result.data)  return result.data
      return errData;
    } catch (error) {
      Log.error('删除LOGO失败:', error);
      return errData;
    }
  }


}

GenerateController.toString = () => '[class GenerateController]';
module.exports = GenerateController;
