fix: 接口新返回等级信息
This commit is contained in:
17
play-generator/src/main/resources/config.properties
Normal file
17
play-generator/src/main/resources/config.properties
Normal file
@@ -0,0 +1,17 @@
|
||||
# 数据库配置
|
||||
db.url=jdbc:mysql://122.51.20.105:3306/play-with?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||
db.driver=com.mysql.cj.jdbc.Driver
|
||||
db.name=play-with
|
||||
db.username=root
|
||||
db.password=KdaKRZ2trpdhNePa
|
||||
|
||||
# 代码生成配置
|
||||
gen.author=huchuansai
|
||||
gen.packageName=com.starry.admin
|
||||
gen.outputDir=./generated-code
|
||||
gen.autoRemovePre=false
|
||||
gen.tablePrefix=sys_
|
||||
gen.tplCategory=crud
|
||||
|
||||
# 要生成的表名,多个表名用逗号分隔
|
||||
gen.tableNames=sys_role
|
||||
12
play-generator/src/main/resources/logback.xml
Normal file
12
play-generator/src/main/resources/logback.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
</configuration>
|
||||
74
play-generator/src/main/resources/vm/java/addVo.java.vm
Normal file
74
play-generator/src/main/resources/vm/java/addVo.java.vm
Normal file
@@ -0,0 +1,74 @@
|
||||
package ${packageName}.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
#foreach ($import in $importList)
|
||||
import ${import};
|
||||
#end
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* ${functionName}添加参数VO
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${datetime}
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "${functionName}添加参数", description = "新增${functionName}信息的请求参数")
|
||||
public class ${ClassName}AddVo {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if(!$column.superColumn && !$column.pk)
|
||||
#if($column.insert == "1")
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
#if($column.javaType == 'Date')
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
#if($column.isRequired == "1")
|
||||
@NotNull(message = "${column.columnComment}不能为空")
|
||||
@ApiModelProperty(value = "$column.columnComment", required = true, example = "2024-01-01 00:00:00", notes = "$column.columnComment")
|
||||
#else
|
||||
@ApiModelProperty(value = "$column.columnComment", example = "2024-01-01 00:00:00", notes = "$column.columnComment")
|
||||
#end
|
||||
#elseif($column.javaType == 'String')
|
||||
#if($column.isRequired == "1")
|
||||
@NotBlank(message = "${column.columnComment}不能为空")
|
||||
@ApiModelProperty(value = "$column.columnComment", required = true, example = "示例${column.columnComment}", notes = "$column.columnComment")
|
||||
#else
|
||||
@ApiModelProperty(value = "$column.columnComment", example = "示例${column.columnComment}", notes = "$column.columnComment")
|
||||
#end
|
||||
#elseif($column.javaType == 'Integer')
|
||||
#if($column.isRequired == "1")
|
||||
@NotNull(message = "${column.columnComment}不能为空")
|
||||
@ApiModelProperty(value = "$column.columnComment", required = true, example = "1", notes = "$column.columnComment")
|
||||
#else
|
||||
@ApiModelProperty(value = "$column.columnComment", example = "1", notes = "$column.columnComment")
|
||||
#end
|
||||
#elseif($column.javaType == 'Long')
|
||||
#if($column.isRequired == "1")
|
||||
@NotNull(message = "${column.columnComment}不能为空")
|
||||
@ApiModelProperty(value = "$column.columnComment", required = true, example = "1", notes = "$column.columnComment")
|
||||
#else
|
||||
@ApiModelProperty(value = "$column.columnComment", example = "1", notes = "$column.columnComment")
|
||||
#end
|
||||
#else
|
||||
#if($column.isRequired == "1")
|
||||
@NotNull(message = "${column.columnComment}不能为空")
|
||||
@ApiModelProperty(value = "$column.columnComment", required = true, notes = "$column.columnComment")
|
||||
#else
|
||||
@ApiModelProperty(value = "$column.columnComment", notes = "$column.columnComment")
|
||||
#end
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
@@ -2,21 +2,24 @@ package ${packageName}.controller;
|
||||
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
|
||||
|
||||
import com.starry.common.annotation.Log;
|
||||
import ${packageName}.entity.${ClassName}Entity;
|
||||
import ${packageName}.vo.${ClassName}QueryVo;
|
||||
import ${packageName}.vo.${ClassName}AddVo;
|
||||
import ${packageName}.service.I${ClassName}Service;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* ${functionName}Controller
|
||||
@@ -24,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @author ${author}
|
||||
* @since ${datetime}
|
||||
*/
|
||||
@Api(tags = "${functionName}管理", description = "${functionName}信息管理相关接口,包括查询、新增、修改、删除等操作")
|
||||
@RestController
|
||||
@RequestMapping("/${moduleName}/${businessName}")
|
||||
public class ${ClassName}Controller {
|
||||
@@ -31,25 +35,45 @@ public class ${ClassName}Controller {
|
||||
private I${ClassName}Service ${className}Service;
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
* 分页查询${functionName}列表
|
||||
*/
|
||||
@ApiOperation(value = "分页查询${functionName}", notes = "分页查询${functionName}信息列表")
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "操作成功", response = ${ClassName}Entity.class, responseContainer = "Page")
|
||||
})
|
||||
@PreAuthorize("@customSs.hasPermission('${permissionPrefix}:list')")
|
||||
@GetMapping("/list")
|
||||
#if($table.crud || $table.sub)
|
||||
public R list(${ClassName}Entity ${className}) {
|
||||
IPage<${ClassName}Entity> list = ${className}Service.select${ClassName}ByPage(${className});
|
||||
return R.ok(list);
|
||||
}
|
||||
#elseif($table.tree)
|
||||
public R list(${ClassName}Entity ${className}) {
|
||||
List<${ClassName}Entity> list = ${className}Service.select${ClassName}List(${className});
|
||||
return R.ok(list);
|
||||
}
|
||||
#end
|
||||
@PostMapping("/listByPage")
|
||||
#if($table.crud || $table.sub)
|
||||
public R listByPage(@ApiParam(value = "查询条件", required = true) @Validated @RequestBody ${ClassName}QueryVo vo) {
|
||||
return R.ok(${className}Service.selectByPage(vo));
|
||||
}
|
||||
#elseif($table.tree)
|
||||
public R listByPage(@ApiParam(value = "查询条件", required = true) @Validated @RequestBody ${ClassName}QueryVo vo) {
|
||||
return R.ok(${className}Service.select${ClassName}List(vo));
|
||||
}
|
||||
#end
|
||||
|
||||
/**
|
||||
* 查询所有${functionName}列表
|
||||
*/
|
||||
@ApiOperation(value = "查询所有${functionName}", notes = "获取所有${functionName}信息列表")
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "操作成功", response = ${ClassName}Entity.class, responseContainer = "List")
|
||||
})
|
||||
@PreAuthorize("@customSs.hasPermission('${permissionPrefix}:list')")
|
||||
@GetMapping("/listAll")
|
||||
public R listAll() {
|
||||
return R.ok(${className}Service.selectAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取${functionName}详细信息
|
||||
*/
|
||||
@ApiOperation(value = "获取${functionName}详情", notes = "根据ID获取${functionName}详细信息")
|
||||
@ApiImplicitParam(name = "${pkColumn.javaField}", value = "${functionName}ID", required = true, paramType = "path", dataType = "${pkColumn.javaType}", example = "1")
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "操作成功", response = ${ClassName}Entity.class)
|
||||
})
|
||||
@PreAuthorize("@customSs.hasPermission('${permissionPrefix}:query')")
|
||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
||||
public R getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
|
||||
@@ -59,11 +83,16 @@ public class ${ClassName}Controller {
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*/
|
||||
@ApiOperation(value = "新增${functionName}", notes = "创建新的${functionName}信息")
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "操作成功"),
|
||||
@ApiResponse(code = 500, message = "添加失败")
|
||||
})
|
||||
@PreAuthorize("@customSs.hasPermission('${permissionPrefix}:create')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create")
|
||||
public R create(@RequestBody ${ClassName}Entity ${className}) {
|
||||
boolean success = ${className}Service.create(${className});
|
||||
public R create(@ApiParam(value = "${functionName}信息", required = true) @Validated @RequestBody ${ClassName}AddVo vo) {
|
||||
boolean success = ${className}Service.create(vo);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
@@ -73,11 +102,17 @@ public class ${ClassName}Controller {
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*/
|
||||
@ApiOperation(value = "修改${functionName}", notes = "根据ID修改${functionName}信息")
|
||||
@ApiImplicitParam(name = "${pkColumn.javaField}", value = "${functionName}ID", required = true, paramType = "path", dataType = "${pkColumn.javaType}", example = "1")
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "操作成功"),
|
||||
@ApiResponse(code = 500, message = "修改失败")
|
||||
})
|
||||
@PreAuthorize("@customSs.hasPermission('${permissionPrefix}:edit')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/update/{${pkColumn.javaField}}")
|
||||
public R update(@PathVariable ${pkColumn.javaType} ${pkColumn.javaField}, @RequestBody ${ClassName}Entity ${className}) {
|
||||
${className}.setId(${pkColumn.javaField});
|
||||
public R update(@PathVariable ${pkColumn.javaType} ${pkColumn.javaField}, @ApiParam(value = "${functionName}信息", required = true) @RequestBody ${ClassName}Entity ${className}) {
|
||||
${className}.set${pkColumn.capJavaField}(${pkColumn.javaField});
|
||||
boolean success = ${className}Service.update(${className});
|
||||
if (success) {
|
||||
return R.ok();
|
||||
@@ -88,6 +123,11 @@ public class ${ClassName}Controller {
|
||||
/**
|
||||
* 删除${functionName}
|
||||
*/
|
||||
@ApiOperation(value = "删除${functionName}", notes = "根据ID批量删除${functionName}信息")
|
||||
@ApiImplicitParam(name = "${pkColumn.javaField}s", value = "${functionName}ID数组", required = true, paramType = "path", dataType = "${pkColumn.javaType}[]", example = "1,2,3")
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "操作成功", response = Integer.class)
|
||||
})
|
||||
@PreAuthorize("@customSs.hasPermission('${permissionPrefix}:remove')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||
|
||||
50
play-generator/src/main/resources/vm/java/queryVo.java.vm
Normal file
50
play-generator/src/main/resources/vm/java/queryVo.java.vm
Normal file
@@ -0,0 +1,50 @@
|
||||
package ${packageName}.vo;
|
||||
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
#foreach ($import in $importList)
|
||||
import ${import};
|
||||
#end
|
||||
#if($table.tree)
|
||||
import java.util.List;
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}查询参数VO
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${datetime}
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel(value = "${functionName}查询参数", description = "查询${functionName}信息的条件参数")
|
||||
public class ${ClassName}QueryVo extends BasePageEntity {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if(!$column.superColumn)
|
||||
#if($column.query)
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
#if($column.javaType == 'Date')
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "$column.columnComment", example = "2024-01-01 00:00:00", notes = "$column.columnComment")
|
||||
#elseif($column.javaType == 'String')
|
||||
@ApiModelProperty(value = "$column.columnComment", example = "示例${column.columnComment}", notes = "$column.columnComment")
|
||||
#elseif($column.javaType == 'Integer')
|
||||
@ApiModelProperty(value = "$column.columnComment", example = "1", notes = "$column.columnComment")
|
||||
#elseif($column.javaType == 'Long')
|
||||
@ApiModelProperty(value = "$column.columnComment", example = "1", notes = "$column.columnComment")
|
||||
#else
|
||||
@ApiModelProperty(value = "$column.columnComment", notes = "$column.columnComment")
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
Reference in New Issue
Block a user