This commit is contained in:
20932067@zju.edu.cn 2021-01-24 15:48:40 +08:00
parent 82dbe02fee
commit 6a8ec484f2
10 changed files with 80 additions and 16 deletions

View File

@ -56,11 +56,11 @@ public class SwaggerConfig
// 设置哪些接口暴露给Swagger展示 // 设置哪些接口暴露给Swagger展示
.select() .select()
// 扫描所有有注解的api用这种方式更灵活 // 扫描所有有注解的api用这种方式更灵活
// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
// 扫描指定包中的swagger注解 // 扫描指定包中的swagger注解
// .apis(RequestHandlerSelectors.basePackage("com.hchyun.project.tool.swagger")) // .apis(RequestHandlerSelectors.basePackage("com.hchyun.project.tool.swagger"))
// 扫描所有 // 扫描所有
.apis(RequestHandlerSelectors.any()) //.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()) .paths(PathSelectors.any())
.build() .build()
/* 设置安全模式swagger可以设置访问token */ /* 设置安全模式swagger可以设置访问token */

View File

@ -107,7 +107,7 @@ swagger:
# 是否开启swagger # 是否开启swagger
enabled: true enabled: true
# 请求前缀 # 请求前缀
pathMapping: /dev-api pathMapping: /
# 防止XSS攻击 # 防止XSS攻击
xss: xss:

View File

@ -118,6 +118,30 @@
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>
</dependency> </dependency>
<!-- swagger2-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<!--防止进入swagger页面报类型转换错误排除2.9.2中的引用手动增加1.5.21版本-->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.21</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.21</version>
</dependency>
<!-- swagger2-UI-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
</dependencies> </dependencies>

View File

