统计美化

This commit is contained in:
Leo
2025-04-01 00:32:22 +08:00
parent 63aa72fea4
commit e9f01b7e5b
6 changed files with 116 additions and 54 deletions

Binary file not shown.

View File

@@ -1,49 +1,50 @@
//package cn.van.business.controller.jd;
//
//import cn.van.business.mq.MessageProducerService;
//import cn.van.business.util.JDUtil;
//import com.alibaba.fastjson2.JSONObject;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
//
///**
// * @author Leo
// * @version 1.0
// * @create 2024/11/7 13:39
// * @description
// */
//@RestController
//@RequestMapping("/order")
//public class OrderController {
//
// public static String TOKEN = "cc0313";
// @Autowired
// private JDUtil jdUtils;
// @Autowired
// private MessageProducerService messageProducerService;
//
// public boolean checkToken(String token) {
// return TOKEN.equals(token);
// }
//
// @RequestMapping("/refreshHistory")
// @ResponseBody
// public String refreshHistory(String token) throws Exception {
// if (checkToken(token)) {
// jdUtils.fetchHistoricalOrders3090();
// }
// return "OK";
// }
//
// @RequestMapping("/mq")
// @ResponseBody
// public String mq() {
// JSONObject jsonObject = new JSONObject();
// messageProducerService.sendMessage(jsonObject);
// return "OK";
// }
//
//}
package cn.van.business.controller.jd;
import cn.van.business.model.ApiResponse;
import cn.van.business.model.jd.ProductOrder;
import cn.van.business.mq.MessageProducerService;
import cn.van.business.repository.ProductOrderRepository;
import cn.van.business.util.JDUtil;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author Leo
* @version 1.0
* @create 2024/11/7 13:39
* @description
*/
@RestController
@RequestMapping("/recordOrder")
public class OrderController {
public static String TOKEN = "cc0313";
@Autowired
private JDUtil jdUtils;
@Autowired
private MessageProducerService messageProducerService;
@Autowired
private ProductOrderRepository productOrderRepository;
public boolean checkToken(String token) {
return TOKEN.equals(token);
}
@RequestMapping("/list")
@ResponseBody
public ApiResponse<List<ProductOrder>> list(String token) throws Exception {
try {
List<ProductOrder> all = productOrderRepository.findAll();
return ApiResponse.success(all);
} catch (Exception e) {
return (ApiResponse<List<ProductOrder>>) ApiResponse.error(500, "Server Error: " + e.getMessage());
}
}
}

View File

@@ -0,0 +1,61 @@
package cn.van.business.model;
import com.alibaba.fastjson2.annotation.JSONField;
public class ApiResponse<T> {
// 状态码(建议使用 HTTP 状态码或自定义业务状态码)
private int code;
// 返回消息
private String message;
// 业务数据(使用泛型支持不同类型)
private T data;
// 时间戳(毫秒)
@JSONField(name = "timestamp")
private long timestamp;
// 常用状态码常量
public static final int CODE_SUCCESS = 200;
public static final int CODE_BAD_REQUEST = 400;
public static final int CODE_UNAUTHORIZED = 401;
public static final int CODE_SERVER_ERROR = 500;
// 构造方法私有化,通过静态工厂方法创建
private ApiResponse(int code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
this.timestamp = System.currentTimeMillis();
}
// 成功响应(带数据)
public static <T> ApiResponse<T> success(T data) {
return new ApiResponse<>(CODE_SUCCESS, "success", data);
}
// 成功响应(无数据)
public static ApiResponse<?> success() {
return success(null);
}
// 错误响应(自定义状态码和消息)
public static ApiResponse<?> error(int code, String message) {
return new ApiResponse<>(code, message, null);
}
// 快速错误响应(预定义类型)
public static ApiResponse<?> badRequest() {
return error(CODE_BAD_REQUEST, "Bad Request");
}
public static ApiResponse<?> unauthorized() {
return error(CODE_UNAUTHORIZED, "Unauthorized");
}
// getters 需要保留用于序列化
public int getCode() { return code; }
public String getMessage() { return message; }
public T getData() { return data; }
public long getTimestamp() { return timestamp; }
// setters 可省略或设为私有,根据实际需求
}

View File

@@ -48,7 +48,7 @@ logging:
cn.van: debug
org.springframework: warn
config:
WX_BASE_URL: http://192.168.8.208:7777/qianxun/httpapi?wxid=wxid_kr145nk7l0an31
WX_BASE_URL: http://192.168.8.33:7777/qianxun/httpapi?wxid=wxid_kr145nk7l0an31
QL_BASE_URL: http://134.175.126.60:35700
rocketmq:
name-server: 192.168.8.88:9876 # RocketMQ Name Server 地址
@@ -61,5 +61,5 @@ rocketmq:
consume-thread-max: 64 # 消费线程池最大线程数
consume-message-batch-max-size: 64 # 批量消费最大消息数
isRunning:
wx: false
wx: true
jd: false

View File

@@ -48,7 +48,7 @@ logging:
cn.van: debug
org.springframework: warn
config:
WX_BASE_URL: http://192.168.8.208:7777/qianxun/httpapi?wxid=wxid_kr145nk7l0an31
WX_BASE_URL: http://192.168.8.33:7777/qianxun/httpapi?wxid=wxid_kr145nk7l0an31
QL_BASE_URL: http://134.175.126.60:35700
rocketmq:
name-server: 192.168.8.88:9876 # RocketMQ Name Server 地址

View File

@@ -1,10 +1,10 @@
server:
port: 6666
port: 8080
spring:
application:
name: jd
profiles:
active: prod
active: dev
servlet:
multipart:
# 单个文件大小