/*
 * Copyright (c) 京北方信息技术股份有限公司 Corporation 2021 . All rights reserved.
 *
 */
package net.northking.cctp.maven.plugin;

import net.northking.cctp.maven.analyse.entity.TableRef;
import net.northking.cctp.maven.gen.CCTPGenerator;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

/**
 * 生成前端Vue框架下的模块功能代码
 *
 * @author : xiusong.xie
 * @version : 1.0
 */
@Mojo(name = "vue", threadSafe = true)
public class VueMojo extends AbsDatabaseLoadMojo
{
  /**
   * Maven工程对象
   **/
  @Parameter(defaultValue = "${project}", readonly = true, required = true)
  private MavenProject project;


  /**
   * basePackage
   */
  @Parameter(required = true)
  private String basePackage;

  @Override
  public void execute() throws MojoExecutionException
  {
    CCTPGenerator generator = new CCTPGenerator(project.getBasedir(), basePackage);
    for (TableRef tableRef : loadTables())
    {
      if (tableNames != null)
      {
        for (String tableName : tableNames)
        {
          if (tableRef.getTableName().equalsIgnoreCase(tableName))
          {
            generator.genVueCode(tableRef);
            break;
          }
        }
      } else
      {
        generator.genVueCode(tableRef);
      }
    }
  }
}
