diff --git a/mysql.sql b/mysql.sql index 43e60ef3fd83bffe50345198975bcfd97c66fb98..22cb16bbfcea359192b0029fb5da653a28f24fd1 100644 --- a/mysql.sql +++ b/mysql.sql @@ -838,7 +838,10 @@ INSERT INTO `gen_template` (`id`, `name`, `content`, `is_deleted`, `group_name`, (7, 'Test', 'export interface Res {\n code: string;\n data: Record;\n msg: string;\n}\n\n/**\n * ${doc.name}\n#foreach($param in ${doc.queryParams})\n * @param {${param.type}} ${param.name} ${param.description}\n#end\n * returns\n*/\nexport function fun(\n#foreach($param in ${doc.queryParams}) \n ${param.name}: ${param.type}\n#end\n) {\n var params = []\n#foreach($param in ${doc.queryParams}) \n params.push(\'${param.name}=\'+${param.name})\n#end\n return request.get(\'${doc.url}?\' + param.join(\'&\'))\n}\n', 0, '默认分组', '2024-07-27 10:40:30', '2024-07-27 10:40:30'), (8, '222', 'import lombok.Data;\n\n@Data\npublic class MyClass implements Serializable {\n\n private static final long serialVersionUID = ${sys.nextId}L;\n\n#foreach($param in ${doc.requestParams})\n /**\n * ${param.description}\n */\n private ${param.type} ${param.name};\n\n#end\n}\n', 1, '默认分组', '2024-07-27 10:42:26', '2024-07-27 10:43:23'), (9, '222', 'import lombok.Data;\n\n@Data\npublic class MyClass implements Serializable {\n\n private static final long serialVersionUID = ${sys.nextId}L;\n\n#foreach($param in ${doc.requestParams})\n /**\n * ${param.description}\n */\n private ${param.type} ${param.name};\n\n#end\n}\n', 1, '默认分组', '2024-07-27 10:42:28', '2024-07-27 10:43:20'), - (10, '2222', '接口编号: ${doc.docKey}\n接口名称: ${doc.name}\nURL: ${doc.url}\nMETHOD: ${doc.httpMethod}\ncontentType: ${doc.contentType}\ndescription: ${doc.description}\n\n-- headers\n#foreach($param in ${doc.headerParams}) \n ${param.name}\n#end\n\n-- pathParams\n#foreach($param in ${doc.pathParams}) \n ${param.name}\n#end\n\n-- queryParams\n#foreach($param in ${doc.queryParams}) \n ${param.name}\n#end\n\n-- requestParams\n#foreach($param in ${doc.requestParams}) \n ${param.name}\n#end\n\n-- responseParams\n#foreach($param in ${doc.responseParams}) \n name: ${param.name}\n type: ${param.type}\n required: ${param.require}\n example: ${param.example}\n description: ${param.description}\n ======\n \n#end\n\n-- req\n${doc.requestExample}\n\n-- resp\n${doc.responseExample}\n', 0, '默认分组', '2024-07-27 10:43:27', '2024-07-27 14:28:56'); + (10, '2222', '接口编号: ${doc.docKey}\n接口名称: ${doc.name}\nURL: ${doc.url}\nMETHOD: ${doc.httpMethod}\ncontentType: ${doc.contentType}\ndescription: ${doc.description}\n\n-- headers\n#foreach($param in ${doc.headerParams}) \n ${param.name}\n#end\n\n-- pathParams\n#foreach($param in ${doc.pathParams}) \n ${param.name}\n#end\n\n-- queryParams\n#foreach($param in ${doc.queryParams}) \n ${param.name}\n#end\n\n-- requestParams\n#foreach($param in ${doc.requestParams}) \n ${param.name}\n#end\n\n-- responseParams\n#foreach($param in ${doc.responseParams}) \n name: ${param.name}\n type: ${param.type}\n required: ${param.require}\n example: ${param.example}\n description: ${param.description}\n ======\n \n#end\n\n-- req\n${doc.requestExample}\n\n-- resp\n${doc.responseExample}\n', 0, '默认分组', '2024-07-27 10:43:27', '2024-07-27 14:28:56'), + (11, 'JAVA_RESPONSE', '## 首字母大写\n#macro(capitalizeFirstLetter $input)\n #if($input && $input.length() > 0)\n #set($firstChar = $input.substring(0, 1).toUpperCase())\n #set($rest = $input.substring(1))\n$firstChar$rest#end\n#end\n## 截取路径的最后一个单词并首字母大写\n#macro(getLastPartCapitalized $path)\n #set($parts = $path.split(\"/\"))\n #set($lastPart = $parts[$parts.size() - 1])\n #set($capitalizedLastPart = $lastPart.substring(0, 1).toUpperCase() + $lastPart.substring(1))\n$capitalizedLastPart#end\n## 转换为java类\n#macro(getType $type $name)\n#if ($type == \"string\")String#elseif ($type == \"number\")BigDecimal#elseif ($type == \"array\")List<${name}>#elseif ($type == \"num_array\")List#elseif ($type == \"str_array\")List#elseif ($type == \"enum\")String#elseif ($type == \"boolean\")Boolean\n#else${name}#end#end\n## 声明递归生成静态内部类\n#macro(generateStaticInnerClasses $responseParam)\n /** 静态内部类${responseParam.name} */\n public static class #capitalizeFirstLetter($responseParam.name) {\n #foreach($childParam in ${responseParam.children})\n\n /** ${childParam.description} */\n #set($capitalizedName = $childParam.name.substring(0, 1).toUpperCase() + $childParam.name.substring(1))\n private #getType(${childParam.type},$capitalizedName) ${childParam.name};\n #end\n #foreach($childParam in ${responseParam.children})\n #set($capitalizedName = $childParam.name.substring(0, 1).toUpperCase() + $childParam.name.substring(1))\n public #getType(${childParam.type},$capitalizedName) get$capitalizedName() {\n return ${childParam.name};\n }\n public void set$capitalizedName(#getType(${childParam.type},$capitalizedName) ${childParam.name}) {\n this.${childParam.name} = ${childParam.name};\n }\n #end\n #foreach($childParam in ${responseParam.children})\n #if(${childParam.children})\n ## 递归生成静态内部类\n #generateStaticInnerClasses($childParam)\n\n #end\n #end\n } \n#end\n\nimport java.util.*;\nimport java.math.*;\n\n/**\n * name : ${doc.name}响应类\n * author : ${doc.author}\n * description : ${doc.description}\n * version : ${doc.version}\n */\npublic class #getLastPartCapitalized($doc.url)ReponseDTO {\n #foreach($responseParam in ${doc.responseParams})\n\n /** ${responseParam.description} */\n #set($capitalizedName = $responseParam.name.substring(0, 1).toUpperCase() + $responseParam.name.substring(1))\n private #getType(${responseParam.type},$capitalizedName) ${responseParam.name};\n #end\n #foreach($responseParam in ${doc.responseParams})\n\n #set($capitalizedName = $responseParam.name.substring(0, 1).toUpperCase() + $responseParam.name.substring(1))\n public #getType(${responseParam.type},$capitalizedName) get$capitalizedName() {\n return ${responseParam.name};\n }\n public void set$capitalizedName(#getType(${responseParam.type},$capitalizedName) ${responseParam.name}) {\n this.${responseParam.name} = ${responseParam.name};\n }\n #end\n #foreach($responseParam in ${doc.responseParams})\n #if(${responseParam.children})\n ## 生成静态内部类\n #generateStaticInnerClasses($responseParam)\n\n #end\n #end\n}\n', 0, 'JAVA', '2024-07-27 10:43:27', '2025-05-31 22:41:29'), + (12, 'JAVA_REQUEST', '## 首字母大写\n#macro(capitalizeFirstLetter $input)\n #if($input && $input.length() > 0)\n #set($firstChar = $input.substring(0, 1).toUpperCase())\n #set($rest = $input.substring(1))\n$firstChar$rest#end\n#end\n## 截取路径的最后一个单词并首字母大写\n#macro(getLastPartCapitalized $path)\n #set($parts = $path.split(\"/\"))\n #set($lastPart = $parts[$parts.size() - 1])\n #set($capitalizedLastPart = $lastPart.substring(0, 1).toUpperCase() + $lastPart.substring(1))\n$capitalizedLastPart#end\n## 转换为java类\n#macro(getType $type $name)\n#if ($type == \"string\")String#elseif ($type == \"number\")BigDecimal#elseif ($type == \"array\")List<${name}>#elseif ($type == \"num_array\")List#elseif ($type == \"str_array\")List#elseif ($type == \"enum\")String#elseif ($type == \"boolean\")Boolean\n#else${name}#end#end\n## 声明递归生成静态内部类\n#macro(generateStaticInnerClasses $requestParam)\n /** 静态内部类${requestParam.name} */\n public static class #capitalizeFirstLetter($requestParam.name) {\n #foreach($childParam in ${requestParam.children})\n\n /** ${childParam.description} */\n #set($capitalizedName = $childParam.name.substring(0, 1).toUpperCase() + $childParam.name.substring(1))\n private #getType(${childParam.type},$capitalizedName) ${childParam.name};\n #end\n #foreach($childParam in ${requestParam.children})\n #set($capitalizedName = $childParam.name.substring(0, 1).toUpperCase() + $childParam.name.substring(1))\n public #getType(${childParam.type},$capitalizedName) get$capitalizedName() {\n return ${childParam.name};\n }\n public void set$capitalizedName(#getType(${childParam.type},$capitalizedName) ${childParam.name}) {\n this.${childParam.name} = ${childParam.name};\n }\n #end\n #foreach($childParam in ${requestParam.children})\n #if(${childParam.children})\n ## 递归生成静态内部类\n #generateStaticInnerClasses($childParam)\n\n #end\n #end\n } \n#end\n\nimport java.util.*;\nimport java.math.*;\n\n/**\n * name : ${doc.name}请求类\n * author : ${doc.author}\n * description : ${doc.description}\n * version : ${doc.version}\n */\npublic class #getLastPartCapitalized($doc.url)RequestDTO {\n #foreach($requestParam in ${doc.requestParams})\n\n /** ${requestParam.description} */\n #set($capitalizedName = $requestParam.name.substring(0, 1).toUpperCase() + $requestParam.name.substring(1))\n private #getType(${requestParam.type},$capitalizedName) ${requestParam.name};\n #end\n #foreach($requestParam in ${doc.requestParams})\n\n #set($capitalizedName = $requestParam.name.substring(0, 1).toUpperCase() + $requestParam.name.substring(1))\n public #getType(${requestParam.type},$capitalizedName) get$capitalizedName() {\n return ${requestParam.name};\n }\n public void set$capitalizedName(#getType(${requestParam.type},$capitalizedName) ${requestParam.name}) {\n this.${requestParam.name} = ${requestParam.name};\n }\n #end\n #foreach($requestParam in ${doc.requestParams})\n #if(${requestParam.children})\n ## 生成静态内部类\n #generateStaticInnerClasses($requestParam)\n\n #end\n #end\n}\n', 0, 'JAVA', '2024-07-27 10:43:27', '2025-05-31 22:38:48'), + (13, 'JAVA_CONTROLLER', '## 截取路径部分\n#macro(splitPath $path)\n #set($parts = $path.split(\"/\"))\n #if($parts.size() > 0)\n #set($pathPart = \"\")\n #foreach($part in $parts)\n #if($foreach.index < $parts.size() - 1)\n #set($pathPart = $pathPart + $part + \"/\")\n #end\n #end\n$pathPart#end\n#end\n## 截取路径的最后一个单词\n#macro(getLastPart $path)\n #set($parts = $path.split(\"/\"))\n #set($lastPart = $parts[$parts.size() - 1])\n$lastPart#end\n## 首字母大写\n#macro(capitalizeFirstLetter $input)\n #if($input && $input.length() > 0)\n #set($firstChar = $input.substring(0, 1).toUpperCase())\n #set($rest = $input.substring(1))\n$firstChar$rest#end\n#end\n## 截取路径的最后一个单词并首字母大写\n#macro(getLastPartCapitalized $path)\n #set($parts = $path.split(\"/\"))\n #set($lastPart = $parts[$parts.size() - 1])\n #set($capitalizedLastPart = $lastPart.substring(0, 1).toUpperCase() + $lastPart.substring(1))\n$capitalizedLastPart#end\n#set($hasResponseParams = $doc.responseParams && $$doc.responseParams.size() > 0)\n#set($hasRequestParams = $doc.requestParams && $doc.requestParams.size() > 0)\n\nimport org.springframework.web.bind.annotation.GetMapping;\nimport org.springframework.web.bind.annotation.PostMapping;\nimport org.springframework.web.bind.annotation.RequestBody;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RestController;\n\n@RestController\n@RequestMapping(\"#splitPath($doc.url)\")\npublic class #getLastPartCapitalized($doc.url)Controller {\n /**\n * name : ${doc.name}请求类\n * author : ${doc.author}\n * description : ${doc.description}\n * version : ${doc.version}\n */\n @PostMapping(\"#getLastPart($doc.url)\")\n public #if($hasResponseParams)#getLastPartCapitalized($doc.url)ReponseDTO#else void#end #getLastPart($doc.url)(#if($hasRequestParams)@RequestBody #getLastPartCapitalized($doc.url)RequestDTO param#else #end) {\n #if($hasResponseParams)\n // 返回响应参数\n return null;\n #else\n // 无返回值\n #end\n }\n}\n', 0, 'JAVA', '2025-05-31 21:10:54', '2025-05-31 22:17:59'); INSERT INTO `gen_template2` (`id`, `name`, `content`, `is_deleted`, `group_name`, `gmt_create`, `gmt_modified`) VALUES (1, 'Test', '接口编号: ${doc.docKey}\n接口名称: ${doc.name}\nURL: ${doc.url}\nMETHOD: ${doc.httpMethod}\ncontentType: ${doc.contentType}\ndescription: ${doc.description}\n\n-- headers\n#foreach($param in ${doc.headerParams}) \n ${param.name}\n#end\n\n-- pathParams\n#foreach($param in ${doc.pathParams}) \n ${param.name}\n#end\n\n-- queryParams\n#foreach($param in ${doc.queryParams}) \n ${param.name}\n#end\n\n-- requestParams\n#foreach($param in ${doc.requestParams}) \n ${param.name}\n#end\n\n-- responseParams\n#foreach($param in ${doc.responseParams}) \n name: ${param.name}\n type: ${param.type}\n required: ${param.require}\n example: ${param.example}\n description: ${param.description}\n ======\n \n#end\n\n-- req\n${doc.requestExample}\n\n-- resp\n${doc.responseExample}\n', 0, '默认分组', '2024-07-12 16:58:22', '2024-07-22 21:42:05'),