This commit is contained in:
雷欧(林平凡)
2025-06-16 09:41:43 +08:00
parent 8e8726804b
commit 98204bb9f9

View File

@@ -23,7 +23,7 @@ import java.util.List;
@RequestMapping("/recordOrder")
public class OrderController {
public static String TOKEN = "cc0313";
public static String TOKEN = "dd7f298cc465e7a9791796ae1303a1f6c031a18d4894ecd9e75d44fdb0ef32d80a49e4c5811b98d8ac65d73d22a54083630d5329c7c9de2276317669ecb2e544";
@Autowired
private JDUtil jdUtils;
@Autowired
@@ -35,14 +35,27 @@ public class OrderController {
return TOKEN.equals(token);
}
@RequestMapping("/testToken")
@ResponseBody
public ApiResponse testToken(String token) {
if (!checkToken(token)){
return ApiResponse.unauthorized();
}
return ApiResponse.success();
}
@RequestMapping("/list")
@ResponseBody
public ApiResponse<List<ProductOrder>> list(String token) throws Exception {
public ApiResponse list(String token) throws Exception {
if (!checkToken(token)){
return ApiResponse.unauthorized();
}
try {
List<ProductOrder> all = productOrderRepository.findAll();
return ApiResponse.success(all);
} catch (Exception e) {
return (ApiResponse<List<ProductOrder>>) ApiResponse.error(500, "Server Error: " + e.getMessage());
return ApiResponse.error(500, "Server Error: " + e.getMessage());
}
}