codegen
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
<module>wol-auth</module>
|
||||
<module>agileboot-system-base</module>
|
||||
<module>wol-gateway</module>
|
||||
<module>wol-codegenerator</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
26
agileboot-system/wol-codegenerator/pom.xml
Normal file
26
agileboot-system/wol-codegenerator/pom.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>agileboot-system</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>wol-codegenerator</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>wol-codegenerator</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.agileboot.codegen;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @Author cuiJiaWang
|
||||
* @Create 2025-08-12 18:07
|
||||
*/
|
||||
@SpringBootApplication(scanBasePackages = "com.agileboot.*")
|
||||
public class CodeGenApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CodeGenApplication.class, args);
|
||||
String successMsg = " ____ _ _ __ _ _ \n"
|
||||
+ " / ___| | |_ __ _ _ __ | |_ _ _ _ __ ___ _ _ ___ ___ ___ ___ ___ / _| _ _ | || |\n"
|
||||
+ " \\___ \\ | __|/ _` || '__|| __| | | | || '_ \\ / __|| | | | / __|/ __|/ _ \\/ __|/ __|| |_ | | | || || |\n"
|
||||
+ " ___) || |_| (_| || | | |_ | |_| || |_) | \\__ \\| |_| || (__| (__| __/\\__ \\\\__ \\| _|| |_| || ||_|\n"
|
||||
+ " |____/ \\__|\\__,_||_| \\__| \\__,_|| .__/ |___/ \\__,_| \\___|\\___|\\___||___/|___/|_| \\__,_||_|(_)\n"
|
||||
+ " |_| ";
|
||||
|
||||
System.out.println(successMsg);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 代码生成器启动成功 ლ(´ڡ`ლ)゙ ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.agileboot.codegen.controller;
|
||||
|
||||
import com.agileboot.codegen.service.IGeneratorService;
|
||||
import com.agileboot.common.core.core.R;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @Author cuiJiaWang
|
||||
* @Create 2025-09-24 14:24
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/codegen")
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class GeneratorController {
|
||||
|
||||
private final IGeneratorService generatorService;
|
||||
|
||||
@GetMapping("/template/all")
|
||||
public R<?> getAllTemplates() {
|
||||
String templates = generatorService.getTemplateConfig();
|
||||
JSONArray jsonArray = JSONArray.parseArray(templates);
|
||||
return R.ok(jsonArray);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.agileboot.codegen.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author cuiJiaWang
|
||||
* @Create 2025-09-24 14:31
|
||||
*/
|
||||
@Service
|
||||
public class GeneratorServiceImpl implements IGeneratorService {
|
||||
@Override
|
||||
public String getTemplateConfig() {
|
||||
String templateConfig = "";
|
||||
try {
|
||||
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("template.json");
|
||||
if (inputStream != null) {
|
||||
templateConfig = new BufferedReader(new InputStreamReader(inputStream)).lines().collect(Collectors.joining(System.lineSeparator()));
|
||||
inputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return templateConfig;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.agileboot.codegen.service;
|
||||
|
||||
/**
|
||||
* @Author cuiJiaWang
|
||||
* @Create 2025-09-24 14:31
|
||||
*/
|
||||
public interface IGeneratorService {
|
||||
String getTemplateConfig();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.agileboot.codegen.util;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author lvyanpu
|
||||
*/
|
||||
public final class mysqlJavaTypeUtil {
|
||||
|
||||
@Getter
|
||||
public static final HashMap<String, String> mysqlJavaTypeMap = new HashMap<>();
|
||||
@Getter
|
||||
public static final HashMap<String, String> mysqlSwaggerTypeMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
mysqlJavaTypeMap.put("bigint", "Long");
|
||||
mysqlJavaTypeMap.put("int", "Integer");
|
||||
mysqlJavaTypeMap.put("tinyint", "Integer");
|
||||
mysqlJavaTypeMap.put("smallint", "Integer");
|
||||
mysqlJavaTypeMap.put("mediumint", "Integer");
|
||||
mysqlJavaTypeMap.put("integer", "Integer");
|
||||
//小数
|
||||
mysqlJavaTypeMap.put("float", "Float");
|
||||
mysqlJavaTypeMap.put("double", "Double");
|
||||
mysqlJavaTypeMap.put("decimal", "Double");
|
||||
//bool
|
||||
mysqlJavaTypeMap.put("bit", "Boolean");
|
||||
//字符串
|
||||
mysqlJavaTypeMap.put("char", "String");
|
||||
mysqlJavaTypeMap.put("varchar", "String");
|
||||
mysqlJavaTypeMap.put("tinytext", "String");
|
||||
mysqlJavaTypeMap.put("text", "String");
|
||||
mysqlJavaTypeMap.put("mediumtext", "String");
|
||||
mysqlJavaTypeMap.put("longtext", "String");
|
||||
//日期
|
||||
mysqlJavaTypeMap.put("date", "Date");
|
||||
mysqlJavaTypeMap.put("datetime", "Date");
|
||||
mysqlJavaTypeMap.put("timestamp", "Date");
|
||||
|
||||
|
||||
mysqlSwaggerTypeMap.put("bigint", "integer");
|
||||
mysqlSwaggerTypeMap.put("int", "integer");
|
||||
mysqlSwaggerTypeMap.put("tinyint", "integer");
|
||||
mysqlSwaggerTypeMap.put("smallint", "integer");
|
||||
mysqlSwaggerTypeMap.put("mediumint", "integer");
|
||||
mysqlSwaggerTypeMap.put("integer", "integer");
|
||||
mysqlSwaggerTypeMap.put("boolean", "boolean");
|
||||
mysqlSwaggerTypeMap.put("float", "number");
|
||||
mysqlSwaggerTypeMap.put("double", "number");
|
||||
mysqlSwaggerTypeMap.put("decimal", "Double");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
server:
|
||||
port: 9211
|
||||
spring:
|
||||
application:
|
||||
name: wol-codegen
|
||||
profiles:
|
||||
active: dev
|
||||
@@ -0,0 +1,74 @@
|
||||
[
|
||||
{
|
||||
"group": "ui",
|
||||
"templates": [{
|
||||
"id": "10",
|
||||
"name": "swagger-ui",
|
||||
"description": "swagger-ui"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"group": "mybatis",
|
||||
"templates": [{
|
||||
"id": "20",
|
||||
"name": "controller",
|
||||
"description": "controller"
|
||||
},
|
||||
{
|
||||
"id": "21",
|
||||
"name": "service",
|
||||
"description": "service"
|
||||
},
|
||||
{
|
||||
"id": "22",
|
||||
"name": "service_impl",
|
||||
"description": "service_impl"
|
||||
},
|
||||
{
|
||||
"id": "23",
|
||||
"name": "mapper",
|
||||
"description": "mapper"
|
||||
},
|
||||
{
|
||||
"id": "24",
|
||||
"name": "mybatis",
|
||||
"description": "mybatis"
|
||||
},
|
||||
{
|
||||
"id": "25",
|
||||
"name": "model",
|
||||
"description": "model"
|
||||
},
|
||||
{
|
||||
"id": "26",
|
||||
"name": "mapper2",
|
||||
"description": "mapper annotation"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"group": "mybatis-plus",
|
||||
"templates": [{
|
||||
"id": "60",
|
||||
"name": "pluscontroller",
|
||||
"description": "pluscontroller"
|
||||
},
|
||||
{
|
||||
"id": "61",
|
||||
"name": "plusservice",
|
||||
"description": "plusservice"
|
||||
},
|
||||
{
|
||||
"id": "62",
|
||||
"name": "plusmapper",
|
||||
"description": "plusmapper"
|
||||
},
|
||||
{
|
||||
"id": "63",
|
||||
"name": "plusentity",
|
||||
"description": "plusentity"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,295 @@
|
||||
[{
|
||||
"group": "ui",
|
||||
"templates": [{
|
||||
"id": "10",
|
||||
"name": "swagger-ui",
|
||||
"description": "swagger-ui"
|
||||
},
|
||||
{
|
||||
"id": "11",
|
||||
"name": "element-ui",
|
||||
"description": "element-ui"
|
||||
},
|
||||
{
|
||||
"id": "12",
|
||||
"name": "bootstrap-ui",
|
||||
"description": "bootstrap-ui"
|
||||
},
|
||||
{
|
||||
"id": "13",
|
||||
"name": "layui-edit",
|
||||
"description": "layui-edit"
|
||||
},
|
||||
{
|
||||
"id": "14",
|
||||
"name": "layui-list",
|
||||
"description": "layui-list"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "mybatis",
|
||||
"templates": [{
|
||||
"id": "20",
|
||||
"name": "controller",
|
||||
"description": "controller"
|
||||
},
|
||||
{
|
||||
"id": "21",
|
||||
"name": "service",
|
||||
"description": "service"
|
||||
},
|
||||
{
|
||||
"id": "22",
|
||||
"name": "service_impl",
|
||||
"description": "service_impl"
|
||||
},
|
||||
{
|
||||
"id": "23",
|
||||
"name": "mapper",
|
||||
"description": "mapper"
|
||||
},
|
||||
{
|
||||
"id": "24",
|
||||
"name": "mybatis",
|
||||
"description": "mybatis"
|
||||
},
|
||||
{
|
||||
"id": "25",
|
||||
"name": "model",
|
||||
"description": "model"
|
||||
},
|
||||
{
|
||||
"id": "26",
|
||||
"name": "mapper2",
|
||||
"description": "mapper annotation"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "jpa",
|
||||
"templates": [{
|
||||
"id": "30",
|
||||
"name": "entity",
|
||||
"description": "entity"
|
||||
},
|
||||
{
|
||||
"id": "31",
|
||||
"name": "repository",
|
||||
"description": "repository"
|
||||
},
|
||||
{
|
||||
"id": "32",
|
||||
"name": "jpacontroller",
|
||||
"description": "jpacontroller"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"group": "jdbc-template",
|
||||
"templates": [{
|
||||
"id": "40",
|
||||
"name": "jtdao",
|
||||
"description": "jtdao"
|
||||
},
|
||||
{
|
||||
"id": "41",
|
||||
"name": "jtdaoimpl",
|
||||
"description": "jtdaoimpl"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"group": "beetlsql",
|
||||
"templates": [{
|
||||
"id": "50",
|
||||
"name": "beetlmd",
|
||||
"description": "beetlmd"
|
||||
},
|
||||
{
|
||||
"id": "51",
|
||||
"name": "beetlentity",
|
||||
"description": "beetlentity"
|
||||
},
|
||||
{
|
||||
"id": "52",
|
||||
"name": "beetlcontroller",
|
||||
"description": "beetlcontroller"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"group": "mybatis-plus",
|
||||
"templates": [{
|
||||
"id": "60",
|
||||
"name": "pluscontroller",
|
||||
"description": "pluscontroller"
|
||||
},
|
||||
{
|
||||
"id": "61",
|
||||
"name": "plusservice",
|
||||
"description": "plusservice"
|
||||
},
|
||||
{
|
||||
"id": "62",
|
||||
"name": "plusmapper",
|
||||
"description": "plusmapper"
|
||||
},
|
||||
{
|
||||
"id": "63",
|
||||
"name": "plusentity",
|
||||
"description": "plusentity"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"group": "util",
|
||||
"templates": [{
|
||||
"id": "70",
|
||||
"name": "beanutil",
|
||||
"description": "beanutil"
|
||||
},
|
||||
{
|
||||
"id": "71",
|
||||
"name": "json",
|
||||
"description": "json"
|
||||
},
|
||||
{
|
||||
"id": "72",
|
||||
"name": "xml",
|
||||
"description": "xml"
|
||||
},
|
||||
{
|
||||
"id": "73",
|
||||
"name": "sql",
|
||||
"description": "sql"
|
||||
},
|
||||
{
|
||||
"id": "74",
|
||||
"name": "swagger-yml",
|
||||
"description": "swagger-yml"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"group": "common-mapper",
|
||||
"templates": [{
|
||||
"id": "81",
|
||||
"name": "tkentity",
|
||||
"description": "tkentity"
|
||||
},
|
||||
{
|
||||
"id": "82",
|
||||
"name": "tkmapper",
|
||||
"description": "tkmapper"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"group": "renren-fast",
|
||||
"templates": [{
|
||||
"id": "91",
|
||||
"name": "menu-sql",
|
||||
"description": "menu-sql"
|
||||
},
|
||||
{
|
||||
"id": "92",
|
||||
"name": "vue-list",
|
||||
"description": "vue-list"
|
||||
},
|
||||
{
|
||||
"id": "93",
|
||||
"name": "vue-edit",
|
||||
"description": "vue-edit"
|
||||
},
|
||||
{
|
||||
"id": "94",
|
||||
"name": "rr-controller",
|
||||
"description": "rr-controller"
|
||||
},
|
||||
{
|
||||
"id": "95",
|
||||
"name": "rr-dao",
|
||||
"description": "rr-dao"
|
||||
},
|
||||
{
|
||||
"id": "96",
|
||||
"name": "rr-daoxml",
|
||||
"description": "rr-daoxml"
|
||||
},
|
||||
{
|
||||
"id": "97",
|
||||
"name": "rr-service",
|
||||
"description": "rr-service"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "jpa-starp",
|
||||
"templates": [{
|
||||
"id": "101",
|
||||
"name": "starp-entity",
|
||||
"description": "entity"
|
||||
},
|
||||
{
|
||||
"id": "102",
|
||||
"name": "starp-repository",
|
||||
"description": "repository"
|
||||
},
|
||||
{
|
||||
"id": "103",
|
||||
"name": "starp-jpa-controller",
|
||||
"description": "jpacontroller"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "bi",
|
||||
"templates": [{
|
||||
"id": "201",
|
||||
"name": "qliksense",
|
||||
"description": "qlik sense"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"group": "cloud",
|
||||
"templates": [
|
||||
{
|
||||
"id": "301",
|
||||
"name": "bigquery",
|
||||
"description": "GCP BigQuery"
|
||||
},
|
||||
{
|
||||
"id": "302",
|
||||
"name": "dataflowjjs",
|
||||
"description": "GCP Dataflow JJS"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "tk-mybatis",
|
||||
"templates": [
|
||||
{
|
||||
"id": "401",
|
||||
"name": "tk-entity",
|
||||
"description": "tk-entity"
|
||||
},
|
||||
{
|
||||
"id": "402",
|
||||
"name": "tk-mapper",
|
||||
"description": "tk-mapper"
|
||||
},
|
||||
{
|
||||
"id": "403",
|
||||
"name": "tk-controller",
|
||||
"description": "tk-controller"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user