commit 3bad77d34b7b8bcd01f89026022108e96ef43037 Author: ycl Date: Mon May 18 14:16:17 2026 +0800 init commit diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e9c10c7 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/spring6-springboot3-project-template-for-community.iml b/.idea/spring6-springboot3-project-template-for-community.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/spring6-springboot3-project-template-for-community.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/tocodesign_project_settings.xml b/.idea/tocodesign_project_settings.xml new file mode 100644 index 0000000..32f9ba4 --- /dev/null +++ b/.idea/tocodesign_project_settings.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/template/.gitignore b/template/.gitignore new file mode 100644 index 0000000..c2255f4 --- /dev/null +++ b/template/.gitignore @@ -0,0 +1,35 @@ +## java +bin/ +classes/ + + +## eclipse +.settings/ +.classpath +.project + +## idea +*.iml +.idea/* +!.idea/codeStyles/ +!.idea/dataSources.xml +HELP.md + +## vscode +.vscode/ +.factorypath + +## maven: +target/ +test-output/ + +## system +.DS_Store +logs/ +*.log + +## vs +.vs +!modules/.gitkeep +.gitattributes +.toco/config.local.yml diff --git a/template/.mvn/jvm.config b/template/.mvn/jvm.config new file mode 100644 index 0000000..f432c96 --- /dev/null +++ b/template/.mvn/jvm.config @@ -0,0 +1 @@ +-Xmx1536m \ No newline at end of file diff --git a/template/.mvn/wrapper/maven-wrapper.jar b/template/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..cb28b0e Binary files /dev/null and b/template/.mvn/wrapper/maven-wrapper.jar differ diff --git a/template/.mvn/wrapper/maven-wrapper.properties b/template/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..c1318ce --- /dev/null +++ b/template/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +distributionUrl=https://maven.aliyun.com/repository/public/org/apache/maven/apache-maven/3.8.8/apache-maven-3.8.8-bin.zip +distributionSha256Sum=2e181515ce8ae14b7a904c40bb4794831f5fd1d9641107a13b916af15af4001a +wrapperUrl=https://maven.aliyun.com/repository/public/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar +wrapperUrlSha256Sum=e63a53cfb9c4d291ebe3c2b0edacb7622bbc480326beaa5a0456e412f52f066a \ No newline at end of file diff --git a/template/.toco/README b/template/.toco/README new file mode 100644 index 0000000..940cf2e --- /dev/null +++ b/template/.toco/README @@ -0,0 +1,8 @@ +Directory Structure for Rules (.md files only): + +global: Directory for storing common rules applicable to all agents +toco: Directory for storing Toco Agent-specific rules, used for overall control of the outer workflow +modeling: Directory for storing Modeling Agent-specific rules, used during the domain modeling phase +plan: Directory for storing Plan Agent-specific rules, used during the overall planning phase +design: Directory for storing Design Agent-specific rules, used for TOCO design element creation +coding: Directory for storing Coding Agent-specific rules, used during the coding phase \ No newline at end of file diff --git a/template/.toco/coding/README b/template/.toco/coding/README new file mode 100644 index 0000000..e848c0c --- /dev/null +++ b/template/.toco/coding/README @@ -0,0 +1 @@ +The directory is used to store dedicated rules for Coding Agent, intended for the coding phase, and only supports .md files. \ No newline at end of file diff --git a/template/.toco/design/README b/template/.toco/design/README new file mode 100644 index 0000000..6fa3576 --- /dev/null +++ b/template/.toco/design/README @@ -0,0 +1 @@ +The directory is used to store dedicated rules for Design Agent, intended for the coding phase, and only supports .md files. \ No newline at end of file diff --git a/template/.toco/global/README b/template/.toco/global/README new file mode 100644 index 0000000..f96d3d0 --- /dev/null +++ b/template/.toco/global/README @@ -0,0 +1 @@ +The directory is used to store common rules for all agents and only supports .md files. \ No newline at end of file diff --git a/template/.toco/modeling/README b/template/.toco/modeling/README new file mode 100644 index 0000000..a31639f --- /dev/null +++ b/template/.toco/modeling/README @@ -0,0 +1 @@ +The directory is used to store dedicated rules for Modeling Agent, intended for the domain modeling phase, and only supports .md files. \ No newline at end of file diff --git a/template/.toco/plan/README b/template/.toco/plan/README new file mode 100644 index 0000000..20484f6 --- /dev/null +++ b/template/.toco/plan/README @@ -0,0 +1 @@ +The directory is used to store dedicated rules for the Plan Agent, intended for the overall planning phase, and only supports .md files. \ No newline at end of file diff --git a/template/.toco/toco/README b/template/.toco/toco/README new file mode 100644 index 0000000..f91b943 --- /dev/null +++ b/template/.toco/toco/README @@ -0,0 +1 @@ +The directory is used to store dedicated rules for the Toco Agent, intended for overall control of the outer workflow, and only supports .md files. \ No newline at end of file diff --git a/template/Dockerfile b/template/Dockerfile new file mode 100644 index 0000000..c5fac88 --- /dev/null +++ b/template/Dockerfile @@ -0,0 +1,20 @@ +FROM maven:3.8.8 AS builder +WORKDIR source +COPY ./ ./ +ARG JAR_FILE=entrance/web/target/*.jar +RUN mvn clean package -Dmaven.test.skip=true +RUN cp ${JAR_FILE} app.jar +RUN java -Djarmode=layertools -jar ./app.jar extract + +FROM openjdk:11.0.14 +WORKDIR /application +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +RUN echo 'Asia/Shanghai' >/etc/timezone +RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list +COPY --from=builder source/dependencies/ ./ +COPY --from=builder source/snapshot-dependencies/ ./ +COPY --from=builder source/spring-boot-loader/ ./ +COPY --from=builder source/application/ ./ +ENV JAVA_OPTS="-Xms512m -Xmx512m" +ENV MAIN_CLASS="org.springframework.boot.loader.JarLauncher" +ENTRYPOINT ["sh", "-c", "exec java ${JAVA_OPTS} -Djava.security.egd=file:dev/./urandom ${MAIN_CLASS}"] diff --git a/template/LICENSE b/template/LICENSE new file mode 100644 index 0000000..32b3071 --- /dev/null +++ b/template/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2019 RuoYi-Vue-Plus + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/template/common/README.md b/template/common/README.md new file mode 100644 index 0000000..2c38b66 --- /dev/null +++ b/template/common/README.md @@ -0,0 +1,5 @@ +> 本模块存放公共组件 +``` \-- *.utils(工具类; package) + \-- *.enums(公共枚举; package) + \-- *.constants(公共常量; package) +``` \ No newline at end of file diff --git a/template/common/pom.xml b/template/common/pom.xml new file mode 100644 index 0000000..331b798 --- /dev/null +++ b/template/common/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + + {{ .groupId }} + {{ .artifactId }} + ${revision} + + + {{ .groupId }} + {{ .artifactId }}-common + + + + + diff --git a/template/common/src/main/java/{{.packagePath}}/common/constants/README.md b/template/common/src/main/java/{{.packagePath}}/common/constants/README.md new file mode 100644 index 0000000..61310bb --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/constants/README.md @@ -0,0 +1,2 @@ +> 本模块存放公共常量 +``` \-- *Constant.java \ No newline at end of file diff --git a/template/common/src/main/java/{{.packagePath}}/common/enums/README.md b/template/common/src/main/java/{{.packagePath}}/common/enums/README.md new file mode 100644 index 0000000..f0628a1 --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/enums/README.md @@ -0,0 +1,2 @@ +> 本模块存放公共枚举 +``` \-- *Enum.java \ No newline at end of file diff --git a/template/common/src/main/java/{{.packagePath}}/common/mybatisplus/EmptyDdl.java b/template/common/src/main/java/{{.packagePath}}/common/mybatisplus/EmptyDdl.java new file mode 100644 index 0000000..347a1e6 --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/mybatisplus/EmptyDdl.java @@ -0,0 +1,25 @@ +package {{ .package }}.common.mybatisplus; + +import com.baomidou.mybatisplus.extension.ddl.IDdl; + +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.function.Consumer; + +import javax.sql.DataSource; + +@Component +public class EmptyDdl implements IDdl { + public void execute() { + // 空实现 + } + + @Override + public void runScript(Consumer consumer) {} + + @Override + public List getSqlFiles() { + return null; + } +} diff --git a/template/common/src/main/java/{{.packagePath}}/common/redis/RedisPoolConfig.java b/template/common/src/main/java/{{.packagePath}}/common/redis/RedisPoolConfig.java new file mode 100644 index 0000000..bf6d30e --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/redis/RedisPoolConfig.java @@ -0,0 +1,60 @@ +package {{ .package }}.common.redis; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import redis.clients.jedis.HostAndPort; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import redis.clients.jedis.JedisCluster; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.JedisPoolConfig; +import cn.hutool.core.util.StrUtil; +import org.springframework.beans.factory.annotation.Value; + + + +@Configuration +@EnableConfigurationProperties({RedisPoolProperties.class}) +@ConditionalOnProperty(name = "redis-config.pool.hostAndPort") +public class RedisPoolConfig { + @Autowired + private RedisPoolProperties redisPoolProperties; + @Value("${redis-config.pool.password:}") + private String password; + + private JedisPoolConfig initPoolConfig() { + JedisPoolConfig poolConfig = new JedisPoolConfig(); + poolConfig.setMaxTotal(redisPoolProperties.getMaxTotal()); + poolConfig.setMaxIdle(redisPoolProperties.getMaxIdle()); + poolConfig.setMinIdle(redisPoolProperties.getMinIdle()); + poolConfig.setNumTestsPerEvictionRun(redisPoolProperties.getNumTestsPerEvictionRun()); + poolConfig.setTestOnBorrow(redisPoolProperties.isTestOnBorrow()); + poolConfig.setTestOnReturn(redisPoolProperties.isTestOnReturn()); + poolConfig.setTestWhileIdle(redisPoolProperties.isTestWhileIdle()); + poolConfig.setBlockWhenExhausted(redisPoolProperties.isBlockWhenExhausted()); + poolConfig.setJmxEnabled(redisPoolProperties.isJmxEnabled()); + poolConfig.setLifo(redisPoolProperties.isLifo()); + poolConfig.setNumTestsPerEvictionRun(redisPoolProperties.getNumTestsPerEvictionRun()); + poolConfig.setTestOnBorrow(false); + return poolConfig; + } + + + /** + * create jedis poll + * + */ + @Bean + public JedisPool getRedisPool() { + String host = StrUtil.subBefore(redisPoolProperties.getHostAndPort(), ":", false); + int port = Integer.parseInt(StrUtil.subAfter(redisPoolProperties.getHostAndPort(), ":", false)); + if(StrUtil.isNotEmpty(this.password)) { + return new JedisPool(initPoolConfig(),host,port ,1000, password); + }else{ + return new JedisPool(initPoolConfig(),host,port); + } + } + +} diff --git a/template/common/src/main/java/{{.packagePath}}/common/redis/RedisPoolProperties.java b/template/common/src/main/java/{{.packagePath}}/common/redis/RedisPoolProperties.java new file mode 100644 index 0000000..f61c8ec --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/redis/RedisPoolProperties.java @@ -0,0 +1,145 @@ +package {{ .package }}.common.redis; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +@Configuration +@ConfigurationProperties(prefix = "redis-config.pool") +public class RedisPoolProperties { + private String hostAndPort; + private int maxTotal; + private int maxIdle; + private int minIdle; + private Long maxWaitMillis; + private Long timeBetweenEvictionRunsMillis; + private Long minEvictableIdleTimeMillis; + private Long softMinEvictableIdleTimeMillis; + private boolean testOnBorrow; + private boolean testOnReturn; + private boolean testWhileIdle; + private boolean blockWhenExhausted; + private boolean jmxEnabled; + private boolean lifo; + private int numTestsPerEvictionRun; + + public String getHostAndPort() { + return hostAndPort; + } + + public void setHostAndPort(String hostAndPort) { + this.hostAndPort = hostAndPort; + } + + public int getMaxTotal() { + return maxTotal; + } + + public void setMaxTotal(int maxTotal) { + this.maxTotal = maxTotal; + } + + public int getMaxIdle() { + return maxIdle; + } + + public void setMaxIdle(int maxIdle) { + this.maxIdle = maxIdle; + } + + public int getMinIdle() { + return minIdle; + } + + public void setMinIdle(int minIdle) { + this.minIdle = minIdle; + } + + public Long getMaxWaitMillis() { + return maxWaitMillis; + } + + public void setMaxWaitMillis(Long maxWaitMillis) { + this.maxWaitMillis = maxWaitMillis; + } + + public Long getTimeBetweenEvictionRunsMillis() { + return timeBetweenEvictionRunsMillis; + } + + public void setTimeBetweenEvictionRunsMillis(Long timeBetweenEvictionRunsMillis) { + this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; + } + + public Long getMinEvictableIdleTimeMillis() { + return minEvictableIdleTimeMillis; + } + + public void setMinEvictableIdleTimeMillis(Long minEvictableIdleTimeMillis) { + this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis; + } + + public Long getSoftMinEvictableIdleTimeMillis() { + return softMinEvictableIdleTimeMillis; + } + + public void setSoftMinEvictableIdleTimeMillis(Long softMinEvictableIdleTimeMillis) { + this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis; + } + + public boolean isTestOnBorrow() { + return testOnBorrow; + } + + public void setTestOnBorrow(boolean testOnBorrow) { + this.testOnBorrow = testOnBorrow; + } + + public boolean isTestOnReturn() { + return testOnReturn; + } + + public void setTestOnReturn(boolean testOnReturn) { + this.testOnReturn = testOnReturn; + } + + public boolean isTestWhileIdle() { + return testWhileIdle; + } + + public void setTestWhileIdle(boolean testWhileIdle) { + this.testWhileIdle = testWhileIdle; + } + + public boolean isBlockWhenExhausted() { + return blockWhenExhausted; + } + + public void setBlockWhenExhausted(boolean blockWhenExhausted) { + this.blockWhenExhausted = blockWhenExhausted; + } + + public boolean isJmxEnabled() { + return jmxEnabled; + } + + public void setJmxEnabled(boolean jmxEnabled) { + this.jmxEnabled = jmxEnabled; + } + + public boolean isLifo() { + return lifo; + } + + public void setLifo(boolean lifo) { + this.lifo = lifo; + } + + public int getNumTestsPerEvictionRun() { + return numTestsPerEvictionRun; + } + + public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) { + this.numTestsPerEvictionRun = numTestsPerEvictionRun; + } +} diff --git a/template/common/src/main/java/{{.packagePath}}/common/response/MyDateFormat.java b/template/common/src/main/java/{{.packagePath}}/common/response/MyDateFormat.java new file mode 100644 index 0000000..0bd8043 --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/response/MyDateFormat.java @@ -0,0 +1,48 @@ +package {{ .package }}.common.response; + +import java.text.*; +import java.util.Calendar; +import java.util.Date; + +public class MyDateFormat extends DateFormat { + private static final long serialVersionUID = -4580955831439573829L; + private static final String customDateFormat = "yyyy-MM-dd HH:mm:ss"; + private DateFormat dateFormat; + private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + public MyDateFormat(DateFormat dateFormat) { + this.calendar = Calendar.getInstance(); + this.dateFormat = dateFormat; + } + + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return this.dateFormat.format(date, toAppendTo, fieldPosition); + } + + public Date parse(String source, ParsePosition pos) { + Date date = null; + if (source.length() == "yyyy-MM-dd HH:mm:ss".length()) { + date = this.simpleDateFormat.parse(source, pos); + } else { + date = this.dateFormat.parse(source, pos); + } + + return date; + } + + public Date parse(String source) throws ParseException { + Date date = null; + if (source.length() == "yyyy-MM-dd HH:mm:ss".length()) { + date = this.simpleDateFormat.parse(source); + } else { + date = this.dateFormat.parse(source); + } + + return date; + } + + public Object clone() { + Object format = this.dateFormat.clone(); + return new MyDateFormat((DateFormat)format); + } +} \ No newline at end of file diff --git a/template/common/src/main/java/{{.packagePath}}/common/response/ResponseJsonExceptionResolver.java b/template/common/src/main/java/{{.packagePath}}/common/response/ResponseJsonExceptionResolver.java new file mode 100644 index 0000000..07fef21 --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/response/ResponseJsonExceptionResolver.java @@ -0,0 +1,118 @@ +package {{ .package }}.common.response; + +import com.vs.common.util.rpc.pub.FailData; +import com.vs.ox.common.exception.ErrorCode; +import com.vs.ox.common.exception.IgnoredException; +import com.vs.ox.common.utils.ObjectMapperFactory; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; +import jakarta.validation.Path; + +import lombok.extern.slf4j.Slf4j; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.Ordered; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.http.server.ServletServerHttpResponse; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +@Slf4j +public class ResponseJsonExceptionResolver extends AbstractHandlerExceptionResolver + implements InitializingBean { + private HttpMessageConverter messageConverter; + + public ResponseJsonExceptionResolver() {} + + @Override + public void afterPropertiesSet() throws Exception { + if (messageConverter == null) { + messageConverter = + new MappingJackson2HttpMessageConverter( + ObjectMapperFactory.getDefaultObjectMapper()); + } + } + + public static String getErrorInfoFromException(Exception e) { + try { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + return "\r\n" + sw.toString() + "\r\n"; + } catch (Exception e2) { + return "bad getErrorInfoFromException"; + } + } + + @Override + protected ModelAndView doResolveException( + HttpServletRequest request, + HttpServletResponse response, + Object handler, + Exception ex) { + /** web请求分页单独处理,应对antd框架 */ + FailData failData = new FailData(); + failData.setMessage(ex.getMessage()); + if (ex instanceof IgnoredException) { + IgnoredException realEx = (IgnoredException) ex; + failData.setCode(realEx.getErrorCode()); + failData.setData(realEx.getData()); + log.error("execute {} failed with exception", request.getRequestURL(), ex); + } else if (ex instanceof ConstraintViolationException) { + failData.setCode(ErrorCode.WRONG_PARAMETER); + failData.setMessage(getMessage((ConstraintViolationException) ex)); + } else if (ex instanceof ErrorCode) { + failData.setCode(((ErrorCode) ex).getErrorCode()); + } else { + log.error("execute {} failed with exception", request.getRequestURL(), ex); + } + try { + response.setCharacterEncoding("utf-8"); + messageConverter.write( + failData, MediaType.APPLICATION_JSON, new ServletServerHttpResponse(response)); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return new ModelAndView(); + } + + @Override + public int getOrder() { + return Ordered.LOWEST_PRECEDENCE; + } + + public static String getMessage(ConstraintViolationException e) { + List msgList = new ArrayList<>(); + for (ConstraintViolation constraintViolation : e.getConstraintViolations()) { + int i = 0; + StringBuilder param = new StringBuilder(); + for (Iterator iterator = constraintViolation.getPropertyPath().iterator(); + iterator.hasNext(); + i++) { + Path.Node node = iterator.next(); + if (i == 0) { + continue; + } + if (!param.toString().isBlank()) { + param.append("."); + } + param.append(node.getName()); + } + msgList.add("参数 [ " + param + " ] " + constraintViolation.getMessage()); + } + return StringUtils.join(msgList.toArray(), ";"); + } +} diff --git a/template/common/src/main/java/{{.packagePath}}/common/response/ResponseJsonMethodReturnValueHandler.java b/template/common/src/main/java/{{.packagePath}}/common/response/ResponseJsonMethodReturnValueHandler.java new file mode 100644 index 0000000..ea14b92 --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/response/ResponseJsonMethodReturnValueHandler.java @@ -0,0 +1,62 @@ +package {{ .package }}.common.response; + +import com.vs.common.util.rpc.pub.SuccessData; +import com.vs.ox.common.utils.ObjectMapperFactory; + +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.MethodParameter; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.http.server.ServletServerHttpResponse; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.method.support.HandlerMethodReturnValueHandler; +import org.springframework.web.method.support.ModelAndViewContainer; + +import java.util.Collections; + +/** 处理 Controller 里的返回值,从 Object转为Json */ +public class ResponseJsonMethodReturnValueHandler + implements HandlerMethodReturnValueHandler, InitializingBean { + private HttpMessageConverter messageConverter; + + @Override + public void afterPropertiesSet() { + if (messageConverter == null) { + messageConverter = + new MappingJackson2HttpMessageConverter( + ObjectMapperFactory.getDefaultObjectMapper()); + } + } + + @Override + public boolean supportsReturnType(MethodParameter returnType) { + return true; + } + + @Override + public void handleReturnValue( + Object returnValue, + MethodParameter returnType, + ModelAndViewContainer mavContainer, + NativeWebRequest webRequest) + throws Exception { + mavContainer.setRequestHandled(true); + Object result = returnValue; + /** Web分页请求的返回按照antd框架要求的格式,不转为SuccessData */ + result = + result == null + ? new SuccessData(Collections.emptyMap()) + : new SuccessData(returnValue); + ServletServerHttpResponse response = + new ServletServerHttpResponse( + webRequest.getNativeResponse(HttpServletResponse.class)); + messageConverter.write( + result, + new MediaType( + MediaType.APPLICATION_JSON, Collections.singletonMap("charset", "utf-8")), + response); + } +} diff --git a/template/common/src/main/java/{{.packagePath}}/common/response/WebMvcConfiguration.java b/template/common/src/main/java/{{.packagePath}}/common/response/WebMvcConfiguration.java new file mode 100644 index 0000000..c607c43 --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/response/WebMvcConfiguration.java @@ -0,0 +1,104 @@ +package {{ .package }}.common.response; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.method.annotation.MapMethodProcessor; +import org.springframework.web.method.support.HandlerMethodReturnValueHandler; +import org.springframework.web.servlet.HandlerExceptionResolver; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; +import org.springframework.web.servlet.mvc.method.annotation.ViewNameMethodReturnValueHandler; + +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +@Configuration +@ComponentScan("com.vs.ox") +public class WebMvcConfiguration implements WebMvcConfigurer, ApplicationContextAware { + private RequestMappingHandlerAdapter requestMappingHandlerAdapter; + private ApplicationContext applicationContext; + + // 删除 init 方法,在 setRequestMappingHandlerAdapter 中调用 + private void init() { + List returnValueHandlers = + this.requestMappingHandlerAdapter.getReturnValueHandlers(); + if (returnValueHandlers == null) { + return; // 避免空指针异常 + } + Iterator iterator = returnValueHandlers.iterator(); + List newProcessors = new ArrayList<>(); + while (iterator.hasNext()) { + HandlerMethodReturnValueHandler next = iterator.next(); + // 为了能在controller中直接返回map,不被默认的MapMethodProcessor拦截 + if (next instanceof MapMethodProcessor + || + // 为了能在controller中直接返回String,不被默认的ViewNameMethodReturnValueHandler拦截 + next instanceof ViewNameMethodReturnValueHandler) { + continue; + } else { + newProcessors.add(next); + } + } + this.requestMappingHandlerAdapter.setReturnValueHandlers(newProcessors); + } + + // 使用 configureHandlerExceptionResolvers 方法 + @Override + public void configureHandlerExceptionResolvers( + List exceptionResolvers) { + ResponseJsonExceptionResolver responseJsonExceptionResolver = + new ResponseJsonExceptionResolver(); + try { + responseJsonExceptionResolver.afterPropertiesSet(); + } catch (Exception e) { + e.printStackTrace(); + } + exceptionResolvers.add(responseJsonExceptionResolver); + } + + // 使用 addReturnValueHandlers 方法 + @Override + public void addReturnValueHandlers(List returnValueHandlers) { + ResponseJsonMethodReturnValueHandler responseJsonMethodReturnValueHandler = + new ResponseJsonMethodReturnValueHandler(); + responseJsonMethodReturnValueHandler.afterPropertiesSet(); + returnValueHandlers.add(responseJsonMethodReturnValueHandler); + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.applicationContext = applicationContext; + } + + @Autowired private Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder; + + @Bean + public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { + ObjectMapper mapper = jackson2ObjectMapperBuilder.build(); + DateFormat dateFormat = mapper.getDateFormat(); + mapper.setDateFormat(new MyDateFormat(dateFormat)); + MappingJackson2HttpMessageConverter mappingJsonpHttpMessageConverter = + new MappingJackson2HttpMessageConverter(mapper); + return mappingJsonpHttpMessageConverter; + } + + // 删除 ServletContextListener,使用 ApplicationListener 或 BeanPostProcessor + // 或者直接注入 RequestMappingHandlerAdapter + @Autowired + public void setRequestMappingHandlerAdapter( + RequestMappingHandlerAdapter requestMappingHandlerAdapter) { + this.requestMappingHandlerAdapter = requestMappingHandlerAdapter; + init(); // 在这里调用 init 方法 + } +} diff --git a/template/common/src/main/java/{{.packagePath}}/common/utils/README.md b/template/common/src/main/java/{{.packagePath}}/common/utils/README.md new file mode 100644 index 0000000..f4bb11f --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/utils/README.md @@ -0,0 +1,3 @@ +> 本模块存放公共工具类 +``` \-- *Util.java +``` \ No newline at end of file diff --git a/template/entrance/README.md b/template/entrance/README.md new file mode 100644 index 0000000..57f8ae9 --- /dev/null +++ b/template/entrance/README.md @@ -0,0 +1 @@ +> 应用入口 \ No newline at end of file diff --git a/template/entrance/pom.xml b/template/entrance/pom.xml new file mode 100644 index 0000000..5a229eb --- /dev/null +++ b/template/entrance/pom.xml @@ -0,0 +1,22 @@ + + + + 4.0.0 + + {{ .groupId }} + {{ .artifactId }} + ${revision} + + {{ .artifactId }}-entrance + pom + + + {{ .groupId }} + {{ .artifactId }}-common + ${revision} + + + + web + + \ No newline at end of file diff --git a/template/entrance/web/pom.xml b/template/entrance/web/pom.xml new file mode 100644 index 0000000..dc92229 --- /dev/null +++ b/template/entrance/web/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + + {{ .groupId }} + {{ .artifactId }}-entrance + ${revision} + + + {{ .artifactId }}-entrance-web + + + + diff --git a/template/entrance/web/src/main/java/{{.packagePath}}/entrance/web/AppApplication.java b/template/entrance/web/src/main/java/{{.packagePath}}/entrance/web/AppApplication.java new file mode 100644 index 0000000..6efd6fe --- /dev/null +++ b/template/entrance/web/src/main/java/{{.packagePath}}/entrance/web/AppApplication.java @@ -0,0 +1,26 @@ +package {{ .package }}.entrance.web; + +import com.vs.sqlmapper.spring.DataSourceConfig; +import com.vs.sqlmapper.spring.scan.VSDaoBeanScan; +import com.vs.agent.TocoAgentInitializer; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Import; +import org.springframework.scheduling.annotation.EnableScheduling; + + +@SpringBootApplication(scanBasePackages = {"{{.groupId}}", "com.vs"}) +@VSDaoBeanScan(basePackages = {"com.vs","{{.groupId}}"}) +@Import(DataSourceConfig.class) +@MapperScan("{{.groupId}}.**.persist.mapper.mybatis") +@EnableScheduling +public class AppApplication{ + + public static void main(String[] args) { + SpringApplication application = new SpringApplication(AppApplication.class); + application.run(args); + } +} diff --git a/template/entrance/web/src/main/resources/application-local.properties b/template/entrance/web/src/main/resources/application-local.properties new file mode 100644 index 0000000..8d4b69e --- /dev/null +++ b/template/entrance/web/src/main/resources/application-local.properties @@ -0,0 +1,17 @@ +server.port=8082 + +mock.enabled=true +#datasource +{{- if eq .dbType "oracle" }} +spring.datasource.url=jdbc:oracle:thin:@//{{ .dbHost }}:1521/ORCLCDB +{{- else if eq .dbType "postgresql" }} +spring.datasource.url=jdbc:postgresql://{{ .dbHost }}:5432/{{ .dbDatabase }}?useUnicode=true&characterEncoding=utf8&autoReconnect=true&stringtype=unspecified +{{- else if eq .dbType "mysql" }} +spring.datasource.url=jdbc:mysql://${DB_HOST:10.0.2.201:3306}/${DB_DATABASE:hande_test}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai +{{- else if eq .dbType "dm"}} +spring.datasource.url=jdbc:dm://${ .dbHost }/5236/SYSDBA?characterEncoding=utf-8&serverTimezone=Asia/Shanghai +{{- end }} +spring.datasource.username=${DB_USER:hande_test_user} +spring.datasource.password=${DB_PASSWORD:Yu0FvhjUQDGdnmm5} +spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource +spring.datasource.tomcat.max-age=3600000 \ No newline at end of file diff --git a/template/entrance/web/src/main/resources/application-online.properties b/template/entrance/web/src/main/resources/application-online.properties new file mode 100644 index 0000000..f15c810 --- /dev/null +++ b/template/entrance/web/src/main/resources/application-online.properties @@ -0,0 +1,17 @@ +server.port=8080 + +#datasource +{{- if eq .dbType "oracle" }} +spring.datasource.url=jdbc:oracle:thin:@//{{ .dbHost }}:{{ .dbPort }}/ORCLCDB +{{- else if eq .dbType "postgresql" }} +spring.datasource.url=jdbc:postgresql://{{ .dbHost }}:{{ .dbPort }}/{{ .dbDatabase }}?useUnicode=true&characterEncoding=utf8&autoReconnect=true&stringtype=unspecified +{{- else if eq .dbType "mysql" }} +spring.datasource.url=jdbc:mysql://${DB_HOST:10.0.2.201:3306}/${DB_DATABASE:hande_test}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai +{{- else if eq .dbType "dm"}} +spring.datasource.url=jdbc:dm://${ .dbHost }/${ .dbPort }/SYSDBA?characterEncoding=utf-8&serverTimezone=Asia/Shanghai +{{- end }} +spring.datasource.username=${DB_USER:hande_test_user} +spring.datasource.password=${DB_PASSWORD:Yu0FvhjUQDGdnmm5} +spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource + + diff --git a/template/entrance/web/src/main/resources/application-remote.properties b/template/entrance/web/src/main/resources/application-remote.properties new file mode 100644 index 0000000..bb29233 --- /dev/null +++ b/template/entrance/web/src/main/resources/application-remote.properties @@ -0,0 +1,15 @@ +server.port=8080 + +#datasource +{{- if eq .dbType "oracle" }} +spring.datasource.url=jdbc:oracle:thin:@//{{ .dbHost }}:{{ .dbPort }}/ORCLCDB +{{- else if eq .dbType "postgresql" }} +spring.datasource.url=jdbc:postgresql://{{ .dbHost }}:{{ .dbPort }}/{{ .dbDatabase }}?useUnicode=true&characterEncoding=utf8&autoReconnect=true&stringtype=unspecified +{{- else if eq .dbType "mysql" }} +spring.datasource.url=jdbc:mysql://${DB_HOST:10.0.2.201:3306}/${DB_DATABASE:hande_test}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai +{{- else if eq .dbType "dm"}} +spring.datasource.url=jdbc:dm://${ .dbHost }/${ .dbPort }/SYSDBA?characterEncoding=utf-8&serverTimezone=Asia/Shanghai +{{- end }} +spring.datasource.username=${DB_USER:hande_test_user} +spring.datasource.password=${DB_PASSWORD:Yu0FvhjUQDGdnmm5} +spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource diff --git a/template/entrance/web/src/main/resources/application.properties b/template/entrance/web/src/main/resources/application.properties new file mode 100644 index 0000000..6091d77 --- /dev/null +++ b/template/entrance/web/src/main/resources/application.properties @@ -0,0 +1,72 @@ +spring.profiles.active=local +envs=local,remote,online,custom +check=true +spring.main.allow-bean-definition-overriding=true +spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER +spring.jpa.open-in-view=false +spring.main.allow-circular-references=true +spring.login.security.csrf=false +application.name={{ .projectName }} +mybatis.configuration.map-underscore-to-camel-case=true +project_id={{ .projectId }} +project_name={{ .projectName }} +base.package={{.groupId}} +{{- if eq .dbType "mysql" }} +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +hibernate.dialect=org.hibernate.dialect.MySQLDialect +{{- else if eq .dbType "postgresql" }} +spring.datasource.driver-class-name=org.postgresql.Driver +vs.sqlmapper.dialect=postgresql +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +{{- else if eq .dbType "oracle" }} +spring.datasource.driver-class-name=oracle.jdbc.OracleDriver +hibernate.dialect=org.hibernate.dialect.OracleDialect +vs.sqlmapper.dialect=oracle +{{- else if eq .dbType "dm" }} +spring.datasource.driver-class-name=dm.jdbc.driver.DmDriver +hibernate.dialect=org.hibernate.dialect.DmDialect +vs.sqlmapper.dialect=dm +{{- end }} +com.toco.agent.attach=false + +#create default table +vs.db.basetable.create=true +server.ssl.enabled=false +server.forward-headers-strategy=framework +#request header +out.request.headers= +#response header +out.response.headers=Content-Type +#custom corss-domain headers, split by ',' +cross.domain.headers= +#eg:https://vsstudio.teitui.com +out.host= +#hibernate.show_sql=true +#vs.sqlmapper.showSql=true +mock.enabled=false + +## message config , use memory for test, mq.type can be redis/rocketmq/kafka +mq.type=memory + +#rocketmq.name-server=${ROCKETMQ_HOST:10.0.2.221:9876;10.0.2.222:9876;10.0.2.223:9876} + +#redis +#redis-config.pool.hostAndPort=${REDIS_HOST:redis.byteawake.com:6379} +#redis-config.pool.password=${REDIS_PASSWORD:} +#redis-config.pool.maxTotal=100 +#redis-config.pool.maxIdle=10 +#redis-config.pool.minIdle=10 +#redis-config.pool.maxWaitMillis=10000 +#redis-config.pool.softMinEvictableIdleTimeMillis=10000 +#redis-config.pool.testOnBorrow=true +#redis-config.pool.testOnReturn=true +#redis-config.pool.testWhileIdle=true +#redis-config.pool.timeBetweenEvictionRunsMillis=30000 +#redis-config.pool.minEvictableIdleTimeMillis=1800000 +#redis-config.pool.numTestsPerEvictionRun=3 +#redis-config.pool.blockWhenExhausted=true +#redis-config.pool.jmxEnabled=true +#redis-config.pool.lifo=true + +#kafka.bootstrap-servers=localhost:9092 diff --git a/template/entrance/web/src/main/resources/visitor_agents.conf b/template/entrance/web/src/main/resources/visitor_agents.conf new file mode 100644 index 0000000..ae84c2a --- /dev/null +++ b/template/entrance/web/src/main/resources/visitor_agents.conf @@ -0,0 +1,26 @@ +[debug.server.host] +// 这块,目前基本是写死这样的配置,不要修改 +vs.debug.host = http://vsstudio.teitui.com + +[debug.proxy.custom] +// 定义需要增强的classs,没有增加的class不记录堆栈 +// 一般明显不需要记录的class,配置成: class.name=false +// 正则表述式支持,请注意书写 +// class.pattern = true 表示要增强记录堆栈的 + +// 自定义的增加的类 + +com.vs.entrance.controller.env.register.DebugEnvRegisterTask=false +com.vs.common.util.rpc.pub.PublicInterfaceExecutor = true +[execute] +com.vs.common.util.rpc.pub.PublicInterfaceFilter = true +[doFilter] +org.springframework.http.converter.json.MappingJackson2HttpMessageConverter=true + +com.vs.sqlmapper.core.SqlManagerImpl = true +[sqlWatcher] +com.vs.common.util.rpc.RpcMethodExecutor = true + +[debug.proxy.service] +// 默认支持serivce下面的所有类,放到最后一行 + +.*?\.service[\.\w_]+ = true -[set*, get*] +.*?\.controller[\.\w_]+ = true -[set*, get*] +.*?\.hibernate[\.\w_]+ = false \ No newline at end of file diff --git a/template/modules/.gitkeep b/template/modules/.gitkeep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/template/modules/.gitkeep @@ -0,0 +1 @@ + diff --git a/template/mvnw b/template/mvnw new file mode 100755 index 0000000..8d937f4 --- /dev/null +++ b/template/mvnw @@ -0,0 +1,308 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.2.0 +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "$(uname)" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=$(java-config --jre-home) + fi +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && + JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=$(which readlink) + if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + if $darwin ; then + javaHome="$(dirname "\"$javaExecutable\"")" + javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" + else + javaExecutable="$(readlink -f "\"$javaExecutable\"")" + fi + javaHome="$(dirname "\"$javaExecutable\"")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$(cd "$wdir/.." || exit 1; pwd) + fi + # end of workaround + done + printf '%s' "$(cd "$basedir" || exit 1; pwd)" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + # Remove \r in case we run on Windows within Git Bash + # and check out the repository with auto CRLF management + # enabled. Otherwise, we may read lines that are delimited with + # \r\n and produce $'-Xarg\r' rather than -Xarg due to word + # splitting rules. + tr -s '\r\n' ' ' < "$1" + fi +} + +log() { + if [ "$MVNW_VERBOSE" = true ]; then + printf '%s\n' "$1" + fi +} + +BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR +log "$MAVEN_PROJECTBASEDIR" + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ -r "$wrapperJarPath" ]; then + log "Found $wrapperJarPath" +else + log "Couldn't find $wrapperJarPath, downloading it ..." + + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + fi + while IFS="=" read -r key value; do + # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) + safeValue=$(echo "$value" | tr -d '\r') + case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; + esac + done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget > /dev/null; then + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + fi + else + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read -r key value; do + case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; + esac +done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + wrapperSha256Result=false + if command -v sha256sum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + elif command -v shasum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." + exit 1 + fi + if [ $wrapperSha256Result = false ]; then + echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 + echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 + echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 + exit 1 + fi +fi + +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +# shellcheck disable=SC2086 # safe args +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/template/mvnw.cmd b/template/mvnw.cmd new file mode 100755 index 0000000..c4586b5 --- /dev/null +++ b/template/mvnw.cmd @@ -0,0 +1,205 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.2.0 +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %WRAPPER_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file +SET WRAPPER_SHA_256_SUM="" +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B +) +IF NOT %WRAPPER_SHA_256_SUM%=="" ( + powershell -Command "&{"^ + "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ + "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ + " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " exit 1;"^ + "}"^ + "}" + if ERRORLEVEL 1 goto error +) + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/template/pom.xml b/template/pom.xml new file mode 100644 index 0000000..082fdb8 --- /dev/null +++ b/template/pom.xml @@ -0,0 +1,293 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.2.11 + + {{ .groupId }} + {{ .artifactId }} + ${revision} + pom + + UTF-8 + 17 + 17 + UTF-8 + 3.0-SNAPSHOT + + + + cn.hutool + hutool-all + 5.7.4 + + + junit + junit + 4.13 + + + ch.qos.logback + logback-classic + 1.4.8 + + + com.alibaba + transmittable-thread-local + 2.12.3 + + + org.json + json + 20170516 + + + org.apache.httpcomponents + httpasyncclient + 4.1.5 + + + org.slf4j + slf4j-api + 2.0.7 + + + com.google.guava + guava + 32.0.0-jre + + + org.apache.httpcomponents + httpclient + 4.5.13 + + + org.apache.httpcomponents + httpmime + 4.5.13 + + + com.fasterxml.jackson.core + jackson-databind + 2.15.2 + + + io.swagger + swagger-annotations + 1.5.22 + + + io.swagger + swagger-models + 1.5.21 + + + io.springfox + springfox-swagger-ui + 2.9.2 + + + io.springfox + springfox-swagger2 + 2.9.2 + + + cglib + cglib-nodep + 3.3.0 + + + com.xuxueli + xxl-job-core + 2.2.0 + + + org.apache.commons + commons-lang3 + 3.12.0 + + + org.aspectj + aspectjrt + 1.9.6 + + + redis.clients + jedis + 3.3.0 + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + org.projectlombok + lombok + 1.18.20 + + + org.springframework.boot + spring-boot-dependencies + 3.2.1 + pom + + + commons-logging + commons-logging + 1.2 + + + com.caucho + hessian + 4.0.63 + + + org.hibernate + hibernate-core + 6.6.4.Final + + + io.github.think-1024 + toco-all-spring6-springboot3-community + 1.0 + + + com.baomidou + mybatis-plus-boot-starter + 3.5.7 + + + org.mybatis + mybatis-spring + 3.0.4 + + + org.mybatis + mybatis + 3.5.16 + + + com.baomidou + mybatis-plus-core + 3.5.7 + + {{- if eq .dbType "dm" }} + + dm + DmJdbcDriver + 18 + + + com.dameng + DmDialect-for-hibernate5.6 + 8.1.3.140 + + {{- else if eq .dbType "mysql" }} + + mysql + mysql-connector-java + 8.0.27 + + {{- else if eq .dbType "postgresql" }} + + org.postgresql + postgresql + 42.6.2 + + {{- else if eq .dbType "oracle" }} + + com.oracle.database.jdbc + ojdbc8 + 21.9.0.0 + + {{- end }} + + jakarta.annotation + jakarta.annotation-api + + + jakarta.persistence + jakarta.persistence-api + + + jakarta.transaction + jakarta.transaction-api + + + jakarta.validation + jakarta.validation-api + + + org.springframework + spring-orm + + + commons-collections + commons-collections + 3.2.2 + + + org.springframework + spring-webmvc + + + org.apache.httpcomponents + httpasyncclient + + + org.springframework + spring-web + + + io.springfox + springfox-spring-web + 3.0.0 + + + org.apache.tomcat + tomcat-jdbc + 9.0.83 + + + jakarta.servlet + jakarta.servlet-api + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + UTF-8 + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + + entrance + common + + + + diff --git a/template/project b/template/project new file mode 100644 index 0000000..aec3bd0 --- /dev/null +++ b/template/project @@ -0,0 +1,3 @@ +id={{ .projectId }} +name={{ .projectName | replace "-" "_" }} +version={{ .vsVersion }} \ No newline at end of file diff --git a/values.yml b/values.yml new file mode 100644 index 0000000..1a5d1fa --- /dev/null +++ b/values.yml @@ -0,0 +1,33 @@ +groupId: com.vs +projectName: volunteer-bank +artifactId: '{{ .projectName | replace "-" "_" }}' +applicationName: "{{ .projectName }}-server" +version: 3.1.0-SNAPSHOT +vsVersion: 1.0.0 +package: "{{ .groupId }}.{{ .artifactId }}" +packagePath: '{{ .package | replace "." "/" }}' +projectId: 06bbe5bc-2174-42ab-aa63-2f1ed5636324 +dbType: mysql +dbHost: 10.0.2.201 +dbPort: 3306 +dbDatabase: '{{ .projectName | replace "-" "_" }}' +dbUsername: '{{ .projectName | replace "-" "_" }}_user' +dbPassword: "{{ randAlphaNum 16 }}" +rocketmq_address: "10.0.2.221:9876;10.0.2.222:9876;10.0.2.223:9876" +rocketmq_topic: '{{ .projectName | replace "-" "_" }}' +rocketmq_consumerGroup: "CID_{{ .artifactId }}" +rocketmq_producerGroup: "PID_{{ .artifactId }}" +elasticsearch_host: "10.0.2.221,10.0.2.222,10.0.2.223" +elasticsearch_port: "9200" +elasticsearch_scheme: "https" +elasticsearch_username: "admin" +elasticsearch_password: "ha/KuGfy" +xxljob_address: "https://xxljob.teitui.com/xxl-job-admin" +xxljob_username: "admin" +xxljob_password: "123456" +xxljob_accessToken: "default_token" +redis_address: "redis.byteawake.com:6379" +redis_password: "" +redis_maxTotal: 100 +redis_maxIdle: 10 +redis_minIdle: 10 \ No newline at end of file