@ -8,6 +8,9 @@ import java.util.regex.Pattern;
import com.hchyun.common.constant.ReturnConstants; import com.hchyun.common.constant.ReturnConstants;
import com.hchyun.common.core.controller.HcyBaseController; import com.hchyun.common.core.controller.HcyBaseController;
import com.hchyun.common.utils.ServerResult; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -37,6 +40,7 @@ import com.hchyun.common.core.page.TableDataInfo;
* @author ${author} * @author ${author}
* @date ${datetime} * @date ${datetime}
*/ */
@Api(value = "${functionName}管理",tags = "${functionName}管理")
@RestController @RestController
@RequestMapping("/${moduleName}/${businessName}") @RequestMapping("/${moduleName}/${businessName}")
public class ${ClassName}Controller extends HcyBaseController { public class ${ClassName}Controller extends HcyBaseController {
@ -48,6 +52,7 @@ public class ${ClassName}Controller extends HcyBaseController {
/** /**
* 查询${functionName}列表 * 查询${functionName}列表
*/ */
@ApiOperation("查询${functionName}列表")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
@GetMapping("/list") @GetMapping("/list")
#if($table.crud || $table.sub) #if($table.crud || $table.sub)
@ -76,6 +81,7 @@ public class ${ClassName}Controller extends HcyBaseController {
/** /**
* 导出${functionName}列表 * 导出${functionName}列表
*/ */
@ApiOperation("导出${functionName}列表")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
@Log(title = "${functionName}", businessType = BusinessType.EXPORT) @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
@GetMapping("/export") @GetMapping("/export")
@ -97,6 +103,8 @@ public class ${ClassName}Controller extends HcyBaseController {
/** /**
* 获取${functionName}详细信息 * 获取${functionName}详细信息
*/ */
@ApiOperation("获取${functionName}详细信息")
@ApiImplicitParam(name = "${pkColumn.javaField}" , value = "${functionName}${pkColumn.javaField}" , required = true, dataType = "${pkColumn.javaType}" , paramType = "path")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
@GetMapping(value = "/{${pkColumn.javaField}}") @GetMapping(value = "/{${pkColumn.javaField}}")
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) { public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
@ -116,6 +124,8 @@ public class ${ClassName}Controller extends HcyBaseController {
/** /**
* 新增${functionName} * 新增${functionName}
*/ */
@ApiOperation("新增${functionName}")
@ApiImplicitParam(name = "${className}" , value = "新增${functionName}信息" , dataType = "${ClassName}")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
@Log(title = "${functionName}", businessType = BusinessType.INSERT) @Log(title = "${functionName}", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
@ -157,6 +167,8 @@ public class ${ClassName}Controller extends HcyBaseController {
/** /**
* 修改${functionName} * 修改${functionName}
*/ */
@ApiOperation("修改${functionName}")
@ApiImplicitParam(name = "${className}" , value = "修改${functionName}信息" , dataType = "${ClassName}")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
@Log(title = "${functionName}", businessType = BusinessType.UPDATE) @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
@ -199,6 +211,8 @@ public class ${ClassName}Controller extends HcyBaseController {
/** /**
* 删除${functionName} * 删除${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')") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
@Log(title = "${functionName}", businessType = BusinessType.DELETE) @Log(title = "${functionName}", businessType = BusinessType.DELETE)
@DeleteMapping("/{${pkColumn.javaField}s}") @DeleteMapping("/{${pkColumn.javaField}s}")

View File

@ -10,6 +10,8 @@ import com.hchyun.common.annotation.Excel;
#set($Entity="TreeEntity") #set($Entity="TreeEntity")
#end #end
import com.hchyun.common.core.entity.${Entity}; 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.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
#if($table.crud || $table.sub) #if($table.crud || $table.sub)
@ -27,6 +29,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
#elseif($table.tree) #elseif($table.tree)
#set($Entity="TreeEntity") #set($Entity="TreeEntity")
#end #end
@ApiModel("${functionName}")
public class ${ClassName} extends ${Entity} public class ${ClassName} extends ${Entity}
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -50,12 +53,14 @@ public class ${ClassName} extends ${Entity}
@Excel(name = "${comment}") @Excel(name = "${comment}")
#end #end
#end #end
@ApiModelProperty("${column.columnComment}")
private $column.javaType $column.javaField; private $column.javaType $column.javaField;
#end #end
#end #end
#if($table.sub) #if($table.sub)
/** $table.subTable.functionName信息 */ /** $table.subTable.functionName信息 */
@ApiModelProperty("${table.subTable.functionName}信息")
private List<${subClassName}> ${subclassName}List; private List<${subClassName}> ${subclassName}List;
#end #end

View File

@ -8,6 +8,9 @@ import java.util.regex.Pattern;
import com.hchyun.common.constant.ReturnConstants; import com.hchyun.common.constant.ReturnConstants;
import com.hchyun.common.core.controller.HcyBaseController; import com.hchyun.common.core.controller.HcyBaseController;
import com.hchyun.common.utils.ServerResult; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize; 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.entity.Results;
import com.hchyun.test.service.ResultsService; import com.hchyun.test.service.ResultsService;
import com.hchyun.common.utils.poi.ExcelUtil; import com.hchyun.common.utils.poi.ExcelUtil;
import com.hchyun.common.core.page.TableDataInfo;
/** /**
* 成绩Controller * 成绩Controller
* *
* @author hchyun * @author hchyun
* @date 2021-01-23 * @date 2021-01-24
*/ */
@Api(value = "成绩管理",tags = "成绩管理")
@RestController @RestController
@RequestMapping("/test/results") @RequestMapping("/test/results")
public class ResultsController extends HcyBaseController { public class ResultsController extends HcyBaseController {
@ -45,6 +48,7 @@ public class ResultsController extends HcyBaseController {
/** /**
* 查询成绩列表 * 查询成绩列表
*/ */
@ApiOperation("查询成绩列表")
@PreAuthorize("@ss.hasPermi('test:results:list')") @PreAuthorize("@ss.hasPermi('test:results:list')")
@GetMapping("/list") @GetMapping("/list")
public Serializable list(Results results) { public Serializable list(Results results) {
@ -65,6 +69,7 @@ public class ResultsController extends HcyBaseController {
/** /**
* 导出成绩列表 * 导出成绩列表
*/ */
@ApiOperation("导出成绩列表")
@PreAuthorize("@ss.hasPermi('test:results:export')") @PreAuthorize("@ss.hasPermi('test:results:export')")
@Log(title = "成绩", businessType = BusinessType.EXPORT) @Log(title = "成绩", businessType = BusinessType.EXPORT)
@GetMapping("/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')") @PreAuthorize("@ss.hasPermi('test:results:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long 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')") @PreAuthorize("@ss.hasPermi('test:results:add')")
@Log(title = "成绩", businessType = BusinessType.INSERT) @Log(title = "成绩", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
@ -134,6 +143,8 @@ public class ResultsController extends HcyBaseController {
/** /**
* 修改成绩 * 修改成绩
*/ */
@ApiOperation("修改成绩")
@ApiImplicitParam(name = "results" , value = "修改成绩信息" , dataType = "Results")
@PreAuthorize("@ss.hasPermi('test:results:edit')") @PreAuthorize("@ss.hasPermi('test:results:edit')")
@Log(title = "成绩", businessType = BusinessType.UPDATE) @Log(title = "成绩", businessType = BusinessType.UPDATE)
@PutMapping @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')") @PreAuthorize("@ss.hasPermi('test:results:remove')")
@Log(title = "成绩", businessType = BusinessType.DELETE) @Log(title = "成绩", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")

View File

@ -7,7 +7,7 @@ import com.hchyun.test.entity.Results;
* 成绩Mapper接口 * 成绩Mapper接口
* *
* @author hchyun * @author hchyun
* @date 2021-01-23 * @date 2021-01-24
*/ */
public interface ResultsDao public interface ResultsDao
{ {

View File

@ -2,6 +2,8 @@ package com.hchyun.test.entity;
import com.hchyun.common.annotation.Excel; import com.hchyun.common.annotation.Excel;
import com.hchyun.common.core.entity.BaseEntity; 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.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
@ -9,29 +11,35 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* 成绩对象 sys_results * 成绩对象 sys_results
* *
* @author hchyun * @author hchyun
* @date 2021-01-23 * @date 2021-01-24
*/ */
@ApiModel("成绩")
public class Results extends BaseEntity public class Results extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** id */ /** id */
@ApiModelProperty("id")
private Long id; private Long id;
/** 学生id */ /** 学生id */
@Excel(name = "学生id") @Excel(name = "学生id")
@ApiModelProperty("学生id")
private Long sId; private Long sId;
/** java成绩 */ /** java成绩 */
@Excel(name = "java成绩") @Excel(name = "java成绩")
@ApiModelProperty("java成绩")
private Long java; private Long java;
/** 图片路径 */ /** 图片路径 */
@Excel(name = "图片路径") @Excel(name = "图片路径")
@ApiModelProperty("图片路径")
private String images; private String images;
/** 文件路径 */ /** 文件路径 */
@Excel(name = "文件路径") @Excel(name = "文件路径")
@ApiModelProperty("文件路径")
private String file; private String file;
public void setId(Long id) public void setId(Long id)
@ -43,16 +51,16 @@ public class Results extends BaseEntity
{ {
return id; return id;
} }
public void setsId(Long sId)
public Long getsId() { {
return sId;
}
public void setsId(Long sId) {
this.sId = sId; this.sId = sId;
} }
public void setJava(Long java) public Long getsId()
{
return sId;
}
public void setJava(Long java)
{ {
this.java = java; this.java = java;
} }

View File

@ -9,7 +9,7 @@ import com.hchyun.test.entity.Results;
* 成绩Service接口 * 成绩Service接口
* *
* @author hchyun * @author hchyun
* @date 2021-01-23 * @date 2021-01-24
*/ */
public interface ResultsService public interface ResultsService
{ {

View File

@ -16,7 +16,7 @@ import com.hchyun.test.service.ResultsService;
* 成绩Service业务层处理 * 成绩Service业务层处理
* *
* @author hchyun * @author hchyun
* @date 2021-01-23 * @date 2021-01-24
*/ */
@Service @Service
public class ResultsServiceImpl implements ResultsService { public class ResultsServiceImpl implements ResultsService {