接口文档注解

nacos
DongZeLiang 2023-10-10 14:09:09 +08:00
parent f76c53aac2
commit 25c38ebeef
4 changed files with 37 additions and 21 deletions

View File

@ -2,6 +2,8 @@ package ${packageName}.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -30,6 +32,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
* @author ${author}
* @date ${datetime}
*/
@Api("${functionName}")
@RestController
@RequestMapping("/${moduleName}/${businessName}")
public class ${ClassName}Controller extends BaseController {
@ -39,6 +42,7 @@ public class ${ClassName}Controller extends BaseController {
/**
* 查询${functionName}列表
*/
@ApiOperation("获取${functionName}列表")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
@GetMapping("/list")
#if($table.crud || $table.sub)
@ -57,11 +61,12 @@ public class ${ClassName}Controller extends BaseController {
/**
* 导出${functionName}列表
*/
@ApiOperation("导出${functionName}列表")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ${ClassName} ${className}) {
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
List<${ClassName}> list = ${className}Service.list(${className});
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
util.exportExcel(response, list, "${functionName}数据");
}
@ -69,8 +74,10 @@ public class ${ClassName}Controller extends BaseController {
/**
* 获取${functionName}详细信息
*/
@ApiOperation("获取${functionName}详细信息")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
@GetMapping(value = "/{${pkColumn.javaField}}")
@ApiImplicitParam(name = "${pkColumn.javaField}", value = "${pkColumn.javaField}", required = true, dataType = "${pkColumn.javaType}", paramType = "path", dataTypeClass = ${pkColumn.javaType}.class)
public Result getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
return success(${className}Service.getById(${pkColumn.javaField}));
}
@ -81,6 +88,7 @@ public class ${ClassName}Controller extends BaseController {
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增${functionName}")
public Result add(@RequestBody ${ClassName} ${className}) {
return toAjax(${className}Service.save(${className}));
}
@ -91,6 +99,7 @@ public class ${ClassName}Controller extends BaseController {
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
@PutMapping
@ApiOperation("修改${functionName}")
public Result edit(@RequestBody ${ClassName} ${className}) {
return toAjax(${className}Service.updateById(${className}));
}
@ -101,6 +110,8 @@ public class ${ClassName}Controller extends BaseController {
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
@DeleteMapping("/{${pkColumn.javaField}s}")
@ApiOperation("删除${functionName}")
@ApiImplicitParam(name = "${pkColumn.javaField}", value = "${pkColumn.javaField}", required = true, dataType = "${pkColumn.javaType}", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result remove(@PathVariable List<${pkColumn.javaType}> ${pkColumn.javaField}s) {
return toAjax(${className}Service.removeBatchByIds(${pkColumn.javaField}s));
}

View File

@ -10,8 +10,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import io.swagger.annotations.*;
import com.ruoyi.common.annotation.Excel;
#if($table.crud || $table.sub)
import com.ruoyi.common.core.domain.BaseEntity;
@ -34,9 +33,11 @@ import com.ruoyi.common.core.domain.TreeEntity;
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("${tableName}")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "${ClassName}", description = "${functionName}")
public class ${ClassName} extends ${Entity} {
private static final long serialVersionUID = 1L;
#foreach ($column in $columns)
@ -61,6 +62,7 @@ public class ${ClassName} extends ${Entity} {
#if($column.javaField == $pkColumn.javaField)
@TableId(value = "${pkColumn.javaField}",type = IdType.AUTO)
#end
@ApiModelProperty(name = "${comment}")
private $column.javaType $column.javaField;
#end

View File

@ -2,6 +2,8 @@ package com.ruoyi.book.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -25,8 +27,9 @@ import com.ruoyi.common.core.page.TableDataInfo;
* Controller
*
* @author DongZeLiang
* @date 2023-10-09
* @date 2023-10-10
*/
@Api("书籍信息")
@RestController
@RequestMapping("/book/info")
public class BookInfoController extends BaseController {
@ -36,6 +39,7 @@ public class BookInfoController extends BaseController {
/**
*
*/
@ApiOperation("获取书籍信息列表")
@PreAuthorize("@ss.hasPermi('book:info:list')")
@GetMapping("/list")
public Result<TableDataInfo> list(BookInfo bookInfo) {
@ -47,6 +51,7 @@ public class BookInfoController extends BaseController {
/**
*
*/
@ApiOperation("导出书籍信息列表")
@PreAuthorize("@ss.hasPermi('book:info:export')")
@Log(title = "书籍信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ -59,8 +64,10 @@ public class BookInfoController extends BaseController {
/**
*
*/
@ApiOperation("获取书籍信息详细信息")
@PreAuthorize("@ss.hasPermi('book:info:query')")
@GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result getInfo(@PathVariable("id") Long id) {
return success(bookInfoService.getById(id));
}
@ -71,6 +78,7 @@ public class BookInfoController extends BaseController {
@PreAuthorize("@ss.hasPermi('book:info:add')")
@Log(title = "书籍信息", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增书籍信息")
public Result add(@RequestBody BookInfo bookInfo) {
return toAjax(bookInfoService.save(bookInfo));
}
@ -81,6 +89,7 @@ public class BookInfoController extends BaseController {
@PreAuthorize("@ss.hasPermi('book:info:edit')")
@Log(title = "书籍信息", businessType = BusinessType.UPDATE)
@PutMapping
@ApiOperation("修改书籍信息")
public Result edit(@RequestBody BookInfo bookInfo) {
return toAjax(bookInfoService.updateById(bookInfo));
}
@ -91,6 +100,8 @@ public class BookInfoController extends BaseController {
@PreAuthorize("@ss.hasPermi('book:info:remove')")
@Log(title = "书籍信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@ApiOperation("删除书籍信息")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result remove(@PathVariable List<Long> ids) {
return toAjax(bookInfoService.removeBatchByIds(ids));
}

View File

@ -5,14 +5,12 @@ import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import io.swagger.annotations.*;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
@ -20,7 +18,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* book_info
*
* @author DongZeLiang
* @date 2023-10-08
* @date 2023-10-10
*/
@Data
@SuperBuilder
@ -28,30 +26,24 @@ import com.ruoyi.common.core.domain.BaseEntity;
@AllArgsConstructor
@TableName("book_info")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "UserEntity", description = "用户实体")
@ApiModel(value = "BookInfo", description = "书籍信息")
public class BookInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(name = "${comment}")
private Long id;
/** 名称 */
@Excel(name = "名称")
@ApiModelProperty(name = "名称")
private String name;
/** 价格 */
@Excel(name = "价格")
@ApiModelProperty(name = "价格")
private BigDecimal price;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("price", getPrice())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.toString();
}
}