upd
This commit is contained in:
16
.gitignore
vendored
Normal file
16
.gitignore
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
backend/target/
|
||||
backend/.idea/
|
||||
backend/*.iml
|
||||
frontend/node_modules/
|
||||
frontend/dist/
|
||||
frontend/.idea/
|
||||
frontend/.vscode/
|
||||
frontend/*.iml
|
||||
uploads/
|
||||
files/
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
npm-debug.log*
|
||||
*.log
|
||||
*.tmp
|
||||
*.swp
|
||||
33
AGENTS.md
Normal file
33
AGENTS.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Repository Guidelines
|
||||
|
||||
## Project Structure & Module Organization
|
||||
- `backend/`: Spring Boot 2.7 (JDK 8) service. Main code in `backend/src/main/java`, config in `backend/src/main/resources`.
|
||||
- `frontend/`: Vue 2 + Element UI client. Source in `frontend/src`, router in `frontend/src/router`, API wrappers in `frontend/src/api`.
|
||||
- `backend/sql/init.sql`: MySQL schema and seed data.
|
||||
- `uploads/` and `files/`: runtime upload directories (ignored by git).
|
||||
|
||||
## Build, Test, and Development Commands
|
||||
- Backend (from `backend/`):
|
||||
- `mvn spring-boot:run`: start the API server on `localhost:8080`.
|
||||
- Frontend (from `frontend/`):
|
||||
- `npm install`: install dependencies.
|
||||
- `npm run serve`: start dev server on `localhost:8081` with proxy to `/api`.
|
||||
- `npm run build`: build production assets to `frontend/dist`.
|
||||
|
||||
## Coding Style & Naming Conventions
|
||||
- Java: 4-space indentation, PascalCase for classes, camelCase for fields/methods.
|
||||
- Vue/JS: 2-space indentation, camelCase for variables/functions, kebab-case for routes.
|
||||
- No lint/format tooling is configured; keep diffs focused and consistent with existing files.
|
||||
|
||||
## Testing Guidelines
|
||||
- No automated tests are currently configured for backend or frontend.
|
||||
- If you add tests, prefer standard defaults: JUnit for Spring Boot and Jest/Vue Test Utils for Vue.
|
||||
|
||||
## Commit & Pull Request Guidelines
|
||||
- Existing commit messages are short and informal (e.g., `add`, `first commit`).
|
||||
- If you add commits, use concise, present-tense messages (e.g., `add order status tags`).
|
||||
- PRs should include a brief description, relevant screenshots for UI changes, and any setup steps.
|
||||
|
||||
## Configuration & Security Notes
|
||||
- Update DB credentials and upload path in `backend/src/main/resources/application.yml`.
|
||||
- API tokens (e.g., AI service) should be stored in config and not committed to git.
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.flower.common;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/upload")
|
||||
public class UploadController {
|
||||
private final String uploadDir;
|
||||
|
||||
public UploadController(@Value("${app.upload.dir}") String uploadDir) {
|
||||
this.uploadDir = uploadDir;
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ApiResponse<Map<String, String>> upload(@RequestParam("file") MultipartFile file) {
|
||||
String bashPath = "D:\\bs\\flower\\files";
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw new ApiException(400, "请选择文件");
|
||||
}
|
||||
String original = file.getOriginalFilename();
|
||||
String suffix = "";
|
||||
if (original != null && original.contains(".")) {
|
||||
suffix = original.substring(original.lastIndexOf("."));
|
||||
}
|
||||
String filename = UUID.randomUUID().toString().replace("-", "") + suffix;
|
||||
Path dir = Paths.get(uploadDir);
|
||||
try {
|
||||
Files.createDirectories(dir);
|
||||
Path path = dir.resolve(filename);
|
||||
file.transferTo(path.toFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new ApiException(500, "上传失败");
|
||||
}
|
||||
Map<String, String> result = new HashMap<>();
|
||||
result.put("url", "/uploads/" + filename);
|
||||
return ApiResponse.ok(result);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flower.confession;
|
||||
package com.flower.confession;
|
||||
|
||||
import com.flower.common.ApiException;
|
||||
import com.flower.common.ApiResponse;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 8080
|
||||
port: 8088
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
|
||||
11022
frontend/package-lock.json
generated
Normal file
11022
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
4
frontend/src/api/review.js
Normal file
4
frontend/src/api/review.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import http from './http';
|
||||
|
||||
export const createReview = (data) => http.post('/reviews', data);
|
||||
export const listReviewsByProduct = (productId) => http.get(`/reviews/product/${productId}`);
|
||||
@@ -2,11 +2,11 @@ module.exports = {
|
||||
devServer: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8080/',
|
||||
target: 'http://localhost:8088/',
|
||||
changeOrigin: true
|
||||
},
|
||||
'/uploads': {
|
||||
target: 'http://localhost:8080',
|
||||
target: 'http://localhost:8088',
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user