1
This commit is contained in:
1
.idea/dataSources.xml
generated
1
.idea/dataSources.xml
generated
@@ -22,6 +22,7 @@
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.resource.type" value="Deployment" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
|
||||
2
.idea/jpa.xml
generated
2
.idea/jpa.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JpaBuddyIdeaProjectConfig">
|
||||
<component name="JpaBuddyIdeaProjectConfig" ddlActionDbType="mysql">
|
||||
<option name="defaultUnitInitialized" value="true" />
|
||||
<option name="reLastEntityCreationPackage" value="src/main/java/cn/van/business/model" />
|
||||
<option name="renamerInitialized" value="true" />
|
||||
|
||||
18
pom.xml
18
pom.xml
@@ -52,12 +52,12 @@
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>8.0.33</version>
|
||||
<version>8.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.rocketmq</groupId>
|
||||
<artifactId>rocketmq-spring-boot-starter</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
@@ -128,11 +128,11 @@
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<!-- <repositories>-->
|
||||
<!-- <repository>-->
|
||||
<!-- <id>maven-local88</id>-->
|
||||
<!-- <name>Local Repository</name>-->
|
||||
<!-- <url>http://192.168.8.88:8081/repository/maven-local88/</url>-->
|
||||
<!-- </repository>-->
|
||||
<!-- </repositories>-->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven-local88</id>
|
||||
<name>Local Repository</name>
|
||||
<url>http://192.168.8.88:8081/repository/maven-local88/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package cn.van;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Leo
|
||||
* @version 1.0
|
||||
@@ -14,7 +18,22 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@EnableScheduling
|
||||
public class Application {
|
||||
|
||||
private final Environment env;
|
||||
|
||||
public Application(Environment env) {
|
||||
this.env = env;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
String[] activeProfiles = env.getActiveProfiles();
|
||||
if (activeProfiles.length == 0) {
|
||||
activeProfiles = env.getDefaultProfiles();
|
||||
}
|
||||
System.out.println("Active profiles: " + Arrays.toString(activeProfiles));
|
||||
}
|
||||
}
|
||||
|
||||
15
src/main/java/cn/van/business/config/RocketMQConfig.java
Normal file
15
src/main/java/cn/van/business/config/RocketMQConfig.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package cn.van.business.config;
|
||||
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class RocketMQConfig {
|
||||
|
||||
@Bean
|
||||
public RocketMQTemplate rocketMQTemplate() {
|
||||
System.out.println("RocketMQTemplate init");
|
||||
return new RocketMQTemplate();
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,49 @@
|
||||
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.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";
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -22,11 +22,11 @@ public class SkuInfo {
|
||||
/**
|
||||
* 商品类型名称。
|
||||
*/
|
||||
@Column(name = "type_name", unique = true, nullable = false)
|
||||
private String typeName;
|
||||
@Column(name = "sku_name")
|
||||
private String skuName;
|
||||
|
||||
@Column(name = "sku", unique = true, nullable = false)
|
||||
private String sku;
|
||||
@Column(name = "sku_id")
|
||||
private String skuId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package cn.van.business.model.jd;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -27,8 +29,30 @@ public class SkuType {
|
||||
/**
|
||||
* 与该商品类型关联的商品ID集合。
|
||||
*/
|
||||
@OneToMany(mappedBy = "sku_id", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private Set<ProductOrder> productOrders;
|
||||
@Column(name = "sku_id")
|
||||
private String skuId;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public String getSkuId() {
|
||||
return skuId;
|
||||
}
|
||||
|
||||
public void setSkuId(String skuId) {
|
||||
this.skuId = skuId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.apache.rocketmq.common.message.Message;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -23,6 +24,7 @@ public class MessageProducerService {
|
||||
|
||||
private final RocketMQTemplate rocketMQTemplate;
|
||||
|
||||
@Autowired
|
||||
public MessageProducerService(RocketMQTemplate rocketMQTemplate) {
|
||||
this.rocketMQTemplate = rocketMQTemplate;
|
||||
}
|
||||
@@ -31,7 +33,6 @@ public class MessageProducerService {
|
||||
public void sendMessage(JSONObject jsonObject) {
|
||||
Message message = new Message(topic, jsonObject.toJSONString().getBytes());
|
||||
message.setTags("wx");
|
||||
this.rocketMQTemplate.convertAndSend(topic, message);
|
||||
|
||||
rocketMQTemplate.convertAndSend(topic, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import lombok.NoArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -100,7 +101,7 @@ public class WXUtil {
|
||||
|
||||
|
||||
@Autowired
|
||||
public WXUtil(Environment env, WxtsUtil wxTsUtil, MessageProducerService messageProducerService) {
|
||||
public WXUtil(Environment env, WxtsUtil wxTsUtil, @Lazy MessageProducerService messageProducerService) {
|
||||
this.messageProducerService = messageProducerService;
|
||||
this.wxTsUtil = wxTsUtil;
|
||||
this.env = env;
|
||||
|
||||
@@ -3,7 +3,7 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: jd
|
||||
#数据源配置
|
||||
# 数据源配置
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.8.88:3306/jd?characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
|
||||
@@ -16,27 +16,13 @@ spring:
|
||||
max-lifetime: 2000000 # 最大生命周期(毫秒)
|
||||
connection-timeout: 30000 # 连接超时时间(毫秒)
|
||||
pool-name: SpringBootHikariCP # 连接池名字
|
||||
#redis配置
|
||||
redis:
|
||||
host: 192.168.8.88
|
||||
port: 6379
|
||||
database: 7
|
||||
timeout: 1800000
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 200
|
||||
#最大阻塞等待时间(负数表示没限制)
|
||||
max-wait: -1
|
||||
max-idle: 5
|
||||
min-idle: 0
|
||||
password: redis_6PZ52S # 文件上传
|
||||
servlet:
|
||||
multipart:
|
||||
# 单个文件大小
|
||||
max-file-size: 20MB
|
||||
# 设置总上传的文件大小
|
||||
max-request-size: 20MB
|
||||
#MyWebMvcConfig中开启@EnableWebMvc则失效
|
||||
# MyWebMvcConfig中开启@EnableWebMvc则失效
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
@@ -47,6 +33,13 @@ spring:
|
||||
messages:
|
||||
# 国际化资源文件路径
|
||||
basename: i18n/messages
|
||||
data:
|
||||
redis:
|
||||
host: 192.168.8.88
|
||||
password: redis_6PZ52S
|
||||
timeout: 1800000
|
||||
port: 6379
|
||||
database: 7
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
|
||||
@@ -16,20 +16,7 @@ spring:
|
||||
max-lifetime: 2000000 # 最大生命周期(毫秒)
|
||||
connection-timeout: 30000 # 连接超时时间(毫秒)
|
||||
pool-name: SpringBootHikariCP # 连接池名字
|
||||
#redis配置
|
||||
redis:
|
||||
host: 192.168.8.88
|
||||
port: 6379
|
||||
database: 7
|
||||
timeout: 1800000
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 200
|
||||
#最大阻塞等待时间(负数表示没限制)
|
||||
max-wait: -1
|
||||
max-idle: 5
|
||||
min-idle: 0
|
||||
password: redis_6PZ52S # 文件上传
|
||||
|
||||
servlet:
|
||||
multipart:
|
||||
# 单个文件大小
|
||||
@@ -47,6 +34,13 @@ spring:
|
||||
messages:
|
||||
# 国际化资源文件路径
|
||||
basename: i18n/messages
|
||||
data:
|
||||
redis:
|
||||
host: 192.168.8.88
|
||||
password: redis_6PZ52S
|
||||
timeout: 1800000
|
||||
port: 6379
|
||||
database: 7
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
|
||||
@@ -5,33 +5,6 @@ spring:
|
||||
name: jd
|
||||
profiles:
|
||||
active: dev
|
||||
#数据源配置
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://134.175.126.60:33306/jd?characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: mysql_7sjTXH
|
||||
hikari:
|
||||
maximum-pool-size: 2000 # 最大连接数
|
||||
minimum-idle: 48 # 最小空闲连接数
|
||||
idle-timeout: 30000 # 空闲连接超时时间(毫秒)
|
||||
max-lifetime: 2000000 # 最大生命周期(毫秒)
|
||||
connection-timeout: 30000 # 连接超时时间(毫秒)
|
||||
pool-name: SpringBootHikariCP # 连接池名字
|
||||
#redis配置
|
||||
redis:
|
||||
host: 134.175.126.60
|
||||
port: 36379
|
||||
database: 7
|
||||
timeout: 1800000
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 200
|
||||
#最大阻塞等待时间(负数表示没限制)
|
||||
max-wait: -1
|
||||
max-idle: 5
|
||||
min-idle: 0
|
||||
password: redis_6PZ52S # 文件上传
|
||||
servlet:
|
||||
multipart:
|
||||
# 单个文件大小
|
||||
@@ -53,6 +26,8 @@ spring:
|
||||
execution:
|
||||
pool:
|
||||
core-size: 32
|
||||
main:
|
||||
allow-circular-references: true
|
||||
|
||||
# token配置
|
||||
token:
|
||||
@@ -76,3 +51,13 @@ logging:
|
||||
level:
|
||||
cn.van333: debug
|
||||
org.springframework: warn
|
||||
rocketmq:
|
||||
name-server: 192.168.8.88:9876 # RocketMQ Name Server 地址
|
||||
producer:
|
||||
group: wx_producer # 生产者组名
|
||||
send-msg-timeout: 1000 # 发送消息超时时间
|
||||
consumer:
|
||||
group: wx_consumer # 消费者组名
|
||||
consume-thread-min: 20 # 消费线程池最小线程数
|
||||
consume-thread-max: 64 # 消费线程池最大线程数
|
||||
consume-message-batch-max-size: 64 # 批量消费最大消息数
|
||||
|
||||
Reference in New Issue
Block a user