-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support Java-SpringBoot-MyBatis template
- Loading branch information
Showing
21 changed files
with
349 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/SmartCode.Generator/RazorTemplates/Java/AppConfig.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@using SmartCode | ||
@model BuildContext | ||
@{ | ||
Layout = "_JavaLayout.cshtml"; | ||
var project = Model.Project; | ||
var buildTask = Model.Build; | ||
} | ||
|
||
|
||
package @(project.Module).config; | ||
|
||
public class AppConfig { | ||
|
||
} |
23 changes: 20 additions & 3 deletions
23
src/SmartCode.Generator/RazorTemplates/Java/Application.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
package me.ahoo.demo; | ||
@using SmartCode | ||
@model BuildContext | ||
@{ | ||
Layout = "_JavaLayout.cshtml"; | ||
var project = Model.Project; | ||
|
||
var appName = "Demo"; | ||
|
||
if (project.Parameters.TryGetValue("ApplicationName", out var _appName)) | ||
{ | ||
appName = _appName.ToString(); | ||
} | ||
var appClassName = $"{appName}Application"; | ||
} | ||
|
||
package @(project.Module); | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
@@SpringBootApplication | ||
public class DemoApplication { | ||
@@EnableSwagger2 | ||
public class @appClassName { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(DemoApplication.class, args); | ||
SpringApplication.run(@(appClassName).class, args); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
@using SmartCode | ||
@model BuildContext | ||
@{ | ||
Layout = "_JavaLayout.cshtml"; | ||
var project = Model.Project; | ||
var buildTask = Model.Build; | ||
var table = Model.GetCurrentTable(); | ||
var pkCol = table.PKColumn; | ||
if (pkCol == null) | ||
{ | ||
throw new SmartCodeException($"Service Template can not find PKColumn,Table:{table.Name}."); | ||
} | ||
var pkType = pkCol.LanguageType; | ||
var insertRetType = table.AutoIncrement ? pkType : "int"; | ||
var entityName = table.ConvertedName; | ||
var entityCamelName = NamingUtil.CamelCase(table.ConvertedName); | ||
var serviceName = $"{table.ConvertedName}Service"; | ||
var serviceCamelName = NamingUtil.CamelCase(serviceName); | ||
var controllerName = $"{table.ConvertedName}Controller"; | ||
} | ||
|
||
|
||
|
||
package @(project.Module).@buildTask.Module; | ||
|
||
import lombok.var; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import javax.validation.Valid; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import @(project.Module).service.@serviceName; | ||
|
||
@Html.NewLine() | ||
@@RestController | ||
@@RequestMapping("@entityCamelName") | ||
public class @controllerName { | ||
@@Autowired | ||
@serviceName @serviceCamelName; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.