Commit 8cfaa557 by flying-cattle

swagger 变成可选择的...

parent ee4eb793
......@@ -79,9 +79,11 @@ public class BasisInfo implements Serializable{
private List<PropertyInfo> cis;
private String isSwagger="true";
public BasisInfo(String project, String author, String version, String dbUrl, String dbName, String dbPassword,
String database, String createTime, String agile, String entityUrl, String daoUrl, String mapperUrl,
String serviceUrl, String serviceImplUrl, String controllerUrl) {
String serviceUrl, String serviceImplUrl, String controllerUrl,String isSwagger) {
super();
this.project = project;
this.author = author;
......@@ -100,5 +102,6 @@ public class BasisInfo implements Serializable{
this.controllerUrl = controllerUrl;
this.abstractControllerUrl = controllerUrl.substring(0, controllerUrl.lastIndexOf("."))+".aid";
this.swaggerConfigUrl=controllerUrl.substring(0, controllerUrl.lastIndexOf("."))+".config";
this.isSwagger=isSwagger;
}
}
......@@ -16,9 +16,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.flying.cattle.mdg.aid.JsonResult;
import com.github.flying.cattle.mdg.aid.PageParam;
<#if isSwagger=="true" >
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
</#if>
/**
* <p>自动生成工具:mybatis-dsc-generator</p>
......@@ -42,8 +43,10 @@ public class AbstractController<S extends IService<T>,T>{
* @time 201949
*/
@GetMapping("/getById/{id}")
<#if isSwagger=="true" >
@ApiOperation(value = "获取对象", notes = "作者:${author}")
@ApiImplicitParam(paramType="path", name = "id", value = "对象id", required = true, dataType = "Long")
</#if>
public JsonResult<T> getUserById(@PathVariable("id")Long id){
T obj=baseService.getById(id);
if (null!=obj ) {
......@@ -62,8 +65,10 @@ public class AbstractController<S extends IService<T>,T>{
* @time 201949
*/
@PostMapping("/deleteById")
<#if isSwagger=="true" >
@ApiOperation(value = "删除", notes = "作者:${author}")
@ApiImplicitParam(paramType="query", name = "id", value = "对象id", required = true, dataType = "Long")
</#if>
public JsonResult<T> deleteById(Long id){
JsonResult<T> result=new JsonResult<T>();
T obj=baseService.getById(id);
......@@ -88,7 +93,9 @@ public class AbstractController<S extends IService<T>,T>{
* @time 201949
*/
@PostMapping("/insert")
<#if isSwagger=="true" >
@ApiOperation(value = "添加", notes = "作者:${author}")
</#if>
public JsonResult<T> insert(T entity){
JsonResult<T> result=new JsonResult<T>();
if (null!=entity) {
......@@ -112,7 +119,9 @@ public class AbstractController<S extends IService<T>,T>{
* @time 201949
*/
@PostMapping("/update")
<#if isSwagger=="true" >
@ApiOperation(value = "修改", notes = "作者:${author}")
</#if>
public JsonResult<T> update(T entity){
JsonResult<T> result=new JsonResult<T>();
if (null!=entity) {
......@@ -136,7 +145,9 @@ public class AbstractController<S extends IService<T>,T>{
* @time 2019520
*/
@GetMapping("/getPages")
<#if isSwagger=="true" >
@ApiOperation(value = "分页查询", notes = "分页查询返回[IPage<T>],作者:边鹏")
</#if>
public JsonResult<IPage<T>> getUserPages(PageParam<T> param){
JsonResult<IPage<T>> returnPage=new JsonResult<IPage<T>>();
Page<T> page=new Page<T>(param.getPageNum(),param.getPageSize());
......
......@@ -11,7 +11,9 @@ import ${entityUrl}.${entityName};
import ${serviceUrl}.${entityName}Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
<#if isSwagger=="true" >
import io.swagger.annotations.Api;
</#if>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
......@@ -22,7 +24,9 @@ import org.slf4j.LoggerFactory;
* @author: ${author}
*
*/
<#if isSwagger=="true" >
@Api(description = "${entityComment}",value="${entityComment}" )
</#if>
@RestController
@RequestMapping("/${objectName}")
public class ${entityName}Controller extends AbstractController<${entityName}Service,${entityName}>{
......
......@@ -5,12 +5,13 @@
* All right reserved.
*/
package ${entityUrl};
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
<#if isSwagger=="true" >
import io.swagger.annotations.ApiModelProperty;
</#if>
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
......@@ -49,7 +50,9 @@ public class ${entityName} extends Model<${entityName}> {
<#if ci.property=="id">
@TableId(value = "id", type = IdType.AUTO)
</#if>
<#if isSwagger=="true" >
@ApiModelProperty(name = "${ci.property}" , value = "${ci.comment}")
</#if>
private ${ci.javaType} ${ci.property};
</#list>
@Override
......
......@@ -20,16 +20,16 @@ import com.github.flying.cattle.mdg.util.MySqlToJavaUtil;
* <p>源码地址:https://gitee.com/flying-cattle/mybatis-dsc-generator</P>
*/
public class MyGenerator {
// 基础信息:项目名、作者、版本
// 基础信息:项目名、作者、版本
public static final String PROJECT = "wallet-sign";
public static final String AUTHOR = "BianPeng";
public static final String VERSION = "V1.0";
// 数据库连接信息:连接URL、用户名、秘密、数据库名
public static final String URL = "jdbc:mysql://127.0.0.1:3306/earn_knife?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=true&serverTimezone=UTC";
public static final String URL = "jdbc:mysql://127.0.0.1:3306/buybit_wallet_sign?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=true&serverTimezone=UTC";
public static final String NAME = "root";
public static final String PASS = "pwd2020";
public static final String DATABASE = "earn_knife";
// 类信息:类名、数据库表名、类说明、时间
public static final String DATABASE = "buybit_wallet_sign";
// 类信息:类名、对象名(一般是【类名】的首字母小些)、类说明、时间
public static final String CLASSNAME = "CollectionRoute";
public static final String TABLE = "collection_route";
public static final String CLASSCOMMENT = "资金归集";
......@@ -42,25 +42,26 @@ public class MyGenerator {
public static final String SERVICE_URL = "com.buybit.ws.service";
public static final String SERVICE_IMPL_URL = "com.buybit.ws.service.impl";
public static final String CONTROLLER_URL = "com.buybit.ws.web";
//是否是Swagger配置
public static final String IS_SWAGGER = "false";
public static void main(String[] args) {
BasisInfo bi = new BasisInfo(PROJECT, AUTHOR, VERSION, URL, NAME, PASS, DATABASE, TIME, AGILE, ENTITY_URL,
DAO_URL, XML_URL, SERVICE_URL, SERVICE_IMPL_URL, CONTROLLER_URL);
DAO_URL, XML_URL, SERVICE_URL, SERVICE_IMPL_URL, CONTROLLER_URL,IS_SWAGGER);
bi.setTable(TABLE);
bi.setEntityName(MySqlToJavaUtil.getClassName(TABLE));
bi.setObjectName(MySqlToJavaUtil.changeToJavaFiled(TABLE));
bi.setEntityComment(CLASSCOMMENT);
try {
bi = EntityInfoUtil.getInfo(bi);
String fileUrl = "E:\\b_mdg\\infrastructure\\springboot-mybatis\\springboot-mybatis-web\\src\\main\\java\\";// 生成文件存放位置
String fileUrl = "E:\\a_item_work\\wallet\\wallet-manage\\wallet-manage-web\\src\\test\\java\\";// 生成文件存放位置
//开始生成文件
String aa1 = Generator.createEntity(fileUrl, bi).toString();
String aa2 = Generator.createDao(fileUrl, bi).toString();
String aa3 = Generator.createDaoImpl(fileUrl, bi).toString();
String aa4 = Generator.createService(fileUrl, bi).toString();
String aa5 = Generator.createServiceImpl(fileUrl, bi).toString();
String aa6 = Generator.createController(fileUrl, bi).toString();
String aa2 = Generator.createDao(fileUrl, bi).toString();
String aa3 = Generator.createDaoImpl(fileUrl, bi).toString();
String aa4 = Generator.createService(fileUrl, bi).toString();
String aa5 = Generator.createServiceImpl(fileUrl, bi).toString();
String aa6 = Generator.createController(fileUrl, bi).toString();
// 是否创建swagger配置文件
String aa7 = Generator.createSwaggerConfig(fileUrl, bi).toString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment