Exemplo n.º 1
0
        private static string GetContent(List <HotchnerTable> tableList)
        {
            StringBuilder outterBuilder = new StringBuilder();

            outterBuilder.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
            outterBuilder.AppendLine("<!DOCTYPE mapper PUBLIC \" -//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\" >");
            outterBuilder.AppendLine();
            outterBuilder.AppendLine($"<mapper namespace=\"{Backend_Anchors.DaoPackagePrefix}.{Backend_Anchors.DaoName}\">");

            foreach (var table in tableList)
            {
                outterBuilder.AppendLine($"    <select id=\"{Backend_Anchors.GetPositions_EachTable(table)}\"  resultType=\"{Backend_Anchors.EntityPackagePrefix}.{Entity.PositionClass}\">");
                outterBuilder.AppendLine($"        SELECT x,y FROM public.{table.DbTableName} where available = 1");
                outterBuilder.AppendLine("    </select>");
            }
            outterBuilder.AppendLine("</mapper>");
            return(outterBuilder.ToString());
        }
Exemplo n.º 2
0
        private static string GetContent(List <HotchnerTable> tableList)
        {
            StringBuilder stringBuilder = new StringBuilder();
            var           daoField      = $"{Backend_Anchors.FieldPrefix}Dao";

            stringBuilder.AppendLine("package " + Backend_Anchors.ServiceImplPackagePrefix + ";");
            stringBuilder.AppendLine();
#warning here need refactor
            stringBuilder.AppendLine("import com.infinite.common.constants.DeviceType;");
            stringBuilder.AppendLine($"import {Backend_Anchors.DaoPackagePrefix}.{Backend_Anchors.DaoName};");
            stringBuilder.AppendLine($"import {Backend_Anchors.EntityPackagePrefix}.{Entity.AnchorsClass};");
            stringBuilder.AppendLine($"import {Backend_Anchors.ServiceInterfacePackagePrefix}.{Backend_Anchors.ServicesName};");
            stringBuilder.AppendLine("import org.springframework.beans.factory.annotation.Autowired;");
            stringBuilder.AppendLine("import org.springframework.stereotype.Service;");
            stringBuilder.AppendLine("");
            stringBuilder.AppendLine("import java.util.ArrayList;");
            stringBuilder.AppendLine("import java.util.List;");
            stringBuilder.AppendLine("");
            stringBuilder.AppendLine("@Service");
            stringBuilder.AppendLine($"public class {Backend_Anchors.ServicesImplName} implements {Backend_Anchors.ServicesName} " + "{");
            stringBuilder.AppendLine("");
            stringBuilder.AppendLine("    @Autowired");
            stringBuilder.AppendLine($"    private {Backend_Anchors.DaoName} {daoField};");
            stringBuilder.AppendLine("");
            stringBuilder.AppendLine("    @Override");
            stringBuilder.AppendLine($"    public List<{Entity.AnchorsClass}> {Backend_Anchors.GetAnchorsByDeviceType_MethodName}(int type) " + "{");
            stringBuilder.AppendLine($"        List<{Entity.AnchorsClass}> result = new ArrayList<>();");
            stringBuilder.AppendLine("");
            foreach (var table in tableList)
            {
                stringBuilder.AppendLine($"        if ((type & DeviceType.{table.PascalMethodName}) == DeviceType.{table.PascalMethodName}) " + "{");
                stringBuilder.AppendLine($"            {Entity.AnchorsClass} anchors = new {Entity.AnchorsClass}(\"{table.PascalMethodName}\");");
                stringBuilder.AppendLine($"            anchors.setPositions({daoField}.{Backend_Anchors.GetPositions_EachTable(table)}());");
                stringBuilder.AppendLine("            result.add(anchors);");
                stringBuilder.AppendLine("        }");
            }
            stringBuilder.AppendLine("        return result;");
            stringBuilder.AppendLine("    }");
            stringBuilder.AppendLine("}");
            return(stringBuilder.ToString());
        }