mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2025-12-25 21:36:47 +08:00
| 2023.01.02 | 新增TkMybatis模板(感谢@sgj666的建议)。
This commit is contained in:
parent
45643663bd
commit
d1062f1622
@ -60,6 +60,7 @@ Thanks for `JetBrains` providing us the `Licenses for Open Source Development`
|
||||
# Update Logs
|
||||
| 更新日期 | 更新内容 |
|
||||
|:-----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| 2023.01.02 | 新增TkMybatis模板(感谢@sgj666的建议)。 |
|
||||
| 2023.01.01 | 新增GCP BigQuery/Dataflow JJS/QlikSense BI模板。 |
|
||||
| 2022.09.28 | MySQL to Java type conversion 数据库类型转换优化(感谢@jadelike得贡献) |
|
||||
| 2022.07.02 | add the script to install and run,添加批处理以便直接构建或运行项目。 |
|
||||
|
||||
@ -271,5 +271,25 @@
|
||||
"description": "GCP Dataflow JJS"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "tk-mybatis",
|
||||
"templates": [
|
||||
{
|
||||
"id": "401",
|
||||
"name": "tk-entity",
|
||||
"description": "tk-entity"
|
||||
},
|
||||
{
|
||||
"id": "402",
|
||||
"name": "tk-mapper",
|
||||
"description": "tk-mapper"
|
||||
},
|
||||
{
|
||||
"id": "403",
|
||||
"name": "tk-controller",
|
||||
"description": "tk-controller"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,79 @@
|
||||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.controller;</#if>
|
||||
<#if isAutoImport?exists && isAutoImport==true>
|
||||
import ${packageName}.entity.${classInfo.className};
|
||||
import ${packageName}.mapper.${classInfo.className}Mapper;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
</#if>
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/${classInfo.className?uncap_first}")
|
||||
public class ${classInfo.className}Controller {
|
||||
|
||||
@Autowired
|
||||
private ${classInfo.className}Mapper ${classInfo.className?uncap_first}Mapper;
|
||||
|
||||
/**
|
||||
* 新增或编辑
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public Object save(${classInfo.className} ${classInfo.className?uncap_first}){
|
||||
if(${classInfo.className?uncap_first}Mapper.selectCount(${classInfo.className?uncap_first})>0){
|
||||
${classInfo.className?uncap_first}Mapper.insert(${classInfo.className?uncap_first});
|
||||
}else{
|
||||
${classInfo.className?uncap_first}Mapper.updateByPrimaryKeySelective(${classInfo.className?uncap_first});
|
||||
}
|
||||
return ${returnUtilSuccess}("新增或编辑成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public Object delete(int id){
|
||||
if(${classInfo.className?uncap_first}Mapper.selectCount(${classInfo.className?uncap_first})>0){
|
||||
${classInfo.className?uncap_first}Mapper.deleteByPrimaryKey(id);
|
||||
return ${returnUtilSuccess}("删除成功");
|
||||
}else{
|
||||
return ${returnUtilFailure}("没有找到该对象");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
@PostMapping("/find")
|
||||
public Object find(int id){
|
||||
Optional<${classInfo.className}> ${classInfo.className?uncap_first}=${classInfo.className?uncap_first}Mapper.selectOne(id);
|
||||
if(${classInfo.className?uncap_first}.isPresent()){
|
||||
return ${returnUtilSuccess}(${classInfo.className?uncap_first}.get());
|
||||
}else{
|
||||
return ${returnUtilFailure}("没有找到该对象");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public Object list(${classInfo.className} ${classInfo.className?uncap_first},
|
||||
@RequestParam(required = false, defaultValue = "0") int pageNumber,
|
||||
@RequestParam(required = false, defaultValue = "10") int pageSize) {
|
||||
//TBC
|
||||
return ${classInfo.className?uncap_first}Mapper.selectList(${classInfo.className?uncap_first});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.entity;</#if>
|
||||
|
||||
<#if isAutoImport?exists && isAutoImport==true>
|
||||
<#if isLombok?exists && isLombok==true>import lombok.Data;</#if>
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.io.Serializable;
|
||||
import io.mybatis.provider.Entity;
|
||||
<#if isSwagger?exists && isSwagger==true>
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;</#if>
|
||||
</#if>
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
<#if isLombok?exists && isLombok==true>@Data</#if>
|
||||
<#if isComment?exists && isComment==true>@Entity.Table("${classInfo.originTableName}")</#if><#if isSwagger?exists && isSwagger==true>
|
||||
@ApiModel("${classInfo.classComment}")</#if>
|
||||
public class ${classInfo.className} implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@Entity.Column(id = true)
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<#if isComment?exists && isComment==true>/**
|
||||
* ${fieldItem.fieldComment}
|
||||
*/</#if><#if isSwagger?exists && isSwagger==true>
|
||||
@ApiModelProperty("${fieldItem.fieldComment}")</#if>
|
||||
<#if isComment?exists && isComment==true>@Entity.Column("${fieldItem.columnName}")</#if>
|
||||
private ${fieldItem.fieldClass} ${fieldItem.fieldName};
|
||||
|
||||
</#list>
|
||||
public ${classInfo.className}() {
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if isLombok?exists && isLombok==false>
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
public ${fieldItem.fieldClass} get${fieldItem.fieldName?cap_first}() {
|
||||
return ${fieldItem.fieldName};
|
||||
}
|
||||
|
||||
public void set${fieldItem.fieldName?cap_first}(${fieldItem.fieldClass} ${fieldItem.fieldName}) {
|
||||
this.${fieldItem.fieldName} = ${fieldItem.fieldName};
|
||||
}
|
||||
</#list>
|
||||
</#if>
|
||||
</#if>
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.mapper;</#if>
|
||||
<#if isAutoImport?exists && isAutoImport==true>import ${packageName}.entity.${classInfo.className};
|
||||
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<#if fieldItem.fieldClass == "Date">
|
||||
<#assign importDdate = true />
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
import java.util.List;
|
||||
import io.mybatis.mapper.Mapper;
|
||||
</#if>
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@org.apache.ibatis.annotations.Mapper
|
||||
public interface ${classInfo.className}Mapper extends Mapper<${classInfo.className},Integer> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user