20250417
This commit is contained in:
13
datasource-config-yml.code-snippets
Normal file
13
datasource-config-yml.code-snippets
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"Jpa config yml": {
|
||||||
|
"prefix": "datasource-config",
|
||||||
|
"scope": "spring-boot-properties-yaml",
|
||||||
|
"body": [
|
||||||
|
"datasource:",
|
||||||
|
"\turl: jdbc:${1|postgresql,mariadb|}://${2:localhost}:${3|5432,3306|}/${4:database}",
|
||||||
|
"\tusername: ${5|postgres,root|}",
|
||||||
|
"\tpassword: ${6:xxxxxx}",
|
||||||
|
],
|
||||||
|
"description": "datasource-config",
|
||||||
|
}
|
||||||
|
}
|
17
http.code-snippets
Normal file
17
http.code-snippets
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"post-json": {
|
||||||
|
"scope": "http",
|
||||||
|
"prefix": "post-json",
|
||||||
|
"body": [
|
||||||
|
"### description",
|
||||||
|
"POST http://${1:zhouxy.xyz/api} HTTP/1.1",
|
||||||
|
"Accept: application/json",
|
||||||
|
"Content-Type: application/json",
|
||||||
|
"$2",
|
||||||
|
"",
|
||||||
|
"{",
|
||||||
|
" \"${3:key}\": ${4:value}$5",
|
||||||
|
"}",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
}
|
32
java-enumeration.code-snippets
Normal file
32
java-enumeration.code-snippets
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"Create a Enumeration": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "enumeration",
|
||||||
|
"isFileTemplate": true,
|
||||||
|
"body": [
|
||||||
|
"import java.util.Collection;",
|
||||||
|
"",
|
||||||
|
"import xyz.zhouxy.plusone.commons.util.Enumeration;",
|
||||||
|
"",
|
||||||
|
"public final class ${1:$TM_FILENAME_BASE} extends Enumeration<${1:$TM_FILENAME_BASE}> {",
|
||||||
|
"",
|
||||||
|
"\tprivate ${1:$TM_FILENAME_BASE}(int id, String name) {",
|
||||||
|
"\t\tsuper(id, name);",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tpublic static final ${1:$TM_FILENAME_BASE} ${2:EXAMPLE} = new ${1:$TM_FILENAME_BASE}(${3:0}, \"${4:正常}\");$5",
|
||||||
|
"",
|
||||||
|
"\tprivate static final ValueSet<${1:$TM_FILENAME_BASE}> VALUE_SET = ValueSet.of(${2:EXAMPLE}$6);",
|
||||||
|
"",
|
||||||
|
"\tpublic static ${1:$TM_FILENAME_BASE} of(int id) {",
|
||||||
|
"\t\treturn VALUE_SET.get(id);",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tpublic static Collection<${1:$TM_FILENAME_BASE}> values() {",
|
||||||
|
"\t\treturn VALUE_SET.getValues();",
|
||||||
|
"\t}",
|
||||||
|
"}",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
513
java.code-snippets
Normal file
513
java.code-snippets
Normal file
@@ -0,0 +1,513 @@
|
|||||||
|
{
|
||||||
|
"Import Java Utils": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "import_java_util",
|
||||||
|
"body": [
|
||||||
|
"import java.util.${1|*,Objects,Collection,List,ArrayList,LinkedList,Map,HashMap,ConcurrentHashMap,Set,HashSet,Collections,Arrays|};",
|
||||||
|
],
|
||||||
|
"description": "Import classes in package java.util."
|
||||||
|
},
|
||||||
|
"Import Java Time": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "import_java_time",
|
||||||
|
"body": [
|
||||||
|
"import java.time.${1|*,LocalDateTime,LocalDate,LocalTime,ZoneDateTime,ZoneId,ZoneOffset,ZoneRegion,Year,Month,MonthDay,DayOfWeek,YearMonth|};",
|
||||||
|
],
|
||||||
|
"description": "Import classes in package java.time."
|
||||||
|
},
|
||||||
|
"const": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "const",
|
||||||
|
"body": "${1|private ,protected ,public |}static final ${2:String} ${3:CONST_NAME} = $4;"
|
||||||
|
},
|
||||||
|
"iterator": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "iterator",
|
||||||
|
"body": [
|
||||||
|
"final Iterator<${2|Integer,Long,String|}> ${3:iterator} = $1.iterator();",
|
||||||
|
"while (${3:iterator}.hasNext()) {",
|
||||||
|
"\tfinal ${2|Integer,Long,String|} ${4:item} = ${3:iterator}.next();",
|
||||||
|
"\t$5",
|
||||||
|
"}",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Throw exception": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "thr",
|
||||||
|
"body": "throw $0;"
|
||||||
|
},
|
||||||
|
"Throw new exception": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": ["thrownew", "thn"],
|
||||||
|
"body": "throw new ${1|IllegalArgumentException,IllegalStateException,NullPointerException,UnsupportedOperationException,ArithmeticException,ClassCastException,ArrayIndexOutOfBoundsException,NumberFormatException,RuntimeException,EnumConstantNotPresentException|}($2);",
|
||||||
|
"description": "Throw new exception"
|
||||||
|
},
|
||||||
|
"Return result": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "ret",
|
||||||
|
"body": [
|
||||||
|
"return ${1|this,result|};",
|
||||||
|
],
|
||||||
|
"description": "Return result"
|
||||||
|
},
|
||||||
|
"Return success": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "success",
|
||||||
|
"body": [
|
||||||
|
"return UnifiedResponses.success($1);",
|
||||||
|
],
|
||||||
|
"description": "return UnifiedResponses#success"
|
||||||
|
},
|
||||||
|
"Charset": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "charset",
|
||||||
|
"body": "StandardCharsets.${1|UTF_8,UTF_16,UTF_16BE,UTF_16LE,US_ASCII,ISO_8859_1|}"
|
||||||
|
},
|
||||||
|
"GetById": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "getById",
|
||||||
|
"body": [
|
||||||
|
"@GetMapping(\"{${2:id}}\")",
|
||||||
|
"public UnifiedResponse ${1:findById}(@PathVariable(\"${2:id}\") Long ${2:id}) {",
|
||||||
|
"\tvar result = $4;",
|
||||||
|
"\treturn UnifiedResponses.success(${3:\"查询成功\"}, result);",
|
||||||
|
"}",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Constructor": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "constructor",
|
||||||
|
"body": [
|
||||||
|
"${1|public ,protected ,private |}${2:$TM_FILENAME_BASE}($3) {$4",
|
||||||
|
"}",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Constructor for utility class": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "constructor-for-utility-class",
|
||||||
|
"body": [
|
||||||
|
"$2",
|
||||||
|
"",
|
||||||
|
"private ${1:$TM_FILENAME_BASE}() {",
|
||||||
|
"\tthrow new IllegalStateException(\"Utility class\");",
|
||||||
|
"}",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Field": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "field",
|
||||||
|
"body": "${1|private ,protected ,public |}${4|@Getter ,@Setter ,@Getter @Setter |}${2:String} ${3:username};"
|
||||||
|
},
|
||||||
|
"Internal method": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "internal_method",
|
||||||
|
"body": [
|
||||||
|
"/*$5 */",
|
||||||
|
"${1|private ,protected |}${2:void} ${3:method}Internal($4) {",
|
||||||
|
"\t",
|
||||||
|
"}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Static internal method": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "static_internal_method",
|
||||||
|
"body": [
|
||||||
|
"/*$5 */",
|
||||||
|
"${1|private ,protected |}static ${2:void} ${3:method}Internal($4) {",
|
||||||
|
"\t",
|
||||||
|
"}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"TODO": {
|
||||||
|
"scope": "java,javascript,typescript",
|
||||||
|
"prefix": ["TODO", "todo"],
|
||||||
|
"body": "// TODO [${1|修复,添加,优化,重构|}] ${2:msg}",
|
||||||
|
"description": "待办事项"
|
||||||
|
},
|
||||||
|
"FIXME": {
|
||||||
|
"scope": "java,javascript,typescript",
|
||||||
|
"prefix": ["FIXME", "fixme"],
|
||||||
|
"body": "// FIXME $1",
|
||||||
|
"description": "修复"
|
||||||
|
},
|
||||||
|
"XXX": {
|
||||||
|
"scope": "java,javascript,typescript",
|
||||||
|
"prefix": ["XXX", "xxx"],
|
||||||
|
"body": "// XXX $1",
|
||||||
|
"description": "待优化"
|
||||||
|
},
|
||||||
|
"NOSONAR": {
|
||||||
|
"scope": "java,javascript,typescript",
|
||||||
|
"prefix": [
|
||||||
|
"nosonar",
|
||||||
|
"sonarIgnore"
|
||||||
|
],
|
||||||
|
"body": "// NOSONAR$1"
|
||||||
|
},
|
||||||
|
"Slf4jLog": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "log-slf4j",
|
||||||
|
"body": "private static final Logger log = LoggerFactory.getLogger(${1:$TM_FILENAME_BASE}.class);"
|
||||||
|
},
|
||||||
|
"log a var": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "log-var",
|
||||||
|
"body": "log.${1|info,debug,error|}(\"${2:var}: {}\", ${2:var});"
|
||||||
|
},
|
||||||
|
"log a obj": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "log-obj",
|
||||||
|
"body": "log.${1|info,debug,error|}(\"{}\", ${2:var});"
|
||||||
|
},
|
||||||
|
"List": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "list",
|
||||||
|
"body": "List<${1:T}> ${2:list} = new ${3|ArrayList,LinkedList|}<>($4);"
|
||||||
|
},
|
||||||
|
"HashMap": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "map",
|
||||||
|
"body": "Map<${1:K}, ${2:V}> ${3:map} = new ${4|HashMap,ConcurrentHashMap|}<>($5);"
|
||||||
|
},
|
||||||
|
"collect": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "collect",
|
||||||
|
"body": ".collect(Collectors.${1|toSet(),toList()|})"
|
||||||
|
},
|
||||||
|
"toArray": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "toArray",
|
||||||
|
"body": ".toArray(${1|String,Integer,Long,SqlParameterSource|}[]::new)"
|
||||||
|
},
|
||||||
|
"SuppressWarnings": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "suppressWarnings",
|
||||||
|
"body": "@SuppressWarnings(\"${1|all,boxing,cast,dep-ann,deprecation,fallthrough,finally,hiding,incomplete-switch,nls,null,rawtypes,restriction,serial,static-access,synthetic-access,unchecked,unqualified-field-access,unused|}\")",
|
||||||
|
},
|
||||||
|
"TimeMillis' now": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "now",
|
||||||
|
"body": "${2|long,var|} ${1:now} = System.currentTimeMillis();"
|
||||||
|
},
|
||||||
|
"Date's now": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "now",
|
||||||
|
"body": "${2|Date,var|} ${1:now} = new Date();"
|
||||||
|
},
|
||||||
|
"LocalDateTime's now": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "now",
|
||||||
|
"body": "${2|LocalDateTime,var|} ${1:now} = LocalDateTime.now();"
|
||||||
|
},
|
||||||
|
"ZonedDateTime's now": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "now",
|
||||||
|
"body": "${2|ZonedDateTime,var|} ${1:now} = ZonedDateTime.now();"
|
||||||
|
},
|
||||||
|
"Instant's now": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "now",
|
||||||
|
"body": "${2|Instant,var|} ${1:now} = Instant.now();"
|
||||||
|
},
|
||||||
|
"today": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "today",
|
||||||
|
"body": "${2|LocalDate,var|} ${1|now,today|} = LocalDate.now();"
|
||||||
|
},
|
||||||
|
"Get Optional": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "optional_getter",
|
||||||
|
"body": [
|
||||||
|
"public Optional<${1:Email}> get${2:Email}() {",
|
||||||
|
"\treturn Optional.ofNullable(${3:email});",
|
||||||
|
"}",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"lombok-pojo": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "lombok-pojo",
|
||||||
|
"body": [
|
||||||
|
"@Getter",
|
||||||
|
"@Setter",
|
||||||
|
"@NoArgsConstructor",
|
||||||
|
"@ToString${1:(callSuper = true)}",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Copyright Apache License 2.0": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "copyright-apache-license-2",
|
||||||
|
"body": [
|
||||||
|
"/*",
|
||||||
|
" * Copyright ${1:$CURRENT_YEAR}-${2:$CURRENT_YEAR} ${3:the original author or authors}.",
|
||||||
|
" *",
|
||||||
|
" * Licensed 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",
|
||||||
|
" *",
|
||||||
|
" * https://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.",
|
||||||
|
" */\n",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"JavaDoc for class": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "javadoc-class",
|
||||||
|
"body": [
|
||||||
|
"/**",
|
||||||
|
" * ${1:$TM_FILENAME_BASE}",
|
||||||
|
" *",
|
||||||
|
" * <p>",
|
||||||
|
" * ${2:description}",
|
||||||
|
" * </p>",
|
||||||
|
" *",
|
||||||
|
" * <p>",
|
||||||
|
" * <b>NOTE: ${3:content}.</b>",
|
||||||
|
" * </p>",
|
||||||
|
" * @author ${4:<a href=\"${5:http://zhouxy.xyz:3000/ZhouXY108}\">${6:ZhouXY}</a>}",
|
||||||
|
" * @since $7",
|
||||||
|
" * @see $8",
|
||||||
|
" */",
|
||||||
|
],
|
||||||
|
"description": "JavaDoc for class"
|
||||||
|
},
|
||||||
|
"inheritDoc": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": ["javadoc-inheritDoc", "doc-inheritDoc"],
|
||||||
|
"body": "/** {@inheritDoc} */"
|
||||||
|
},
|
||||||
|
"Jdbc Template": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "jdbc",
|
||||||
|
"body": "private final ${1|NamedParameterJdbcTemplate,JdbcTemplate|} ${2:jdbcTemplate};"
|
||||||
|
},
|
||||||
|
"JUnit4 test class": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "test-class-junit4",
|
||||||
|
"isFileTemplate": true,
|
||||||
|
"body": [
|
||||||
|
"import org.junit.Test;",
|
||||||
|
"",
|
||||||
|
"import static org.junit.Assert.*;",
|
||||||
|
"",
|
||||||
|
"public class ${1:$TM_FILENAME_BASE} {",
|
||||||
|
"",
|
||||||
|
"\t@Test",
|
||||||
|
"\tpublic void test$2() {",
|
||||||
|
"\t\t$3",
|
||||||
|
"\t}",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"JUnit4 test case": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "test-case-junit4",
|
||||||
|
"body": [
|
||||||
|
"@Test",
|
||||||
|
"public void test$1() {",
|
||||||
|
"\t$2",
|
||||||
|
"}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"JUnit5 test class": {
|
||||||
|
"scope": "java",
|
||||||
|
"isFileTemplate": true,
|
||||||
|
"prefix": "test-class-junit5",
|
||||||
|
"body": [
|
||||||
|
"import static org.junit.jupiter.api.Assertions.*;",
|
||||||
|
"",
|
||||||
|
"import org.junit.jupiter.api.Test;",
|
||||||
|
"",
|
||||||
|
"public class ${1:$TM_FILENAME_BASE} {",
|
||||||
|
"",
|
||||||
|
"\t@Test",
|
||||||
|
"\tvoid test$2() {",
|
||||||
|
"\t\t$3",
|
||||||
|
"\t}",
|
||||||
|
"}",
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"JUnit5 test case": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "test-case-junit5",
|
||||||
|
"body": [
|
||||||
|
"@Test",
|
||||||
|
"void test$1() {",
|
||||||
|
"\t$2",
|
||||||
|
"}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ParameterizedTest": {
|
||||||
|
"prefix": "parameterized-test",
|
||||||
|
"body": [
|
||||||
|
"@ParameterizedTest",
|
||||||
|
"@ValueSource(${2|strings,ints,shorts,bytes,longs,floats,doubles,chars,booleans,classes|} = { $3 })",
|
||||||
|
"void test$1(${4|String,int,short,byte,long,float,double,char,boolean,Class<?>|} $5) {",
|
||||||
|
"\t$6",
|
||||||
|
"}"
|
||||||
|
],
|
||||||
|
"description": "ParameterizedTest"
|
||||||
|
},
|
||||||
|
"SerializableUID": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "serializableUID",
|
||||||
|
"body": [
|
||||||
|
"private static final long serialVersionUID = ${1:${RANDOM/(0)//}$CURRENT_DATE$CURRENT_MONTH$CURRENT_YEAR_SHORT$CURRENT_SECOND$CURRENT_MINUTE$CURRENT_HOUR}L;"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Exception": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "exception",
|
||||||
|
"body": [
|
||||||
|
"class ${1:$TM_FILENAME_BASE} extends ${2|RuntimeException,Exception|} {",
|
||||||
|
"\tprivate static final long serialVersionUID = ${3:${RANDOM/(0)//}$CURRENT_DATE$CURRENT_MONTH$CURRENT_YEAR_SHORT$CURRENT_SECOND$CURRENT_MINUTE$CURRENT_HOUR}L;",
|
||||||
|
"",
|
||||||
|
"\t/**",
|
||||||
|
"\t * Constructs a new {@code ${1:$TM_FILENAME_BASE}} with null as its detail message.",
|
||||||
|
"\t * The cause is not initialized, and may subsequently be initialized by a call to initCause.",
|
||||||
|
"\t */",
|
||||||
|
"\t${4|public,protected|} ${1:$TM_FILENAME_BASE}() {",
|
||||||
|
"\t\tsuper();",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t/**",
|
||||||
|
"\t * Constructs a new {@code ${1:$TM_FILENAME_BASE}} with the specified detail message.",
|
||||||
|
"\t * The cause is not initialized, and may subsequently be initialized by a",
|
||||||
|
"\t * call to {@link #initCause}.",
|
||||||
|
"\t *",
|
||||||
|
"\t * @param message the detail message. The detail message is saved for",
|
||||||
|
"\t * later retrieval by the {@link #getMessage()} method.",
|
||||||
|
"\t */",
|
||||||
|
"\t${4|public,protected|} ${1:$TM_FILENAME_BASE}(String message) {",
|
||||||
|
"\t\tsuper(message);",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t/**",
|
||||||
|
"\t * Constructs a new {@code ${1:$TM_FILENAME_BASE}} with the specified cause and a",
|
||||||
|
"\t * detail message of {@code (cause==null ? null : cause.toString())}",
|
||||||
|
"\t * (which typically contains the class and detail message of {@code cause}).",
|
||||||
|
"\t * This constructor is useful for exceptions",
|
||||||
|
"\t * that are little more than wrappers for other throwables.",
|
||||||
|
"\t *",
|
||||||
|
"\t * @param cause the cause (which is saved for later retrieval by the",
|
||||||
|
"\t * {@link #getCause()} method). (A {@code null} value is",
|
||||||
|
"\t * permitted, and indicates that the cause is nonexistent or",
|
||||||
|
"\t * unknown.)",
|
||||||
|
"\t */",
|
||||||
|
"\t${4|public,protected|} ${1:$TM_FILENAME_BASE}(Throwable cause) {",
|
||||||
|
"\t\tsuper(cause);",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t/**",
|
||||||
|
"\t * Constructs a new {@code ${1:$TM_FILENAME_BASE}} with the specified detail message and",
|
||||||
|
"\t * cause. <p>Note that the detail message associated with",
|
||||||
|
"\t * {@code cause} is <i>not</i> automatically incorporated in",
|
||||||
|
"\t * this exception's detail message.",
|
||||||
|
"\t *",
|
||||||
|
"\t * @param message the detail message (which is saved for later retrieval",
|
||||||
|
"\t * by the {@link #getMessage()} method).",
|
||||||
|
"\t * @param cause the cause (which is saved for later retrieval by the",
|
||||||
|
"\t * {@link #getCause()} method). (A {@code null} value is",
|
||||||
|
"\t * permitted, and indicates that the cause is nonexistent or",
|
||||||
|
"\t * unknown.)",
|
||||||
|
"\t */",
|
||||||
|
"\t${4|public,protected|} ${1:$TM_FILENAME_BASE}(String message, Throwable cause) {",
|
||||||
|
"\t\tsuper(message, cause);",
|
||||||
|
"\t}",
|
||||||
|
"}",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"#region": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "#regoin",
|
||||||
|
"body": [
|
||||||
|
"// ================================",
|
||||||
|
"// #region - $1",
|
||||||
|
"// ================================",
|
||||||
|
"",
|
||||||
|
"$TM_SELECTED_TEXT",
|
||||||
|
"",
|
||||||
|
"// ================================",
|
||||||
|
"// #endregion - $1",
|
||||||
|
"// ================================",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"=if": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "=if",
|
||||||
|
"body": [
|
||||||
|
"if ($1) {",
|
||||||
|
"\t${2:var} = ${3:value};",
|
||||||
|
"}",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"String line": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "line",
|
||||||
|
"body": "+ \"\\n\" + \"$1\""
|
||||||
|
},
|
||||||
|
"Static factory method": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": ["staticFactoryMethod", "of"],
|
||||||
|
"body": [
|
||||||
|
"@StaticFactoryMethod(${1:$TM_FILENAME_BASE}.class)",
|
||||||
|
"public static ${1:$TM_FILENAME_BASE} of($2) {",
|
||||||
|
"\treturn new ${1:$TM_FILENAME_BASE}($3);",
|
||||||
|
"}",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Static factory method with type param": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": ["staticFactoryMethodWithTypeParam", "of_T"],
|
||||||
|
"body": [
|
||||||
|
"@StaticFactoryMethod(${1:$TM_FILENAME_BASE}.class)",
|
||||||
|
"public static <${2:T}> ${1:$TM_FILENAME_BASE}<${2:T}> of($3) {",
|
||||||
|
"\treturn new ${1:$TM_FILENAME_BASE}<>($4);",
|
||||||
|
"}",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
// assert
|
||||||
|
"Import AssertTools": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "import_assert_tools",
|
||||||
|
"body": [
|
||||||
|
"",
|
||||||
|
"import static xyz.zhouxy.plusone.commons.util.AssertTools.*;",
|
||||||
|
"",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"AssertTools.checkCondition": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "assert_checkCondition",
|
||||||
|
"body": [
|
||||||
|
"AssertTools.checkCondition($3, () -> new ${1|IllegalArgumentException,IllegalStateException,NullPointerException,UnsupportedOperationException,ArithmeticException,ClassCastException,ArrayIndexOutOfBoundsException,NumberFormatException,RuntimeException,EnumConstantNotPresentException|}($2));"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"AssertTools.checkArgument": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "assert_checkArgument",
|
||||||
|
"body": [
|
||||||
|
"AssertTools.checkArgument(${1|StringTools.isNotBlank,Objects.nonNull|}($2)${3:, \"$4\"});"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Lock": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "lock",
|
||||||
|
"body": [
|
||||||
|
"${1:lock}.lock();",
|
||||||
|
"try {",
|
||||||
|
"\t// access the resource protected by this lock",
|
||||||
|
"\t$2",
|
||||||
|
"}",
|
||||||
|
"finally {",
|
||||||
|
"\t${1:lock}.unlock();",
|
||||||
|
"}",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
9
javadoc.code-snippets
Normal file
9
javadoc.code-snippets
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"code": {
|
||||||
|
"prefix": "@code",
|
||||||
|
"body": [
|
||||||
|
"{@code $TM_SELECTED_TEXT}"
|
||||||
|
],
|
||||||
|
"scope": "java"
|
||||||
|
}
|
||||||
|
}
|
42
jdk_config.code-snippets
Normal file
42
jdk_config.code-snippets
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"JdkConfigWin": {
|
||||||
|
"scope": "jsonc",
|
||||||
|
"prefix": "jdk_config-win",
|
||||||
|
"body": [
|
||||||
|
"\"maven.terminal.customEnv\": [",
|
||||||
|
"\t{",
|
||||||
|
"\t\t\"environmentVariable\": \"JAVA_HOME\",",
|
||||||
|
"\t\t\"value\": \"${2:$}{env:JDK_${1:8}}\",",
|
||||||
|
"\t},",
|
||||||
|
"],",
|
||||||
|
"\"terminal.integrated.env.windows\": {",
|
||||||
|
"\t\"JAVA_HOME\": \"${2:$}{env:JDK_${1:8}}\",",
|
||||||
|
"\t\"path\": \"${2:$}{env:JDK_${1:8}}/bin;${2:$}{env:path}\",",
|
||||||
|
"},"
|
||||||
|
],
|
||||||
|
"description": "Config JDK version in settings.json of VS Code."
|
||||||
|
},
|
||||||
|
"JdkConfigLinux": {
|
||||||
|
"scope": "jsonc",
|
||||||
|
"prefix": "jdk_config-linux",
|
||||||
|
"body": [
|
||||||
|
"\"java.configuration.runtimes\": [",
|
||||||
|
"\t{",
|
||||||
|
"\t\t\"name\": \"JavaSE-1.8\",",
|
||||||
|
"\t\t\"path\": \"/home/zhouxy/softwares/jdk/jdk-8\"",
|
||||||
|
"\t}",
|
||||||
|
"],",
|
||||||
|
"\"maven.terminal.customEnv\": [",
|
||||||
|
"\t{",
|
||||||
|
"\t\t\"environmentVariable\": \"JAVA_HOME\",",
|
||||||
|
"\t\t\"value\": \"/home/zhouxy/softwares/jdk/jdk-8\",",
|
||||||
|
"\t},",
|
||||||
|
"],",
|
||||||
|
"\"terminal.integrated.env.linux\": {",
|
||||||
|
"\t\"JAVA_HOME\": \"/home/zhouxy/softwares/jdk/jdk-8\",",
|
||||||
|
"\t\"PATH\": \"/home/zhouxy/softwares/jdk/jdk-8/bin:$$0{env:PATH}\",",
|
||||||
|
"},",
|
||||||
|
],
|
||||||
|
"description": "Config JDK version in settings.json of VS Code."
|
||||||
|
}
|
||||||
|
}
|
24
jpa-config-yml.code-snippets
Normal file
24
jpa-config-yml.code-snippets
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
// Place your snippets for spring-boot-properties-yaml here. Each snippet is defined under a snippet name and has a prefix, body and
|
||||||
|
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
|
||||||
|
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
|
||||||
|
// same ids are connected.
|
||||||
|
// Example:
|
||||||
|
"Jpa config yml": {
|
||||||
|
"prefix": "jpa-config-yml",
|
||||||
|
"scope": "yaml",
|
||||||
|
"body": [
|
||||||
|
"spring:",
|
||||||
|
"\tdatasource:",
|
||||||
|
"\t\turl: jdbc:mariadb://${1:localhost}:3306/${2:database}",
|
||||||
|
"\t\tusername: ${3:root}",
|
||||||
|
"\t\tpassword: ${4:zhouxy108}",
|
||||||
|
"\t\tdriver-class-name: org.mariadb.jdbc.Driver",
|
||||||
|
"\tjpa:",
|
||||||
|
"\t\tshow-sql: true",
|
||||||
|
"\t\thibernate:",
|
||||||
|
"\t\t\tddl-auto: update",
|
||||||
|
],
|
||||||
|
"description": "jpa-config-yml"
|
||||||
|
}
|
||||||
|
}
|
22
map-pojo.code-snippets
Normal file
22
map-pojo.code-snippets
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"Getter of MapPojo's field": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "getterOfMapPojo",
|
||||||
|
"body": [
|
||||||
|
"public ${3:String} get${2:FieldName}() {",
|
||||||
|
" return (${3:String}) this.fields.get(\"${1:field_name}\");",
|
||||||
|
"}",
|
||||||
|
],
|
||||||
|
"description": "Getter of MapPojo's field."
|
||||||
|
},
|
||||||
|
"Setter of MapPojo's field": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "setterOfMapPojo",
|
||||||
|
"body": [
|
||||||
|
"public ${5:Pojo} set${3:FieldName}(String ${2:fieldName}) {",
|
||||||
|
" this.fields.put(\"${1:field_name}\", ${2:fieldName});${4:\n return this;}",
|
||||||
|
"}",
|
||||||
|
],
|
||||||
|
"description": "Setter of MapPojo's field."
|
||||||
|
},
|
||||||
|
}
|
33
maven-aliyun-mirror.code-snippets
Normal file
33
maven-aliyun-mirror.code-snippets
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"Print to console": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "aliyun-mirror",
|
||||||
|
"body": [
|
||||||
|
"<repositories>",
|
||||||
|
"\t<repository>",
|
||||||
|
"\t\t<id>aliyun</id>",
|
||||||
|
"\t\t<url>https://maven.aliyun.com/repository/public</url>",
|
||||||
|
"\t\t<releases>",
|
||||||
|
"\t\t\t<enabled>true</enabled>",
|
||||||
|
"\t\t</releases>",
|
||||||
|
"\t\t<snapshots>",
|
||||||
|
"\t\t\t<enabled>false</enabled>",
|
||||||
|
"\t\t</snapshots>",
|
||||||
|
"\t</repository>",
|
||||||
|
"</repositories>",
|
||||||
|
"<pluginRepositories>",
|
||||||
|
"\t<pluginRepository>",
|
||||||
|
"\t\t<id>aliyun-plugin</id>",
|
||||||
|
"\t\t<url>https://maven.aliyun.com/repository/public</url>",
|
||||||
|
"\t\t<releases>",
|
||||||
|
"\t\t\t<enabled>true</enabled>",
|
||||||
|
"\t\t</releases>",
|
||||||
|
"\t\t<snapshots>",
|
||||||
|
"\t\t\t<enabled>false</enabled>",
|
||||||
|
"\t\t</snapshots>",
|
||||||
|
"\t</pluginRepository>",
|
||||||
|
"</pluginRepositories>",
|
||||||
|
],
|
||||||
|
"description": "pom.xml 中配置阿里云镜像"
|
||||||
|
}
|
||||||
|
}
|
86
multi-types-exception.code-snippets
Normal file
86
multi-types-exception.code-snippets
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
{
|
||||||
|
"Multi-types Exception": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "multi-types-exception",
|
||||||
|
"body": [
|
||||||
|
"public final class ${2:$TM_FILENAME_BASE}",
|
||||||
|
"\t\textends ${3|RuntimeException,Exception,BizException,SysException|}",
|
||||||
|
"\t\timplements MultiTypesException<${2:$TM_FILENAME_BASE}, ${2:$TM_FILENAME_BASE}.Type> {",
|
||||||
|
"\tprivate static final long serialVersionUID = ${4:${RANDOM/(0)//}$CURRENT_DATE$CURRENT_MONTH$CURRENT_YEAR_SHORT$CURRENT_SECOND$CURRENT_MINUTE$CURRENT_HOUR}L;",
|
||||||
|
"",
|
||||||
|
"\tprivate final ${1|@NonNull ,@Nonnull |}Type type;",
|
||||||
|
"",
|
||||||
|
"\tprivate ${2:$TM_FILENAME_BASE}(${1|@NonNull ,@Nonnull |}Type type) {",
|
||||||
|
"\t\tsuper(type.getDefaultMessage());",
|
||||||
|
"\t\tthis.type = type;",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tprivate ${2:$TM_FILENAME_BASE}(${1|@NonNull ,@Nonnull |}Type type, @Nullable String msg) {",
|
||||||
|
"\t\tsuper(msg);",
|
||||||
|
"\t\tthis.type = type;",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tprivate ${2:$TM_FILENAME_BASE}(${1|@NonNull ,@Nonnull |}Type type, @Nullable Throwable cause) {",
|
||||||
|
"\t\tsuper(cause);",
|
||||||
|
"\t\tthis.type = type;",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tprivate ${2:$TM_FILENAME_BASE}(${1|@NonNull ,@Nonnull |}Type type, @Nullable String msg, @Nullable Throwable cause) {",
|
||||||
|
"\t\tsuper(msg, cause);",
|
||||||
|
"\t\tthis.type = type;",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t@Override",
|
||||||
|
"\tpublic ${1|@NonNull ,@Nonnull |}Type getType() {",
|
||||||
|
"\t\treturn type;",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tpublic enum Type implements ExceptionType<${2:$TM_FILENAME_BASE}> {",
|
||||||
|
"\t\tDEFAULT(\"00\", \"$5\"),",
|
||||||
|
"\t\t// TODO other types",
|
||||||
|
"\t\t;",
|
||||||
|
"",
|
||||||
|
"\t\tprivate final ${1|@NonNull ,@Nonnull |}String code;",
|
||||||
|
"\t\tprivate final ${1|@NonNull ,@Nonnull |}String defaultMessage;",
|
||||||
|
"",
|
||||||
|
"\t\tType(${1|@NonNull ,@Nonnull |}String code, ${1|@NonNull ,@Nonnull |}String defaultMessage) {",
|
||||||
|
"\t\t\tthis.code = code;",
|
||||||
|
"\t\t\tthis.defaultMessage = defaultMessage;",
|
||||||
|
"\t\t}",
|
||||||
|
"",
|
||||||
|
"\t\t@Override",
|
||||||
|
"\t\tpublic ${1|@NonNull ,@Nonnull |}String getCode() {",
|
||||||
|
"\t\t\treturn code;",
|
||||||
|
"\t\t}",
|
||||||
|
"",
|
||||||
|
"\t\t@Override",
|
||||||
|
"\t\tpublic ${1|@NonNull ,@Nonnull |}String getDefaultMessage() {",
|
||||||
|
"\t\t\treturn defaultMessage;",
|
||||||
|
"\t\t}",
|
||||||
|
"",
|
||||||
|
"\t\t@Override",
|
||||||
|
"\t\tpublic ${1|@NonNull ,@Nonnull |}${2:$TM_FILENAME_BASE} create() {",
|
||||||
|
"\t\t\treturn new ${2:$TM_FILENAME_BASE}(this);",
|
||||||
|
"\t\t}",
|
||||||
|
"\t",
|
||||||
|
"\t\t@Override",
|
||||||
|
"\t\tpublic ${1|@NonNull ,@Nonnull |}${2:$TM_FILENAME_BASE} create(@Nullable String message) {",
|
||||||
|
"\t\t\treturn new ${2:$TM_FILENAME_BASE}(this, message);",
|
||||||
|
"\t\t}",
|
||||||
|
"\t",
|
||||||
|
"\t\t@Override",
|
||||||
|
"\t\tpublic ${1|@NonNull ,@Nonnull |}${2:$TM_FILENAME_BASE} create(@Nullable Throwable cause) {",
|
||||||
|
"\t\t\treturn new ${2:$TM_FILENAME_BASE}(this, cause);",
|
||||||
|
"\t\t}",
|
||||||
|
"\t",
|
||||||
|
"\t\t@Override",
|
||||||
|
"\t\tpublic ${1|@NonNull ,@Nonnull |}${2:$TM_FILENAME_BASE} create(@Nullable String message, @Nullable Throwable cause) {",
|
||||||
|
"\t\t\treturn new ${2:$TM_FILENAME_BASE}(this, message, cause);",
|
||||||
|
"\t\t}",
|
||||||
|
"\t}",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
],
|
||||||
|
"description": "Exception with multiple types."
|
||||||
|
}
|
||||||
|
}
|
607
mybatis-mapper.code-snippets
Normal file
607
mybatis-mapper.code-snippets
Normal file
@@ -0,0 +1,607 @@
|
|||||||
|
{
|
||||||
|
"Mybatis mapper template": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "mybatis-mapper",
|
||||||
|
"isFileTemplate": true,
|
||||||
|
"body": [
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
|
||||||
|
"<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\">",
|
||||||
|
"<mapper namespace=\"${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.dal.mapper.${5:ModuleShortName}${7:Entity}Mapper\">",
|
||||||
|
"\t<!-- //////////////////// INSERT //////////////////// -->",
|
||||||
|
"\t<!--",
|
||||||
|
"\t\tint insert(${5:ModuleShortName}${7:Entity}Info po);",
|
||||||
|
"\t-->",
|
||||||
|
"\t<insert id=\"insert\" useGeneratedKeys=\"true\" keyColumn=\"id\" keyProperty=\"id\">",
|
||||||
|
"\t\tINSERT INTO ${4:module_short_name}_${6:entity}",
|
||||||
|
"\t\t(",
|
||||||
|
"\t\t\temail, phone_num, username, password, salt, avatar, sex, nickname, remarks, status,",
|
||||||
|
"\t\t\t# TODO: other columns",
|
||||||
|
"\t\t\tcreated_by, created_time, updated_by, updated_time, version",
|
||||||
|
"\t\t)",
|
||||||
|
"\t\tVALUES",
|
||||||
|
"\t\t(",
|
||||||
|
"\t\t\t#{email}, #{phoneNum}, #{username}, #{password}, #{salt}, #{avatar}, #{sex}, #{nickname}, #{remarks}, #{status},",
|
||||||
|
"\t\t\t# TODO: other properties",
|
||||||
|
"\t\t\t#{createdBy}, #{createdTime}, #{updatedBy}, #{updatedTime}, #{version}",
|
||||||
|
"\t\t)",
|
||||||
|
"\t</insert>",
|
||||||
|
"",
|
||||||
|
"\t<!-- //////////////////// DELETE //////////////////// -->",
|
||||||
|
"\t<!--",
|
||||||
|
"\t\tint delete(${5:ModuleShortName}${7:Entity}Info po);",
|
||||||
|
"\t-->",
|
||||||
|
"\t<update id=\"delete\">",
|
||||||
|
"\t\tUPDATE ${4:module_short_name}_${6:entity}",
|
||||||
|
"\t\tSET deleted = id,",
|
||||||
|
"\t\t\tversion = version + 1",
|
||||||
|
"\t\tWHERE deleted = 0 AND id = #{id} AND version = #{version}",
|
||||||
|
"\t</update>",
|
||||||
|
"",
|
||||||
|
"\t<!-- //////////////////// UPDATE //////////////////// -->",
|
||||||
|
"\t<!--",
|
||||||
|
"\t\tint update(${5:ModuleShortName}${7:Entity}Info po);",
|
||||||
|
"\t-->",
|
||||||
|
"\t<update id=\"update\">",
|
||||||
|
"\t\tUPDATE ${4:module_short_name}_${6:entity}",
|
||||||
|
"\t\tSET email\t\t= #{email},",
|
||||||
|
"\t\t\tphone_num\t= #{phoneNum},",
|
||||||
|
"\t\t\tusername\t = #{username},",
|
||||||
|
"\t\t\tpassword\t = #{password},",
|
||||||
|
"\t\t\tsalt\t\t = #{salt},",
|
||||||
|
"\t\t\tavatar\t = #{avatar},",
|
||||||
|
"\t\t\tsex\t\t = #{sex},",
|
||||||
|
"\t\t\tnickname\t = #{nickname},",
|
||||||
|
"\t\t\tremarks\t = #{remarks},",
|
||||||
|
"\t\t\tstatus\t = #{status},",
|
||||||
|
"\t\t\t# TODO: other columns",
|
||||||
|
"\t\t\t# created_by = #{createdBy},",
|
||||||
|
"\t\t\t# created_time = #{createdTime},",
|
||||||
|
"\t\t\tupdated_by = #{updatedBy},",
|
||||||
|
"\t\t\tupdated_time = #{updatedTime},",
|
||||||
|
"\t\t\tversion = version + 1",
|
||||||
|
"\t\tWHERE deleted = 0 AND id = #{id} AND version = #{version}",
|
||||||
|
"\t</update>",
|
||||||
|
"",
|
||||||
|
"\t<!-- //////////////////// SELECT //////////////////// -->",
|
||||||
|
"",
|
||||||
|
"\t<sql id=\"SELECT_${5:ModuleShortName}${7:Entity}PO\">",
|
||||||
|
"\t\tSELECT",
|
||||||
|
"\t\t\t${8:a}.id\t\t AS ${8:a}_id,",
|
||||||
|
"\t\t\t${8:a}.email\t\tAS ${8:a}_email,",
|
||||||
|
"\t\t\t${8:a}.phone_num\tAS ${8:a}_phone_num,",
|
||||||
|
"\t\t\t${8:a}.username\t AS ${8:a}_username,",
|
||||||
|
"\t\t\t${8:a}.password\t AS ${8:a}_password,",
|
||||||
|
"\t\t\t${8:a}.salt\t\t AS ${8:a}_salt,",
|
||||||
|
"\t\t\t${8:a}.avatar\t AS ${8:a}_avatar,",
|
||||||
|
"\t\t\t${8:a}.sex\t\t AS ${8:a}_sex,",
|
||||||
|
"\t\t\t${8:a}.nickname\t AS ${8:a}_nickname,",
|
||||||
|
"\t\t\t${8:a}.remarks\t AS ${8:a}_remarks,",
|
||||||
|
"\t\t\t${8:a}.status\t AS ${8:a}_status,",
|
||||||
|
"\t\t\t# TODO: other columns",
|
||||||
|
"\t\t\t${8:a}.created_by AS ${8:a}_created_by,",
|
||||||
|
"\t\t\t${8:a}.created_time AS ${8:a}_created_time,",
|
||||||
|
"\t\t\t${8:a}.updated_by AS ${8:a}_updated_by,",
|
||||||
|
"\t\t\t${8:a}.updated_time AS ${8:a}_updated_time,",
|
||||||
|
"\t\t\t${8:a}.version\t AS ${8:a}_version",
|
||||||
|
"\t\tFROM ${4:module_short_name}_${6:entity} AS ${8:a}",
|
||||||
|
"\t</sql>",
|
||||||
|
"",
|
||||||
|
"\t<resultMap id=\"${5:ModuleShortName}${7:Entity}PO_ResultMap\" type=\"${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.info.${5:ModuleShortName}${7:Entity}Info\">",
|
||||||
|
"\t\t<id column=\"${8:a}_id\" property=\"id\" javaType=\"Long\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_email\" property=\"email\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_phone_num\" property=\"phoneNum\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_username\" property=\"username\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_password\" property=\"password\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_salt\" property=\"salt\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_avatar\" property=\"avatar\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_sex\" property=\"sex\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_nickname\" property=\"nickname\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_remarks\" property=\"remarks\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_status\" property=\"status\" />",
|
||||||
|
"\t\t<!-- TODO: other columns -->",
|
||||||
|
"\t\t<result column=\"${8:a}_created_by\" property=\"createdBy\" javaType=\"Long\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_created_time\" property=\"createdTime\" javaType=\"java.time.LocalDateTime\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_updated_by\" property=\"updatedBy\" javaType=\"Long\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_updated_time\" property=\"updatedTime\" javaType=\"java.time.LocalDateTime\" />",
|
||||||
|
"\t\t<result column=\"${8:a}_version\" property=\"version\" javaType=\"Long\" />",
|
||||||
|
"\t</resultMap>",
|
||||||
|
"",
|
||||||
|
"\t<!--",
|
||||||
|
"\t\t${5:ModuleShortName}${7:Entity}Info findById(Long id);",
|
||||||
|
"\t-->",
|
||||||
|
"\t<select id=\"findById\" resultMap=\"${5:ModuleShortName}${7:Entity}PO_ResultMap\">",
|
||||||
|
"\t\t<include refid=\"SELECT_${5:ModuleShortName}${7:Entity}PO\" />",
|
||||||
|
"\t\tWHERE ${8:a}.deleted = 0 AND ${8:a}.id = #{id}",
|
||||||
|
"\t\tLIMIT 1",
|
||||||
|
"\t</select>",
|
||||||
|
"",
|
||||||
|
"\t<!--",
|
||||||
|
"\t\tCollection<${5:ModuleShortName}${7:Entity}Info> findByIdIn(Collection<Long> ids);",
|
||||||
|
"\t-->",
|
||||||
|
"\t<select id=\"findByIdIn\" resultMap=\"${5:ModuleShortName}${7:Entity}PO_ResultMap\">",
|
||||||
|
"\t\t<include refid=\"SELECT_${5:ModuleShortName}${7:Entity}PO\" />",
|
||||||
|
"\t\tWHERE ${8:a}.deleted = 0 AND ${8:a}.id IN",
|
||||||
|
"\t\t<foreach collection=\"ids\" item=\"id\" open=\"(\" close=\")\" separator=\",\">",
|
||||||
|
"\t\t\t#{id}",
|
||||||
|
"\t\t</foreach>",
|
||||||
|
"\t</select>",
|
||||||
|
"",
|
||||||
|
"\t<!--",
|
||||||
|
"\t\tCollection<${5:ModuleShortName}${7:Entity}Info> query(${5:ModuleShortName}${7:Entity}Query queryParams);",
|
||||||
|
"\t-->",
|
||||||
|
"\t<select id=\"query\" resultMap=\"${5:ModuleShortName}${7:Entity}PO_ResultMap\">",
|
||||||
|
"\t\t<include refid=\"SELECT_${5:ModuleShortName}${7:Entity}PO\" />",
|
||||||
|
"\t\t,",
|
||||||
|
"\t\t(SELECT id FROM ${4:module_short_name}_${6:entity} WHERE deleted = 0",
|
||||||
|
"\t\t<if test=\"id != null\">",
|
||||||
|
"\t\t\tAND id = #{id}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"email != null\">",
|
||||||
|
"\t\t\tAND email = #{email}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"phoneNum != null\">",
|
||||||
|
"\t\t\tAND phone_num = #{phoneNum}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"username != null\">",
|
||||||
|
"\t\t\tAND username = #{username}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"sex != null\">",
|
||||||
|
"\t\t\tAND sex = #{sex}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"nickname != null\">",
|
||||||
|
"\t\t\tAND nickname = #{nickname}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"remarks != null\">",
|
||||||
|
"\t\t\tAND remarks LIKE '%#{remarks}%'",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"status != null\">",
|
||||||
|
"\t\t\tAND status = #{status}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<!-- TODO: other params -->",
|
||||||
|
"\t\t<if test=\"createdBy != null\">",
|
||||||
|
"\t\t\tAND created_by = #{createdBy}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"createdTimeStart != null\">",
|
||||||
|
"\t\t\tAND created_time > #{createdTimeStart}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"createdTimeEnd != null\">",
|
||||||
|
"\t\t\tAND created_time < #{createdTimeEnd}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"updatedBy != null\">",
|
||||||
|
"\t\t\tAND updated_by = #{updatedBy}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"updatedTimeStart != null\">",
|
||||||
|
"\t\t\tAND updated_time > #{updatedTimeStart}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"updatedTimeEnd != null\">",
|
||||||
|
"\t\t\tAND updated_time < #{updatedTimeEnd}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\tLIMIT #{size} OFFSET #{offset}) b",
|
||||||
|
"\t\tWHERE ${8:a}.id = b.id",
|
||||||
|
"\t</select>",
|
||||||
|
"",
|
||||||
|
"\t<!--",
|
||||||
|
"\t\tlong count(${5:ModuleShortName}${7:Entity}Query queryParams);",
|
||||||
|
"\t-->",
|
||||||
|
"\t<select id=\"count\" resultType=\"long\">",
|
||||||
|
"\t\tSELECT COUNT(*) FROM ${4:module_short_name}_${6:entity} WHERE deleted = 0",
|
||||||
|
"\t\t<if test=\"id != null\">",
|
||||||
|
"\t\t\tAND id = #{id}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"email != null\">",
|
||||||
|
"\t\t\tAND email = #{email}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"phoneNum != null\">",
|
||||||
|
"\t\t\tAND phone_num = #{phoneNum}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"username != null\">",
|
||||||
|
"\t\t\tAND username = #{username}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"sex != null\">",
|
||||||
|
"\t\t\tAND sex = #{sex}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"nickname != null\">",
|
||||||
|
"\t\t\tAND nickname = #{nickname}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"remarks != null\">",
|
||||||
|
"\t\t\tAND remarks LIKE '%#{remarks}%'",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"status != null\">",
|
||||||
|
"\t\t\tAND status = #{status}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<!-- TODO: other params -->",
|
||||||
|
"\t\t<if test=\"createdBy != null\">",
|
||||||
|
"\t\t\tAND created_by = #{createdBy}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"createdTimeStart != null\">",
|
||||||
|
"\t\t\tAND created_time > #{createdTimeStart}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"createdTimeEnd != null\">",
|
||||||
|
"\t\t\tAND created_time < #{createdTimeEnd}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"updatedBy != null\">",
|
||||||
|
"\t\t\tAND updated_by = #{updatedBy}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"updatedTimeStart != null\">",
|
||||||
|
"\t\t\tAND updated_time > #{updatedTimeStart}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t\t<if test=\"updatedTimeEnd != null\">",
|
||||||
|
"\t\t\tAND updated_time < #{updatedTimeEnd}",
|
||||||
|
"\t\t</if>",
|
||||||
|
"\t</select>",
|
||||||
|
"",
|
||||||
|
"\t<!--",
|
||||||
|
"\t\tCollection<${5:ModuleShortName}${7:Entity}Info> findBy${10:Entity2}Id(Long ${11:entity2}Id);",
|
||||||
|
"\t-->",
|
||||||
|
"\t<select id=\"findBy${10:Entity2}Id\" resultMap=\"${5:ModuleShortName}${7:Entity}PO_ResultMap\">",
|
||||||
|
"\t\t<include refid=\"SELECT_${5:ModuleShortName}${7:Entity}PO\" />",
|
||||||
|
"\t\tWHERE ${8:a}.deleted = 0",
|
||||||
|
"\t\t\tAND ${8:a}.id IN (SELECT ${6:entity}_id FROM ${4:module_short_name}_${6:entity}_${11:entity2} WHERE ${11:entity2}_id = #{${11:entity2}Id})",
|
||||||
|
"\t</select>",
|
||||||
|
"",
|
||||||
|
"\t<!--",
|
||||||
|
"\t\tint clear${10:Entity2}s(Long id);",
|
||||||
|
"\t-->",
|
||||||
|
"\t<delete id=\"clear${10:Entity2}s\">",
|
||||||
|
"\t\tDELETE FROM ${4:module_short_name}_${6:entity}_${11:entity2} WHERE ${6:entity}_id = #{id}",
|
||||||
|
"\t</delete>",
|
||||||
|
"",
|
||||||
|
"\t<!--",
|
||||||
|
"\t\tint bind${10:Entity2}s(Long id, Collection<Long> ${11:entity2}s);",
|
||||||
|
"\t-->",
|
||||||
|
"\t<insert id=\"bind${10:Entity2}s\">",
|
||||||
|
"\t\tINSERT INTO ${4:module_short_name}_${6:entity}_${11:entity2}(${6:entity}_id, ${11:entity2}_id)",
|
||||||
|
"\t\tVALUES",
|
||||||
|
"\t\t<foreach collection=\"${11:entity2}s\" item=\"${11:entity2}_id\" separator=\",\">",
|
||||||
|
"\t\t\t(#{id}, #{${11:entity2}_id})",
|
||||||
|
"\t\t</foreach>",
|
||||||
|
"\t</insert>",
|
||||||
|
"",
|
||||||
|
"</mapper>",
|
||||||
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.common.domain.BaseDomain /////////////// -->",
|
||||||
|
"<!--",
|
||||||
|
"package ${1:xyz.zhouxy}.${2:plusone}.common.domain;",
|
||||||
|
"",
|
||||||
|
"import java.time.LocalDateTime;",
|
||||||
|
"",
|
||||||
|
"/**",
|
||||||
|
" * Entity 和 Info 的父类",
|
||||||
|
" * ",
|
||||||
|
" * @author ZhouXY",
|
||||||
|
" */",
|
||||||
|
"public abstract class BaseDomain implements Serializable {",
|
||||||
|
"\tprotected Long id;",
|
||||||
|
"",
|
||||||
|
"\tprotected Long createdBy;",
|
||||||
|
"\tprotected LocalDateTime createdTime;",
|
||||||
|
"\tprotected Long updatedBy;",
|
||||||
|
"\tprotected LocalDateTime updatedTime;",
|
||||||
|
"\tprotected Long version;",
|
||||||
|
"",
|
||||||
|
"\tprotected BaseDomain() {",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tprotected BaseDomain(BaseDomain prototype) {",
|
||||||
|
"\t\tthis.id = prototype.id;",
|
||||||
|
"\t\tthis.createdBy = prototype.createdBy;",
|
||||||
|
"\t\tthis.createdTime = prototype.createdTime;",
|
||||||
|
"\t\tthis.updatedBy = prototype.updatedBy;",
|
||||||
|
"\t\tthis.updatedTime = prototype.updatedTime;",
|
||||||
|
"\t\tthis.version = prototype.version;",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t// TODO: getters & setters",
|
||||||
|
"",
|
||||||
|
"} -->",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.info.${5:ModuleShortName}${7:Entity}Info /////////////// -->",
|
||||||
|
"<!-- ",
|
||||||
|
"package ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.info;",
|
||||||
|
"",
|
||||||
|
"import ${1:xyz.zhouxy}.${2:plusone}.common.domain.BaseDomain;",
|
||||||
|
"",
|
||||||
|
"/**",
|
||||||
|
" * ${5:ModuleShortName}${7:Entity} 的基本属性",
|
||||||
|
" * ",
|
||||||
|
" * @author ZhouXY",
|
||||||
|
" */",
|
||||||
|
"public class ${5:ModuleShortName}${7:Entity}Info extends BaseDomain {",
|
||||||
|
"\tprivate String username;",
|
||||||
|
"\tprivate String email;",
|
||||||
|
"\tprivate String phoneNum;",
|
||||||
|
"\tprivate String password;",
|
||||||
|
"\tprivate String salt;",
|
||||||
|
"",
|
||||||
|
"\tprivate ${7:Entity}Status status;",
|
||||||
|
"",
|
||||||
|
"\tprivate String remarks;",
|
||||||
|
"\tprivate String nickname;",
|
||||||
|
"\tprivate Sex sex;",
|
||||||
|
"\tprivate String avatar;",
|
||||||
|
"",
|
||||||
|
"\t// TODO: other columns",
|
||||||
|
"",
|
||||||
|
"\tpublic ${5:ModuleShortName}${7:Entity}Info() {",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tpublic ${5:ModuleShortName}${7:Entity}Info(BaseDomain prototype) {",
|
||||||
|
"\t\tsuper(prototype);",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t// ==============================================================",
|
||||||
|
"",
|
||||||
|
"\t// TODO: getters & setters",
|
||||||
|
"",
|
||||||
|
"\t// ==============================================================",
|
||||||
|
"",
|
||||||
|
"\tpublic PasswordWithSalt getPwd() {",
|
||||||
|
"\t\treturn new PasswordWithSalt(password, salt);",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tpublic void setPwd(PasswordWithSalt password) {",
|
||||||
|
"\t\tthis.password = password.getPassword();",
|
||||||
|
"\t\tthis.salt = password.getSalt();",
|
||||||
|
"\t}",
|
||||||
|
"}",
|
||||||
|
" -->",
|
||||||
|
"",
|
||||||
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.common.domain.BaseQueryParams /////////////// -->",
|
||||||
|
"<!-- ",
|
||||||
|
"package ${1:xyz.zhouxy}.${2:plusone}.common.domain;",
|
||||||
|
"/**",
|
||||||
|
" * 查询参数的基本属性",
|
||||||
|
" * ",
|
||||||
|
" * @author ZhouXY",
|
||||||
|
" */",
|
||||||
|
"public abstract class BaseQueryParams {",
|
||||||
|
"\tprotected Long id;",
|
||||||
|
"\tprotected Long createdBy;",
|
||||||
|
"\tprotected LocalDateTime createdTimeStart;",
|
||||||
|
"\tprotected LocalDateTime createdTimeEnd;",
|
||||||
|
"\tprotected Long updatedBy;",
|
||||||
|
"\tprotected LocalDateTime updatedTimeStart;",
|
||||||
|
"\tprotected LocalDateTime updatedTimeEnd;",
|
||||||
|
"",
|
||||||
|
"\tprotected Integer size;",
|
||||||
|
"\tprotected Long pageNum;",
|
||||||
|
"",
|
||||||
|
"\tprotected Long getOffset() {",
|
||||||
|
"\t\treturn (pageNum - 1) * size;",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t// TODO: getters & setters",
|
||||||
|
"}",
|
||||||
|
" -->",
|
||||||
|
"",
|
||||||
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.query.${5:ModuleShortName}${7:Entity}Query /////////////// -->",
|
||||||
|
"<!--",
|
||||||
|
"package ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.query;",
|
||||||
|
"",
|
||||||
|
"import ${1:xyz.zhouxy}.${2:plusone}.common.domain.BaseQueryParams;",
|
||||||
|
"",
|
||||||
|
"/**",
|
||||||
|
" * ${5:ModuleShortName}${7:Entity} 的查询参数",
|
||||||
|
" * ",
|
||||||
|
" * @author ZhouXY",
|
||||||
|
" */",
|
||||||
|
"public class ${5:ModuleShortName}${7:Entity}Query extends BaseQueryParams {",
|
||||||
|
"\tprivate String email;",
|
||||||
|
"\tprivate String phoneNum;",
|
||||||
|
"\tprivate String username;",
|
||||||
|
"\tprivate Sex sex;",
|
||||||
|
"\tprivate String nickname;",
|
||||||
|
"\tprivate String remarks;",
|
||||||
|
"\tprivate ${7:Entity}Status status;",
|
||||||
|
"",
|
||||||
|
"\t// TODO: other params",
|
||||||
|
"}",
|
||||||
|
" -->",
|
||||||
|
"",
|
||||||
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.entity.${5:ModuleShortName}${7:Entity} /////////////// -->",
|
||||||
|
"<!-- ",
|
||||||
|
"package ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.entity;",
|
||||||
|
"",
|
||||||
|
"import ${1:xyz.zhouxy}.${2:plusone}.common.domain.BaseDomain;",
|
||||||
|
"",
|
||||||
|
"/**",
|
||||||
|
" * ${5:ModuleShortName}${7:Entity} 实体",
|
||||||
|
" *",
|
||||||
|
" * @author ZhouXY",
|
||||||
|
" */",
|
||||||
|
"public class ${5:ModuleShortName}${7:Entity} extends BaseDomain {",
|
||||||
|
"\tprivate String username;",
|
||||||
|
"\tprivate String email;",
|
||||||
|
"\tprivate String phoneNum;",
|
||||||
|
"\tprivate PasswordWithSalt password;",
|
||||||
|
"",
|
||||||
|
"\tprivate ${7:Entity}Status status;",
|
||||||
|
"",
|
||||||
|
"\tprivate String remarks;",
|
||||||
|
"\tprivate String nickname;",
|
||||||
|
"\tprivate Sex sex;",
|
||||||
|
"\tprivate String avatar;",
|
||||||
|
"\t// TODO: other columns",
|
||||||
|
"",
|
||||||
|
"\tprivate final Map<Long, ${9:ModuleShortName2}${10:Entity2}> ${11:entity2}Refs = new HashMap<>();",
|
||||||
|
"\t// TODO: other entities",
|
||||||
|
"",
|
||||||
|
"\tpublic ${5:ModuleShortName}${7:Entity}() {",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tpublic ${5:ModuleShortName}${7:Entity}(${5:ModuleShortName}${7:Entity}Info prototype) {",
|
||||||
|
"\t\tsuper(prototype);",
|
||||||
|
"\t\tthis.username = prototype.getUsername();",
|
||||||
|
"\t\tthis.email = prototype.getEmail();",
|
||||||
|
"\t\tthis.phoneNum = prototype.getPhoneNum();",
|
||||||
|
"\t\tthis.password = prototype.getPwd();",
|
||||||
|
"\t\tthis.status = prototype.getStatus();",
|
||||||
|
"\t\tthis.remarks = prototype.getremarks();",
|
||||||
|
"\t\tthis.nickname = prototype.getNickname();",
|
||||||
|
"\t\tthis.sex = prototype.getSex();",
|
||||||
|
"\t\tthis.avatar = prototype.getAvatar();",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tpublic ${5:ModuleShortName}${7:Entity}Info buildInfo() {",
|
||||||
|
"\t\tvar info = new ${5:ModuleShortName}${7:Entity}Info(this);",
|
||||||
|
"\t\tinfo.setUsername(this.username);",
|
||||||
|
"\t\tinfo.setEmail(this.email);",
|
||||||
|
"\t\tinfo.setPhoneNum(this.phoneNum);",
|
||||||
|
"\t\tinfo.setPwd(this.password);",
|
||||||
|
"\t\tinfo.setStatus(this.status);",
|
||||||
|
"\t\tinfo.setremarks(this.remarks);",
|
||||||
|
"\t\tinfo.setNickname(this.nickname);",
|
||||||
|
"\t\tinfo.setSex(this.sex);",
|
||||||
|
"\t\tinfo.setAvatar(this.avatar);",
|
||||||
|
"\t\treturn info;",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tpublic void bind${10:Entity2}s(Collection<${9:ModuleShortName2}${10:Entity2}> ${11:entity2}s) {",
|
||||||
|
"\t\tthis.${11:entity2}Refs.clear();",
|
||||||
|
"\t\tfor (var ${11:entity2} : ${11:entity2}s) {",
|
||||||
|
"\t\t\tthis.${11:entity2}Refs.put(${11:entity2}.getId(), ${11:entity2});",
|
||||||
|
"\t\t}",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tpublic static final class Builder extends BaseEntityBuilder<${5:ModuleShortName}${7:Entity}> {",
|
||||||
|
"\t\tprivate final String username;",
|
||||||
|
"\t\tprivate final String email;",
|
||||||
|
"\t\tprivate final String phoneNum;",
|
||||||
|
"\t\tprivate final PasswordWithSalt password;",
|
||||||
|
"\t\tprivate String remarks;",
|
||||||
|
"\t\tprivate String nickname;",
|
||||||
|
"\t\tprivate Sex sex;",
|
||||||
|
"\t\tprivate String avatar;",
|
||||||
|
"\t\tprivate final ${7:Entity}Status status;",
|
||||||
|
"\t\t// TODO: other columns",
|
||||||
|
"",
|
||||||
|
"\t\tprivate Collection<${9:ModuleShortName2}${10:Entity2}> ${11:entity2}s;",
|
||||||
|
"\t\t// TODO: other entities",
|
||||||
|
"",
|
||||||
|
"\t\tpublic Builder(String username, String email, String phoneNum, PasswordWithSalt password, ${7:Entity}Status status,",
|
||||||
|
"\t\t\t\tLong createdBy) {",
|
||||||
|
"\t\t\tsuper(createdBy);",
|
||||||
|
"\t\t\tthis.username = username;",
|
||||||
|
"\t\t\tthis.email = email;",
|
||||||
|
"\t\t\tthis.phoneNum = phoneNum;",
|
||||||
|
"\t\t\tthis.password = password;",
|
||||||
|
"\t\t\tthis.status = status;",
|
||||||
|
"\t\t}",
|
||||||
|
"",
|
||||||
|
"\t\tpublic Builder remarks(String remarks) {",
|
||||||
|
"\t\t\tthis.remarks = remarks;",
|
||||||
|
"\t\t\treturn this;",
|
||||||
|
"\t\t}",
|
||||||
|
"",
|
||||||
|
"\t\tpublic Builder ${6:entity}Info(String nickname, Sex sex, String avatar) {",
|
||||||
|
"\t\t\tthis.nickname = nickname;",
|
||||||
|
"\t\t\tthis.sex = sex;",
|
||||||
|
"\t\t\tthis.avatar = avatar;",
|
||||||
|
"\t\t\treturn this;",
|
||||||
|
"\t\t}",
|
||||||
|
"",
|
||||||
|
"\t\tpublic Builder ${11:entity2}s(Collection<${9:ModuleShortName2}${10:Entity2}> ${11:entity2}s) {",
|
||||||
|
"\t\t\tthis.${11:entity2}s = ${11:entity2}s;",
|
||||||
|
"\t\t\treturn this;",
|
||||||
|
"\t\t}",
|
||||||
|
"",
|
||||||
|
"\t\t@Override",
|
||||||
|
"\t\tpublic ${5:ModuleShortName}${7:Entity} build() {",
|
||||||
|
"\t\t\t${5:ModuleShortName}${7:Entity} entity = new ${5:ModuleShortName}${7:Entity}();",
|
||||||
|
"\t\t\tentity.username = this.username;",
|
||||||
|
"\t\t\tentity.email = this.email;",
|
||||||
|
"\t\t\tentity.phoneNum = this.phoneNum;",
|
||||||
|
"\t\t\tentity.password = this.password;",
|
||||||
|
"\t\t\tentity.remarks = this.remarks;",
|
||||||
|
"\t\t\tentity.nickname = this.nickname;",
|
||||||
|
"\t\t\tentity.sex = this.sex;",
|
||||||
|
"\t\t\tentity.avatar = this.avatar;",
|
||||||
|
"\t\t\tentity.status = this.status;",
|
||||||
|
"\t\t\t// TODO: other columns",
|
||||||
|
"\t\t\t// TODO: bind other entities",
|
||||||
|
"\t\t\tentity.bind${10:Entity2}s(${11:entity2}s);",
|
||||||
|
"\t\t\treturn super.build(entity);",
|
||||||
|
"\t\t}",
|
||||||
|
"\t}",
|
||||||
|
"}",
|
||||||
|
" -->",
|
||||||
|
"",
|
||||||
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.common.domain.BaseEntityBuilder /////////////// -->",
|
||||||
|
"<!-- ",
|
||||||
|
"package ${1:xyz.zhouxy}.${2:plusone}.common.domain;",
|
||||||
|
"",
|
||||||
|
"/**",
|
||||||
|
" * BaseEntityBuilder",
|
||||||
|
" * ",
|
||||||
|
" * @author ZhouXY",
|
||||||
|
" */",
|
||||||
|
"public abstract class BaseEntityBuilder<E extends BaseDomain> {",
|
||||||
|
"",
|
||||||
|
"\tprotected final Long createdBy;",
|
||||||
|
"",
|
||||||
|
"\tprotected BaseEntityBuilder(Long createdBy) {",
|
||||||
|
"\t\tthis.createdBy = createdBy;",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tprotected E build(E entity) {",
|
||||||
|
"\t\tentity.createdBy = this.createdBy;",
|
||||||
|
"\t\tentity.updatedBy = this.createdBy;",
|
||||||
|
"\t\tvar now = LocalDateTime.now();",
|
||||||
|
"\t\tentity.createdTime = now;",
|
||||||
|
"\t\tentity.updatedTime = now;",
|
||||||
|
"\t\tentity.version = 0L;",
|
||||||
|
"\t\treturn entity;",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tprotected abstract E build();",
|
||||||
|
"}",
|
||||||
|
" -->",
|
||||||
|
"",
|
||||||
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.dal.mapper.${5:ModuleShortName}${7:Entity}Mapper /////////////// -->",
|
||||||
|
"<!--",
|
||||||
|
"package ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.dal.mapper;",
|
||||||
|
"",
|
||||||
|
"public interface ${5:ModuleShortName}${7:Entity}Mapper {",
|
||||||
|
"\tint insert(${5:ModuleShortName}${7:Entity}Info po);",
|
||||||
|
"",
|
||||||
|
"\tdefault int insertAll(Collection<${5:ModuleShortName}${7:Entity}Info> pos) {",
|
||||||
|
"\t\tint i = 0;",
|
||||||
|
"\t\tfor (var po : pos) {",
|
||||||
|
"\t\t\ti += insert(po);",
|
||||||
|
"\t\t}",
|
||||||
|
"\t\treturn i;",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tint delete(${5:ModuleShortName}${7:Entity}Info po);",
|
||||||
|
"",
|
||||||
|
"\tdefault int deleteAll(Collection<${5:ModuleShortName}${7:Entity}Info> pos) {",
|
||||||
|
"\t\tint i = 0;",
|
||||||
|
"\t\tfor (var po : pos) {",
|
||||||
|
"\t\t\ti += delete(po);",
|
||||||
|
"\t\t}",
|
||||||
|
"\t\treturn i;",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\tint update(${5:ModuleShortName}${7:Entity}Info po);",
|
||||||
|
"",
|
||||||
|
"\t${5:ModuleShortName}${7:Entity}Info findById(Long id);",
|
||||||
|
"",
|
||||||
|
"\tCollection<${5:ModuleShortName}${7:Entity}Info> findByIdIn(Collection<Long> ids);",
|
||||||
|
"",
|
||||||
|
"\tCollection<${5:ModuleShortName}${7:Entity}Info> query(${5:ModuleShortName}${7:Entity}Query queryParams);",
|
||||||
|
"",
|
||||||
|
"\tlong count(${5:ModuleShortName}${7:Entity}Query queryParams);",
|
||||||
|
"",
|
||||||
|
"\tCollection<${5:ModuleShortName}${7:Entity}Info> findBy${10:Entity2}Id(Long ${11:entity2}Id);",
|
||||||
|
"",
|
||||||
|
"\tint clear${10:Entity2}s(Long id);",
|
||||||
|
"",
|
||||||
|
"\tint bind${10:Entity2}s(Long id, Collection<Long> ${11:entity2}s);",
|
||||||
|
"",
|
||||||
|
"}",
|
||||||
|
"-->",
|
||||||
|
"",
|
||||||
|
],
|
||||||
|
"description": "Mybatis mapper 模板"
|
||||||
|
}
|
||||||
|
}
|
191
popular-dependencies.code-snippets
Normal file
191
popular-dependencies.code-snippets
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
{
|
||||||
|
"guava": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "guava",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
" <groupId>com.google.guava</groupId>",
|
||||||
|
" <artifactId>guava</artifactId>",
|
||||||
|
" ${1:<version>${2|${guava.version},33.2.1-jre|}</version>}${3:\n\t<optional>true</optional>}",
|
||||||
|
"</dependency>"
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"apache-commons": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "apache-commons",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
" <groupId>org.apache.commons</groupId>",
|
||||||
|
" <artifactId>${1|commons-lang3,commons-collections4,commons-math3,commons-pool2|}</artifactId>",
|
||||||
|
" <version>${${1|commons-lang3,commons-collections4,commons-math3,commons-pool2|}.version}</version>",
|
||||||
|
"</dependency>",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"commons-io": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "commons-io",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
" <groupId>commons-io</groupId>",
|
||||||
|
" <artifactId>commons-io</artifactId>",
|
||||||
|
" <version>${commons-io.version}</version>",
|
||||||
|
"</dependency>",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"Apache Commons Crypto": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "commons-crypto",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
" <groupId>org.apache.commons</groupId>",
|
||||||
|
" <artifactId>commons-crypto</artifactId>",
|
||||||
|
" <version>1.2.0</version>",
|
||||||
|
"</dependency>",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"mica-xss": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "mica-xss",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
" <groupId>net.dreamlu</groupId>",
|
||||||
|
" <artifactId>mica-xss</artifactId>",
|
||||||
|
" <version>${1|${mica-xss.version},2.7.18.6,3.3.2|}</version>",
|
||||||
|
"</dependency>",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"mybatis-spring-boot-starter": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "mybatis-spring-boot-starter",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
" <groupId>org.mybatis.spring.boot</groupId>",
|
||||||
|
" <artifactId>mybatis-spring-boot-starter</artifactId>",
|
||||||
|
" <version>${mybatis-starter.version}</version>",
|
||||||
|
"</dependency>",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"mapstruct": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "mapstruct",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
" <groupId>org.mapstruct</groupId>",
|
||||||
|
" <artifactId>mapstruct</artifactId>",
|
||||||
|
" <version>${mapstruct.version}</version>",
|
||||||
|
"</dependency>",
|
||||||
|
"<dependency>",
|
||||||
|
" <groupId>org.mapstruct</groupId>",
|
||||||
|
" <artifactId>mapstruct-processor</artifactId>",
|
||||||
|
" <version>${mapstruct.version}</version>",
|
||||||
|
"</dependency>",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"hutool": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "hutool",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
" <groupId>cn.hutool</groupId>",
|
||||||
|
" <artifactId>${1|hutool-core,hutool-crypto,hutool-captcha,hutool-json,hutool-poi,hutool-jwt,hutool-aop,hutool-bloomFilter,hutool-cache,hutool-cron,hutool-db,hutool-dfa,hutool-extra,hutool-http,hutool-log,hutool-script,hutool-setting,hutool-system,hutool-socket|}</artifactId>",
|
||||||
|
" <version>${hutool.version}</version>",
|
||||||
|
"</dependency>",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"JUnit4": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "junit4",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
"\t<groupId>junit</groupId>",
|
||||||
|
"\t<artifactId>junit</artifactId>",
|
||||||
|
"\t<version>4.11</version>",
|
||||||
|
"\t<scope>test</scope>",
|
||||||
|
"</dependency>",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"JUnit5": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "junit5",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
"\t<groupId>org.junit.jupiter</groupId>",
|
||||||
|
"\t<artifactId>junit-jupiter-api</artifactId>",
|
||||||
|
"\t<version>5.9.2</version>",
|
||||||
|
"\t<scope>test</scope>",
|
||||||
|
"</dependency>",
|
||||||
|
"<dependency>",
|
||||||
|
"\t<groupId>org.junit.jupiter</groupId>",
|
||||||
|
"\t<artifactId>junit-jupiter-engine</artifactId>",
|
||||||
|
"\t<version>5.9.2</version>",
|
||||||
|
"\t<scope>test</scope>",
|
||||||
|
"</dependency>",
|
||||||
|
"<dependency>",
|
||||||
|
"\t<groupId>org.junit.jupiter</groupId>",
|
||||||
|
"\t<artifactId>junit-jupiter-params</artifactId>",
|
||||||
|
"\t<version>5.9.2</version>",
|
||||||
|
"\t<scope>test</scope>",
|
||||||
|
"</dependency>",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"jsr305": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "jsr305",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
"\t<groupId>com.google.code.findbugs</groupId>",
|
||||||
|
"\t<artifactId>jsr305</artifactId>",
|
||||||
|
"\t<version>${1:3.0.2}</version>$2",
|
||||||
|
"</dependency>",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"gson": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "gson",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
"\t<groupId>com.google.code.gson</groupId>",
|
||||||
|
"\t<artifactId>gson</artifactId>",
|
||||||
|
"\t<version>${1:2.11.0}</version>$2",
|
||||||
|
"</dependency>",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"joda-time": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "joda-time",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
"\t<groupId>joda-time</groupId>",
|
||||||
|
"\t<artifactId>joda-time</artifactId>",
|
||||||
|
"\t<version>${1:2.12.7}</version>",
|
||||||
|
"</dependency>",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"maven-shade-plugin": {
|
||||||
|
"scope": "xml",
|
||||||
|
"prefix": "maven-shade-plugin",
|
||||||
|
"body": [
|
||||||
|
"<plugin>",
|
||||||
|
"\t<groupId>org.apache.maven.plugins</groupId>",
|
||||||
|
"\t<artifactId>maven-shade-plugin</artifactId>",
|
||||||
|
"\t<version>${1:3.2.4}</version>",
|
||||||
|
"\t<executions>",
|
||||||
|
"\t\t<execution>",
|
||||||
|
"\t\t\t<phase>package</phase>",
|
||||||
|
"\t\t\t<goals>",
|
||||||
|
"\t\t\t\t<goal>shade</goal>",
|
||||||
|
"\t\t\t</goals>",
|
||||||
|
"\t\t\t<configuration>",
|
||||||
|
"\t\t\t\t<transformers>",
|
||||||
|
"\t\t\t\t\t<transformer",
|
||||||
|
"\t\t\t\t\t\timplementation=\"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer\">",
|
||||||
|
"\t\t\t\t\t\t<mainClass>${2:com.example.App}</mainClass>",
|
||||||
|
"\t\t\t\t\t</transformer>",
|
||||||
|
"\t\t\t\t</transformers>",
|
||||||
|
"\t\t\t</configuration>",
|
||||||
|
"\t\t</execution>",
|
||||||
|
"\t</executions>",
|
||||||
|
"</plugin>",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
143
repository.code-snippets
Normal file
143
repository.code-snippets
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
{
|
||||||
|
"Repository": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "repository",
|
||||||
|
"body": [
|
||||||
|
"package ${1:base package}.${2:context}.domain.model.${3:aggregateroot};",
|
||||||
|
"",
|
||||||
|
"import java.util.List;",
|
||||||
|
"",
|
||||||
|
"import xyz.zhouxy.plusone.domain.IRepository;",
|
||||||
|
"",
|
||||||
|
"public interface ${4:AggregateRoot}Repository extends IRepository<${4:AggregateRoot}, ${5:ID}> {",
|
||||||
|
"",
|
||||||
|
" List<${4:AggregateRoot}> findAll();",
|
||||||
|
"}",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"RepositoryImplTemplate": {
|
||||||
|
"scope": "java",
|
||||||
|
"prefix": "repoImplTemplate",
|
||||||
|
"body": [
|
||||||
|
"@Repository",
|
||||||
|
"public class ${1:Entity}RepositoryImpl extends JdbcRepositorySupport<${1:Entity}, Long> implements ${1:Entity}Repository {",
|
||||||
|
"",
|
||||||
|
"\t// private final ${1:Entity}RoleRefDAO ${3:entity}RoleDAO;",
|
||||||
|
"",
|
||||||
|
"\tpublic ${1:Entity}RepositoryImpl(@Nonnull NamedParameterJdbcTemplate namedParameterJdbcTemplate) {",
|
||||||
|
"\t\tsuper(namedParameterJdbcTemplate);",
|
||||||
|
"\t\t// this.${3:entity}RoleDAO = new ${1:Entity}RoleRefDAO(namedParameterJdbcTemplate);",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t/**",
|
||||||
|
"\t * @DefinedIn {@link JdbcRepositorySupport}",
|
||||||
|
"\t */",
|
||||||
|
"\t@Override",
|
||||||
|
"\tprotected final void doDelete(@Nonnull ${1:Entity} entity) {",
|
||||||
|
"\t\tint i = update(\"\"\"",
|
||||||
|
"\t\t\t\tUPDATE ${2:table_name} SET deleted = id, \"version\" = \"version\" + 1",
|
||||||
|
"\t\t\t\tWHERE id = :id AND deleted = 0 AND \"version\" = :version",
|
||||||
|
"\t\t\t\t\"\"\",",
|
||||||
|
"\t\t\t\tnew MapSqlParameterSource()",
|
||||||
|
"\t\t\t\t\t\t.addValue(\"id\", entity.getId().orElseThrow())",
|
||||||
|
"\t\t\t\t\t\t.addValue(\"version\", entity.getVersion()));",
|
||||||
|
"\t\tassertUpdateOneRow(i);",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t/**",
|
||||||
|
"\t * @DefinedIn {@link JdbcRepositorySupport}",
|
||||||
|
"\t */",
|
||||||
|
"\t@Override",
|
||||||
|
"\tprotected final Optional<${1:Entity}> doFindById(@Nonnull Long id) {",
|
||||||
|
"\t\treturn queryForObject(\"\"\"",
|
||||||
|
"\t\t\t\tSELECT",
|
||||||
|
"\t\t\t\t\tid, ..., \"version\"",
|
||||||
|
"\t\t\t\tFROM ${2:table_name}",
|
||||||
|
"\t\t\t\tWHERE id = :id AND deleted = 0",
|
||||||
|
"\t\t\t\t\"\"\",",
|
||||||
|
"\t\t\t\t\"id\", id);",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t/**",
|
||||||
|
"\t * @DefinedIn {@link IRepository}",
|
||||||
|
"\t */",
|
||||||
|
"\t@Override",
|
||||||
|
"\tpublic boolean exists(Long id) {",
|
||||||
|
"\t\treturn queryForBool(\"SELECT EXISTS (SELECT 1 FROM ${2:table_name} WHERE id = :id AND deleted = 0 LIMIT 1)\",",
|
||||||
|
"\t\t\t\t\"id\", id);",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t/**",
|
||||||
|
"\t * @DefinedIn {@link JdbcRepositorySupport}",
|
||||||
|
"\t */",
|
||||||
|
"\t@Override",
|
||||||
|
"\tprotected final ${1:Entity} doInsert(@Nonnull ${1:Entity} entity) {",
|
||||||
|
"\t\tlong id = IdUtil.getSnowflakeNextId();",
|
||||||
|
"\t\tint i = update(\"\"\"",
|
||||||
|
"\t\t\t\tINSERT INTO ${2:table_name}",
|
||||||
|
"\t\t\t\t\t(id, ... created_by, create_time)",
|
||||||
|
"\t\t\t\tVALUES",
|
||||||
|
"\t\t\t\t\t(:id, ..., :createdBy, :createTime)",
|
||||||
|
"\t\t\t\t\"\"\",",
|
||||||
|
"\t\t\t\tgenerateParamSource(id, entity));",
|
||||||
|
"\t\tassertUpdateOneRow(i);",
|
||||||
|
"\t\t// this.${3:entity}RoleDAO.insert${1:Entity}RoleRefs(id, entity.getRoleIds());",
|
||||||
|
"\t\treturn find(id).orElseThrow();",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t/**",
|
||||||
|
"\t * @DefinedIn {@link JdbcRepositorySupport}",
|
||||||
|
"\t */",
|
||||||
|
"\t@Override",
|
||||||
|
"\tprotected final ${1:Entity} doUpdate(@Nonnull ${1:Entity} entity) {",
|
||||||
|
"\t\tint i = update(\"\"\"",
|
||||||
|
"\t\t\t\tUPDATE ${2:table_name}",
|
||||||
|
"\t\t\t\tSET ...",
|
||||||
|
"\t\t\t\t\t\"updated_by\" = :updatedBy,",
|
||||||
|
"\t\t\t\t\t\"update_time\" = :updateTime,",
|
||||||
|
"\t\t\t\t\t\"version\" = \"version\" + 1",
|
||||||
|
"\t\t\t\tWHERE id = :id AND deleted = 0 AND \"version\" = :version",
|
||||||
|
"\t\t\t\t\"\"\",",
|
||||||
|
"\t\t\t\tgenerateParamSource(entity));",
|
||||||
|
"\t\tassertUpdateOneRow(i);",
|
||||||
|
"\t\t// this.${3:entity}RoleDAO.save${1:Entity}RoleRefs(entity);",
|
||||||
|
"\t\treturn find(entity.getId().orElseThrow()).orElseThrow();",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t/**",
|
||||||
|
"\t * @DefinedIn {@link JdbcEntityDaoSupport}",
|
||||||
|
"\t */",
|
||||||
|
"\t@Override",
|
||||||
|
"\tprotected final ${1:Entity} mapRow(ResultSet rs) throws SQLException {",
|
||||||
|
"\t\tlong id = rs.getLong(\"id\");",
|
||||||
|
"",
|
||||||
|
"\t\treturn new ${1:Entity}(",
|
||||||
|
"\t\t\t\tid,",
|
||||||
|
"\t\t\t\t...",
|
||||||
|
"\t\t\t\trs.getLong(\"created_by\"),",
|
||||||
|
"\t\t\t\trs.getLong(\"updated_by\"),",
|
||||||
|
"\t\t\t\trs.getLong(\"version\"));",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"\t/**",
|
||||||
|
"\t * @DefinedIn {@link JdbcRepositorySupport}",
|
||||||
|
"\t */",
|
||||||
|
"\t@Override",
|
||||||
|
"\tprotected final SqlParameterSource generateParamSource(Long id, @Nonnull ${1:Entity} entity) {",
|
||||||
|
"\t\tLocalDateTime now = LocalDateTime.now();",
|
||||||
|
"\t\t",
|
||||||
|
"\t\treturn new MapSqlParameterSource()",
|
||||||
|
"\t\t\t\t.addValue(\"id\", id)",
|
||||||
|
"\t\t\t\t...",
|
||||||
|
"\t\t\t\t.addValue(\"createdBy\", entity.getCreatedBy())",
|
||||||
|
"\t\t\t\t.addValue(\"createTime\", now)",
|
||||||
|
"\t\t\t\t.addValue(\"updatedBy\", entity.getUpdatedBy())",
|
||||||
|
"\t\t\t\t.addValue(\"updateTime\", now)",
|
||||||
|
"\t\t\t\t.addValue(\"version\", entity.getVersion());",
|
||||||
|
"\t}",
|
||||||
|
"",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
16
spring-boot-dependencies.code-snippets
Normal file
16
spring-boot-dependencies.code-snippets
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"SpringBoot Dependencies": {
|
||||||
|
"prefix": "spring-boot-dependencies",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
"\t<groupId>org.springframework.boot</groupId>",
|
||||||
|
"\t<artifactId>spring-boot-dependencies</artifactId>",
|
||||||
|
"\t<version>${spring-boot.version}</version>",
|
||||||
|
"\t<type>pom</type>",
|
||||||
|
"\t<scope>import</scope>",
|
||||||
|
"</dependency>",
|
||||||
|
],
|
||||||
|
"description": "Import SpringBoot Dependencies",
|
||||||
|
"scope": "xml"
|
||||||
|
}
|
||||||
|
}
|
27
spring-cloud-alibaba-dependencies.code-snippets
Normal file
27
spring-cloud-alibaba-dependencies.code-snippets
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"Spring Cloud Alibaba Dependencies": {
|
||||||
|
"prefix": "spring-cloud-alibaba-dependencies",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
"\t<groupId>com.alibaba.cloud</groupId>",
|
||||||
|
"\t<artifactId>spring-cloud-alibaba-dependencies</artifactId>",
|
||||||
|
"\t<version>${spring-cloud-alibaba.version}</version>",
|
||||||
|
"\t<type>pom</type>",
|
||||||
|
"\t<scope>import</scope>",
|
||||||
|
"</dependency>",
|
||||||
|
],
|
||||||
|
"description": "Import Spring Cloud Alibaba Dependencies",
|
||||||
|
"scope": "xml"
|
||||||
|
},
|
||||||
|
"Spring Cloud Alibaba Nacos Discovery": {
|
||||||
|
"prefix": "spring-cloud-starter-alibaba-nacos-discovery",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
"\t<groupId>com.alibaba.cloud</groupId>",
|
||||||
|
"\t<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>",
|
||||||
|
"</dependency>",
|
||||||
|
],
|
||||||
|
"description": "Import Spring Cloud Alibaba Nacos Discovery",
|
||||||
|
"scope": "xml"
|
||||||
|
}
|
||||||
|
}
|
16
spring-cloud-dependencies.code-snippets
Normal file
16
spring-cloud-dependencies.code-snippets
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"Spring Cloud Alibaba Dependencies": {
|
||||||
|
"prefix": "spring-cloud-dependencies",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
"\t<groupId>org.springframework.cloud</groupId>",
|
||||||
|
"\t<artifactId>spring-cloud-dependencies</artifactId>",
|
||||||
|
"\t<version>${spring-cloud.version}</version>",
|
||||||
|
"\t<type>pom</type>",
|
||||||
|
"\t<scope>import</scope>",
|
||||||
|
"</dependency>",
|
||||||
|
],
|
||||||
|
"description": "Import Spring Cloud Dependencies",
|
||||||
|
"scope": "xml"
|
||||||
|
}
|
||||||
|
}
|
13
spring-cloud-starter-alibaba-nacos-discovery.code-snippets
Normal file
13
spring-cloud-starter-alibaba-nacos-discovery.code-snippets
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"Spring Cloud Alibaba Dependencies": {
|
||||||
|
"prefix": "spring-cloud-starter-alibaba-nacos-discovery",
|
||||||
|
"body": [
|
||||||
|
"<dependency>",
|
||||||
|
"\t<groupId>com.alibaba.cloud</groupId>",
|
||||||
|
"\t<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>",
|
||||||
|
"</dependency>",
|
||||||
|
],
|
||||||
|
"description": "Import Spring Cloud Alibaba Nacos Discovery",
|
||||||
|
"scope": "xml"
|
||||||
|
}
|
||||||
|
}
|
26
spring-context.code-snippets
Normal file
26
spring-context.code-snippets
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"Spring XML Context": {
|
||||||
|
"prefix": "spring-xml-context",
|
||||||
|
"scope": "xml",
|
||||||
|
"body": [
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
|
||||||
|
"<beans xmlns=\"http://www.springframework.org/schema/beans\"",
|
||||||
|
"\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"",
|
||||||
|
"\txmlns:aop=\"http://www.springframework.org/schema/aop\"",
|
||||||
|
"\txmlns:tx=\"http://www.springframework.org/schema/tx\"",
|
||||||
|
"\txmlns:context=\"http://www.springframework.org/schema/context\"",
|
||||||
|
"\txsi:schemaLocation=\"http://www.springframework.org/schema/beans",
|
||||||
|
"\t\t\thttp://www.springframework.org/schema/beans/spring-beans-4.3.xsd",
|
||||||
|
"\t\t\thttp://www.springframework.org/schema/tx",
|
||||||
|
"\t\t\thttp://www.springframework.org/schema/tx/spring-tx-4.3.xsd",
|
||||||
|
"\t\t\thttp://www.springframework.org/schema/context",
|
||||||
|
"\t\t\thttp://www.springframework.org/schema/context/spring-context-4.3.xsd",
|
||||||
|
"\t\t\thttp://www.springframework.org/schema/aop",
|
||||||
|
"\t\t\thttp://www.springframework.org/schema/aop/spring-aop-4.3.xsd\">",
|
||||||
|
"",
|
||||||
|
"\t$1",
|
||||||
|
"</beans>",
|
||||||
|
],
|
||||||
|
"description": "Spring xml context template"
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user