mirror of https://gitee.com/maxjhandsome/pig
swagger添加heard 配置
This commit is contained in:
parent
6ce9ae2e3f
commit
ed246de2af
|
@ -4,14 +4,20 @@ import io.swagger.annotations.ApiOperation;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.ParameterBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.schema.ModelRef;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.service.Parameter;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2017/12/28
|
||||
|
@ -24,12 +30,22 @@ public class SwaggerConfig {
|
|||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
ParameterBuilder tokenBuilder = new ParameterBuilder();
|
||||
List<Parameter> parameterList = new ArrayList<Parameter>();
|
||||
tokenBuilder.name("Authorization")
|
||||
.defaultValue("去其他请求中获取heard中token参数")
|
||||
.description("令牌")
|
||||
.modelRef(new ModelRef("string"))
|
||||
.parameterType("header")
|
||||
.required(true).build();
|
||||
parameterList.add(tokenBuilder.build());
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
.build()
|
||||
.globalOperationParameters(parameterList);
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
|
|
|
@ -76,8 +76,8 @@ public class UserController extends BaseController {
|
|||
* @param id ID
|
||||
* @return R
|
||||
*/
|
||||
@ApiOperation(value="删除用户", notes="根据ID删除用户")
|
||||
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Integer")
|
||||
@ApiOperation(value = "删除用户", notes = "根据ID删除用户")
|
||||
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "Integer", paramType = "path")
|
||||
@DeleteMapping("/{id}")
|
||||
public R<Boolean> userDel(@PathVariable Integer id) {
|
||||
SysUser sysUser = userService.selectById(id);
|
||||
|
@ -139,13 +139,15 @@ public class UserController extends BaseController {
|
|||
|
||||
/**
|
||||
* 通过OpenId查询
|
||||
*
|
||||
* @param openId openid
|
||||
* @return 对象
|
||||
*/
|
||||
@GetMapping("/findUserByOpenId/{openId}")
|
||||
public UserVo findUserByOpenId(@PathVariable String openId){
|
||||
public UserVo findUserByOpenId(@PathVariable String openId) {
|
||||
return userService.findUserByOpenId(openId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询用户
|
||||
*
|
||||
|
@ -169,7 +171,7 @@ public class UserController extends BaseController {
|
|||
String fileExt = FileUtil.extName(file.getOriginalFilename());
|
||||
Map<String, String> resultMap = new HashMap<>(1);
|
||||
try {
|
||||
StorePath storePath = fastFileStorageClient.uploadFile(file.getBytes(),fileExt);
|
||||
StorePath storePath = fastFileStorageClient.uploadFile(file.getBytes(), fileExt);
|
||||
resultMap.put("filename", fdfsPropertiesConfig.getFileHost() + storePath.getFullPath());
|
||||
} catch (IOException e) {
|
||||
logger.error("文件上传异常", e);
|
||||
|
|
Loading…
Reference in New Issue