예제 #1
0
파일: Dao.cs 프로젝트: LaiHotchner/TestCode
        private static string GetContent(HotchnerTable table)
        {
            var daoClassName = Backend_Devices.GetDaoClassName(table);
            var entityName   = Backend_Devices.GetEntityName(table);

            var stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("package " + Backend_Devices.DaoPackagePrefix + ";");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"import {Backend_Code.GetPagingParameterEntity()};");
            stringBuilder.AppendLine($"import {Backend_Devices.EntityPackagePrefix}.{entityName};");
            stringBuilder.AppendLine("import org.apache.ibatis.annotations.Param;");
            stringBuilder.AppendLine("import org.springframework.stereotype.Repository;");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("import java.util.List;");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("@Repository");
            stringBuilder.AppendLine("public interface " + daoClassName + " {");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"    int {Backend_Devices.GetCreateMethodName(table)}(@Param(\"infoList\")List<{entityName}> infoList);");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"    int {Backend_Devices.GetDeleteByIdMethodName(table)}(@Param(\"id\") long id);");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"    int {Backend_Devices.GetUpdateMethodName(table)}(@Param(\"info\") {entityName} info);");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"    {entityName} {Backend_Devices.GetByIdMethodName(table)}(@Param(\"id\") long id);");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"    List<{entityName}> {Backend_Devices.GetAllMethodName(table)}(@Param(\"parameter\")PagingParameter parameter);");
            stringBuilder.AppendLine("}");

            return(stringBuilder.ToString());
        }
예제 #2
0
        private static string GetContent(HotchnerTable table)
        {
            var entityName       = Backend_Devices.GetEntityName(table);
            var serviceClassName = Backend_Devices.GetServiceInterfaceClassName(table);

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("package " + Backend_Devices.DeviceServiceInterfacePackagePrefix + ";");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"import {Backend_Code.GetPagingParameterEntity()};");
            stringBuilder.AppendLine($"import {Backend_Devices.EntityPackagePrefix}.{entityName};");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("import java.util.List;");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("public interface " + serviceClassName + " {");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"    int {Backend_Devices.GetCreateMethodName(table)}(List<{entityName}> infoList);");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"    int {Backend_Devices.GetDeleteByIdMethodName(table)}(long id);");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"    int {Backend_Devices.GetUpdateMethodName(table)}({entityName} info);");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"    {entityName} {Backend_Devices.GetByIdMethodName(table)}(long id);");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"    List<{entityName}> {Backend_Devices.GetAllMethodName(table)}(PagingParameter parameter);");
            stringBuilder.AppendLine("}");

            return(stringBuilder.ToString());
        }
예제 #3
0
        public static void GenerateCode(List <HotchnerTable> tableList)
        {
            Backend_Code.PreProcessFolder(RetrievalFolder,
                                          out var entityFolderPath,
                                          out var daoFolderPath,
                                          out var mapperFolderPath,
                                          out var controllerFolderPath,
                                          out var serviceImplFolderPath,
                                          out var serviceInterfaceFolderPath);

            Entity.Generate(entityFolderPath);
            Dao.Generate(daoFolderPath, tableList);
            Mapper.Generate(mapperFolderPath, tableList);
            Controller.Generate(controllerFolderPath, tableList);
            ServiceImpl.Generate(serviceImplFolderPath, tableList);
            ServiceInterface.Generate(serviceInterfaceFolderPath, tableList);
        }
예제 #4
0
        private static string GetContent(HotchnerTable table)
        {
            var daoFieldName              = table.camelcaseMethodName + "Dao";
            var entityName                = Backend_Devices.GetEntityName(table);
            var daoClassName              = Backend_Devices.GetDaoClassName(table);
            var serviceImplClassName      = Backend_Devices.GetServiceImplClassName(table);
            var serviceInterfaceClassName = Backend_Devices.GetServiceInterfaceClassName(table);

            StringBuilder stringBuilder = new StringBuilder();

            #region import
            stringBuilder.AppendLine("package " + Backend_Devices.ServiceImplPackagePrefix + ";");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine($"import {Backend_Code.GetPagingParameterEntity()};");
            stringBuilder.AppendLine($"import {Backend_Devices.DaoPackagePrefix}.{daoClassName};");
            stringBuilder.AppendLine($"import {Backend_Devices.EntityPackagePrefix}.{entityName};");
            stringBuilder.AppendLine($"import {Backend_Devices.DeviceServiceInterfacePackagePrefix}.{serviceInterfaceClassName};");
            stringBuilder.AppendLine("import org.springframework.beans.factory.annotation.Autowired;");
            stringBuilder.AppendLine("import org.springframework.stereotype.Service;");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("import java.util.List;");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("@Service");
            stringBuilder.AppendLine("public class " + serviceImplClassName + " implements " + serviceInterfaceClassName + " {");
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("    @Autowired");
            stringBuilder.AppendLine($"    private {daoClassName} {daoFieldName};");
            stringBuilder.AppendLine();
            #endregion
            #region Implement
            stringBuilder.AppendLine("    @Override");
            stringBuilder.AppendLine($"    public int {Backend_Devices.GetCreateMethodName(table)}(List<{entityName}> infoList) " + "{");
            stringBuilder.AppendLine($"        return {daoFieldName}.{Backend_Devices.GetCreateMethodName(table)}(infoList);");
            stringBuilder.AppendLine("    }");
            stringBuilder.AppendLine("");

            stringBuilder.AppendLine("    @Override");
            stringBuilder.AppendLine($"    public int {Backend_Devices.GetDeleteByIdMethodName(table)}(long id)" + " {");
            stringBuilder.AppendLine($"        return {daoFieldName}.{Backend_Devices.GetDeleteByIdMethodName(table)}(id);");
            stringBuilder.AppendLine("    }");
            stringBuilder.AppendLine("");

            stringBuilder.AppendLine("    @Override");
            stringBuilder.AppendLine($"    public int {Backend_Devices.GetUpdateMethodName(table)}({entityName} info)" + " {");
            stringBuilder.AppendLine($"        return {daoFieldName}.{Backend_Devices.GetUpdateMethodName(table)}(info);");
            stringBuilder.AppendLine("    }");
            stringBuilder.AppendLine("");

            stringBuilder.AppendLine("    @Override");
            stringBuilder.AppendLine($"    public {entityName} {Backend_Devices.GetByIdMethodName(table)}(long id)" + " {");
            stringBuilder.AppendLine($"        return {daoFieldName}.{Backend_Devices.GetByIdMethodName(table)}(id);");
            stringBuilder.AppendLine("    }");
            stringBuilder.AppendLine("");

            stringBuilder.AppendLine("    @Override");
            stringBuilder.AppendLine($"    public List<{entityName}> {Backend_Devices.GetAllMethodName(table)}(PagingParameter parameter)" + " {");
            stringBuilder.AppendLine($"        return {daoFieldName}.{Backend_Devices.GetAllMethodName(table)}(parameter);");
            stringBuilder.AppendLine("    }");
            stringBuilder.AppendLine("");

            #endregion
            stringBuilder.AppendLine("}");
            return(stringBuilder.ToString());
        }