当前位置:网站首页>0701~ holiday summary
0701~ holiday summary
2022-07-24 17:48:00 【Life is so hard】
Integrated today swagger Stores that automatically generate templates and register functions logo Upload , They are all functions that have been done before ;
swagger Automatically generate steps ;
1. Create a new template class , hold swagger Put the code of the configuration class ;
2. The automatically generated path can be selected ;
1. Create a new template class , hold swagger Put the code of the configuration class ;
package cn.itsource.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @ClassName: Swagger2
* @description: System API Interface document configuration class
* @author ${author}
* @since ${date}
* @Version 1.1.0.1
*/
@Configuration
@EnableSwagger2
public class Swagger2 {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
// Package of external exposure Services , With controller The way to expose , So is controller My bag .
.apis(RequestHandlerSelectors.basePackage("cn.itsource.controller"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title(" system service API")
.description(" Platform service interface document description ")
.contact(new Contact("colin", "", "[email protected]"))
.version("1.0")
.build();
}
}2. The automatically generated path can be selected ;
//swagger Output configuration for
focList.add(new FileOutConfig("/templates/swagger2.java.vm") {
@Override
public String outputFile(TableInfo tableInfo) {
// Where to output the merged content ?
return rb.getString("OutputDir")+ "/cn/itsource/config/swagger2.java";
}
});Alibaba cloud oss Upload steps ;
1. Refer to the official website for the back-end code , Remove the formwork and use ;
2. Remember to give the front end name; When connecting parameters at the back end, use name The value of ;
3. Splicing parameters after the completion of back-end business , Return the path to the front-end display ;
1. Refer to the official website for the back-end code , Remove the formwork and use ;
@Override
public JSONResult getFileOss(MultipartFile file) {
// File upload interface ( Upload to OSS Medium bucket)
// Endpoint: Regional nodes
String endpoint = "oss-cn-chengdu.aliyuncs.com";
// Alicloud account AccessKey Have all the API Access rights of , The risk is high . It is highly recommended that you create and use it RAM The user carries out API Visit or daily operations , Please log in RAM Console creation RAM user .
String accessKeyId = " Fill in here id";
String accessKeySecret = " Fill in the key here ";
// Fill in Bucket name , for example examplebucket.
String bucketName = "0217blog";
// Get the suffix of the uploaded file
String originalFilename = file.getOriginalFilename();//.jpg.jng
int i = originalFilename.lastIndexOf(".");
String fileType = originalFilename.substring(i);
// Fill in Object The full path , The full path cannot contain Bucket name , for example exampledir/exampleobject.txt.
//
String fileName = UUID.randomUUID().toString().replace("-", "") + fileType;
// establish OSSClient example .
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
try {
InputStream inputStream = file.getInputStream();
// establish PutObject request .
ossClient.putObject(bucketName, fileName, inputStream);
} catch (OSSException oe) {
System.out.println("Caught an OSSException, which means your request made it to OSS, "
+ "but was rejected with an error response for some reason.");
System.out.println("Error Message:" + oe.getErrorMessage());
System.out.println("Error Code:" + oe.getErrorCode());
System.out.println("Request ID:" + oe.getRequestId());
System.out.println("Host ID:" + oe.getHostId());
} catch (Exception ce) {
System.out.println(" Upload files OSS abnormal :" + ce.getMessage());
return JSONResult.error(ce.getMessage());
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}
// Splicing URL The address is returned to the front end
//https://blog0217.oss-cn-chengdu.aliyuncs.com/77786f3d6f31445bad462e5464085de8.jpg
String url = "https://" + bucketName + "." + endpoint + "/" + fileName;
return JSONResult.success(url);2. Remember to give the front end name; When connecting parameters at the back end, use name The value of ;
@RequestMapping("/file") public JSONResult fileOss(@RequestParam("fileName") MultipartFile file){ return iFileService.getFileOss(file); }<el-upload class="upload-demo" action="http://localhost:1020/hrm/file/file/file" name="fileName" :on-preview="handlePreview" :on-remove="handleRemove" :on-success="handleSuccess" :file-list="fileList" list-type="picture"> <el-button size="small" type="primary"> Click upload </el-button> <div slot="tip" class="el-upload__tip"> Can only upload jpg/png file , And no more than 500kb</div> </el-upload>there name Keep consistent with the receiving parameters of the back-end interface ;
3. Splicing parameters after the completion of back-end business , Return the path to the front-end display ;
// Splicing URL The address is returned to the front end //https://blog0217.oss-cn-chengdu.aliyuncs.com/77786f3d6f31445bad462e5464085de8.jpg
String url = "https://" + bucketName + "." + endpoint + "/" + fileName;
return JSONResult.success(url);
边栏推荐
- Use 4D nerf to display occlusion (cvpr2022)
- es(1)
- Definition and storage of adjacency table and adjacency storage of directed graph and undirected graph
- 使用matplotlib模拟线性回归
- Tensorflow introductory tutorial (38) -- V2 net
- Array double pointer - deliberate practice
- NPM install reported -4058 error
- 0611~自习课
- Tensorflow introductory tutorial (40) -- acunet
- Section 7 Data Dictionary: hash followed by Daewoo redis ------- directory post
猜你喜欢

Review and analysis of noodle dishes

二维卷积——torch.nn.conv2d的使用

实习报告1——人脸三维重建方法

Practical application cases of digital Twins - Smart Park

C语言编程训练题目:左旋字符串中的k个字符、小乐乐与欧几里得、打印箭型图案、公务员面试、杨树矩阵

Getaverse,走向Web3的远方桥梁

Two dimensional convolution -- use of torch.nn.conv2d

Tensorflow introductory tutorial (37) -- DC Vnet

Internship report 1 - face 3D reconstruction method

2022 Asia International Internet of things exhibition
随机推荐
Detailed explanation of ansible automatic operation and maintenance (V) the setting and use of variables in ansible, the use of jinja2 template and the encryption control of ansible
Internship report 1 - face 3D reconstruction method
Class bytecode file
Codeforces Round #794 (Div. 2)(A.B.C)
Js实现继承的六种方式
Are the top ten securities companies safe and risky to open accounts?
SSM framework learning
[waiting for insurance] what does waiting for insurance rectification mean? What are the rectification contents?
How the computer accesses the Internet (IV) LAN and server response
Tensorflow introductory tutorial (40) -- acunet
The ability to detect movement in vivo and build a safe and reliable payment level "face brushing" experience
仅需一个依赖给Swagger换上新皮肤,既简单又炫酷!
Fast power writing
0612~quartz定时器框架
0613~自习
A problem of MySQL database
Shengxin commonly used analysis graphics drawing 02 -- unlock the essence of volcano map!
es(1)
Can Lu Zhengyao hide from the live broadcast room dominated by Luo min?
Step by step introduction to the development framework based on sqlsugar (12) -- split the content of the page module into components to realize the division and rule processing