feat(biji-houdaun): 实现用户注册、登录、 Markdown 文件和图片上传功能
- 新增用户注册、登录接口及服务实现 - 添加 Markdown 文件创建、更新接口及服务实现 - 实现图片上传、获取接口及服务实现 - 集成 Snowflake ID 生成器 - 添加全局异常处理和统一返回结果封装 - 配置跨域访问和静态资源处理 - 实现基础的 XSS 防护
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.test.bijihoudaun.controller;
|
||||
|
||||
|
||||
import com.test.bijihoudaun.entity.Image;
|
||||
import com.test.bijihoudaun.service.ImageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/images")
|
||||
public class ImageController {
|
||||
|
||||
@Autowired
|
||||
private ImageService imageService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Image> uploadImage(
|
||||
@RequestParam Integer userId,
|
||||
@RequestParam(required = false) Integer markdownId,
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
try {
|
||||
Image image = imageService.uploadImage(userId, markdownId, file);
|
||||
return ResponseEntity.ok(image);
|
||||
} catch (IOException e) {
|
||||
return ResponseEntity.status(500).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user