From 1fae85080b49842c6ce7b0f7fb6ac7856f4214b8 Mon Sep 17 00:00:00 2001 From: Mario Luo Date: Tue, 27 Apr 2021 16:18:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/spring-data-mongodb/controller.vm | 15 ++++++++------- .../template/spring-data-mongodb/repository.vm | 7 ++++--- .../template/spring-data-mongodb/service.vm | 4 +++- .../template/spring-data-mongodb/serviceImpl.vm | 2 ++ 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/resources/template/spring-data-mongodb/controller.vm b/src/main/resources/template/spring-data-mongodb/controller.vm index c29ee24..bfee4fd 100644 --- a/src/main/resources/template/spring-data-mongodb/controller.vm +++ b/src/main/resources/template/spring-data-mongodb/controller.vm @@ -16,8 +16,9 @@ $!define #set($entityShortType = $!tableInfo.name) #set($entityType = $!tableInfo.psiClassObj.getQualifiedName()) #set($entityVarName = $!tool.firstLowerCase($!tableInfo.name)) +#set($pkType = $!pk.type) - +import $pkType; import $entityType; import $serviceType; import lombok.AllArgsConstructor; @@ -44,7 +45,7 @@ public class $!{tableName} { private $serviceSortType $serviceVarName; /** - * 获取列表(分页) + * 获取$!{tableInfo.comment}列表(分页) */ @GetMapping("/list") public Page<$entityShortType> list(Pageable page) { @@ -52,7 +53,7 @@ public class $!{tableName} { } /** - * 获取一条数据 + * 获取$!{tableInfo.comment} */ @GetMapping("/get") public $entityShortType get($!pk.shortType id) { @@ -60,7 +61,7 @@ public class $!{tableName} { } /** - * 添加 + * 添加$!{tableInfo.comment} */ @PostMapping("/add") public void add(@RequestBody $entityShortType $entityVarName) { @@ -69,7 +70,7 @@ public class $!{tableName} { /** - * 修改 + * 修改$!{tableInfo.comment} */ @PostMapping("/update") public void update(@RequestBody $entityShortType $entityVarName) { @@ -77,11 +78,11 @@ public class $!{tableName} { } /** - * 删除 + * 删除$!{tableInfo.comment} */ @PostMapping("/delete") public void delete($!pk.shortType id) { ${serviceVarName}.deleteById(id); } -} \ No newline at end of file +} diff --git a/src/main/resources/template/spring-data-mongodb/repository.vm b/src/main/resources/template/spring-data-mongodb/repository.vm index b84f372..ce690a3 100644 --- a/src/main/resources/template/spring-data-mongodb/repository.vm +++ b/src/main/resources/template/spring-data-mongodb/repository.vm @@ -10,11 +10,12 @@ $!define #end ##实体类名、主键类名 #set($entityShortType = $!tableInfo.name) +#set($entityType = $!tableInfo.psiClassObj.getQualifiedName()) #set($pkShortType = $!pk.shortType) +#set($pkType = $!pk.type) -#if($tableInfo.psiClassObj) -import $!tableInfo.psiClassObj.getQualifiedName(); -#end +import $pkType; +import $entityType; import org.springframework.data.mongodb.repository.MongoRepository; diff --git a/src/main/resources/template/spring-data-mongodb/service.vm b/src/main/resources/template/spring-data-mongodb/service.vm index 56941fb..bcc99c5 100644 --- a/src/main/resources/template/spring-data-mongodb/service.vm +++ b/src/main/resources/template/spring-data-mongodb/service.vm @@ -13,7 +13,9 @@ $!define #set($entityType = $!tableInfo.psiClassObj.getQualifiedName()) #set($entityVarName = $!tool.firstLowerCase($!tableInfo.name)) #set($pkShortType = $!pk.shortType) +#set($pkType = $!pk.type) +import $pkType; import $entityType; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -28,7 +30,7 @@ import java.util.List; * @since $!time.currTime() */ public interface $!{tableName} { - + void save($entityShortType $entityVarName); void deleteById($pkShortType id); diff --git a/src/main/resources/template/spring-data-mongodb/serviceImpl.vm b/src/main/resources/template/spring-data-mongodb/serviceImpl.vm index 4d1305f..ebb00c2 100644 --- a/src/main/resources/template/spring-data-mongodb/serviceImpl.vm +++ b/src/main/resources/template/spring-data-mongodb/serviceImpl.vm @@ -18,7 +18,9 @@ $!define #set($entityType = $!tableInfo.psiClassObj.getQualifiedName()) #set($entityVarName = $!tool.firstLowerCase($!tableInfo.name)) #set($pkShortType = $!pk.shortType) +#set($pkType = $!pk.type) +import $pkType; import $entityType; import $serviceType; import $repositoryType;