Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e12331e61 | ||
|
|
7e7332694e | ||
|
|
8db690a55f |
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -9,7 +9,8 @@
|
||||
### 2. 拉取项目到本地
|
||||
``` shell script
|
||||
git clone https://github.com/xiaohai2271/blog-backEnd.git
|
||||
或 git clone git@github.com:xiaohai2271/blog-backEnd.git
|
||||
# 或
|
||||
git clone git@github.com:xiaohai2271/blog-backEnd.git
|
||||
```
|
||||
|
||||
### 3. maven构建
|
||||
@@ -26,7 +27,7 @@ java -jar target/blog-0.0.1-SNAPSHOT.jar
|
||||
```shell script
|
||||
mvn clean # 清理项目资源
|
||||
mvn clean package # 清理项目资源并重新打包
|
||||
mvn clean package -DskipTest # 清理项目资源,重新打包并跳过测试
|
||||
mvn clean package -DskipTests # 清理项目资源,重新打包并跳过测试
|
||||
mvn test # 运行测试
|
||||
..... #待添加
|
||||
```
|
||||
@@ -7,6 +7,7 @@ import cn.celess.blog.exception.MyException;
|
||||
import cn.celess.blog.service.CountService;
|
||||
import cn.celess.blog.service.QiniuService;
|
||||
import cn.celess.blog.util.HttpUtil;
|
||||
import cn.celess.blog.util.RedisUserUtil;
|
||||
import cn.celess.blog.util.RedisUtil;
|
||||
import cn.celess.blog.util.VeriCodeUtil;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -27,9 +28,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@@ -47,7 +46,7 @@ public class CommonController {
|
||||
@Autowired
|
||||
RedisUtil redisUtil;
|
||||
@Autowired
|
||||
HttpServletRequest request;
|
||||
RedisUserUtil redisUserUtil;
|
||||
|
||||
|
||||
@GetMapping("/counts")
|
||||
@@ -89,7 +88,7 @@ public class CommonController {
|
||||
* @throws IOException IOException
|
||||
*/
|
||||
@GetMapping(value = "/imgCode", produces = MediaType.IMAGE_PNG_VALUE)
|
||||
public void getImg(HttpServletResponse response) throws IOException {
|
||||
public void getImg(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
Object[] obj = VeriCodeUtil.createImage();
|
||||
request.getSession().setAttribute("code", obj[0]);
|
||||
//将图片输出给浏览器
|
||||
@@ -133,9 +132,10 @@ public class CommonController {
|
||||
* FIXME :: 单张图片多次上传的问题
|
||||
* editor.md图片上传的接口
|
||||
* FUCK !!!
|
||||
*
|
||||
* !! 推荐使用 fileUpload(/fileUpload) 接口
|
||||
* @param file 文件
|
||||
*/
|
||||
@Deprecated
|
||||
@PostMapping("/imgUpload")
|
||||
public void upload(HttpServletRequest request, HttpServletResponse response, @RequestParam("editormd-image-file") MultipartFile file) throws IOException {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
@@ -186,4 +186,37 @@ public class CommonController {
|
||||
JsonNode images = root.get("images").elements().next();
|
||||
return Response.success("https://cn.bing.com" + images.get("url").asText());
|
||||
}
|
||||
|
||||
@PostMapping("/fileUpload")
|
||||
public Response<List<Map<String, Object>>> fileUpload(@RequestParam("file[]") MultipartFile[] files) throws IOException {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
String uploadTimesStr = redisUtil.get(redisUserUtil.get().getEmail() + "-fileUploadTimes");
|
||||
int uploadTimes = 0;
|
||||
if (uploadTimesStr != null) {
|
||||
uploadTimes = Integer.parseInt(uploadTimesStr);
|
||||
}
|
||||
if (uploadTimes == 10) {
|
||||
throw new MyException(ResponseEnum.FAILURE.getCode(), "上传次数已达10次,请2小时后在上传");
|
||||
}
|
||||
if (files.length == 0) {
|
||||
throw new MyException(ResponseEnum.NO_FILE);
|
||||
}
|
||||
for (MultipartFile file : files) {
|
||||
Map<String, Object> resp = new HashMap<>(4);
|
||||
|
||||
String fileName = file.getOriginalFilename();
|
||||
assert fileName != null;
|
||||
String mime = fileName.substring(fileName.lastIndexOf("."));
|
||||
String name = fileName.replace(mime, "").replaceAll(" ", "");
|
||||
QiniuResponse qiniuResponse = qiniuService.uploadFile(file.getInputStream(), "file_" + name + '_' + System.currentTimeMillis() + mime);
|
||||
resp.put("originalFilename", fileName);
|
||||
resp.put("success", qiniuResponse != null);
|
||||
if (qiniuResponse != null) {
|
||||
resp.put("host", "http://cdn.celess.cn/");
|
||||
resp.put("path", qiniuResponse.key);
|
||||
}
|
||||
result.add(resp);
|
||||
}
|
||||
return Response.success(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@ public enum ResponseEnum {
|
||||
APPLY_LINK_NO_ADD_THIS_SITE(7200, "暂未在您的网站中抓取到本站链接"),
|
||||
DATA_EXPIRED(7300, "数据过期"),
|
||||
CANNOT_GET_DATA(7400, "暂无法获取到数据"),
|
||||
NO_FILE(7500, "未选择文件,请重新选择"),
|
||||
|
||||
|
||||
//提交更新之前,没有获取数据/,
|
||||
DID_NOT_GET_THE_DATA(8020, "非法访问"),
|
||||
|
||||
@@ -32,8 +32,8 @@ public class Response<T> implements Serializable {
|
||||
* @param result 结果
|
||||
* @return Response
|
||||
*/
|
||||
public static Response success(Object result) {
|
||||
return new Response(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), result);
|
||||
public static <T> Response<T> success(T result) {
|
||||
return new Response<T>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getMsg(), result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,8 +42,8 @@ public class Response<T> implements Serializable {
|
||||
* @param result 结果
|
||||
* @return Response
|
||||
*/
|
||||
public static Response failure(String result) {
|
||||
return new Response(ResponseEnum.FAILURE.getCode(), ResponseEnum.FAILURE.getMsg(), result);
|
||||
public static Response<String> failure(String result) {
|
||||
return new Response<String>(ResponseEnum.FAILURE.getCode(), ResponseEnum.FAILURE.getMsg(), result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,8 +53,8 @@ public class Response<T> implements Serializable {
|
||||
* @param result 结果
|
||||
* @return Response
|
||||
*/
|
||||
public static Response response(ResponseEnum r, String result) {
|
||||
return new Response(r.getCode(), r.getMsg(), result);
|
||||
public static <T> Response<T> response(ResponseEnum r, T result) {
|
||||
return new Response<T>(r.getCode(), r.getMsg(), result);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
|
||||
Reference in New Issue
Block a user