refactor(music-houduan): 移除基本测试控制器并优化 Web MVC 配置

- 删除了 BasicTestController 类,不再提供基本测试接口
- 优化了 WebMvcConfig 配置类:
  - 移除了不必要的属性注入
  - 简化了资源处理器的配置,直接使用固定的 "/upload/**" 路
This commit is contained in:
ikmkj
2025-07-23 21:36:54 +08:00
parent 2215aab64e
commit 3899b79470
4 changed files with 4 additions and 38 deletions

View File

@@ -5,24 +5,19 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.nio.file.Paths;
/**
* Web MVC 配置
*/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Value("${file.upload-path}")
private String uploadPath;
@Value("${file.access-path}")
private String accessPath;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// 配置上传文件资源映射
registry.addResourceHandler(accessPath + "**")
.addResourceLocations("file:" + uploadPath);
// 注意:前后端分离项目,不需要配置静态资源映射
registry.addResourceHandler("/upload/**") // 处理这个路径的请求
.addResourceLocations("file:" + uploadPath + "/"); // 文件路径,映射到本地文件系统
}
}

View File

@@ -1,29 +0,0 @@
package com.test.musichouduan.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* 基本测试控制器
*/
@RestController
@RequestMapping("/basic-test")
public class BasicTestController {
/**
* 基本测试接口
*/
@GetMapping
public Map<String, Object> test() {
Map<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("message", "基本测试成功");
result.put("data", "Hello, Basic Test!");
result.put("time", System.currentTimeMillis());
return result;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB