统计美化

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; package cn.van.business.controller.jd;
//
//import cn.van.business.mq.MessageProducerService; import cn.van.business.model.ApiResponse;
//import cn.van.business.util.JDUtil; import cn.van.business.model.jd.ProductOrder;
//import com.alibaba.fastjson2.JSONObject; import cn.van.business.mq.MessageProducerService;
//import org.springframework.beans.factory.annotation.Autowired; import cn.van.business.repository.ProductOrderRepository;
//import org.springframework.web.bind.annotation.RequestMapping; import cn.van.business.util.JDUtil;
//import org.springframework.web.bind.annotation.ResponseBody; import com.alibaba.fastjson2.JSONObject;
//import org.springframework.web.bind.annotation.RestController; 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 import java.util.List;
// * @create 2024/11/7 13:39
// * @description
// */ /**
//@RestController * @author Leo
//@RequestMapping("/order") * @version 1.0
//public class OrderController { * @create 2024/11/7 13:39
// * @description
// public static String TOKEN = "cc0313"; */
// @Autowired @RestController
// private JDUtil jdUtils; @RequestMapping("/recordOrder")
// @Autowired public class OrderController {
// private MessageProducerService messageProducerService;
// public static String TOKEN = "cc0313";
// public boolean checkToken(String token) { @Autowired
// return TOKEN.equals(token); private JDUtil jdUtils;
// } @Autowired
// private MessageProducerService messageProducerService;
// @RequestMapping("/refreshHistory") @Autowired
// @ResponseBody private ProductOrderRepository productOrderRepository;
// public String refreshHistory(String token) throws Exception {
// if (checkToken(token)) { public boolean checkToken(String token) {
// jdUtils.fetchHistoricalOrders3090(); return TOKEN.equals(token);
// } }
// return "OK";
// } @RequestMapping("/list")
// @ResponseBody
// @RequestMapping("/mq") public ApiResponse<List<ProductOrder>> list(String token) throws Exception {
// @ResponseBody try {
// public String mq() { List<ProductOrder> all = productOrderRepository.findAll();
// JSONObject jsonObject = new JSONObject(); return ApiResponse.success(all);
// messageProducerService.sendMessage(jsonObject); } catch (Exception e) {
// return "OK"; 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 cn.van: debug
org.springframework: warn org.springframework: warn
config: 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 QL_BASE_URL: http://134.175.126.60:35700
rocketmq: rocketmq:
name-server: 192.168.8.88:9876 # RocketMQ Name Server 地址 name-server: 192.168.8.88:9876 # RocketMQ Name Server 地址
@@ -61,5 +61,5 @@ rocketmq:
consume-thread-max: 64 # 消费线程池最大线程数 consume-thread-max: 64 # 消费线程池最大线程数
consume-message-batch-max-size: 64 # 批量消费最大消息数 consume-message-batch-max-size: 64 # 批量消费最大消息数
isRunning: isRunning:
wx: false wx: true
jd: false jd: false

View File

@@ -48,7 +48,7 @@ logging:
cn.van: debug cn.van: debug
org.springframework: warn org.springframework: warn
config: 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 QL_BASE_URL: http://134.175.126.60:35700
rocketmq: rocketmq:
name-server: 192.168.8.88:9876 # RocketMQ Name Server 地址 name-server: 192.168.8.88:9876 # RocketMQ Name Server 地址

View File

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