diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/core/config/SwaggerConfig.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/core/config/SwaggerConfig.java index 3573ecf..866a038 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/core/config/SwaggerConfig.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/core/config/SwaggerConfig.java @@ -56,11 +56,11 @@ public class SwaggerConfig // 设置哪些接口暴露给Swagger展示 .select() // 扫描所有有注解的api,用这种方式更灵活 -// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) // 扫描指定包中的swagger注解 // .apis(RequestHandlerSelectors.basePackage("com.hchyun.project.tool.swagger")) // 扫描所有 - .apis(RequestHandlerSelectors.any()) + //.apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build() /* 设置安全模式,swagger可以设置访问token */ diff --git a/hchyun/hchyun-admin/src/main/resources/application.yml b/hchyun/hchyun-admin/src/main/resources/application.yml index c245e2a..15ce3df 100644 --- a/hchyun/hchyun-admin/src/main/resources/application.yml +++ b/hchyun/hchyun-admin/src/main/resources/application.yml @@ -107,7 +107,7 @@ swagger: # 是否开启swagger enabled: true # 请求前缀 - pathMapping: /dev-api + pathMapping: / # 防止XSS攻击 xss: diff --git a/hchyun/hchyun-common/pom.xml b/hchyun/hchyun-common/pom.xml index 058689c..e3d4f38 100644 --- a/hchyun/hchyun-common/pom.xml +++ b/hchyun/hchyun-common/pom.xml @@ -118,6 +118,30 @@ javax.servlet javax.servlet-api + + + io.springfox + springfox-swagger2 + + + + + io.swagger + swagger-annotations + 1.5.21 + + + + io.swagger + swagger-models + 1.5.21 + + + + + io.springfox + springfox-swagger-ui + diff --git a/hchyun/hchyun-generator/src/main/resources/vm/java/controller.java.vm b/hchyun/hchyun-generator/src/main/resources/vm/java/controller.java.vm index 364b51f..dda8687 100644 --- a/hchyun/hchyun-generator/src/main/resources/vm/java/controller.java.vm +++ b/hchyun/hchyun-generator/src/main/resources/vm/java/controller.java.vm @@ -8,6 +8,9 @@ import java.util.regex.Pattern; import com.hchyun.common.constant.ReturnConstants; import com.hchyun.common.core.controller.HcyBaseController; import com.hchyun.common.utils.ServerResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.access.prepost.PreAuthorize; @@ -37,6 +40,7 @@ import com.hchyun.common.core.page.TableDataInfo; * @author ${author} * @date ${datetime} */ +@Api(value = "${functionName}管理",tags = "${functionName}管理") @RestController @RequestMapping("/${moduleName}/${businessName}") public class ${ClassName}Controller extends HcyBaseController { @@ -48,6 +52,7 @@ public class ${ClassName}Controller extends HcyBaseController { /** * 查询${functionName}列表 */ + @ApiOperation("查询${functionName}列表") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") @GetMapping("/list") #if($table.crud || $table.sub) @@ -76,6 +81,7 @@ public class ${ClassName}Controller extends HcyBaseController { /** * 导出${functionName}列表 */ + @ApiOperation("导出${functionName}列表") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") @Log(title = "${functionName}", businessType = BusinessType.EXPORT) @GetMapping("/export") @@ -97,6 +103,8 @@ public class ${ClassName}Controller extends HcyBaseController { /** * 获取${functionName}详细信息 */ + @ApiOperation("获取${functionName}详细信息") + @ApiImplicitParam(name = "${pkColumn.javaField}" , value = "${functionName}${pkColumn.javaField}" , required = true, dataType = "${pkColumn.javaType}" , paramType = "path") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") @GetMapping(value = "/{${pkColumn.javaField}}") public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) { @@ -116,6 +124,8 @@ public class ${ClassName}Controller extends HcyBaseController { /** * 新增${functionName} */ + @ApiOperation("新增${functionName}") + @ApiImplicitParam(name = "${className}" , value = "新增${functionName}信息" , dataType = "${ClassName}") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") @Log(title = "${functionName}", businessType = BusinessType.INSERT) @PostMapping @@ -157,6 +167,8 @@ public class ${ClassName}Controller extends HcyBaseController { /** * 修改${functionName} */ + @ApiOperation("修改${functionName}") + @ApiImplicitParam(name = "${className}" , value = "修改${functionName}信息" , dataType = "${ClassName}") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") @Log(title = "${functionName}", businessType = BusinessType.UPDATE) @PutMapping @@ -199,6 +211,8 @@ public class ${ClassName}Controller extends HcyBaseController { /** * 删除${functionName} */ + @ApiOperation("删除${functionName}") + @ApiImplicitParam(name = "${pkColumn.javaField}s" , value = "${functionName}${pkColumn.javaField}s" , required = true, dataType = "${pkColumn.javaType}" , paramType = "path") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')") @Log(title = "${functionName}", businessType = BusinessType.DELETE) @DeleteMapping("/{${pkColumn.javaField}s}") diff --git a/hchyun/hchyun-generator/src/main/resources/vm/java/entity.java.vm b/hchyun/hchyun-generator/src/main/resources/vm/java/entity.java.vm index 5f2db81..e517e43 100644 --- a/hchyun/hchyun-generator/src/main/resources/vm/java/entity.java.vm +++ b/hchyun/hchyun-generator/src/main/resources/vm/java/entity.java.vm @@ -10,6 +10,8 @@ import com.hchyun.common.annotation.Excel; #set($Entity="TreeEntity") #end import com.hchyun.common.core.entity.${Entity}; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; #if($table.crud || $table.sub) @@ -27,6 +29,7 @@ import org.apache.commons.lang3.builder.ToStringStyle; #elseif($table.tree) #set($Entity="TreeEntity") #end +@ApiModel("${functionName}") public class ${ClassName} extends ${Entity} { private static final long serialVersionUID = 1L; @@ -50,12 +53,14 @@ public class ${ClassName} extends ${Entity} @Excel(name = "${comment}") #end #end + @ApiModelProperty("${column.columnComment}") private $column.javaType $column.javaField; #end #end #if($table.sub) /** $table.subTable.functionName信息 */ + @ApiModelProperty("${table.subTable.functionName}信息") private List<${subClassName}> ${subclassName}List; #end diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/ResultsController.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/ResultsController.java index ed02fe5..a6d5861 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/ResultsController.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/ResultsController.java @@ -8,6 +8,9 @@ import java.util.regex.Pattern; import com.hchyun.common.constant.ReturnConstants; import com.hchyun.common.core.controller.HcyBaseController; import com.hchyun.common.utils.ServerResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.access.prepost.PreAuthorize; @@ -26,14 +29,14 @@ import com.hchyun.common.enums.BusinessType; import com.hchyun.test.entity.Results; import com.hchyun.test.service.ResultsService; import com.hchyun.common.utils.poi.ExcelUtil; -import com.hchyun.common.core.page.TableDataInfo; /** * 成绩Controller * * @author hchyun - * @date 2021-01-23 + * @date 2021-01-24 */ +@Api(value = "成绩管理",tags = "成绩管理") @RestController @RequestMapping("/test/results") public class ResultsController extends HcyBaseController { @@ -45,6 +48,7 @@ public class ResultsController extends HcyBaseController { /** * 查询成绩列表 */ + @ApiOperation("查询成绩列表") @PreAuthorize("@ss.hasPermi('test:results:list')") @GetMapping("/list") public Serializable list(Results results) { @@ -65,6 +69,7 @@ public class ResultsController extends HcyBaseController { /** * 导出成绩列表 */ + @ApiOperation("导出成绩列表") @PreAuthorize("@ss.hasPermi('test:results:export')") @Log(title = "成绩", businessType = BusinessType.EXPORT) @GetMapping("/export") @@ -86,6 +91,8 @@ public class ResultsController extends HcyBaseController { /** * 获取成绩详细信息 */ + @ApiOperation("获取成绩详细信息") + @ApiImplicitParam(name = "id" , value = "成绩id" , required = true, dataType = "Long" , paramType = "path") @PreAuthorize("@ss.hasPermi('test:results:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { @@ -105,6 +112,8 @@ public class ResultsController extends HcyBaseController { /** * 新增成绩 */ + @ApiOperation("新增成绩") + @ApiImplicitParam(name = "results" , value = "新增成绩信息" , dataType = "Results") @PreAuthorize("@ss.hasPermi('test:results:add')") @Log(title = "成绩", businessType = BusinessType.INSERT) @PostMapping @@ -134,6 +143,8 @@ public class ResultsController extends HcyBaseController { /** * 修改成绩 */ + @ApiOperation("修改成绩") + @ApiImplicitParam(name = "results" , value = "修改成绩信息" , dataType = "Results") @PreAuthorize("@ss.hasPermi('test:results:edit')") @Log(title = "成绩", businessType = BusinessType.UPDATE) @PutMapping @@ -164,6 +175,8 @@ public class ResultsController extends HcyBaseController { /** * 删除成绩 */ + @ApiOperation("删除成绩") + @ApiImplicitParam(name = "ids" , value = "成绩ids" , required = true, dataType = "Long" , paramType = "path") @PreAuthorize("@ss.hasPermi('test:results:remove')") @Log(title = "成绩", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/ResultsDao.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/ResultsDao.java index b1f9726..3abb0c4 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/ResultsDao.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/ResultsDao.java @@ -7,7 +7,7 @@ import com.hchyun.test.entity.Results; * 成绩Mapper接口 * * @author hchyun - * @date 2021-01-23 + * @date 2021-01-24 */ public interface ResultsDao { diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/Results.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/Results.java index c971385..7ed20c4 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/Results.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/Results.java @@ -2,6 +2,8 @@ package com.hchyun.test.entity; import com.hchyun.common.annotation.Excel; import com.hchyun.common.core.entity.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -9,29 +11,35 @@ import org.apache.commons.lang3.builder.ToStringStyle; * 成绩对象 sys_results * * @author hchyun - * @date 2021-01-23 + * @date 2021-01-24 */ +@ApiModel("成绩") public class Results extends BaseEntity { private static final long serialVersionUID = 1L; /** id */ + @ApiModelProperty("id") private Long id; /** 学生id */ @Excel(name = "学生id") + @ApiModelProperty("学生id") private Long sId; /** java成绩 */ @Excel(name = "java成绩") + @ApiModelProperty("java成绩") private Long java; /** 图片路径 */ @Excel(name = "图片路径") + @ApiModelProperty("图片路径") private String images; /** 文件路径 */ @Excel(name = "文件路径") + @ApiModelProperty("文件路径") private String file; public void setId(Long id) @@ -43,16 +51,16 @@ public class Results extends BaseEntity { return id; } - - public Long getsId() { - return sId; - } - - public void setsId(Long sId) { + public void setsId(Long sId) + { this.sId = sId; } - public void setJava(Long java) + public Long getsId() + { + return sId; + } + public void setJava(Long java) { this.java = java; } diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/ResultsService.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/ResultsService.java index 6e1a69b..19faa87 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/ResultsService.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/ResultsService.java @@ -9,7 +9,7 @@ import com.hchyun.test.entity.Results; * 成绩Service接口 * * @author hchyun - * @date 2021-01-23 + * @date 2021-01-24 */ public interface ResultsService { diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/ResultsServiceImpl.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/ResultsServiceImpl.java index 7308374..68deaf3 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/ResultsServiceImpl.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/ResultsServiceImpl.java @@ -16,7 +16,7 @@ import com.hchyun.test.service.ResultsService; * 成绩Service业务层处理 * * @author hchyun - * @date 2021-01-23 + * @date 2021-01-24 */ @Service public class ResultsServiceImpl implements ResultsService {