Merge remote-tracking branch 'origin/dev/dev' into dev/dev
# Conflicts: # src/main/resources/application-dev.properties
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC1XpZ0+EIoJvQk
|
||||
GHAdpcpr35S+UnxNdOE+1sZsIDWuyzXG0d6vOudITmYFTqVzJRaAArhwp+NQ/R9y
|
||||
onsuUsEc0x2qTntySYMedHfI2TSl6qTsqpHykSLr6u0E4TuYUiGs/nf3t0A/rEvm
|
||||
KK6OP4vNgUlANhOKDwiCAdmJkiOBEHJwLsN1xlcnBkUR0Wr+uauVo+A0opkM7HrB
|
||||
aXXTcy+gpold+uCgCbRzFCiDr0uKsLJgb3Ce1aXTwa8k2dDg6mzhE0U65yhsNzjC
|
||||
Cqg+g8tfEVha9Nrsmd6hG2iFHnk4rCqRXhjuI1V10GiZUppMWJtGD2tj7ZK0XXKh
|
||||
5sAclu9RAgMBAAECggEBAKSQy8IclKKsHbA2wFwWV6Ijv2olnAYH/G0xId9wJmWQ
|
||||
mx3oxb6Hmt3fzPAZ2UOuLkk+rq4Bl9+fnQ494bk5e2G1KWCjT512mFNk6F9EvmGh
|
||||
k73uUvkeueoIQsG/wHxIYaf/SUlqbBCaPE/9L82AWVDBc36g0n/dfiHAnesWv8JV
|
||||
agiTF/SIWDPtzRaVh8VObFOusHdqnRuLqV7n0FSVJePSNBFSSOz5XTttOtM4whg8
|
||||
kw3jlCHbVMVKtPYcebxGf0vkDapyGJiZ6wc1rD4MXJTciG+WQNfNE+Af2UB606VC
|
||||
Nlq/CRkXr2Ix9ASSMeE4TcH+0EoxeITpP2NV+3hAzgECgYEA7mWSd6HgPXMdwO33
|
||||
efmx0qky+I/4bhicG9Go6021fRY+jUhRcj6VtDWBzuZwblgTSiDH4t2TbfB+hvQD
|
||||
GVTJNc21+hXEVNu0ajqLuMiCgqaZCeNeJYYYowbLSbYd4t/nQh1vCZ/44aRWqG8G
|
||||
eWEGruMaqSlGyFG7kyaoQaY1X6ECgYEAwsMGiupkNZ/JU3PZd2X2X+37b8BXcIt7
|
||||
itL413GDiLwCNII5pArD7GHYFQzN4GaUCt/VjrRXbTY1xYCk2RA0FyBMsxAGa+eH
|
||||
9iTSLQvDJpxV/44UY3L9ZFcz4t0WjRcsdqPt30yUBNWiAIGcjtae2tMvtfxKICLQ
|
||||
sYXAS+ciMbECgYEA4tnerV5pfq/7QSpw0y4Ky5ZcPXDqiwF6E3LH1dlleTlgnpqR
|
||||
fjAVzp0X/+UCWc4P1PsqmjQU5YnzLMIn7MPkkAFHSEnMQJ+sp2U8rcKHhoG3oVQt
|
||||
s3FOIlwFuAfHmqtLaXuOvM7wSu9R0weLVpdAf8z2AsCXbWlxH86qT4Y0xeECgYBM
|
||||
NJkbw8i//qx8vciqYjf7oxeNy1mrTLhjQldhnSXVW5MVTpsVJ60vkb1Fx0PK+PgW
|
||||
JSzfcIsAzYROqh5WXHO1VMsOCUgp8mcNlayzOXX7ZpJzsvkhTH3/Q+umadGIFTgt
|
||||
l8jcZY9JMPn5br1+WlW/04BImdW7K0QzId1zFZYYkQKBgQDqswTLEpbBDOE/3uk4
|
||||
laZ9kTLJMP/hVmDJ0/jbETMdCkzIORnr3xFxmZIHG17E2In9PVumD0ESCh7qbCDE
|
||||
isbfLSgfJR6ItdOM6W2R0GAsXQ3e0byBpR7qm0j9J3zYRhQwfVbZtkX0uywB9a/4
|
||||
q2bz4491ESrbryx16FZKUJeX8g==
|
||||
-----END PRIVATE KEY-----
|
||||
9
files/CODE-CREATE LIMITED.merchant.aqs.public.key.pem
Normal file
9
files/CODE-CREATE LIMITED.merchant.aqs.public.key.pem
Normal file
@@ -0,0 +1,9 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtV6WdPhCKCb0JBhwHaXK
|
||||
a9+UvlJ8TXThPtbGbCA1rss1xtHerzrnSE5mBU6lcyUWgAK4cKfjUP0fcqJ7LlLB
|
||||
HNMdqk57ckmDHnR3yNk0peqk7KqR8pEi6+rtBOE7mFIhrP5397dAP6xL5iiujj+L
|
||||
zYFJQDYTig8IggHZiZIjgRBycC7DdcZXJwZFEdFq/rmrlaPgNKKZDOx6wWl103Mv
|
||||
oKaJXfrgoAm0cxQog69LirCyYG9wntWl08GvJNnQ4Ops4RNFOucobDc4wgqoPoPL
|
||||
XxFYWvTa7JneoRtohR55OKwqkV4Y7iNVddBomVKaTFibRg9rY+2StF1yoebAHJbv
|
||||
UQIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
55
pom.xml
55
pom.xml
@@ -158,6 +158,12 @@
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>mssql-jdbc</artifactId>
|
||||
<version>9.2.1.jre8</version>
|
||||
</dependency>
|
||||
|
||||
<!-- RabbitMQ -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -177,6 +183,55 @@
|
||||
<version>4.22.57.ALL</version>
|
||||
</dependency>
|
||||
|
||||
<!--PayPal SDK-->
|
||||
<dependency>
|
||||
<groupId>com.paypal.sdk</groupId>
|
||||
<artifactId>checkout-sdk</artifactId>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.paypal.sdk</groupId>
|
||||
<artifactId>rest-api-sdk</artifactId>
|
||||
<version>LATEST</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20230618</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>5.2.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>5.2.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.stripe</groupId>
|
||||
<artifactId>stripe-java</artifactId>
|
||||
<version>25.0.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
216
src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java
Normal file
216
src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java
Normal file
@@ -0,0 +1,216 @@
|
||||
package com.ai.da.common.RabbitMQ;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.constant.CommonConstant;
|
||||
import com.ai.da.common.utils.RedisUtil;
|
||||
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
||||
import com.ai.da.model.vo.GenerateResultVO;
|
||||
import com.ai.da.service.GenerateService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.tomcat.jni.Time;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class GenerateConsumer {
|
||||
|
||||
@Resource
|
||||
private GenerateService generateService;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Value("${redis.key.orderForGenerate}")
|
||||
private String consumptionOrderKey;
|
||||
|
||||
@Value("${redis.key.generateCancelSet}")
|
||||
private String cancelSetKey;
|
||||
|
||||
@Value("${redis.key.generateExceptionMap}")
|
||||
private String exceptionMapKey;
|
||||
|
||||
@Value("${redis.key.generateResult}")
|
||||
private String generateResultKey;
|
||||
|
||||
public void generate(Message msg, Channel channel, String consumerName) {
|
||||
log.info("============start listening==========");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
GenerateThroughImageTextDTO generateThroughImageTextDTO = JSONObject.parseObject(msg.getBody(), GenerateThroughImageTextDTO.class);
|
||||
String uniqueId = generateThroughImageTextDTO.getUniqueId();
|
||||
log.info("From " + consumerName + " : " + uniqueId);
|
||||
|
||||
try {
|
||||
// 2、判断当前消息是否在取消列表中
|
||||
Boolean isMember = redisUtil.isElementExistsInSet(cancelSetKey, uniqueId);
|
||||
if (isMember) {
|
||||
try {
|
||||
// 2.1 手动确认该消息
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
} catch (IOException ex) {
|
||||
log.error("手动确认,不返回队列重新消费");
|
||||
}
|
||||
// 2.2 将该消息从取消列表中删除
|
||||
// redisUtil.removeFromSet(cancelSetKey, uniqueId);
|
||||
} else {
|
||||
// GenerateCollectionVO generateCollectionVO = generateService.generateThroughImageText(generateThroughImageTextDTO);
|
||||
generateService.generateThroughImageText(generateThroughImageTextDTO);
|
||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||
redisUtil.removeFromZSet(consumptionOrderKey, uniqueId);
|
||||
/*if (!Objects.isNull(generateCollectionVO)) {
|
||||
HashMap<String, String> generateResult = new HashMap<>();
|
||||
generateResult.put(uniqueId, JSONObject.toJSONString(generateCollectionVO));
|
||||
// 将结果存在redis中 ,为空时不要存
|
||||
redisUtil.addToMap(resultMapKey, generateResult);
|
||||
}*/
|
||||
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
log.error(e.getMsg());
|
||||
// channel.basicNack() 为不确认deliveryTag对应的消息,第二个参数是否应用于多消息,第三个参数是否requeue
|
||||
try {
|
||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||
redisUtil.removeFromZSet(consumptionOrderKey, uniqueId);
|
||||
String key = generateResultKey + ":" + uniqueId;
|
||||
GenerateResultVO generateResultVO = new GenerateResultVO(generateThroughImageTextDTO.getUniqueId(), null, null, "Fail");
|
||||
redisUtil.addToString(key, new Gson().toJson(generateResultVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
} catch (IOException exception) {
|
||||
log.error("手动确认,取消返回队列,不再重新消费");
|
||||
}
|
||||
// 将入参和错误信息存入数据库
|
||||
String exceptionMessage = JSONObject.toJSONString(generateThroughImageTextDTO) +
|
||||
" Exception message : " + e.getMsg();
|
||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||
exceptionInfo.put(String.valueOf(uniqueId), exceptionMessage);
|
||||
// 存redis
|
||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
log.info(" task_id: " + uniqueId + "----------" + consumerName + " 执行时长:" + (end - start) + "毫秒");
|
||||
log.info("=============end listening===========");
|
||||
}
|
||||
|
||||
public void processGenerateResult(Message msg, Channel channel) {
|
||||
log.info("============ProcessGenerateResult listening==========");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
Map<String, String> generateResult = JSONObject.parseObject(msg.getBody(), Map.class);
|
||||
log.info("generate response : {}", generateResult);
|
||||
|
||||
try {
|
||||
log.info("tasks_id : {} start ", generateResult.get("tasks_id"));
|
||||
if (generateResult.get("status").equals("SUCCESS")) {
|
||||
String url = generateResult.get("image_url");
|
||||
String taskId = generateResult.get("tasks_id");
|
||||
String category = generateResult.get("category");
|
||||
generateService.processGenerateResult(taskId, url, category);
|
||||
} else {
|
||||
// 修改redis中的数据状态为exception
|
||||
String key = generateResultKey + ":" + generateResult.get("tasks_id");
|
||||
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.get("tasks_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
// 将异常信息存到exception中
|
||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||
exceptionInfo.put(generateResult.get("tasks_id"), generateResult.get("data"));
|
||||
// 存redis
|
||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
try {
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.get("tasks_id"));
|
||||
} catch (IOException exception) {
|
||||
log.error("手动确认,取消返回队列,不再重新消费");
|
||||
}
|
||||
// 将入参和错误信息存入数据库
|
||||
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
||||
" Exception message : " + e.getMessage();
|
||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||
exceptionInfo.put(String.valueOf(generateResult.get("tasks_id")), exceptionMessage);
|
||||
// 存redis
|
||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("tasks_id"), generateResult.get("message"), (end - start));
|
||||
log.info("============ProcessGenerateResult End listening==========");
|
||||
|
||||
}
|
||||
|
||||
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void generateConsumer1(Message msg, Channel channel) {
|
||||
// generate(msg, channel, "consumer 1");
|
||||
// }
|
||||
//
|
||||
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void generateConsumer2(Message msg, Channel channel) {
|
||||
// generate(msg, channel, "consumer 2");
|
||||
// }
|
||||
//
|
||||
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void generateConsumer3(Message msg, Channel channel) {
|
||||
// generate(msg, channel, "consumer 3");
|
||||
// }
|
||||
//
|
||||
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void generateConsumer4(Message msg, Channel channel) {
|
||||
// generate(msg, channel, "consumer 4");
|
||||
// }
|
||||
//
|
||||
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void generateConsumer5(Message msg, Channel channel) {
|
||||
// generate(msg, channel, "consumer 5");
|
||||
// }
|
||||
//
|
||||
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void generateConsumer6(Message msg, Channel channel) {
|
||||
// generate(msg, channel, "consumer 6");
|
||||
// }
|
||||
//
|
||||
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void generateConsumer7(Message msg, Channel channel) {
|
||||
// generate(msg, channel, "consumer 7");
|
||||
// }
|
||||
//
|
||||
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void generateConsumer8(Message msg, Channel channel) {
|
||||
// generate(msg, channel, "consumer 8");
|
||||
// }
|
||||
//
|
||||
// @RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void generateConsumer9(Message msg, Channel channel) {
|
||||
// generate(msg, channel, "consumer 9");
|
||||
// }
|
||||
//
|
||||
// @RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void getGenerateResult(Message msg, Channel channel) {
|
||||
// processGenerateResult(msg, channel);
|
||||
// }
|
||||
}
|
||||
@@ -1,25 +1,28 @@
|
||||
package com.ai.da.common.RabbitMQ;
|
||||
|
||||
import org.springframework.amqp.core.Binding;
|
||||
import org.springframework.amqp.core.BindingBuilder;
|
||||
import org.springframework.amqp.core.FanoutExchange;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
@Configuration
|
||||
public class MQConfig {
|
||||
|
||||
public static final String GENERATE_EXCHANGE_FANOUT = "generate-exchange";
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-prod";
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-prod";
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-test";
|
||||
// ==================================================================
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-local";
|
||||
public static final String GENERATE_QUEUE = "generate-queue-dev";
|
||||
|
||||
// public static final String SR_QUEUE = "SR-queue-local";
|
||||
public static final String SR_QUEUE = "SR-queue-dev";
|
||||
|
||||
// public static final String SR_RESULT_QUEUE = "SuperResolution-local";
|
||||
public static final String SR_RESULT_QUEUE = "SuperResolution-dev";
|
||||
|
||||
// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-local";
|
||||
public static final String GENERATE_RESULT_QUEUE = "GenerateImage-dev";
|
||||
|
||||
public MQConfig() {
|
||||
}
|
||||
|
||||
@@ -32,10 +35,20 @@ public class MQConfig {
|
||||
* 创建队列,使用工作模式,不用定义交换机
|
||||
*/
|
||||
@Bean
|
||||
public Queue queueRasa() {
|
||||
public Queue generateQueue() {
|
||||
return new Queue(GENERATE_QUEUE);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue SRQueue() {
|
||||
return new Queue(SR_QUEUE);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue SRResultQueue() {
|
||||
return new Queue(SR_RESULT_QUEUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将队列绑定到交换机上【队列订阅交换机】
|
||||
*/
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
package com.ai.da.common.RabbitMQ;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.utils.RedisUtil;
|
||||
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
||||
import com.ai.da.model.vo.GenerateCollectionVO;
|
||||
import com.ai.da.service.GenerateService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MQConsumer {
|
||||
|
||||
@Resource
|
||||
private GenerateService generateService;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Value("${redis.key.consumptionOrder}")
|
||||
private String consumptionOrderKey;
|
||||
|
||||
@Value("${redis.key.cancelSet}")
|
||||
private String cancelSetKey;
|
||||
|
||||
@Value("${redis.key.exceptionMap}")
|
||||
private String exceptionMapKey;
|
||||
|
||||
@Value("${redis.key.resultMap}")
|
||||
private String resultMapKey;
|
||||
|
||||
public void generate(Message msg, Channel channel, String consumerName) {
|
||||
log.info("============start listening==========");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
GenerateThroughImageTextDTO generateThroughImageTextDTO = JSONObject.parseObject(msg.getBody(), GenerateThroughImageTextDTO.class);
|
||||
String uniqueId = generateThroughImageTextDTO.getUniqueId();
|
||||
log.info("From " + consumerName + " : " + uniqueId);
|
||||
|
||||
try {
|
||||
// 2、判断当前消息是否在取消列表中
|
||||
Boolean isMember = redisUtil.isElementExistsInSet(cancelSetKey, uniqueId);
|
||||
if (isMember) {
|
||||
try {
|
||||
// 2.1 手动确认该消息
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
} catch (IOException ex) {
|
||||
log.error("手动确认,不返回队列重新消费");
|
||||
}
|
||||
// 2.2 将该消息从取消列表中删除
|
||||
// redisUtil.removeFromSet(cancelSetKey, uniqueId);
|
||||
} else {
|
||||
/*try {
|
||||
Thread.sleep(15000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}*/
|
||||
GenerateCollectionVO generateCollectionVO = generateService.generateThroughImageText(generateThroughImageTextDTO);
|
||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||
redisUtil.removeFromZSet(consumptionOrderKey, uniqueId);
|
||||
if (!Objects.isNull(generateCollectionVO)) {
|
||||
HashMap<String, String> generateResult = new HashMap<>();
|
||||
generateResult.put(uniqueId, JSONObject.toJSONString(generateCollectionVO));
|
||||
// 将结果存在redis中 ,为空时不要存
|
||||
redisUtil.addToMap(resultMapKey, generateResult);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
log.error(e.getMsg());
|
||||
// channel.basicNack() 为不确认deliveryTag对应的消息,第二个参数是否应用于多消息,第三个参数是否requeue
|
||||
try {
|
||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||
redisUtil.removeFromZSet(consumptionOrderKey, uniqueId);
|
||||
} catch (IOException exception) {
|
||||
log.error("手动确认,取消返回队列,不再重新消费");
|
||||
}
|
||||
// 将入参和错误信息存入数据库
|
||||
String exceptionMessage = JSONObject.toJSONString(generateThroughImageTextDTO) +
|
||||
" Exception message : " + e.getMsg();
|
||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||
exceptionInfo.put(String.valueOf(uniqueId), exceptionMessage);
|
||||
// 存redis
|
||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
log.info(" task_id: " + uniqueId + "----------" + consumerName + " 执行时长:" + (end - start) + "毫秒");
|
||||
log.info("=============end listening===========");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitHandler
|
||||
public void generateConsumer1(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 1");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitHandler
|
||||
public void generateConsumer2(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 2");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitHandler
|
||||
public void generateConsumer3(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 3");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitHandler
|
||||
public void generateConsumer4(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 4");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitHandler
|
||||
public void generateConsumer5(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 5");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitHandler
|
||||
public void generateConsumer6(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 6");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitHandler
|
||||
public void generateConsumer7(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 7");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitHandler
|
||||
public void generateConsumer8(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 8");
|
||||
}
|
||||
|
||||
@RabbitListener(queues = MQConfig.GENERATE_QUEUE)
|
||||
@RabbitHandler
|
||||
public void generateConsumer9(Message msg, Channel channel) {
|
||||
generate(msg, channel, "consumer 9");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import javax.annotation.Resource;
|
||||
@Component
|
||||
public class MQPublisher {
|
||||
|
||||
private final String url = "http://localhost:15672/api/queues/%2f/generate-queue";
|
||||
// private final String url = "http://localhost:15672/api/queues/%2f/generate-queue";
|
||||
|
||||
@Resource
|
||||
private AmqpTemplate amqpTemplate;
|
||||
@@ -18,7 +18,11 @@ public class MQPublisher {
|
||||
public void sendGenerateMessage(String mm) {
|
||||
log.info("send message:" + mm);
|
||||
amqpTemplate.convertAndSend(MQConfig.GENERATE_QUEUE, mm);
|
||||
}
|
||||
|
||||
public void sendSRMessage(String mm) {
|
||||
log.info("send message:" + mm);
|
||||
amqpTemplate.convertAndSend(MQConfig.SR_QUEUE, mm);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
234
src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java
Normal file
234
src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java
Normal file
@@ -0,0 +1,234 @@
|
||||
package com.ai.da.common.RabbitMQ;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.utils.RedisUtil;
|
||||
import com.ai.da.model.dto.SuperResolutionDTO;
|
||||
import com.ai.da.model.dto.TaskDTO;
|
||||
import com.ai.da.service.SuperResolutionService;
|
||||
import com.ai.da.service.TaskListService;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SRConsumer {
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Resource
|
||||
private TaskListService taskListService;
|
||||
|
||||
@Value("${redis.key.orderForSR}")
|
||||
private String consumptionOrderKey;
|
||||
|
||||
@Value("${redis.key.SRCancelSet}")
|
||||
private String cancelSetKey;
|
||||
|
||||
@Value("${redis.key.SRExceptionMap}")
|
||||
private String exceptionMapKey;
|
||||
|
||||
@Value("${redis.key.taskList}")
|
||||
private String taskListKey;
|
||||
|
||||
@Resource
|
||||
private SuperResolutionService superResolutionService;
|
||||
|
||||
/**
|
||||
* 请求超分处理
|
||||
*/
|
||||
public void superResolution(Message msg, Channel channel, String consumerName) {
|
||||
log.info("============SR start listening==========");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
SuperResolutionDTO superResolutionDTO;
|
||||
String uniqueId = null;
|
||||
|
||||
try {
|
||||
superResolutionDTO = JSONObject.parseObject(msg.getBody(), SuperResolutionDTO.class);
|
||||
uniqueId = superResolutionDTO.getUniqueId();
|
||||
log.info("From " + consumerName + " : " + uniqueId);
|
||||
superResolutionService.updateSROutput(uniqueId, "Executing", null);
|
||||
taskListService.updateTaskStatusOrOutputRedis(uniqueId, "Executing", null);
|
||||
/*try {
|
||||
Thread.sleep(2 * 60 * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}*/
|
||||
// 2、判断当前消息是否在取消列表中
|
||||
Boolean isMember = redisUtil.isElementExistsInSet(cancelSetKey, uniqueId);
|
||||
if (isMember) {
|
||||
try {
|
||||
// 2.1 手动确认该消息
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
} catch (IOException ex) {
|
||||
log.error("手动确认,不返回队列重新消费");
|
||||
}
|
||||
} else {
|
||||
// 请求python端进行超分
|
||||
superResolutionService.SR(superResolutionDTO);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
log.error(e.getMsg());
|
||||
superResolutionDTO = JSONObject.parseObject(msg.getBody(), SuperResolutionDTO.class);
|
||||
// channel.basicNack() 为不确认deliveryTag对应的消息,第二个参数是否应用于多消息,第三个参数是否requeue
|
||||
setErrorMessage(msg, channel, e.getMsg(), superResolutionDTO);
|
||||
try {
|
||||
// 2.1 手动确认该消息
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
} catch (IOException ex) {
|
||||
log.error("手动确认,不返回队列重新消费, error message : " + e.getMessage());
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
log.error(e.getMessage());
|
||||
setErrorMessage(msg, channel, e.getMessage(), null);
|
||||
try {
|
||||
// 2.1 手动确认该消息
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
} catch (IOException ex) {
|
||||
log.error("手动确认,不返回队列重新消费, error message : " + e.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
superResolutionDTO = JSONObject.parseObject(msg.getBody(), SuperResolutionDTO.class);
|
||||
setErrorMessage(msg, channel, e.getMessage(), superResolutionDTO);
|
||||
try {
|
||||
// 2.1 手动确认该消息
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
} catch (IOException ex) {
|
||||
log.error("手动确认,不返回队列重新消费, error message : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
log.info(" task_id: " + uniqueId + "----------" + consumerName + " 执行时长:" + (end - start) + "毫秒");
|
||||
log.info("=============SR end listening===========");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取超分结果
|
||||
*/
|
||||
public void getSRResult(Message msg, Channel channel, String consumerName) {
|
||||
log.info("============SRResult start listening==========");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
JSONObject result = null;
|
||||
String taskId = null;
|
||||
|
||||
try {
|
||||
result = JSONObject.parseObject(msg.getBody(), JSONObject.class);
|
||||
log.info("SR response : {}", result);
|
||||
taskId = result.get("tasks_id").toString();
|
||||
} catch (JSONException e) {
|
||||
log.error("SRResult 返回数据格式不合规范");
|
||||
log.error(e.getMessage());
|
||||
setErrorMessage(msg, channel, e.getMessage(), null);
|
||||
try {
|
||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
} catch (IOException exception) {
|
||||
log.error("手动确认,取消返回队列,不再重新消费");
|
||||
}
|
||||
} catch (Exception e){
|
||||
log.error(e.getMessage());
|
||||
setErrorMessage(msg, channel, e.getMessage(), null);
|
||||
try {
|
||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
} catch (IOException exception) {
|
||||
log.error("手动确认,取消返回队列,不再重新消费");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// 2、判断状态是否成功
|
||||
if ("SUCCESS".equals(result.get("status").toString())) {
|
||||
String output = result.get("data").toString();
|
||||
superResolutionService.setSRResult(taskId, output, "success");
|
||||
taskListService.updateTaskStatusOrOutputRedis(taskId, "success", output);
|
||||
} else {
|
||||
superResolutionService.setSRResult(taskId, null, "fail");
|
||||
taskListService.updateTaskStatusOrOutputRedis(taskId, "fail", null);
|
||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||
// 获取输入信息
|
||||
String task = redisUtil.getFromString(taskListKey + taskId + taskId.substring(taskId.lastIndexOf("-") + 1));
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<TaskDTO<SuperResolutionDTO>>() {
|
||||
}.getType();
|
||||
TaskDTO<SuperResolutionDTO> taskDTO = gson.fromJson(task, type);
|
||||
// 将输入信息和报错信息均存入redis todo 加判空
|
||||
exceptionInfo.put(taskId, "Input ==> " + taskDTO.getInputParam() + "Fail Message ==> " + result.get("message").toString());
|
||||
// 将报错信息存入redis
|
||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
// channel.basicNack() 为不确认deliveryTag对应的消息,第二个参数是否应用于多消息,第三个参数是否requeue
|
||||
try {
|
||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
} catch (IOException exception) {
|
||||
log.error("手动确认,取消返回队列,不再重新消费");
|
||||
}
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
log.info(" task_id: " + taskId + "----------" + consumerName + " 执行时长:" + (end - start) + "毫秒");
|
||||
log.info("=============SRResult end listening===========");
|
||||
}
|
||||
|
||||
private void setErrorMessage(Message msg, Channel channel, String message, SuperResolutionDTO superResolutionDTO) {
|
||||
String uniqueId;
|
||||
try {
|
||||
// 第二个参数,是否批量确认消息,当传false时,只确认当前 deliveryTag对应的消息;当传true时,会确认当前及之前所有未确认的消息。
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
uniqueId = superResolutionDTO.getUniqueId();
|
||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||
redisUtil.removeFromZSet(consumptionOrderKey, uniqueId);
|
||||
} catch (Exception exception) {
|
||||
log.error("手动确认,取消返回队列,不再重新消费");
|
||||
throw new BusinessException("发生错误,手动确认消息");
|
||||
}
|
||||
// 将入参和错误信息存入redis
|
||||
String exceptionMessage = JSONObject.toJSONString(superResolutionDTO) +
|
||||
" Exception message : " + message;
|
||||
// " Exception message : " + e.getMessage();
|
||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||
uniqueId = superResolutionDTO.getUniqueId();
|
||||
exceptionInfo.put(String.valueOf(uniqueId), exceptionMessage);
|
||||
// 存redis
|
||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||
taskListService.updateTaskStatusOrOutputRedis(uniqueId, "fail", null);
|
||||
}
|
||||
|
||||
// @RabbitListener(queues = MQConfig.SR_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void SRConsumer1(Message msg, Channel channel) {
|
||||
// superResolution(msg, channel, "consumer 1");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RabbitListener(queues = MQConfig.SR_RESULT_QUEUE)
|
||||
// @RabbitHandler
|
||||
// public void SRResultConsumer1(Message msg, Channel channel) {
|
||||
// getSRResult(msg, channel, "consumer 1");
|
||||
// }
|
||||
|
||||
}
|
||||
393
src/main/java/com/ai/da/common/config/CRMReportInterface.java
Normal file
393
src/main/java/com/ai/da/common/config/CRMReportInterface.java
Normal file
@@ -0,0 +1,393 @@
|
||||
package com.ai.da.common.config;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.CustomerData;
|
||||
import com.ai.da.mapper.primary.entity.TransactionData;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CRMReportInterface {
|
||||
|
||||
// JDBC 驱动器名称以及数据库 URL
|
||||
static final String JDBC_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
|
||||
static final String DB_URL = "jdbc:sqlserver://118.142.0.178:1550;databaseName=Hayman_prod";
|
||||
|
||||
// 数据库凭据
|
||||
static final String USER = "user01";
|
||||
static final String PASS = "haySIS-2302";
|
||||
|
||||
public static void main(String[] args) {
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
try {
|
||||
// 注册 JDBC 驱动器
|
||||
Class.forName(JDBC_DRIVER);
|
||||
|
||||
// 打开一个连接
|
||||
System.out.println("连接数据库...");
|
||||
conn = DriverManager.getConnection(DB_URL, USER, PASS);
|
||||
|
||||
// 执行查询步骤1: 生成 RW0095 报告以获取客户完整数据
|
||||
System.out.println("执行步骤1:生成 RW0095 报告...");
|
||||
// 执行相应的查询并获取数据
|
||||
// List<CustomerData> customerData = retrieveCustomerData();
|
||||
// 执行查询步骤2: 使用 MZG013 报告检查客户的销售历史
|
||||
System.out.println("执行步骤2:使用 MZG013 报告检查客户的销售历史...");
|
||||
// 执行相应的查询并获取数据
|
||||
List<TransactionData> transactionData = retrieveTransactionData();
|
||||
List<String> collect = transactionData.stream().map(TransactionData::getUserMember).collect(Collectors.toList());
|
||||
List<CustomerData> customerData = retrieveCustomerData(collect);
|
||||
for (TransactionData transactionDatum : transactionData) {
|
||||
for (CustomerData customerDatum : customerData) {
|
||||
if (customerDatum.getMbrCode().equals(transactionDatum.getUserMember())) {
|
||||
customerDatum.setLastMonth(transactionDatum.getSumAmt());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 执行步骤3: 合并(vlookup)RW0095中的客户购买金额
|
||||
System.out.println("执行步骤3:合并客户购买金额...");
|
||||
// 执行相应的操作,如vlookup
|
||||
|
||||
// 执行步骤4: 按“发行店”筛选以分离不同文件并逐个发送给店铺
|
||||
System.out.println("执行步骤4:按发行店筛选并发送文件给店铺...");
|
||||
// 执行相应的操作,如过滤和导出
|
||||
String filePath = "C:\\Users\\10233\\Desktop\\CRM.csv";
|
||||
exportToCSV(customerData, filePath);
|
||||
// 关闭连接
|
||||
conn.close();
|
||||
} catch (SQLException se) {
|
||||
// 处理 JDBC 错误
|
||||
se.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// 处理 Class.forName 错误
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 关闭资源
|
||||
try {
|
||||
if (stmt != null) stmt.close();
|
||||
} catch (SQLException se2) {
|
||||
} // 什么都不做
|
||||
try {
|
||||
if (conn != null) conn.close();
|
||||
} catch (SQLException se) {
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println("接口执行完成!");
|
||||
}
|
||||
|
||||
private static void exportToCSV(List<CustomerData> customerDataList, String filePath) throws IOException {
|
||||
FileWriter writer = new FileWriter(filePath);
|
||||
|
||||
// // 写入 CSV 文件的第一行,即字段名
|
||||
// writer.append("User Member,Mbr Name,Sh Code,Sum Amt\n");
|
||||
//
|
||||
// // 遍历数据列表,并将每一行数据写入 CSV 文件
|
||||
// for (TransactionData transaction : transactionDataList) {
|
||||
// writer.append(transaction.getUserMember()).append(",");
|
||||
// writer.append(transaction.getMbrName()).append(",");
|
||||
// writer.append(transaction.getShCode()).append(",");
|
||||
// writer.append(String.valueOf(transaction.getSumAmt())).append("\n");
|
||||
// }
|
||||
writer.append("mbrCode,mbrName,mbrMobile,mbrGroup,mbrStatus,joinDate,mbrIssue,birthMonth,mbrSex,offBonus,effBonus,sumBonus,lastMonth\n");
|
||||
|
||||
// 遍历 customerDataList,并将数据写入 CSV 文件
|
||||
for (CustomerData customer : customerDataList) {
|
||||
writer.append(customer.getMbrCode()).append(",");
|
||||
writer.append(customer.getMbrName()).append(",");
|
||||
writer.append(customer.getMbrMobile()).append(",");
|
||||
writer.append(customer.getMbrGroup()).append(",");
|
||||
writer.append(customer.getMbrStatus()).append(",");
|
||||
writer.append(customer.getJoinDate().toString()).append(","); // 日期需要根据实际情况格式化
|
||||
writer.append(customer.getMbrIssue()).append(",");
|
||||
writer.append(Integer.toString(customer.getBirthMonth())).append(",");
|
||||
writer.append(customer.getMbrSex()).append(",");
|
||||
writer.append(Double.toString(customer.getOffBonus())).append(",");
|
||||
writer.append(Double.toString(customer.getEffBonus())).append(",");
|
||||
writer.append(Double.toString(customer.getSumBonus())).append(",");
|
||||
writer.append(Double.toString(customer.getLastMonth())).append("\n");
|
||||
}
|
||||
|
||||
writer.close();
|
||||
}
|
||||
|
||||
public static List<CustomerData> retrieveCustomerData(List<String> collect) {
|
||||
List<CustomerData> customerDataList = new ArrayList<>();
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
try {
|
||||
// 注册 JDBC 驱动器
|
||||
Class.forName(JDBC_DRIVER);
|
||||
|
||||
// 打开一个连接
|
||||
System.out.println("连接数据库...");
|
||||
conn = DriverManager.getConnection(DB_URL, USER, PASS);
|
||||
|
||||
// 执行查询
|
||||
System.out.println("创建声明...");
|
||||
stmt = conn.createStatement();
|
||||
String sql;
|
||||
// 构建 IN 子句的字符串,用于添加到 SQL 查询中
|
||||
StringBuilder inClause = new StringBuilder("(");
|
||||
for (String code : collect) {
|
||||
inClause.append("'").append(code).append("',");
|
||||
}
|
||||
inClause.deleteCharAt(inClause.length() - 1); // 删除最后一个逗号
|
||||
inClause.append(")");
|
||||
|
||||
// 构建完整的 SQL 查询语句
|
||||
sql = "SELECT * FROM V_RW0095B WHERE mbr_code IN " + inClause.toString();
|
||||
ResultSet rs = stmt.executeQuery(sql);
|
||||
|
||||
|
||||
// 处理结果集
|
||||
while (rs.next()) {
|
||||
// 将每行数据转换为 CustomerData 对象并添加到列表中
|
||||
CustomerData customer = new CustomerData();
|
||||
customer.setMbrCode(rs.getString("mbr_code"));
|
||||
customer.setMbrName(rs.getString("mbr_name"));
|
||||
customer.setMbrMobile(rs.getString("mbr_mobile"));
|
||||
customer.setMbrGroup(rs.getString("mbr_group"));
|
||||
customer.setMbrStatus(rs.getString("mbr_status"));
|
||||
customer.setJoinDate(rs.getDate("join_date"));
|
||||
customer.setMbrIssue(rs.getString("mbr_issue"));
|
||||
customer.setBirthMonth(rs.getInt("birth_m"));
|
||||
customer.setMbrSex(rs.getString("mbr_sex"));
|
||||
customer.setOffBonus(rs.getDouble("off_bonus"));
|
||||
customer.setEffBonus(rs.getDouble("eff_bonus"));
|
||||
customer.setSumBonus(rs.getDouble("sum_bonus"));
|
||||
customerDataList.add(customer);
|
||||
|
||||
}
|
||||
|
||||
// 清理环境
|
||||
rs.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
} catch (SQLException se) {
|
||||
// 处理 JDBC 错误
|
||||
se.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// 处理 Class.forName 错误
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 关闭资源
|
||||
try {
|
||||
if (stmt != null) stmt.close();
|
||||
} catch (SQLException se2) {
|
||||
} // 什么都不做
|
||||
try {
|
||||
if (conn != null) conn.close();
|
||||
} catch (SQLException se) {
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println("查询执行完成!");
|
||||
return customerDataList;
|
||||
}
|
||||
|
||||
public static List<TransactionData> retrieveTransactionData() {
|
||||
List<TransactionData> transactionDataList = new ArrayList<>();
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
try {
|
||||
// 注册 JDBC 驱动器
|
||||
Class.forName(JDBC_DRIVER);
|
||||
|
||||
// 打开一个连接
|
||||
System.out.println("连接数据库...");
|
||||
conn = DriverManager.getConnection(DB_URL, USER, PASS);
|
||||
|
||||
// 执行查询
|
||||
System.out.println("创建声明...");
|
||||
stmt = conn.createStatement();
|
||||
String sql;
|
||||
sql = "SELECT user_member,mbr_name,sum(trx_bas_amt) sumAmtByMebBySh FROM V_MZG013\n" +
|
||||
"WHERE trx_date >= DATEADD(day, -7, GETDATE())\n" +
|
||||
"and user_member is not NULL\n" +
|
||||
"GROUP BY user_member,mbr_name";
|
||||
ResultSet rs = stmt.executeQuery(sql);
|
||||
|
||||
// 处理结果集
|
||||
while (rs.next()) {
|
||||
// 将每行数据转换为 TransactionData 对象并添加到列表中
|
||||
TransactionData transaction = new TransactionData();
|
||||
transaction.setUserMember(rs.getString("user_member"));
|
||||
transaction.setMbrName(rs.getString("mbr_name"));
|
||||
// transaction.setShCode(rs.getString("sh_code"));
|
||||
transaction.setSumAmt(rs.getDouble("sumAmtByMebBySh"));
|
||||
// transaction.setTrxNo(rs.getString("trx_no"));
|
||||
// transaction.setTrxDate(rs.getTimestamp("trx_date"));
|
||||
// transaction.setTrxType(rs.getString("trx_type"));
|
||||
// transaction.setTrxStatus(rs.getString("trx_status"));
|
||||
// transaction.setTrxTotQty(rs.getDouble("trx_tot_qty"));
|
||||
// transaction.setCurrCode(rs.getString("curr_code"));
|
||||
// transaction.setExchRate(rs.getDouble("exch_rate"));
|
||||
// transaction.setDiscountPerc(rs.getDouble("discount_perc"));
|
||||
// transaction.setTrxAccAmt(rs.getDouble("trx_acc_amt"));
|
||||
// transaction.setTrxBasAmt(rs.getDouble("trx_bas_amt"));
|
||||
// transaction.setOutstandAmt(rs.getDouble("outstand_amt"));
|
||||
// transaction.setReceiveAmt(rs.getDouble("receive_amt"));
|
||||
// transaction.setChangeAmt(rs.getDouble("change_amt"));
|
||||
// transaction.setTrxTotBonus(rs.getDouble("trx_tot_bonus"));
|
||||
// transaction.setDepositNo(rs.getString("deposit_no"));
|
||||
// transaction.setDepositAmt(rs.getDouble("deposit_amt"));
|
||||
// transaction.setDepositStatus(rs.getString("deposit_status"));
|
||||
// transaction.setTrxAmtDesc(rs.getString("trx_amt_desc"));
|
||||
// transaction.setRemark(rs.getString("remark"));
|
||||
// transaction.setShCode(rs.getString("sh_code"));
|
||||
// transaction.setWhCodeFrom(rs.getString("wh_code_from"));
|
||||
// transaction.setWhCodeTo(rs.getString("wh_code_to"));
|
||||
// transaction.setIssuedBy(rs.getString("issued_by"));
|
||||
// transaction.setClientCode(rs.getString("client_code"));
|
||||
// transaction.setClientName(rs.getString("client_name"));
|
||||
// transaction.setSalesmanCode(rs.getString("salesman_code"));
|
||||
// transaction.setCtypeCode(rs.getString("ctype_code"));
|
||||
// transaction.setUpdatedOn(rs.getTimestamp("updated_on"));
|
||||
// transaction.setDocType(rs.getString("doc_type"));
|
||||
// transaction.setRefNo(rs.getString("ref_no"));
|
||||
// transaction.setAdjType(rs.getString("adj_type"));
|
||||
// transaction.setRefType(rs.getString("ref_type"));
|
||||
// transaction.setOrderNo(rs.getString("order_no"));
|
||||
// transaction.setRecoverF(rs.getString("recover_f"));
|
||||
// transaction.setRecoverT(rs.getString("recover_t"));
|
||||
// transaction.setRequestBy(rs.getString("request_by"));
|
||||
// transaction.setError(rs.getString("error"));
|
||||
// transaction.setAuthorizedDate(rs.getTimestamp("authorized_date"));
|
||||
// transaction.setAuthorizedBy(rs.getString("authorized_by"));
|
||||
// transaction.setChangeCurrCode(rs.getString("change_curr_code"));
|
||||
// transaction.setChgRate(rs.getDouble("chg_rate"));
|
||||
// transaction.setCashier(rs.getString("cashier"));
|
||||
// transaction.setCashiNo(rs.getString("cashi_no"));
|
||||
// transaction.setSalesmanCode2(rs.getString("salesman_code2"));
|
||||
// transaction.setClassId(rs.getString("class_id"));
|
||||
// transaction.setDisAmt(rs.getDouble("dis_amt"));
|
||||
// transaction.setAcStatus(rs.getString("ac_status"));
|
||||
// transaction.setReprint(rs.getString("reprint"));
|
||||
// transaction.setAlt1(rs.getString("alt_1"));
|
||||
// transaction.setAlt2(rs.getString("alt_2"));
|
||||
// transaction.setAlt3(rs.getString("alt_3"));
|
||||
// transaction.setAlt4(rs.getString("alt_4"));
|
||||
// transaction.setAlt5(rs.getString("alt_5"));
|
||||
// transaction.setAltD1(rs.getDate("alt_d1"));
|
||||
// transaction.setAltD2(rs.getDate("alt_d2"));
|
||||
// transaction.setAltD3(rs.getDate("alt_d3"));
|
||||
// transaction.setAltD4(rs.getDate("alt_d4"));
|
||||
// transaction.setAltD5(rs.getDate("alt_d5"));
|
||||
// transaction.setSalesmanCode3(rs.getString("salesman_code3"));
|
||||
// transaction.setContractNo(rs.getString("contract_no"));
|
||||
// transaction.setExpireDate(rs.getTimestamp("expire_date"));
|
||||
// transaction.setDepositNetAmt(rs.getDouble("deposit_netamt"));
|
||||
// transaction.setClientRestriction(rs.getString("client_restriction"));
|
||||
// transaction.setRefStatus(rs.getString("ref_status"));
|
||||
// transaction.setMbrDis(rs.getDouble("mbr_dis"));
|
||||
// transaction.setPmtDiscount(rs.getDouble("pmt_discount"));
|
||||
// transaction.setPmtAmount(rs.getDouble("pmt_amount"));
|
||||
// transaction.setPmtNo(rs.getString("pmt_no"));
|
||||
// transaction.setRefCode(rs.getString("ref_code"));
|
||||
// transaction.setDocApproved(rs.getString("doc_approved"));
|
||||
// transaction.setRefractionNo(rs.getString("refraction_no"));
|
||||
// transaction.setCcpTot(rs.getDouble("ccp_tot"));
|
||||
// transaction.setCcpRed(rs.getDouble("ccp_red"));
|
||||
// transaction.setCcpExpired(rs.getDouble("ccp_expired"));
|
||||
// transaction.setPrintedTimes(rs.getInt("printed_times"));
|
||||
// transaction.setPickupShop(rs.getString("pickup_shop"));
|
||||
// transaction.setDeliveryDate(rs.getDate("delivery_date"));
|
||||
// transaction.setDeliveryTime(rs.getString("delivery_time"));
|
||||
// transaction.setWsCode(rs.getString("ws_code"));
|
||||
// transaction.setClCode(rs.getString("cl_code"));
|
||||
// transaction.setClDesc(rs.getString("cl_desc"));
|
||||
// transaction.setRatio(rs.getString("ratio"));
|
||||
// transaction.setUserMember(rs.getString("user_member"));
|
||||
// transaction.setHflag(rs.getString("hflag"));
|
||||
// transaction.setIssueShop(rs.getString("issue_shop"));
|
||||
// transaction.setHoUpdBy(rs.getString("ho_upd_by"));
|
||||
// transaction.setHoUpdOn(rs.getTimestamp("ho_upd_on"));
|
||||
// transaction.setBonusExpired(rs.getDouble("bonus_expired"));
|
||||
// transaction.setBonusRed(rs.getDouble("bonus_red"));
|
||||
// transaction.setConfirmedOn(rs.getTimestamp("confirmed_on"));
|
||||
// transaction.setConfirmedBy(rs.getString("confirmed_by"));
|
||||
// transaction.setDocConfirmed(rs.getString("doc_confirmed"));
|
||||
// transaction.setBrNo(rs.getString("br_no"));
|
||||
// transaction.setChangeAmt2(rs.getDouble("change_amt2"));
|
||||
// transaction.setSalesDate(rs.getDate("sales_date"));
|
||||
// transaction.setMbrName(rs.getString("mbr_name"));
|
||||
// transaction.setCanEntryDis(rs.getString("can_entry_dis"));
|
||||
// transaction.setReactiveClient(rs.getString("reactive_client"));
|
||||
// transaction.setReactiveMbr(rs.getString("reactive_mbr"));
|
||||
// transaction.setShUpdBy(rs.getString("sh_upd_by"));
|
||||
// transaction.setShUpdOn(rs.getTimestamp("sh_upd_on"));
|
||||
// transaction.setTax1(rs.getDouble("tax1"));
|
||||
// transaction.setTax2(rs.getDouble("tax2"));
|
||||
// transaction.setTax3(rs.getDouble("tax3"));
|
||||
// transaction.setTax4(rs.getDouble("tax4"));
|
||||
// transaction.setTax5(rs.getDouble("tax5"));
|
||||
// transaction.setAltChar1(rs.getString("alt_char1"));
|
||||
// transaction.setAltChar2(rs.getString("alt_char2"));
|
||||
// transaction.setAltChar3(rs.getString("alt_char3"));
|
||||
// transaction.setAltChar4(rs.getString("alt_char4"));
|
||||
// transaction.setAltChar5(rs.getString("alt_char5"));
|
||||
// transaction.setAltNum1(rs.getDouble("alt_num1"));
|
||||
// transaction.setAltNum2(rs.getDouble("alt_num2"));
|
||||
// transaction.setAltNum3(rs.getDouble("alt_num3"));
|
||||
// transaction.setAltNum4(rs.getDouble("alt_num4"));
|
||||
// transaction.setAltNum5(rs.getDouble("alt_num5"));
|
||||
// transaction.setNewClient(rs.getString("new_client"));
|
||||
// transaction.setNewMbr(rs.getString("new_mbr"));
|
||||
// transaction.setPmtExtraDiscount(rs.getDouble("pmt_extra_discount"));
|
||||
// transaction.setPmtExtraAmount(rs.getDouble("pmt_extra_amount"));
|
||||
// transaction.setManualDiscount(rs.getDouble("manual_discount"));
|
||||
// transaction.setManualAmount(rs.getDouble("manual_amount"));
|
||||
// transaction.setUsermbrDiscount(rs.getDouble("usermbr_discount"));
|
||||
// transaction.setClientDiscount(rs.getDouble("client_discount"));
|
||||
// transaction.setHoldVoid(rs.getString("hold_void"));
|
||||
// transaction.setPayBasAmt(rs.getDouble("pay_bas_amt"));
|
||||
// transaction.setPayDesc(rs.getString("pay_desc"));
|
||||
// transaction.setPayCode(rs.getString("pay_code"));
|
||||
// transaction.setCardNo(rs.getString("card_no"));
|
||||
// transaction.setPayCurr(rs.getString("pay_curr"));
|
||||
// transaction.setPayCurrAmt(rs.getDouble("pay_curr_amt"));
|
||||
// transaction.setOnbehalfPaid(rs.getString("onbehalf_paid"));
|
||||
// transaction.setOnbehalfLoc(rs.getString("onbehalf_loc"));
|
||||
// transaction.setOldCardNo(rs.getString("old_card_no"));
|
||||
// transaction.setTrxYear(rs.getInt("TRX_YEAR"));
|
||||
// transaction.setTrxMonth(rs.getInt("TRX_MONTH"));
|
||||
|
||||
transactionDataList.add(transaction);
|
||||
}
|
||||
|
||||
|
||||
// 清理环境
|
||||
rs.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
// 处理异常
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("查询执行完成!");
|
||||
return transactionDataList;
|
||||
}
|
||||
|
||||
// 示例:导出数据到CSV文件
|
||||
private static void exportToCSV(ResultSet resultSet, String filePath) throws SQLException, IOException {
|
||||
FileWriter writer = new FileWriter(filePath);
|
||||
|
||||
while (resultSet.next()) {
|
||||
// 将结果写入CSV文件
|
||||
// 这里需要根据实际情况将数据写入CSV文件
|
||||
}
|
||||
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
package com.ai.da.common.config;
|
||||
|
||||
import com.ai.da.common.utils.SendEmailUtil;
|
||||
import com.ai.da.mapper.AccountMapper;
|
||||
import com.ai.da.mapper.entity.Account;
|
||||
import com.ai.da.mapper.primary.AccountMapper;
|
||||
import com.ai.da.mapper.primary.TrialOrderMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@@ -17,9 +29,12 @@ public class MyTaskScheduler {
|
||||
@Resource
|
||||
private AccountMapper accountMapper;
|
||||
|
||||
@Resource
|
||||
private TrialOrderMapper trialOrderMapper;
|
||||
|
||||
// 定时任务,每十五天执行一次
|
||||
// @Scheduled(cron = "0 0 0 ? * MON")
|
||||
@Scheduled(cron = "0 0 0 */15 * ?")
|
||||
// @Scheduled(cron = "0 0 0 */15 * ?")
|
||||
public void checkExpiry() {
|
||||
// 检测正式用户是否快要过期
|
||||
QueryWrapper<Account> qw = new QueryWrapper<>();
|
||||
@@ -53,4 +68,70 @@ public class MyTaskScheduler {
|
||||
}
|
||||
}
|
||||
}
|
||||
// @Scheduled(cron = "0 0 8 * * ?")
|
||||
public void sendTrialOrderExcelToManagements() {
|
||||
// 获取前一天日期
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
|
||||
// 查询前一天的试用订单
|
||||
QueryWrapper<TrialOrder> qw = new QueryWrapper<>();
|
||||
qw.lambda().between(TrialOrder::getCreateTime, yesterday.atStartOfDay(), yesterday.atTime(23, 59, 59));
|
||||
List<TrialOrder> trialOrders = trialOrderMapper.selectList(qw);
|
||||
|
||||
if (!trialOrders.isEmpty()) {
|
||||
// 创建Excel工作簿
|
||||
try (Workbook workbook = new XSSFWorkbook()) {
|
||||
// 创建工作表
|
||||
Sheet sheet = workbook.createSheet("Trial Orders");
|
||||
// 创建标题行
|
||||
Row headerRow = sheet.createRow(0);
|
||||
headerRow.createCell(0).setCellValue("ID");
|
||||
headerRow.createCell(1).setCellValue("Title");
|
||||
headerRow.createCell(2).setCellValue("Surname");
|
||||
headerRow.createCell(3).setCellValue("Given Name");
|
||||
headerRow.createCell(4).setCellValue("Username");
|
||||
headerRow.createCell(5).setCellValue("Email");
|
||||
headerRow.createCell(6).setCellValue("Country");
|
||||
headerRow.createCell(7).setCellValue("Occupation");
|
||||
headerRow.createCell(8).setCellValue("Create Time");
|
||||
headerRow.createCell(9).setCellValue("Update Time");
|
||||
headerRow.createCell(10).setCellValue("Status");
|
||||
|
||||
// 填充数据
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
int rowNum = 1;
|
||||
for (TrialOrder trialOrder : trialOrders) {
|
||||
Row row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue(trialOrder.getId());
|
||||
row.createCell(1).setCellValue(trialOrder.getTitle());
|
||||
row.createCell(2).setCellValue(trialOrder.getSurname());
|
||||
row.createCell(3).setCellValue(trialOrder.getGivenName());
|
||||
row.createCell(4).setCellValue(trialOrder.getUserName());
|
||||
row.createCell(5).setCellValue(trialOrder.getEmail());
|
||||
row.createCell(6).setCellValue(trialOrder.getCountry());
|
||||
row.createCell(7).setCellValue(trialOrder.getOccupation());
|
||||
row.createCell(8).setCellValue(trialOrder.getCreateTime().format(formatter));
|
||||
row.createCell(9).setCellValue(trialOrder.getUpdateTime().format(formatter));
|
||||
row.createCell(10).setCellValue(trialOrder.getStatus());
|
||||
}
|
||||
|
||||
// 保存Excel文件
|
||||
String fileName = "trialOrder-" + yesterday.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
|
||||
try (FileOutputStream fileOut = new FileOutputStream(fileName)) {
|
||||
workbook.write(fileOut);
|
||||
SendEmailUtil.sendExcelEmail("1023316923@qq.com", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
SendEmailUtil.sendExcelEmail("calvinwong@aidlab.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
SendEmailUtil.sendExcelEmail("kaicpang.pang@connect.polyu.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
SendEmailUtil.sendExcelEmail("kimwong@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
SendEmailUtil.sendNoExcelEmail("1023316923@qq.com", null);
|
||||
SendEmailUtil.sendNoExcelEmail("calvinwong@aidlab.hk", null);
|
||||
SendEmailUtil.sendNoExcelEmail("kaicpang.pang@connect.polyu.hk", null);
|
||||
SendEmailUtil.sendNoExcelEmail("kimwong@code-create.com.hk", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
package com.ai.da.common.config.mybatis.plus;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@MapperScan("com.ai.da.mapper")
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
package com.ai.da.common.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
@Bean(name = "primaryMybatisPlusInterceptor")
|
||||
public MybatisPlusInterceptor primaryMybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
@Bean(name = "secondaryMybatisPlusInterceptor")
|
||||
public MybatisPlusInterceptor secondaryMybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
51
src/main/java/com/ai/da/common/config/PayPalClient.java
Normal file
51
src/main/java/com/ai/da/common/config/PayPalClient.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.ai.da.common.config;
|
||||
|
||||
import com.paypal.core.PayPalEnvironment;
|
||||
import com.paypal.core.PayPalHttpClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
@PropertySource("classpath:paypal-sandbox.properties")
|
||||
public class PayPalClient {
|
||||
|
||||
public PayPalHttpClient client(String mode, String clientId, String clientSecret) {
|
||||
log.info("mode={}, clientId={}, clientSecret={}", mode, clientId, clientSecret);
|
||||
PayPalEnvironment environment = mode.equals("live") ? new PayPalEnvironment.Live(clientId, clientSecret) : new PayPalEnvironment.Sandbox(clientId, clientSecret);
|
||||
return new PayPalHttpClient(environment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jo
|
||||
* @param pre
|
||||
* @return
|
||||
*/
|
||||
/*public String prettyPrint(JSONObject jo, String pre) {
|
||||
Iterator<?> keys = jo.keys();
|
||||
StringBuilder pretty = new StringBuilder();
|
||||
while (keys.hasNext()) {
|
||||
String key = (String) keys.next();
|
||||
pretty.append(String.format("%s%s: ", pre, StringUtils.capitalize(key)));
|
||||
if (jo.get(key) instanceof JSONObject) {
|
||||
pretty.append(prettyPrint(jo.getJSONObject(key), pre + "\t"));
|
||||
} else if (jo.get(key) instanceof JSONArray) {
|
||||
int sno = 1;
|
||||
for (Object jsonObject : jo.getJSONArray(key)) {
|
||||
pretty.append(String.format("\n%s\t%d:\n", pre, sno++));
|
||||
pretty.append(prettyPrint((JSONObject) jsonObject, pre + "\t\t"));
|
||||
}
|
||||
} else {
|
||||
pretty.append(String.format("%s\n", jo.getString(key)));
|
||||
}
|
||||
}
|
||||
return pretty.toString();
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.ai.da.common.config;
|
||||
|
||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
|
||||
import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
@MapperScan(basePackages = "com.ai.da.mapper.primary", sqlSessionFactoryRef = "primarySqlSessionFactory")
|
||||
public class PrimaryDataSourceConfig {
|
||||
@Autowired
|
||||
private MybatisPlusProperties mybatisPlusProperties;
|
||||
|
||||
@Primary
|
||||
@Bean(name = "primaryDataSource")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.primary")
|
||||
public DataSource dataSource() {
|
||||
return DataSourceBuilder.create().build();
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean(name = "primarySqlSessionFactory")
|
||||
public SqlSessionFactory sqlSessionFactory(
|
||||
@Qualifier("primaryDataSource") DataSource dataSource,
|
||||
ApplicationContext applicationContext,
|
||||
@Qualifier("primaryMybatisPlusInterceptor") MybatisPlusInterceptor mybatisPlusInterceptor) throws Exception {
|
||||
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
|
||||
bean.setDataSource(dataSource);
|
||||
bean.setMapperLocations(applicationContext.getResources("classpath:mapper/primary/*.xml"));
|
||||
// 设置 MyBatis Plus 全局配置
|
||||
GlobalConfig globalConfig = this.mybatisPlusProperties.getGlobalConfig();
|
||||
if (globalConfig != null) {
|
||||
bean.setGlobalConfig(globalConfig);
|
||||
}
|
||||
bean.setPlugins(mybatisPlusInterceptor);
|
||||
return bean.getObject();
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean(name = "primarySqlSessionTemplate")
|
||||
public SqlSessionTemplate sqlSessionTemplate(
|
||||
@Qualifier("primarySqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
|
||||
return new SqlSessionTemplate(sqlSessionFactory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.ai.da.common.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
@MapperScan(basePackages = "com.ai.da.mapper.secondary", sqlSessionFactoryRef = "secondarySqlSessionFactory")
|
||||
public class SecondaryDataSourceConfig {
|
||||
|
||||
@Bean(name = "secondaryDataSource")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.secondary")
|
||||
public DataSource dataSource() {
|
||||
return DataSourceBuilder.create().build();
|
||||
}
|
||||
|
||||
@Bean(name = "secondarySqlSessionFactory")
|
||||
public SqlSessionFactory sqlSessionFactory(
|
||||
@Qualifier("secondaryDataSource") DataSource dataSource,
|
||||
ApplicationContext applicationContext,
|
||||
@Qualifier("secondaryMybatisPlusInterceptor") MybatisPlusInterceptor mybatisPlusInterceptor) throws Exception {
|
||||
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
|
||||
// SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
|
||||
bean.setDataSource(dataSource);
|
||||
bean.setMapperLocations(applicationContext.getResources("classpath:mapper/secondary/*.xml"));
|
||||
bean.setPlugins(mybatisPlusInterceptor);
|
||||
return bean.getObject();
|
||||
}
|
||||
|
||||
@Bean(name = "secondarySqlSessionTemplate")
|
||||
public SqlSessionTemplate sqlSessionTemplate(
|
||||
@Qualifier("secondarySqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
|
||||
return new SqlSessionTemplate(sqlSessionFactory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.ai.da.common.config.mybatis.plus;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface CommonMapper<T> extends BaseMapper<T> {
|
||||
|
||||
IPage<T> voPage(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
|
||||
}
|
||||
package com.ai.da.common.config.mybatis.plus;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface CommonMapper<T> extends BaseMapper<T> {
|
||||
|
||||
IPage<T> voPage(IPage<T> page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
package com.ai.da.common.config.mybatis.plus;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ai.da.common.response.PageResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class CommonServiceImpl<M extends CommonMapper<T>, T, E> extends ServiceImpl<M, T> {
|
||||
|
||||
public PageResponse<E> voPage(QueryCriteria<T, E> criteria) {
|
||||
IPage<T> tPage = baseMapper.voPage(new Page<>(criteria.getPage(), criteria.getLimit()), criteria.buildWrapper());
|
||||
if (criteria.getMapper() != null && tPage != null && CollUtil.isNotEmpty(tPage.getRecords())) {
|
||||
List<E> convert = convert(tPage, criteria.getMapper(), criteria);
|
||||
Response<List<E>> response = Response.success(convert);
|
||||
PageResponse<E> pageResponse = new PageResponse<>(response, tPage.getCurrent(), tPage.getSize(), tPage.getTotal(), tPage.getPages());
|
||||
if (criteria.getPeekAllAfter() != null) {
|
||||
Consumer<List<E>> peekAllAfter = criteria.getPeekAllAfter();
|
||||
peekAllAfter.accept(pageResponse.getData());
|
||||
}
|
||||
return pageResponse;
|
||||
}
|
||||
PageResponse<E> pageResponse = new PageResponse<>(null, criteria.getPage(), criteria.getLimit(), 0, 0);
|
||||
if (criteria.getPeekAllAfter() != null) {
|
||||
Consumer<List<E>> peekAllAfter = criteria.getPeekAllAfter();
|
||||
peekAllAfter.accept(pageResponse.getData());
|
||||
}
|
||||
return pageResponse;
|
||||
}
|
||||
|
||||
List<E> convert(IPage<T> page, Function<? super T, E> mapper, QueryCriteria<T, E> criteria) {
|
||||
if (criteria.getPeekBefore() != null && criteria.getPeekAfter() != null) {
|
||||
return page.getRecords().stream().peek(criteria.getPeekBefore()).map(mapper).peek(criteria.getPeekAfter()).collect(Collectors.toList());
|
||||
} else if (criteria.getPeekBefore() != null && criteria.getPeekAfter() == null) {
|
||||
return page.getRecords().stream().peek(criteria.getPeekBefore()).map(mapper).collect(Collectors.toList());
|
||||
} else if (criteria.getPeekBefore() == null && criteria.getPeekAfter() != null) {
|
||||
return page.getRecords().stream().map(mapper).peek(criteria.getPeekAfter()).collect(Collectors.toList());
|
||||
}
|
||||
return page.getRecords().stream().map(mapper).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
package com.ai.da.common.config.mybatis.plus;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ai.da.common.response.PageResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class CommonServiceImpl<M extends CommonMapper<T>, T, E> extends ServiceImpl<M, T> {
|
||||
|
||||
public PageResponse<E> voPage(QueryCriteria<T, E> criteria) {
|
||||
IPage<T> tPage = baseMapper.voPage(new Page<>(criteria.getPage(), criteria.getLimit()), criteria.buildWrapper());
|
||||
if (criteria.getMapper() != null && tPage != null && CollUtil.isNotEmpty(tPage.getRecords())) {
|
||||
List<E> convert = convert(tPage, criteria.getMapper(), criteria);
|
||||
Response<List<E>> response = Response.success(convert);
|
||||
PageResponse<E> pageResponse = new PageResponse<>(response, tPage.getCurrent(), tPage.getSize(), tPage.getTotal(), tPage.getPages());
|
||||
if (criteria.getPeekAllAfter() != null) {
|
||||
Consumer<List<E>> peekAllAfter = criteria.getPeekAllAfter();
|
||||
peekAllAfter.accept(pageResponse.getData());
|
||||
}
|
||||
return pageResponse;
|
||||
}
|
||||
PageResponse<E> pageResponse = new PageResponse<>(null, criteria.getPage(), criteria.getLimit(), 0, 0);
|
||||
if (criteria.getPeekAllAfter() != null) {
|
||||
Consumer<List<E>> peekAllAfter = criteria.getPeekAllAfter();
|
||||
peekAllAfter.accept(pageResponse.getData());
|
||||
}
|
||||
return pageResponse;
|
||||
}
|
||||
|
||||
List<E> convert(IPage<T> page, Function<? super T, E> mapper, QueryCriteria<T, E> criteria) {
|
||||
if (criteria.getPeekBefore() != null && criteria.getPeekAfter() != null) {
|
||||
return page.getRecords().stream().peek(criteria.getPeekBefore()).map(mapper).peek(criteria.getPeekAfter()).collect(Collectors.toList());
|
||||
} else if (criteria.getPeekBefore() != null && criteria.getPeekAfter() == null) {
|
||||
return page.getRecords().stream().peek(criteria.getPeekBefore()).map(mapper).collect(Collectors.toList());
|
||||
} else if (criteria.getPeekBefore() == null && criteria.getPeekAfter() != null) {
|
||||
return page.getRecords().stream().map(mapper).peek(criteria.getPeekAfter()).collect(Collectors.toList());
|
||||
}
|
||||
return page.getRecords().stream().map(mapper).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package com.ai.da.common.config.mybatis.plus;
|
||||
|
||||
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
||||
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class CustomerSqlInjector extends DefaultSqlInjector {
|
||||
|
||||
@Override
|
||||
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
|
||||
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
|
||||
methodList.add(new SelectVoPage());
|
||||
return methodList;
|
||||
}
|
||||
}
|
||||
package com.ai.da.common.config.mybatis.plus;
|
||||
|
||||
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
||||
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class CustomerSqlInjector extends DefaultSqlInjector {
|
||||
|
||||
@Override
|
||||
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
|
||||
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
|
||||
methodList.add(new SelectVoPage());
|
||||
return methodList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,85 +1,85 @@
|
||||
package com.ai.da.common.config.mybatis.plus;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ai.da.common.annotation.Condition;
|
||||
import com.ai.da.common.annotation.Order;
|
||||
import com.ai.da.common.enums.ConditionType;
|
||||
import com.ai.da.common.utils.ConvertUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author: dangweijian
|
||||
* @description:
|
||||
* @create: 2020-09-14 15:47
|
||||
**/
|
||||
@Data
|
||||
@Slf4j
|
||||
public abstract class QueryCriteria<T, E> {
|
||||
|
||||
private long page = 1;
|
||||
private long limit = 10;
|
||||
private Function<T, E> mapper;
|
||||
private Consumer<QueryWrapper<T>> appendWrapper;
|
||||
private Consumer<T> peekBefore;
|
||||
private Consumer<E> peekAfter;
|
||||
private Consumer<List<E>> peekAllAfter;
|
||||
|
||||
public QueryCriteria(Function<T, E> mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public QueryWrapper<T> buildWrapper() {
|
||||
QueryWrapper<T> wrapper = new QueryWrapper<>();
|
||||
Field[] fields = this.getClass().getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
Condition condition = field.getAnnotation(Condition.class);
|
||||
if (condition != null) {
|
||||
field.setAccessible(true);
|
||||
Object value = null;
|
||||
try {
|
||||
value = field.get(this);
|
||||
} catch (IllegalAccessException e) {
|
||||
log.warn("reflection anomaly!");
|
||||
}
|
||||
if (!StrUtil.isEmptyIfStr(value)) {
|
||||
switch (condition.type()) {
|
||||
case EQ:
|
||||
wrapper.eq(ConvertUtil.humpToLine2(field.getName()), value);
|
||||
break;
|
||||
case LIKE:
|
||||
wrapper.like(ConvertUtil.humpToLine2(field.getName()), value);
|
||||
case BETWEEN:
|
||||
if (value instanceof Collection && ((List) value).size() >= 2) {
|
||||
wrapper.between(ConvertUtil.humpToLine2(field.getName()), ((List) value).get(0), ((List) value).get(1));
|
||||
}
|
||||
default:
|
||||
}
|
||||
} else if (condition.isNull()) {
|
||||
wrapper.isNull(ConvertUtil.humpToLine2(field.getName()));
|
||||
}
|
||||
}
|
||||
Order order = field.getAnnotation(Order.class);
|
||||
if (order != null) {
|
||||
if (!StrUtil.isEmptyIfStr(order.order())) {
|
||||
switch (order.order()) {
|
||||
case DESC:
|
||||
wrapper.orderByDesc(ConvertUtil.humpToLine2(field.getName()));
|
||||
break;
|
||||
case ASC:
|
||||
wrapper.orderByAsc(ConvertUtil.humpToLine2(field.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
wrapper.func(this.getAppendWrapper() != null, this.getAppendWrapper());
|
||||
return wrapper;
|
||||
}
|
||||
}
|
||||
package com.ai.da.common.config.mybatis.plus;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ai.da.common.annotation.Condition;
|
||||
import com.ai.da.common.annotation.Order;
|
||||
import com.ai.da.common.enums.ConditionType;
|
||||
import com.ai.da.common.utils.ConvertUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author: dangweijian
|
||||
* @description:
|
||||
* @create: 2020-09-14 15:47
|
||||
**/
|
||||
@Data
|
||||
@Slf4j
|
||||
public abstract class QueryCriteria<T, E> {
|
||||
|
||||
private long page = 1;
|
||||
private long limit = 10;
|
||||
private Function<T, E> mapper;
|
||||
private Consumer<QueryWrapper<T>> appendWrapper;
|
||||
private Consumer<T> peekBefore;
|
||||
private Consumer<E> peekAfter;
|
||||
private Consumer<List<E>> peekAllAfter;
|
||||
|
||||
public QueryCriteria(Function<T, E> mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public QueryWrapper<T> buildWrapper() {
|
||||
QueryWrapper<T> wrapper = new QueryWrapper<>();
|
||||
Field[] fields = this.getClass().getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
Condition condition = field.getAnnotation(Condition.class);
|
||||
if (condition != null) {
|
||||
field.setAccessible(true);
|
||||
Object value = null;
|
||||
try {
|
||||
value = field.get(this);
|
||||
} catch (IllegalAccessException e) {
|
||||
log.warn("reflection anomaly!");
|
||||
}
|
||||
if (!StrUtil.isEmptyIfStr(value)) {
|
||||
switch (condition.type()) {
|
||||
case EQ:
|
||||
wrapper.eq(ConvertUtil.humpToLine2(field.getName()), value);
|
||||
break;
|
||||
case LIKE:
|
||||
wrapper.like(ConvertUtil.humpToLine2(field.getName()), value);
|
||||
case BETWEEN:
|
||||
if (value instanceof Collection && ((List) value).size() >= 2) {
|
||||
wrapper.between(ConvertUtil.humpToLine2(field.getName()), ((List) value).get(0), ((List) value).get(1));
|
||||
}
|
||||
default:
|
||||
}
|
||||
} else if (condition.isNull()) {
|
||||
wrapper.isNull(ConvertUtil.humpToLine2(field.getName()));
|
||||
}
|
||||
}
|
||||
Order order = field.getAnnotation(Order.class);
|
||||
if (order != null) {
|
||||
if (!StrUtil.isEmptyIfStr(order.order())) {
|
||||
switch (order.order()) {
|
||||
case DESC:
|
||||
wrapper.orderByDesc(ConvertUtil.humpToLine2(field.getName()));
|
||||
break;
|
||||
case ASC:
|
||||
wrapper.orderByAsc(ConvertUtil.humpToLine2(field.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
wrapper.func(this.getAppendWrapper() != null, this.getAppendWrapper());
|
||||
return wrapper;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
package com.ai.da.common.config.mybatis.plus;
|
||||
|
||||
import com.baomidou.mybatisplus.core.enums.SqlMethod;
|
||||
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
import org.apache.ibatis.mapping.SqlSource;
|
||||
|
||||
public class SelectVoPage extends AbstractMethod {
|
||||
|
||||
private static final String MAPPER_METHOD = "voPage";
|
||||
|
||||
public SelectVoPage() {
|
||||
super(MAPPER_METHOD);
|
||||
}
|
||||
|
||||
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
|
||||
String sql = String.format(SqlMethod.SELECT_PAGE.getSql(), this.sqlFirst(), this.sqlSelectColumns(tableInfo, true), tableInfo.getTableName(), this.sqlWhereEntityWrapper(true, tableInfo), this.sqlOrderBy(tableInfo), this.sqlComment());
|
||||
SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sql, modelClass);
|
||||
return this.addSelectMappedStatementForTable(mapperClass, MAPPER_METHOD, sqlSource, tableInfo);
|
||||
}
|
||||
}
|
||||
package com.ai.da.common.config.mybatis.plus;
|
||||
|
||||
import com.baomidou.mybatisplus.core.enums.SqlMethod;
|
||||
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
import org.apache.ibatis.mapping.SqlSource;
|
||||
|
||||
public class SelectVoPage extends AbstractMethod {
|
||||
|
||||
private static final String MAPPER_METHOD = "voPage";
|
||||
|
||||
public SelectVoPage() {
|
||||
super(MAPPER_METHOD);
|
||||
}
|
||||
|
||||
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
|
||||
String sql = String.format(SqlMethod.SELECT_PAGE.getSql(), this.sqlFirst(), this.sqlSelectColumns(tableInfo, true), tableInfo.getTableName(), this.sqlWhereEntityWrapper(true, tableInfo), this.sqlOrderBy(tableInfo), this.sqlComment());
|
||||
SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sql, modelClass);
|
||||
return this.addSelectMappedStatementForTable(mapperClass, MAPPER_METHOD, sqlSource, tableInfo);
|
||||
}
|
||||
}
|
||||
|
||||
14
src/main/java/com/ai/da/common/constant/CommonConstant.java
Normal file
14
src/main/java/com/ai/da/common/constant/CommonConstant.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.ai.da.common.constant;
|
||||
|
||||
public class CommonConstant {
|
||||
// 单位 秒 10分钟过期
|
||||
// public static final Long TASK_EXPIRE_TIME = 24 * 60 * 60L;
|
||||
public static final Long TASK_EXPIRE_TIME = 10 * 60L;
|
||||
// 单位 秒 两天过期
|
||||
public static final Long CREDITS_EXPIRE_TIME = 2 * 24 * 60 * 60L;
|
||||
// 单位 分钟
|
||||
public static final Integer MINIO_IMAGE_EXPIRE_TIME = 24 * 60;
|
||||
// 单位 秒 一天过期 in redis
|
||||
public static final Long GENERATE_RESULT_EXPIRE_TIME = 24 * 60 * 60L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package com.ai.da.common.constant;
|
||||
|
||||
public class PayPalCheckoutConstant {
|
||||
|
||||
public static final String CAPTURE = "CAPTURE";
|
||||
/**
|
||||
* 该标签将覆盖PayPal网站上PayPal帐户中的公司名称
|
||||
*/
|
||||
public static final String BRANDNAME = "AIDA";
|
||||
/**
|
||||
* LOGIN。当客户单击PayPal Checkout时,客户将被重定向到页面以登录PayPal并批准付款。
|
||||
* BILLING。当客户单击PayPal Checkout时,客户将被重定向到一个页面,以输入信用卡或借记卡以及完成购买所需的其他相关账单信息
|
||||
* NO_PREFERENCE。当客户单击“ PayPal Checkout”时,将根据其先前的交互方式将其重定向到页面以登录PayPal并批准付款,或重定向至页面以输入信用卡或借记卡以及完成购买所需的其他相关账单信息使用PayPal。
|
||||
* 默认值:NO_PREFERENCE
|
||||
*/
|
||||
public static final String LANDINGPAGE = "NO_PREFERENCE";
|
||||
/**
|
||||
* CONTINUE。将客户重定向到PayPal付款页面后,将出现“ 继续”按钮。当结帐流程启动时最终金额未知时,请使用此选项,并且您想将客户重定向到商家页面而不处理付款。
|
||||
* PAY_NOW。将客户重定向到PayPal付款页面后,出现“ 立即付款”按钮。当启动结帐时知道最终金额并且您要在客户单击“ 立即付款”时立即处理付款时,请使用此选项。
|
||||
*/
|
||||
public static final String USERACTION = "PAY_NOW";
|
||||
/**
|
||||
* GET_FROM_FILE。使用贝宝网站上客户提供的送货地址。
|
||||
* NO_SHIPPING。从PayPal网站编辑送货地址。推荐用于数字商品
|
||||
* SET_PROVIDED_ADDRESS。使用商家提供的地址。客户无法在PayPal网站上更改此地址
|
||||
*/
|
||||
// public static final String SHIPPINGPREFERENCE = "SET_PROVIDED_ADDRESS";
|
||||
public static final String SHIPPINGPREFERENCE = "NO_SHIPPING";
|
||||
/**
|
||||
* 交易异常
|
||||
*/
|
||||
public static final String FAILURE = "failure";
|
||||
/**
|
||||
* 交易成功
|
||||
*/
|
||||
public static final String SUCCESS = "success";
|
||||
|
||||
/**
|
||||
* ipn回调。支付成功
|
||||
*/
|
||||
public static final String PAYMENT_STATUS_COMPLETED = "Completed";
|
||||
/**
|
||||
* ipn回调。退款成功
|
||||
*/
|
||||
public static final String PAYMENT_STATUS_REFUNDED = "Refunded";
|
||||
/**
|
||||
* ipn回调。待定
|
||||
*/
|
||||
public static final String PAYMENT_STATUS_PENDING = "Pending";
|
||||
|
||||
/**
|
||||
* ipn回调,付款因退款或其他类型的冲销而被冲销。资金已从您的帐户余额中删除,并退还给买方
|
||||
*/
|
||||
public static final String PAYMENT_STATUS_REVERSED = "Reversed";
|
||||
|
||||
/**
|
||||
* ipn回调, 撤销已被取消。例如,您赢得了与客户的纠纷,并且撤回的交易资金已退还给您
|
||||
*/
|
||||
public static final String PAYMENT_STATUS_CANCELED_REVERSAL = "Canceled_Reversal";
|
||||
|
||||
/**
|
||||
* ipn回调,付款被拒绝
|
||||
*/
|
||||
public static final String PAYMENT_STATUS_DENIED = "Denied";
|
||||
|
||||
/**
|
||||
* ipn回调, 此授权已过期,无法捕获
|
||||
*/
|
||||
public static final String PAYMENT_STATUS_EXPIRED = "Expired";
|
||||
|
||||
/**
|
||||
* ipn回调, 德国的ELV付款是通过Express Checkout进行的
|
||||
*/
|
||||
public static final String PAYMENT_STATUS_CREATED = "Created";
|
||||
|
||||
/**
|
||||
* ipn回调, 付款失败。仅当付款是通过您客户的银行帐户进行的。
|
||||
*/
|
||||
public static final String PAYMENT_STATUS_FAILED = "Failed";
|
||||
|
||||
/**
|
||||
* ipn回调,付款已被接受
|
||||
*/
|
||||
public static final String PAYMENT_STATUS_PROCESSED = "Processed";
|
||||
|
||||
/**
|
||||
* ipn回调,此授权已失效
|
||||
*/
|
||||
public static final String PAYMENT_STATUS_VOIDED = "Voided";
|
||||
|
||||
//订单状态
|
||||
/**
|
||||
* 1、支付完成;捕获的付款的资金已记入收款人的PayPal帐户
|
||||
* 2、退款完成;该交易的资金已记入客户的帐户
|
||||
*/
|
||||
public static final String STATE_COMPLETED = "COMPLETED";
|
||||
/**
|
||||
* 部分退款;少于所捕获付款金额的金额已部分退还给付款人。
|
||||
*/
|
||||
public static final String STATE_PARTIALLY_REFUNDED = "PARTIALLY_REFUNDED";
|
||||
|
||||
|
||||
/**
|
||||
* 1、支付待定;捕获的付款资金尚未记入收款人的PayPal帐户。有关更多信息请参见status.details。
|
||||
* 2、退款待定;有关更多信息,请参见status_details.reason。
|
||||
*/
|
||||
/**
|
||||
* 支付待定:
|
||||
* capture_status_details
|
||||
* reason 枚举
|
||||
* 捕获的付款状态为PENDING或DENIED的原因。可能的值为:
|
||||
* BUYER_COMPLAINT。付款人与贝宝(PayPal)对此捕获的付款提出了争议。
|
||||
* CHARGEBACK。响应于付款人与用于支付此已捕获付款的金融工具的发行人对此已捕获的付款提出异议,已收回的资金被撤回。
|
||||
* ECHECK。由尚未结清的电子支票支付的付款人。
|
||||
* INTERNATIONAL_WITHDRAWAL。访问您的在线帐户。在您的“帐户概览”中,接受并拒绝此笔付款。
|
||||
* OTHER。无法提供其他特定原因。有关此笔付款的更多信息,请在线访问您的帐户或联系PayPal。
|
||||
* PENDING_REVIEW。捕获的付款正在等待人工审核。
|
||||
*(手动收取)RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION。收款人尚未为其帐户设置适当的接收首选项。有关如何接受或拒绝此付款的更多信息,请在线访问您的帐户。通常在某些情况下提供此原因,例如,当所捕获付款的货币与收款人的主要持有货币不同时。
|
||||
* REFUNDED。收回的资金已退还。
|
||||
* TRANSACTION_APPROVED_AWAITING_FUNDING。付款人必须将这笔付款的资金汇出。通常,此代码适用于手动EFT。
|
||||
* UNILATERAL。收款人没有PayPal帐户。
|
||||
* VERIFICATION_REQUIRED。收款人的PayPal帐户未通过验证。
|
||||
*/
|
||||
/**
|
||||
* 退款待定
|
||||
* 退款具有“PENDING”或“FAILED”状态的原因。 可能的值为:
|
||||
* ECHECK。客户的帐户通过尚未结清的eCheck进行注资。
|
||||
*/
|
||||
public static final String STATE_PENDING = "PENDING";
|
||||
/**
|
||||
* 退款;大于或等于此捕获的付款金额的金额已退还给付款人
|
||||
*/
|
||||
public static final String STATE_REFUNDED = "REFUNDED";
|
||||
/**
|
||||
* 支付拒绝
|
||||
*/
|
||||
public static final String STATE_DENIED = "DENIED";
|
||||
/**
|
||||
* 退款失败
|
||||
*/
|
||||
public static final String STATE_FAILED = "FAILED";
|
||||
|
||||
/**
|
||||
* 争议状态
|
||||
*/
|
||||
public static final String BUYER_COMPLAINT = "BUYER_COMPLAINT";
|
||||
|
||||
/**
|
||||
* 沙箱环境请求网关地址
|
||||
*/
|
||||
public static final String SANDBOX = "https://api.sandbox.paypal.com";
|
||||
/**
|
||||
* 生产环境请求网关地址
|
||||
*/
|
||||
public static final String LIVE = "https://api.paypal.com";
|
||||
/**
|
||||
* 添加物流信息请求路径
|
||||
*/
|
||||
public static final String ADD_TRACK_URL = "/v1/shipping/trackers-batch";
|
||||
|
||||
/**
|
||||
* 修改物流信息请求路径
|
||||
*/
|
||||
public static final String UPDATE_TRACK_URL = "/v1/shipping/trackers/";
|
||||
|
||||
public final static String CMD_NOTIFY_VALIDATE = "_notify-validate";
|
||||
|
||||
public final static String PAYPAL_TOKEN_KEY = "PayPalAccessToken";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
31
src/main/java/com/ai/da/common/enums/CreditsEventsEnum.java
Normal file
31
src/main/java/com/ai/da/common/enums/CreditsEventsEnum.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.ai.da.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum CreditsEventsEnum {
|
||||
|
||||
PRICE("price","6"),
|
||||
|
||||
BUY_CREDITS("Buy Credits","600"),
|
||||
|
||||
INIT("init", "500"),
|
||||
|
||||
DAILY_CHECKIN("Daily Check-In", "20"),
|
||||
|
||||
SOCIAL_MEDIA_SHARING("Social Media Sharing","20"),
|
||||
|
||||
// SUPER_RESOLUTION("Super Resolution","300"),
|
||||
SUPER_RESOLUTION("Super Resolution","5"),
|
||||
|
||||
OTHER("Other","10");
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 对应事件需要消耗or获得的积分
|
||||
*/
|
||||
private String value;
|
||||
}
|
||||
40
src/main/java/com/ai/da/common/enums/CurrencyCodesEnum.java
Normal file
40
src/main/java/com/ai/da/common/enums/CurrencyCodesEnum.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.ai.da.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum CurrencyCodesEnum {
|
||||
|
||||
AUSTRALIAN_DOLLAR("AUD"),
|
||||
BRAZILIAN_REAL("BRL"),
|
||||
CANADIAN_DOLLAR("CAD"),
|
||||
CHINESE_RENMENBI("CNY"),
|
||||
CZECH_KORUNA("CZK"),
|
||||
DANISH_KRONE("DKK"),
|
||||
EURO("EUR"),
|
||||
HONG_KONG_DOLLAR("HKD"),
|
||||
HUNGARIAN_FORINT("HUF"),
|
||||
ISRAELI_NEW_SHEKEL("ILS"),
|
||||
JAPANESE_YEN("JPY"),
|
||||
MALAYSIAN_RINGGIT("MYR"),
|
||||
MEXICAN_PESO("MXN"),
|
||||
NEW_TAIWAN_DOLLAR("TWD"),
|
||||
NEW_ZEALAND_DOLLAR("NZD"),
|
||||
NORWEGIAN_KRONE("NOK"),
|
||||
PHILIPPINE_PESO("PHP"),
|
||||
POLISH_ZLOTY("PLN"),
|
||||
POUND_STERLING("GBP"),
|
||||
RUSSIAN_RUBLE("RUB"),
|
||||
SINGAPORE_DOLLAR("SGD"),
|
||||
SWEDISH_KRONA("SEK"),
|
||||
SWISS_FRANC("CHF"),
|
||||
THAI_BAHT("THB"),
|
||||
UNITED_STATES_DOLLAR("USD");
|
||||
|
||||
private String code;
|
||||
|
||||
CurrencyCodesEnum(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -20,15 +20,15 @@ public enum CurrentDesignPictureTypeEnum {
|
||||
/**
|
||||
* USER_LIBRARY
|
||||
*/
|
||||
USER_LIBRARY(2, "userLibrary"),
|
||||
// USER_LIBRARY(2, "userLibrary"),
|
||||
/**
|
||||
* SYS_FILE
|
||||
*/
|
||||
SYS_FILE(3, "sysFile"),
|
||||
SYS_FILE(2, "sysFile"),
|
||||
/**
|
||||
* noPIN
|
||||
*/
|
||||
NO_PIN(4, "noPIN");
|
||||
NO_PIN(3, "noPIN");
|
||||
|
||||
private Integer code;
|
||||
private String desc;
|
||||
|
||||
@@ -12,26 +12,33 @@ public enum GenerateModeEnum {
|
||||
/**
|
||||
* 通过文本生成
|
||||
*/
|
||||
TEXT(1, "text"),
|
||||
TEXT(1, "text","txt2img"),
|
||||
|
||||
/**
|
||||
* 通过图片生成
|
||||
*/
|
||||
IMAGE(2, "image"),
|
||||
IMAGE(2, "image", "img2img"),
|
||||
|
||||
/**
|
||||
* 通过文本和图片生成
|
||||
*/
|
||||
TEXT_IMAGE(2, "text-image");
|
||||
TEXT_IMAGE(2, "text-image","img2img");
|
||||
|
||||
private Integer code;
|
||||
private String value;
|
||||
private String type;
|
||||
|
||||
GenerateModeEnum(int code, String value) {
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
GenerateModeEnum(Integer code, String value, String type) {
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static List<String> getGenerateModeList(){
|
||||
return Stream.of(TEXT,IMAGE,TEXT_IMAGE).map(GenerateModeEnum::getValue).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public enum OrderStatusEnum {
|
||||
/**
|
||||
* 已关闭
|
||||
*/
|
||||
CLOSED("超时已关闭"),
|
||||
TIMEOUT_CLOSED("超时已关闭"),
|
||||
|
||||
/**
|
||||
* 已取消
|
||||
@@ -40,7 +40,12 @@ public enum OrderStatusEnum {
|
||||
/**
|
||||
* 退款异常
|
||||
*/
|
||||
REFUND_ABNORMAL("退款异常");
|
||||
REFUND_ABNORMAL("退款异常"),
|
||||
|
||||
/**
|
||||
* paypal订单状态为 APPROVED
|
||||
*/
|
||||
ORDER_PROCESSING("订单处理中");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ai.da.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PayPalOrderStatusEnum {
|
||||
|
||||
// The order was created with the specified context.
|
||||
// 订单已创建并具有指定的上下文。
|
||||
CREATED("CREATED"),
|
||||
// The order was saved and persisted. The order status continues to be in progress until a capture is made with final_capture = true for all purchase units within the order.
|
||||
// 订单已保存并持久化。订单状态仍处于进行中,直到对订单中的所有购买单元进行了 final_capture = true 的捕获为止
|
||||
SAVED("SAVED"),
|
||||
// The customer approved the payment through the PayPal wallet or another form of guest or unbranded payment. For example, a card, bank account, or so on.
|
||||
// 客户通过PayPal钱包或其他形式的游客或非品牌支付批准了付款。例如,信用卡、银行账户等。
|
||||
APPROVED("APPROVED"),
|
||||
// All purchase units in the order are voided.
|
||||
// 订单中的所有购买单元都已作废。
|
||||
VOIDED("VOIDED"),
|
||||
// The payment was authorized or the authorized payment was captured for the order.
|
||||
// 订单的支付已被授权或已捕获授权的支付。
|
||||
COMPLETED("COMPLETED"),
|
||||
// The order requires an action from the payer (e.g. 3DS authentication). Redirect the payer to the "rel":"payer-action" HATEOAS link returned as part of the response prior to authorizing or capturing the order.
|
||||
// 订单需要支付者执行某项操作(例如3DS身份验证)。在授权或捕获订单之前,请将支付者重定向到响应中返回的"rel":"payer-action" HATEOAS链接。
|
||||
PAYER_ACTION_REQUIRED("PAYER_ACTION_REQUIRED");
|
||||
|
||||
private final String status;
|
||||
}
|
||||
@@ -11,11 +11,15 @@ public enum PayTypeEnum {
|
||||
*/
|
||||
WXPAY("微信"),
|
||||
|
||||
|
||||
/**
|
||||
* 支付宝
|
||||
*/
|
||||
ALIPAY("支付宝");
|
||||
ALIPAY("支付宝"),
|
||||
|
||||
/**
|
||||
* PayPal
|
||||
*/
|
||||
PAYPAL("PayPal");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.ai.da.common.security.jwt.JWTTokenHelper;
|
||||
import com.ai.da.common.utils.LocalCacheUtils;
|
||||
import com.ai.da.common.utils.MultiReadHttpServletRequest;
|
||||
import com.ai.da.common.utils.MultiReadHttpServletResponse;
|
||||
import com.ai.da.common.utils.RequestInfoUtil;
|
||||
import com.ai.da.model.vo.AuthPrincipalVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -48,8 +49,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
||||
"/api/third/party/addNoLoginRequiredNew","/api/third/party/deleteNoLoginRequiredNew",
|
||||
"/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl",
|
||||
// "/api/python/chatStream",
|
||||
"/api/python/flush",
|
||||
"/api/account/healthy"
|
||||
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back"
|
||||
);
|
||||
|
||||
@Override
|
||||
@@ -92,6 +92,8 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
||||
log.debug("后台检查令牌:{}", jwtToken);
|
||||
|
||||
if (StrUtil.isBlank(jwtToken)) {
|
||||
String ipAddress = RequestInfoUtil.getIpAddress(request);
|
||||
log.info("本次请求的ip为 : " + ipAddress);
|
||||
throw new RuntimeException("请传入token!");
|
||||
}
|
||||
if(jwtToken.equals("Bearer-eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiIyIiwic3ViIjoie1wiaWRcIjoyLFwidXNlcm5hbWVcIjpcImxpcnNcIn0iLCJpYXQiOjE2NjU3NDEwODcsImlzcyI6IkRXSiIsImF1dGhvcml0aWVzIjoiW10iLCJleHAiOjE2NzQzODEwODd9.ShM9R_NNFD7oo1OvxrEgg7PFeWinOuAKkuInUCMQupp66s64Hhv8tN0Wwr83nIN4rHPqtn95wmd4msWcvaFYJA")){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ai.da.common.task;
|
||||
|
||||
import com.ai.da.mapper.entity.OrderInfo;
|
||||
import com.ai.da.mapper.primary.entity.OrderInfo;
|
||||
import com.ai.da.common.enums.PayTypeEnum;
|
||||
import com.ai.da.service.AliPayService;
|
||||
import com.ai.da.service.OrderInfoService;
|
||||
@@ -24,12 +24,12 @@ public class AliPayTask {
|
||||
/**
|
||||
* 从第0秒开始每隔30秒执行1次,查询创建超过5分钟,并且未支付的订单
|
||||
*/
|
||||
@Scheduled(cron = "0/30 * * * * ?")
|
||||
// @Scheduled(cron = "0/30 * * * * ?")
|
||||
public void orderConfirm(){
|
||||
|
||||
log.info("orderConfirm 被执行......");
|
||||
log.info("Alipay orderConfirm 被执行......");
|
||||
|
||||
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(1, PayTypeEnum.ALIPAY.getType());
|
||||
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(5, PayTypeEnum.ALIPAY.getType());
|
||||
|
||||
for (OrderInfo orderInfo : orderInfoList) {
|
||||
String orderNo = orderInfo.getOrderNo();
|
||||
|
||||
21
src/main/java/com/ai/da/common/task/GenerateTask.java
Normal file
21
src/main/java/com/ai/da/common/task/GenerateTask.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.ai.da.common.task;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class GenerateTask {
|
||||
|
||||
// @Scheduled(cron = "0 0 */1 * * ?")
|
||||
public void generateScheduled(){
|
||||
log.info("测试定时器:generate");
|
||||
|
||||
try{
|
||||
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
42
src/main/java/com/ai/da/common/task/PaypalTask.java
Normal file
42
src/main/java/com/ai/da/common/task/PaypalTask.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.ai.da.common.task;
|
||||
|
||||
import com.ai.da.common.enums.PayTypeEnum;
|
||||
import com.ai.da.mapper.primary.entity.OrderInfo;
|
||||
import com.ai.da.service.OrderInfoService;
|
||||
import com.ai.da.service.PayPalCheckoutService;
|
||||
import com.paypal.http.exceptions.SerializeException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PaypalTask {
|
||||
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
@Resource
|
||||
private PayPalCheckoutService payPalCheckoutService;
|
||||
|
||||
// @Scheduled(cron = "0/30 * * * * ?")
|
||||
public void orderConfirm() throws SerializeException {
|
||||
|
||||
log.info("PayPal orderConfirm 被执行......");
|
||||
|
||||
List<OrderInfo> orderInfoList = orderInfoService.getNoPayOrderByDuration(5, PayTypeEnum.PAYPAL.getType());
|
||||
|
||||
for (OrderInfo orderInfo : orderInfoList) {
|
||||
String orderNo = orderInfo.getOrderNo();
|
||||
log.warn("超时订单 ===> {}", orderNo);
|
||||
|
||||
//核实订单状态:调用支付宝查单接口
|
||||
payPalCheckoutService.checkOrderStatus(orderNo);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
329
src/main/java/com/ai/da/common/utils/AlipayHKEncryptionUtil.java
Normal file
329
src/main/java/com/ai/da/common/utils/AlipayHKEncryptionUtil.java
Normal file
@@ -0,0 +1,329 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import com.ai.da.model.dto.AlipayHKParametersDTO;
|
||||
import com.ai.da.model.dto.AlipayHKRequestDTO;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bouncycastle.util.io.pem.PemObject;
|
||||
import org.bouncycastle.util.io.pem.PemReader;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.*;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
public class AlipayHKEncryptionUtil {
|
||||
|
||||
@Value("${alipay.hk.merchant-id}")
|
||||
private static String merchantId;
|
||||
|
||||
@Value("${alipay.hk.segment-id}")
|
||||
private static String segmentId;
|
||||
|
||||
@Value("${alipay.hk.AESKey}")
|
||||
private static String aesKey;
|
||||
|
||||
@Value("${alipay.hk.rsaPrivateKey}")
|
||||
private static String privateKeyPath;
|
||||
|
||||
@Value("${alipay.hk.rsaPublicKey}")
|
||||
private static String publicKeyPath;
|
||||
|
||||
/**
|
||||
* 加密
|
||||
* @param param
|
||||
* @param serviceName
|
||||
* @return
|
||||
* @throws NoSuchPaddingException
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws InvalidAlgorithmParameterException
|
||||
* @throws InvalidKeyException
|
||||
* @throws IllegalBlockSizeException
|
||||
* @throws BadPaddingException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static AlipayHKRequestDTO AESCBCWithRSA(HashMap<String, Object> param, String serviceName) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException {
|
||||
// Pre-shared secret key, DO NOT hardcode this key
|
||||
String key = aesKey;
|
||||
// The path to the rsa private key file, DO NOT save this key to a publicly accessible location
|
||||
// 使用私钥创建数字签名
|
||||
// Mode, aes-128-cbc for 128bit key
|
||||
String mode = "aes-128-cbc";
|
||||
// Padding mode
|
||||
String padding = "pkcs7";
|
||||
// signature alogrithm
|
||||
String signatureAlgorithm = "rsa-sha256";
|
||||
// String signatureAlgorithm = "SHA256withRSA";
|
||||
// Message body
|
||||
AlipayHKParametersDTO requestMessage = new AlipayHKParametersDTO();
|
||||
requestMessage.setService(serviceName);
|
||||
requestMessage.setMerchant_id(merchantId);
|
||||
requestMessage.setRequest_time(Long.toString(System.currentTimeMillis() / 1000L));
|
||||
requestMessage.setRequest_uuid(UUID.randomUUID().toString());
|
||||
// HashMap<String, Object> param = new HashMap<>();
|
||||
requestMessage.setParameters(param);
|
||||
/*String orderRef = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||
param.put("order_ref", orderRef);
|
||||
param.put("amount", 208.12);
|
||||
param.put("subject", "四月帳單 April Bill");
|
||||
param.put("wallet", "ALIPAYHK");
|
||||
param.put("segment_id", segmentId);
|
||||
param.put("payment_solution", "WAP");*/
|
||||
|
||||
|
||||
// Serialize message body
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
String content = gson.toJson(requestMessage);
|
||||
|
||||
// Secure random iv 获取随机种子
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
byte[] iv = new byte[16]; //NEVER REUSE THIS IV WITH THE SAME KEY
|
||||
secureRandom.nextBytes(iv);
|
||||
|
||||
// Algorithms
|
||||
String alogrithm = "AES/CBC/PKCS5Padding";
|
||||
|
||||
// 创建 AES 密钥对象
|
||||
SecretKey secretKey = new SecretKeySpec(key.getBytes(), "AES");
|
||||
// 为加密算法提供一个随机的初始化向量,以增强加密安全性
|
||||
IvParameterSpec parameterSpec = new IvParameterSpec(iv);
|
||||
// 创建 Cipher 对象
|
||||
Cipher cipher = Cipher.getInstance(alogrithm);
|
||||
// 初始化为加密模式 Cipher.ENCRYPT_MODE
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey, parameterSpec);
|
||||
|
||||
// Cipher text 对请求内容加密
|
||||
byte[] cipherText = cipher.doFinal(content.getBytes());
|
||||
|
||||
// Concat iv and cipher text for signing
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
outputStream.write(iv);
|
||||
outputStream.write(cipherText);
|
||||
byte signMessage[] = outputStream.toByteArray();
|
||||
|
||||
// Sign key 读取rsa私钥文件,解析并得到私钥对象 privateKey
|
||||
String rsaPrivateKeyPath = privateKeyPath;
|
||||
PrivateKey privateKey = null;
|
||||
byte[] signature;
|
||||
try {
|
||||
privateKey = readPrivateKeyFromFile(rsaPrivateKeyPath);
|
||||
Signature signer = Signature.getInstance("SHA256withRSA");
|
||||
signer.initSign(privateKey);
|
||||
// 将加密内容和随机向量均加签
|
||||
signer.update(signMessage);
|
||||
signature = signer.sign();
|
||||
} catch (SignatureException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Base64.Encoder encoder = Base64.getEncoder();
|
||||
// Combine result
|
||||
AlipayHKRequestDTO alipayHKRequestDTO = new AlipayHKRequestDTO();
|
||||
alipayHKRequestDTO.setMerchant_id(merchantId);
|
||||
alipayHKRequestDTO.setNonce(encoder.encodeToString(iv));
|
||||
alipayHKRequestDTO.setMessage(encoder.encodeToString(cipherText));
|
||||
alipayHKRequestDTO.setTag(encoder.encodeToString(signature));
|
||||
String cipherSuite = mode + "-" + padding + "-with-" + signatureAlgorithm;
|
||||
alipayHKRequestDTO.setCipher_suite(cipherSuite);
|
||||
|
||||
// Encode to json
|
||||
String jsonEncoded = JSONObject.toJSONString(alipayHKRequestDTO);
|
||||
log.info(jsonEncoded);
|
||||
|
||||
// String info = AlipayHKRequestUtil.createOrder(alipayHKRequestDTO);
|
||||
// log.info(info);
|
||||
return alipayHKRequestDTO;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 从文件中读取RSA私钥
|
||||
* @param filePath
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static PrivateKey readPrivateKeyFromFile(String filePath) throws Exception {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(filePath));
|
||||
StringBuilder keyBuffer = new StringBuilder();
|
||||
String line;
|
||||
|
||||
// 读取文本文件中的内容
|
||||
while ((line = reader.readLine()) != null) {
|
||||
keyBuffer.append(line);
|
||||
}
|
||||
reader.close();
|
||||
|
||||
// 去除私钥内容中的头部和尾部信息
|
||||
String privateKeyContent = keyBuffer.toString()
|
||||
.replace("-----BEGIN PRIVATE KEY-----", "")
|
||||
.replace("-----END PRIVATE KEY-----", "")
|
||||
.replaceAll("\\s+", ""); // 去除空格、换行等字符
|
||||
|
||||
// 进行 Base64 解码
|
||||
byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyContent);
|
||||
|
||||
// 根据 PKCS8 格式的私钥字节数组构造私钥对象
|
||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
|
||||
return keyFactory.generatePrivate(keySpec);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用 AES 密钥和随机向量进行解密
|
||||
*/
|
||||
public static String decryptAES(String encryptedText, String iv) throws Exception {
|
||||
byte[] encryptedBytes = Base64.getDecoder().decode(encryptedText);
|
||||
byte[] ivBytes = Base64.getDecoder().decode(iv);
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(aesKey.getBytes(), "AES");
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(ivBytes);
|
||||
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
|
||||
byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
|
||||
|
||||
return new String(decryptedBytes, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static void test() throws Exception {
|
||||
// 加密数据
|
||||
AlipayHKParametersDTO requestMessage = new AlipayHKParametersDTO();
|
||||
requestMessage.setService("create_order");
|
||||
requestMessage.setMerchant_id(merchantId);
|
||||
requestMessage.setRequest_time(Long.toString(System.currentTimeMillis() / 1000L));
|
||||
requestMessage.setRequest_uuid(UUID.randomUUID().toString());
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
requestMessage.setParameters(param);
|
||||
String orderRef = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||
param.put("order_ref", orderRef);
|
||||
param.put("amount", 208.12);
|
||||
param.put("subject", "四月帳單 April Bill");
|
||||
param.put("wallet", "ALIPAYHK");
|
||||
param.put("segment_id", segmentId);
|
||||
param.put("payment_solution", "WAP");
|
||||
Gson gson = new Gson();
|
||||
String plaintext = gson.toJson(requestMessage);
|
||||
System.out.println(plaintext);
|
||||
|
||||
// 生成 AES 密钥
|
||||
String key = aesKey;
|
||||
SecretKey aesKey = new SecretKeySpec(key.getBytes(), "AES");
|
||||
|
||||
// 使用 RSA 公钥加密 AES 密钥
|
||||
String rsaPublicKeyPath = publicKeyPath;
|
||||
PublicKey publicKey = readPublicKey(new File(rsaPublicKeyPath));
|
||||
|
||||
Cipher rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
|
||||
// Cipher rsaCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
rsaCipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||
byte[] encryptedAesKey = rsaCipher.doFinal(aesKey.getEncoded());
|
||||
|
||||
// 使用 AES-128-CBC 加密数据
|
||||
Cipher aesCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
byte[] ivBytes = generateRandomIV(aesCipher.getBlockSize());
|
||||
IvParameterSpec ivSpec = new IvParameterSpec(ivBytes);
|
||||
|
||||
aesCipher.init(Cipher.ENCRYPT_MODE, aesKey, ivSpec);
|
||||
byte[] encryptedData = aesCipher.doFinal(plaintext.getBytes());
|
||||
|
||||
// 数字签名(使用 RSA 私钥)
|
||||
String rsaPrivateKeyPath = privateKeyPath;
|
||||
PrivateKey privateKey = readPrivateKeyFromFile(rsaPrivateKeyPath);
|
||||
Signature signer = Signature.getInstance("SHA256withRSA");
|
||||
signer.initSign(privateKey);
|
||||
signer.update(encryptedData);
|
||||
byte[] signatureBytes = signer.sign();
|
||||
Base64.Encoder encoder = Base64.getEncoder();
|
||||
|
||||
// 将加密后的数据和签名进行Base64编码
|
||||
String base64EncryptedData = Base64.getEncoder().encodeToString(encryptedData);
|
||||
String base64Signature = Base64.getEncoder().encodeToString(signatureBytes);
|
||||
|
||||
// 输出加密后的数据和签名
|
||||
System.out.println("加密后的数据:" + base64EncryptedData);
|
||||
System.out.println("数字签名:" + base64Signature);
|
||||
|
||||
|
||||
HashMap<String, String> result = new HashMap<String, String>();
|
||||
result.put("merchant_id",merchantId);
|
||||
result.put("nonce", encoder.encodeToString(ivBytes));
|
||||
result.put("message", encoder.encodeToString(encryptedData));
|
||||
result.put("tag", encoder.encodeToString(signatureBytes));
|
||||
|
||||
String mode = "aes-128-cbc";
|
||||
// Padding mode
|
||||
String padding = "pkcs7";
|
||||
// signature alogrithm
|
||||
String signatureAlgorithm = "rsa-sha256";
|
||||
String cipherSuite = mode + "-" + padding + "-with-" + signatureAlgorithm;
|
||||
result.put("cipher_suite", cipherSuite);
|
||||
|
||||
System.out.println("map 格式:" + result);
|
||||
// Encode to json
|
||||
String jsonEncoded = JSONObject.toJSONString(result);
|
||||
System.out.println("json 格式:" + jsonEncoded);
|
||||
|
||||
AlipayHKRequestDTO alipayHKRequestDTO = new AlipayHKRequestDTO();
|
||||
alipayHKRequestDTO.setMerchant_id(merchantId);
|
||||
alipayHKRequestDTO.setNonce(encoder.encodeToString(ivBytes));
|
||||
alipayHKRequestDTO.setMessage(encoder.encodeToString(encryptedData));
|
||||
alipayHKRequestDTO.setTag(encoder.encodeToString(signatureBytes));
|
||||
alipayHKRequestDTO.setCipher_suite(cipherSuite);
|
||||
|
||||
// String info = AlipayHKRequestUtil.createOrder(result);
|
||||
// log.info(info);
|
||||
|
||||
// 解密和验证
|
||||
// byte[] decryptedAesKey = rsaCipher.doFinal(encryptedAesKey);
|
||||
byte[] decryptedAesKey = rsaCipher.doFinal(aesKey.getEncoded());
|
||||
SecretKey decryptedAesSecretKey = new SecretKeySpec(decryptedAesKey, "AES");
|
||||
|
||||
aesCipher.init(Cipher.DECRYPT_MODE, decryptedAesSecretKey, ivSpec);
|
||||
byte[] decryptedData = aesCipher.doFinal(Base64.getDecoder().decode(base64EncryptedData));
|
||||
|
||||
// 验证数字签名
|
||||
Signature verifier = Signature.getInstance("SHA256withRSA");
|
||||
verifier.initVerify(publicKey);
|
||||
verifier.update(decryptedData);
|
||||
boolean signatureValid = verifier.verify(Base64.getDecoder().decode(base64Signature));
|
||||
|
||||
System.out.println("解密后的数据:" + new String(decryptedData));
|
||||
System.out.println("数字签名验证结果:" + signatureValid);
|
||||
}
|
||||
|
||||
public static PublicKey readPublicKey(File file) throws Exception {
|
||||
KeyFactory factory = KeyFactory.getInstance("RSA");
|
||||
|
||||
try (FileReader keyReader = new FileReader(file);
|
||||
PemReader pemReader = new PemReader(keyReader)) {
|
||||
|
||||
PemObject pemObject = pemReader.readPemObject();
|
||||
byte[] content = pemObject.getContent();
|
||||
X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(content);
|
||||
return factory.generatePublic(pubKeySpec);
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] generateRandomIV(int blockSize) {
|
||||
SecureRandom random = new SecureRandom();
|
||||
byte[] iv = new byte[blockSize];
|
||||
random.nextBytes(iv);
|
||||
return iv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.model.dto.AlipayHKRequestDTO;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
@Slf4j
|
||||
public class AlipayHKRequestUtil {
|
||||
|
||||
public static String createOrder(AlipayHKRequestDTO alipayHKRequestDTO) throws IOException {
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||
.readTimeout(60, TimeUnit.SECONDS)//读取超时(单位:秒)
|
||||
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json;charset=utf-8");
|
||||
long epochMilli = Instant.now().toEpochMilli();
|
||||
log.info("Alipay-HK send request unix timestamp: {}", epochMilli);
|
||||
|
||||
String jsonString = JSONObject.toJSONString(alipayHKRequestDTO, SerializerFeature.WriteMapNullValue);
|
||||
log.info(jsonString);
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, jsonString);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
// .url("https://aqs-api.sandbox-codpayment.com")
|
||||
.url("https://aqs-api.sandbox-codpayment.com/v1/service")
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/json;charset=utf-8")
|
||||
.build();
|
||||
Response response = null;
|
||||
String bodyString;
|
||||
try {
|
||||
// log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(alipayHKRequestDTO, SerializerFeature.WriteMapNullValue));
|
||||
response = client.newCall(request).execute();
|
||||
} catch (Exception e) {
|
||||
// log.error("PythonService##generateSketchOrPrint异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||
// throw new BusinessException("generate.interface.error");
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
return response.body().string();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import java.util.concurrent.*;
|
||||
@Component
|
||||
public class AsyncCallerUtil {
|
||||
|
||||
// 存放状态 表示当前任务是否需要继续等待,默认持续等待
|
||||
public static Map<String, Boolean> waitingStatus = new HashMap<>();
|
||||
|
||||
private static PythonService pythonService;
|
||||
@@ -24,7 +25,8 @@ public class AsyncCallerUtil {
|
||||
}
|
||||
|
||||
public CompletableFuture<List<String>> callGenerateAsync(GenerateToPythonDTO generateToPython) {
|
||||
return CompletableFuture.supplyAsync(() -> pythonService.generateSketchOrPrint(generateToPython));
|
||||
// return CompletableFuture.supplyAsync(() -> pythonService.generateSketchOrPrint(generateToPython));
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> generate(GenerateToPythonDTO generateToPython) {
|
||||
@@ -58,7 +60,7 @@ public class AsyncCallerUtil {
|
||||
return null;
|
||||
} catch (InterruptedException | ExecutionException | BusinessException e) {
|
||||
// 处理异常
|
||||
log.error("发生错误 : " + e);
|
||||
log.error("发生错误 : " + e, e);
|
||||
// 取消定时任务
|
||||
assert timeoutTask != null;
|
||||
timeoutTask.cancel(true);
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import com.ai.da.mapper.entity.Collection;
|
||||
import com.ai.da.mapper.entity.SysFile;
|
||||
import com.ai.da.model.vo.SysFileVO;
|
||||
import com.google.common.cache.*;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -1,29 +1,22 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.mapper.entity.ObjectItem;
|
||||
import com.ai.da.mapper.primary.entity.ObjectItem;
|
||||
import io.minio.*;
|
||||
import io.minio.errors.MinioException;
|
||||
import io.minio.http.Method;
|
||||
import io.minio.messages.DeleteError;
|
||||
import io.minio.messages.DeleteObject;
|
||||
import io.minio.messages.Item;
|
||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -134,6 +127,26 @@ public class MinioUtil {
|
||||
return names;
|
||||
}
|
||||
|
||||
public String uploadImageFromBase64(String bucketName, String base64Image, String imageType) {
|
||||
byte[] imageBytes = Base64.getDecoder().decode(base64Image);
|
||||
String fileName = UUID.randomUUID().toString() + "." + imageType; // or any other image format
|
||||
|
||||
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
|
||||
minioClient.putObject(PutObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(fileName)
|
||||
.stream(in, in.available(), -1)
|
||||
.contentType("image/png") // Set the content type according to your image format
|
||||
.build()
|
||||
);
|
||||
|
||||
return bucketName + "/" + fileName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null; // or throw an exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* description: 上传文件
|
||||
*
|
||||
@@ -423,6 +436,13 @@ public class MinioUtil {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String base64Upload(String base64, String bucketName){
|
||||
String[] parts = base64.split(",");
|
||||
String imageType = parts[0].split("/")[1].split(";")[0];
|
||||
String base64Data = parts[1];
|
||||
return uploadImageFromBase64(bucketName, base64Data, imageType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,5 +48,9 @@ public class RandomsUtil {
|
||||
return RandomUtil.randomLong(randomStart, randomEnd);
|
||||
}
|
||||
|
||||
public static Integer randomSysFile(Integer randomEnd) {
|
||||
return RandomUtil.randomInt(randomEnd);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -17,6 +19,10 @@ public class RedisUtil {
|
||||
@Resource
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
public Boolean hasKey(String key){
|
||||
return redisTemplate.hasKey(key);
|
||||
}
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - ZSet类型 - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
/**
|
||||
@@ -64,10 +70,15 @@ public class RedisUtil {
|
||||
/**
|
||||
* 获取当前ZSet中数据量的总和
|
||||
*/
|
||||
public Long getZSetTotal(String key) {
|
||||
public Long getZSetTotalCount(String key) {
|
||||
return redisTemplate.opsForZSet().zCard(key);
|
||||
}
|
||||
|
||||
|
||||
public Set<String> getZSetTotalData(String key){
|
||||
return redisTemplate.opsForZSet().range(key, 0, -1);
|
||||
}
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - set类型 - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
/**
|
||||
@@ -123,4 +134,34 @@ public class RedisUtil {
|
||||
public Long removeFromMap(String key, String hashKeys) {
|
||||
return redisTemplate.opsForHash().delete(key, hashKeys);
|
||||
}
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - String类型 - - - - - - - - - - - - - - - - - - - -
|
||||
public void addToString(String key, String value){
|
||||
redisTemplate.opsForValue().set(key,value);
|
||||
}
|
||||
|
||||
public void addToString(String key, String value, Long expiresIn){
|
||||
redisTemplate.opsForValue().set(key,value,expiresIn, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public String getFromString(String key){
|
||||
return redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
public Set<String> getKeysFromString(String key){
|
||||
return redisTemplate.keys(key);
|
||||
}
|
||||
|
||||
public List<String> getMultiValue(Set<String> keys){
|
||||
return redisTemplate.opsForValue().multiGet(keys);
|
||||
}
|
||||
|
||||
public Long getExpire(String key){
|
||||
return redisTemplate.getExpire(key);
|
||||
}
|
||||
|
||||
public void removeFromString(String key){
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ai.da.common.utils;
|
||||
|
||||
import com.ai.da.mapper.entity.Account;
|
||||
import com.ai.da.mapper.entity.TrialOrder;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.tencentcloudapi.common.Credential;
|
||||
@@ -9,12 +9,14 @@ import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||
import com.tencentcloudapi.common.profile.HttpProfile;
|
||||
import com.tencentcloudapi.ses.v20201002.SesClient;
|
||||
import com.tencentcloudapi.ses.v20201002.models.Attachment;
|
||||
import com.tencentcloudapi.ses.v20201002.models.SendEmailRequest;
|
||||
import com.tencentcloudapi.ses.v20201002.models.SendEmailResponse;
|
||||
import com.tencentcloudapi.ses.v20201002.models.Template;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -130,7 +132,10 @@ public class SendEmailUtil {
|
||||
private final static Long YOUR_TRIAL_TEMPLATE_ID = 117214L;
|
||||
private final static Long APPROVAL_TEMPLATE_ID = 117215L;
|
||||
private final static Long NOTIFICATION_TEMPLATE_ID = 117216L;
|
||||
public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType) {
|
||||
private final static Long NOTIFICATION_CHINESE_TEMPLATE_ID = 122229L;
|
||||
private final static Long TRIAL_ORDER_LIST_ID = 122273L;
|
||||
private final static Long NO_TRIAL_ORDER_LIST_ID = 122591L;
|
||||
public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType, String country) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
@@ -162,7 +167,11 @@ public class SendEmailUtil {
|
||||
break;
|
||||
case 3:
|
||||
subject = "Approval Confirmation for AiDA System Trial Access";
|
||||
template.setTemplateID(NOTIFICATION_TEMPLATE_ID);
|
||||
if (country.equals("China")) {
|
||||
template.setTemplateID(NOTIFICATION_CHINESE_TEMPLATE_ID);
|
||||
}else {
|
||||
template.setTemplateID(NOTIFICATION_TEMPLATE_ID);
|
||||
}
|
||||
template.setTemplateData(buildNotificationData(trialOrder));
|
||||
break;
|
||||
default:
|
||||
@@ -180,6 +189,78 @@ public class SendEmailUtil {
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendExcelEmail(String receiverAddress, String senderAddress, byte[] fileContent, String fileName) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
if (StringUtils.isEmpty(senderAddress)) {
|
||||
senderAddress = SEND_ADDRESS;
|
||||
}
|
||||
req.setFromEmailAddress(senderAddress);
|
||||
req.setDestination(new String[]{receiverAddress});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
subject = "昨日试用订单数据";
|
||||
template.setTemplateID(TRIAL_ORDER_LIST_ID);
|
||||
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(template);
|
||||
|
||||
Attachment attachment = new Attachment();
|
||||
attachment.setFileName(fileName); // 设置附件文件名
|
||||
// 设置附件内容
|
||||
attachment.setContent(Base64.getEncoder().encodeToString(fileContent));
|
||||
req.setAttachments(new Attachment[] {attachment});
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendNoExcelEmail(String receiverAddress, String senderAddress) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
if (StringUtils.isEmpty(senderAddress)) {
|
||||
senderAddress = SEND_ADDRESS;
|
||||
}
|
||||
req.setFromEmailAddress(senderAddress);
|
||||
req.setDestination(new String[]{receiverAddress});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
subject = "昨日试用订单数据";
|
||||
template.setTemplateID(NO_TRIAL_ORDER_LIST_ID);
|
||||
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(template);
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
private final static Long WILLBEEXPIRED_TEMPLATE_ID = 118178L;
|
||||
public static void sendWillBeExpiredEmail(Account account, String senderAddress) {
|
||||
try {
|
||||
@@ -274,7 +355,10 @@ public class SendEmailUtil {
|
||||
}
|
||||
|
||||
private final static Long UPGRADE_NOTIFICATION_ID = 118855L;
|
||||
public static void sendUpgradeNotification(Account account, String senderAddress) {
|
||||
private final static Long UPGRADE_SUCCESS_NOTIFICATION_ID = 118856L;
|
||||
private final static Long UPGRADE_NOTIFICATION_ID_CHINESE = 122898L;
|
||||
private final static Long UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE = 122899L;
|
||||
public static void sendUpgradeNotification(Account account, String senderAddress, Integer type) {
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
@@ -293,8 +377,20 @@ public class SendEmailUtil {
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
subject = "Upcoming AiDA 3.0 Launch and Scheduled Maintenance";
|
||||
template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
||||
// if (type == 1) {
|
||||
// subject = "Upcoming System Upgrade for AiDA 3.0";
|
||||
// template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
||||
// }else {
|
||||
// subject = "即将到来的AiDA 3.0系统升级";
|
||||
// template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE);
|
||||
// }
|
||||
if (type == 1) {
|
||||
subject = "Successful System Upgrade and New Features in AiDA 3.0";
|
||||
template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID);
|
||||
}else {
|
||||
subject = "系统升级成功和AiDA 3.0新功能";
|
||||
template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE);
|
||||
}
|
||||
template.setTemplateData(buildAccountData(account));
|
||||
|
||||
req.setSubject(subject);
|
||||
@@ -308,4 +404,46 @@ public class SendEmailUtil {
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
private final static Long GENERATE_EXCEPTION_WARNING_ID = 122589L;
|
||||
public static void sendGenerateExceptionWarning(String message){
|
||||
try {
|
||||
// 实例化一个认证对象
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||
SendEmailRequest req = new SendEmailRequest();
|
||||
req.setFromEmailAddress(CODE_CREATE_SEND_ADDRESS);
|
||||
req.setDestination(new String[]{"xupei3360@163.com"});
|
||||
|
||||
// 根据邮件类型设置不同的主题和模板
|
||||
String subject = "";
|
||||
Template template = new Template();
|
||||
subject = "Warning: AiDA 3.0 Generate Exception Warning";
|
||||
template.setTemplateID(GENERATE_EXCEPTION_WARNING_ID);
|
||||
|
||||
JSONObject parameter = new JSONObject();
|
||||
parameter.put("errorMessage", message);
|
||||
parameter.put("time", DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS));
|
||||
|
||||
template.setTemplateData(parameter.toJSONString());
|
||||
|
||||
req.setSubject(subject);
|
||||
req.setTemplate(template);
|
||||
|
||||
// 发送邮件
|
||||
SendEmailResponse resp = client.SendEmail(req);
|
||||
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.info("邮件发送失败###{}", e.toString());
|
||||
throw new BusinessException("failed.to.send.mail");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ai.da.common.utils.paypalRequest;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.paypal.http.HttpRequest;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@Component
|
||||
public class AuthenticationRequest extends HttpRequest<HashMap> {
|
||||
|
||||
public AuthenticationRequest() {
|
||||
super("/v1/oauth2/token", "POST", HashMap.class);
|
||||
this.header("Content-Type", "application/x-www-form-urlencoded");
|
||||
body();
|
||||
}
|
||||
|
||||
public AuthenticationRequest authorization(String clientId, String clientSecret) {
|
||||
this.header(clientId, clientSecret);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuthenticationRequest body() {
|
||||
HashMap<String, String> body = new HashMap<>();
|
||||
body.put("grant_type", "client_credentials");
|
||||
this.requestBody(body);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ai.da.common.utils.paypalRequest;
|
||||
|
||||
import com.ai.da.model.dto.WebhookVerifyDTO;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.paypal.http.HttpRequest;
|
||||
import com.paypal.orders.OrdersCreateRequest;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class WebhookVerifyRequest extends HttpRequest<HashMap> {
|
||||
public WebhookVerifyRequest() {
|
||||
super("/v1/notifications/verify-webhook-signature", "POST", HashMap.class);
|
||||
this.header("Content-Type", "application/json");
|
||||
}
|
||||
|
||||
public WebhookVerifyRequest authorization(String authorization) {
|
||||
this.header("Authorization", "Bearer " + String.valueOf(authorization));
|
||||
return this;
|
||||
}
|
||||
|
||||
public WebhookVerifyRequest requestBody(HashMap<String,String> webhookVerify) {
|
||||
super.requestBody(webhookVerify);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,10 @@ package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
||||
import com.ai.da.mapper.entity.TrialOrder;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.enums.Language;
|
||||
import com.ai.da.model.vo.AccountLoginVO;
|
||||
import com.ai.da.model.vo.AccountPreLoginVO;
|
||||
import com.ai.da.model.vo.QueryLibraryPageVO;
|
||||
import com.ai.da.service.AccountService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.entity.OrderInfo;
|
||||
import com.ai.da.service.AliPayService;
|
||||
import com.ai.da.service.OrderInfoService;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayConstants;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
@CrossOrigin
|
||||
@@ -27,22 +20,13 @@ public class AliPayController {
|
||||
@Resource
|
||||
private AliPayService aliPayService;
|
||||
|
||||
@Resource
|
||||
private Environment config;
|
||||
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
@ApiOperation("统一收单下单并支付页面接口的调用")
|
||||
@PostMapping("/trade/page/pay/{productId}")
|
||||
public Response<String> tradePagePay(@PathVariable Long productId,@RequestParam String returnUrl){
|
||||
|
||||
System.out.println(productId + " " + returnUrl);
|
||||
|
||||
@PostMapping("/trade/page/pay/{amount}")
|
||||
public Response<String> tradePagePay(@PathVariable Integer amount, @RequestParam String returnUrl){
|
||||
log.info("统一收单下单并支付页面接口的调用");
|
||||
//支付宝开放平台接受 request 请求对象后
|
||||
// 会为开发者生成一个html 形式的 form表单,包含自动提交的脚本
|
||||
String formStr = aliPayService.tradeCreate(productId, returnUrl);
|
||||
String formStr = aliPayService.tradeCreate(amount, returnUrl);
|
||||
//我们将form表单字符串返回给前端程序,之后前端将会调用自动提交脚本,进行表单的提交
|
||||
//此时,表单会自动提交到action属性所指向的支付宝开放平台中,从而为用户展示一个支付页面
|
||||
return Response.success(formStr);
|
||||
@@ -51,80 +35,7 @@ public class AliPayController {
|
||||
@ApiOperation("支付通知")
|
||||
@PostMapping("/trade/notify")
|
||||
public String tradeNotify(@RequestParam Map<String, String> params){
|
||||
|
||||
log.info("支付通知正在执行");
|
||||
log.info("通知参数 ===> {}", params);
|
||||
|
||||
String result = "failure";
|
||||
|
||||
try {
|
||||
//异步通知验签
|
||||
boolean signVerified = AlipaySignature.rsaCheckV1(
|
||||
params,
|
||||
config.getProperty("alipay.alipay-public-key"),
|
||||
AlipayConstants.CHARSET_UTF8,
|
||||
AlipayConstants.SIGN_TYPE_RSA2); //调用SDK验证签名
|
||||
|
||||
if(!signVerified){
|
||||
//验签失败则记录异常日志,并在response中返回failure.
|
||||
log.error("支付成功异步通知验签失败!");
|
||||
return result;
|
||||
}
|
||||
|
||||
// 验签成功后
|
||||
log.info("支付成功异步通知验签成功!");
|
||||
|
||||
//按照支付结果异步通知中的描述,对支付结果中的业务内容进行二次校验,
|
||||
//1 商户需要验证该通知数据中的 out_trade_no 是否为商户系统中创建的订单号
|
||||
String outTradeNo = params.get("out_trade_no");
|
||||
OrderInfo order = orderInfoService.getOrderByOrderNo(outTradeNo);
|
||||
if(order == null){
|
||||
log.error("订单不存在");
|
||||
return result;
|
||||
}
|
||||
|
||||
//2 判断 total_amount 是否确实为该订单的实际金额(即商户订单创建时的金额)
|
||||
String totalAmount = params.get("total_amount");
|
||||
int totalAmountInt = new BigDecimal(totalAmount).multiply(new BigDecimal("100")).intValue();
|
||||
int totalFeeInt = order.getTotalFee().intValue();
|
||||
if(totalAmountInt != totalFeeInt){
|
||||
log.error("金额校验失败");
|
||||
return result;
|
||||
}
|
||||
|
||||
//3 校验通知中的 seller_id(或者 seller_email) 是否为 out_trade_no 这笔单据的对应的操作方
|
||||
String sellerId = params.get("seller_id");
|
||||
String sellerIdProperty = config.getProperty("alipay.seller-id");
|
||||
if(!sellerId.equals(sellerIdProperty)){
|
||||
log.error("商家pid校验失败");
|
||||
return result;
|
||||
}
|
||||
|
||||
//4 验证 app_id 是否为该商户本身
|
||||
String appId = params.get("app_id");
|
||||
String appIdProperty = config.getProperty("alipay.app-id");
|
||||
if(!appId.equals(appIdProperty)){
|
||||
log.error("appid校验失败");
|
||||
return result;
|
||||
}
|
||||
|
||||
//在支付宝的业务通知中,只有交易通知状态为 TRADE_SUCCESS时,
|
||||
// 支付宝才会认定为买家付款成功。
|
||||
String tradeStatus = params.get("trade_status");
|
||||
if(!"TRADE_SUCCESS".equals(tradeStatus)){
|
||||
log.error("支付未成功");
|
||||
return result;
|
||||
}
|
||||
|
||||
//处理业务 修改订单状态 记录支付日志
|
||||
aliPayService.processOrder(params);
|
||||
|
||||
//校验成功后在response中返回success并继续商户自身业务处理,校验失败返回failure
|
||||
result = "success";
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
return aliPayService.tradeNotify(params);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +46,6 @@ public class AliPayController {
|
||||
@ApiOperation("用户取消订单")
|
||||
@PostMapping("/trade/close/{orderNo}")
|
||||
public Response<String> cancel(@PathVariable String orderNo){
|
||||
|
||||
log.info("取消订单");
|
||||
aliPayService.cancelOrder(orderNo);
|
||||
return Response.success("订单已取消");
|
||||
@@ -149,16 +59,14 @@ public class AliPayController {
|
||||
@ApiOperation("查询订单:测试订单状态用")
|
||||
@GetMapping("/trade/query/{orderNo}")
|
||||
public Response<String> queryOrder(@PathVariable String orderNo) {
|
||||
|
||||
log.info("查询订单");
|
||||
|
||||
String result = aliPayService.queryOrder(orderNo);
|
||||
return Response.success(result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请退款
|
||||
* 不在页面提供申请退款接口
|
||||
* @param orderNo
|
||||
* @param reason
|
||||
* @return
|
||||
@@ -166,7 +74,6 @@ public class AliPayController {
|
||||
@ApiOperation("申请退款")
|
||||
@PostMapping("/trade/refund/{orderNo}/{reason}")
|
||||
public Response<String> refunds(@PathVariable String orderNo, @PathVariable String reason){
|
||||
|
||||
log.info("申请退款");
|
||||
aliPayService.refund(orderNo, reason);
|
||||
return Response.success();
|
||||
@@ -180,10 +87,8 @@ public class AliPayController {
|
||||
*/
|
||||
@ApiOperation("查询退款:测试用")
|
||||
@GetMapping("/trade/fastpay/refund/{orderNo}")
|
||||
public Response<String> queryRefund(@PathVariable String orderNo) throws Exception {
|
||||
|
||||
public Response<String> queryRefund(@PathVariable String orderNo) {
|
||||
log.info("查询退款");
|
||||
|
||||
String result = aliPayService.queryRefund(orderNo);
|
||||
return Response.success(result);
|
||||
}
|
||||
|
||||
22
src/main/java/com/ai/da/controller/AlipayHKController.java
Normal file
22
src/main/java/com/ai/da/controller/AlipayHKController.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/api/ali-pay-hk")
|
||||
@Api(tags = "网站支付 香港支付宝")
|
||||
@Slf4j
|
||||
public class AlipayHKController {
|
||||
|
||||
public Response<String> createOrder(){
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,27 +1,19 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.entity.Workspace;
|
||||
import com.ai.da.model.dto.ClassificationDTO;
|
||||
import com.ai.da.model.dto.WorkspaceDTO;
|
||||
import com.ai.da.model.enums.BizJson;
|
||||
import com.ai.da.model.vo.ClassificationVO;
|
||||
import com.ai.da.model.vo.ModelsVO;
|
||||
import com.ai.da.model.vo.WorkspaceVO;
|
||||
import com.ai.da.service.ClassificationService;
|
||||
import com.ai.da.service.WorkspaceService;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.DesignMapper;
|
||||
import com.ai.da.mapper.primary.TrialOrderMapper;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.model.dto.UserDesignStatisticDTO;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "便利查询")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/inquiry")
|
||||
public class ConvenientInquiryController {
|
||||
|
||||
@Resource
|
||||
private TrialOrderMapper trialOrderMapper;
|
||||
|
||||
@Resource
|
||||
private DesignMapper designMapper;
|
||||
|
||||
@ApiOperation("获取当前所有试用用户")
|
||||
@GetMapping("/getTrial")
|
||||
public Response<List<TrialOrder>> getTrial(){
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)){
|
||||
List<TrialOrder> trialOrders = trialOrderMapper.selectList(null);
|
||||
return Response.success(trialOrders);
|
||||
}else {
|
||||
return Response.fail("Sorry, you don't have permission");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("获取指定时间区间内所有用户design的使用情况")
|
||||
@GetMapping("/getDesignStatistic")
|
||||
public Response<List<UserDesignStatisticDTO>> getDesignStatistic(@RequestParam String startTime,@RequestParam String endTime){
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)){
|
||||
if (StringUtil.isNullOrEmpty(startTime)) startTime = "2024-02-01 00:00:00";
|
||||
if (StringUtil.isNullOrEmpty(endTime)){
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
Date date = new Date();
|
||||
endTime = simpleDateFormat.format(date);
|
||||
}
|
||||
List<UserDesignStatisticDTO> designStatistic = designMapper.getDesignStatistic(startTime, endTime);
|
||||
return Response.success(designStatistic);
|
||||
}else {
|
||||
return Response.fail("Sorry, you don't have permission");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
42
src/main/java/com/ai/da/controller/CreditsController.java
Normal file
42
src/main/java/com/ai/da/controller/CreditsController.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.entity.CreditsDetail;
|
||||
import com.ai.da.model.dto.QueryIncomeOrExpenditureDTO;
|
||||
import com.ai.da.service.CreditsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/api/credits")
|
||||
@Api(tags = "积分")
|
||||
@Slf4j
|
||||
public class CreditsController {
|
||||
|
||||
@Resource
|
||||
private CreditsService creditsService;
|
||||
|
||||
@ApiOperation("获取当前积分")
|
||||
@GetMapping("/getCredits")
|
||||
public Response<String> getCredits() {
|
||||
String credits = creditsService.getCredits(UserContext.getUserHolder().getId());
|
||||
return Response.success(credits);
|
||||
}
|
||||
|
||||
@ApiOperation("获取积分详细")
|
||||
@PostMapping("/getCreditsDetail")
|
||||
public Response<PageBaseResponse<CreditsDetail>> getCreditsDetail(@Valid @RequestBody QueryIncomeOrExpenditureDTO queryPageByTimeDTO) {
|
||||
PageBaseResponse<CreditsDetail> credits = creditsService.queryCreditsDetailsPage(queryPageByTimeDTO);
|
||||
return Response.success(credits);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ public class DesignController {
|
||||
|
||||
@ApiOperation(value = "设计 Conllection")
|
||||
@PostMapping("/designCollection")
|
||||
@CrossOrigin
|
||||
public Response<DesignCollectionVO> designCollection(@Valid @RequestBody DesignCollectionDTO designDTO) {
|
||||
return Response.success(designService.designCollection(designDTO));
|
||||
}
|
||||
|
||||
@@ -3,10 +3,7 @@ package com.ai.da.controller;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.model.dto.GenerateLikeDTO;
|
||||
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
||||
import com.ai.da.model.vo.GenerateCaptionVO;
|
||||
import com.ai.da.model.vo.GenerateCollectionVO;
|
||||
import com.ai.da.model.vo.GenerateLikeVO;
|
||||
import com.ai.da.model.vo.PrepareForGenerateVO;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.GenerateService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -16,6 +13,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author XP
|
||||
@@ -35,11 +33,12 @@ public class GenerateController {
|
||||
return Response.success(generateService.generateCaption(sketchElementId));
|
||||
}
|
||||
|
||||
@ApiOperation("通过文字、图片生成图片")
|
||||
/*@ApiOperation("通过文字、图片生成图片")
|
||||
@PostMapping("/sketchAndPrint")
|
||||
public Response<GenerateCollectionVO> generateThroughImageText(@Valid @RequestBody GenerateThroughImageTextDTO generateThroughImageTextDTO) {
|
||||
return Response.success(generateService.generateThroughImageText(generateThroughImageTextDTO));
|
||||
}
|
||||
public void generateThroughImageText(@Valid @RequestBody GenerateThroughImageTextDTO generateThroughImageTextDTO) {
|
||||
// return Response.success(generateService.generateThroughImageText(generateThroughImageTextDTO));
|
||||
generateService.generateThroughImageText(generateThroughImageTextDTO);
|
||||
}*/
|
||||
|
||||
@ApiOperation("喜欢生成的图片")
|
||||
@PostMapping("/like")
|
||||
@@ -63,16 +62,25 @@ public class GenerateController {
|
||||
@ApiOperation(value = "取消继续生成")
|
||||
@GetMapping("/stopWaiting")
|
||||
public Response<String> stopWaiting(@RequestParam("userId") Long userId,
|
||||
@RequestParam("uniqueId") String uniqueId,
|
||||
@RequestParam("uniqueId") List<String> uniqueId,
|
||||
@RequestParam("timeZone") String timeZone) {
|
||||
generateService.cancelGenerate(userId, uniqueId, timeZone);
|
||||
return Response.success("stop waiting successfully");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取生成结果")
|
||||
/*@ApiOperation(value = "获取生成结果")
|
||||
@GetMapping("/result")
|
||||
public Response<GenerateCollectionVO> getGenerateResult(@RequestParam("uniqueId") String uniqueId) {
|
||||
GenerateCollectionVO generateResult = generateService.getGenerateResult(uniqueId);
|
||||
return Response.success(generateResult);
|
||||
}*/
|
||||
|
||||
@ApiOperation(value = "获取生成结果")
|
||||
@PostMapping("/result")
|
||||
public Response<List<GenerateResultVO>> getGenerateResults(@Valid @RequestBody List<String> taskIdList) {
|
||||
List<GenerateResultVO> generateResult = generateService.getGenerateResultList(taskIdList);
|
||||
return Response.success(generateResult);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,10 +7,9 @@ import com.ai.da.common.enums.LibraryLevel1TypeEnum;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.utils.*;
|
||||
import com.ai.da.mapper.entity.Library;
|
||||
import com.ai.da.mapper.entity.LibraryModelPoint;
|
||||
import com.ai.da.mapper.primary.entity.Library;
|
||||
import com.ai.da.mapper.primary.entity.LibraryModelPoint;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.enums.ModelType;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.LibraryModelPointService;
|
||||
import com.ai.da.service.LibraryService;
|
||||
@@ -20,7 +19,6 @@ import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -30,7 +28,6 @@ import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.enums.OrderStatusEnum;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.entity.OrderInfo;
|
||||
import com.ai.da.mapper.primary.entity.OrderInfo;
|
||||
import com.ai.da.model.dto.QueryPageByTimeDTO;
|
||||
import com.ai.da.service.OrderInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@CrossOrigin //开放前端的跨域访问
|
||||
@Api(tags = "商品订单管理")
|
||||
@@ -21,11 +23,11 @@ public class OrderInfoController {
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
@ApiOperation("订单列表")
|
||||
@GetMapping("/list")
|
||||
public Response<List<OrderInfo>> list(){
|
||||
|
||||
List<OrderInfo> list = orderInfoService.listOrderByCreateTimeDesc();
|
||||
return Response.success(list);
|
||||
@PostMapping("/list")
|
||||
public Response<PageBaseResponse<OrderInfo>> list(@Valid @RequestBody QueryPageByTimeDTO queryPageByTimeDTO){
|
||||
PageBaseResponse<OrderInfo> orderByAccountId = orderInfoService.getOrderByPage(queryPageByTimeDTO);
|
||||
// List<OrderInfo> list = orderInfoService.listOrderByCreateTimeDesc();
|
||||
return Response.success(orderByAccountId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,15 +38,11 @@ public class OrderInfoController {
|
||||
@ApiOperation("查询本地订单状态")
|
||||
@GetMapping("/query-order-status/{orderNo}")
|
||||
public Response<String> queryOrderStatus(@PathVariable String orderNo){
|
||||
|
||||
String orderStatus = orderInfoService.getOrderStatus(orderNo);
|
||||
if(OrderStatusEnum.SUCCESS.getType().equals(orderStatus)){
|
||||
return Response.success("支付成功"); //支付成功
|
||||
}
|
||||
|
||||
return Response.success(101,"支付中......");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.service.PayPalCheckoutService;
|
||||
import com.paypal.http.HttpResponse;
|
||||
import com.paypal.http.exceptions.SerializeException;
|
||||
import com.paypal.orders.Order;
|
||||
import com.paypal.payments.Refund;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "PayPalCheckout接口")
|
||||
@RequestMapping("/api/paypal")
|
||||
public class PayPalCheckoutController {
|
||||
|
||||
@Resource
|
||||
private PayPalCheckoutService payPalCheckoutService;
|
||||
|
||||
@ApiOperation(value = "创建订单")
|
||||
@PostMapping(value = "/trade/{amount}")
|
||||
public Response<HashMap<String, String>> createOrder(@PathVariable Integer amount, @RequestParam String returnUrl) throws SerializeException {
|
||||
HashMap<String, String> approvalUrl = payPalCheckoutService.createOrder(amount,returnUrl);
|
||||
return Response.success(approvalUrl);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "ipn异步回调")
|
||||
@PostMapping(value = "/ipn/back")
|
||||
public Response<String> callback(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
Boolean result = payPalCheckoutService.doPost(request, response);
|
||||
if (result){
|
||||
return Response.success(200,"success");
|
||||
}else {
|
||||
return Response.fail(500,"failure");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询指定订单")
|
||||
@PostMapping(value = "/trade/query/{orderNo}")
|
||||
public Response<Order> queryOrder(@PathVariable String orderNo) throws SerializeException {
|
||||
Order s = payPalCheckoutService.queryOrder(orderNo);
|
||||
return Response.success(s);
|
||||
}
|
||||
|
||||
/** 不提供退款接口 */
|
||||
@ApiOperation("申请退款")
|
||||
@PostMapping("/trade/refund/{orderNo}/{reason}")
|
||||
public Response<HttpResponse<Refund>> refund(@PathVariable String orderNo, @PathVariable String reason) throws IOException {
|
||||
Boolean response = payPalCheckoutService.refundOrder(orderNo,reason);
|
||||
if (response){
|
||||
return Response.success();
|
||||
}else {
|
||||
return Response.fail("Request for refund failed.");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("执行扣款")
|
||||
@PostMapping("/trade/capture/{orderNo}")
|
||||
public Response<com.paypal.orders.Order> captureOrder(@PathVariable String orderNo) throws IOException {
|
||||
Order response = payPalCheckoutService.captureOrder(orderNo);
|
||||
return Response.success(response);
|
||||
}
|
||||
}
|
||||
|
||||
59
src/main/java/com/ai/da/controller/PortfolioController.java
Normal file
59
src/main/java/com/ai/da/controller/PortfolioController.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.model.dto.PortfolioDTO;
|
||||
import com.ai.da.model.dto.QueryPortfolioPageDTO;
|
||||
import com.ai.da.model.vo.PortfolioVO;
|
||||
import com.ai.da.model.vo.UserLikeChooseVO;
|
||||
import com.ai.da.service.PortfolioService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Api(tags = "Portfolio模块")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/portfolio")
|
||||
public class PortfolioController {
|
||||
|
||||
@Resource
|
||||
private PortfolioService portfolioService;
|
||||
|
||||
@ApiOperation(value = "发布作品集")
|
||||
@PostMapping("/publish")
|
||||
public Response<Boolean> preLogin(@Valid @RequestBody PortfolioDTO portfolioDTO) {
|
||||
return Response.success(portfolioService.publish(portfolioDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "作品集page")
|
||||
@PostMapping("/page")
|
||||
public Response<PageBaseResponse<PortfolioVO>> page(@Valid @RequestBody QueryPortfolioPageDTO query) {
|
||||
return Response.success(portfolioService.page(query));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "作品详情")
|
||||
@PostMapping("/detail")
|
||||
public Response<PortfolioVO> detail(@Valid @RequestBody PortfolioDTO portfolioDTO) {
|
||||
return Response.success(portfolioService.detail(portfolioDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "选择作品")
|
||||
@PostMapping("/choose")
|
||||
public Response<UserLikeChooseVO> choose(@Valid @RequestBody PortfolioDTO portfolioDTO) {
|
||||
return Response.success(portfolioService.choose(portfolioDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新作品")
|
||||
@PostMapping("/update")
|
||||
public Response<PortfolioVO> update(@Valid @RequestBody PortfolioDTO portfolioDTO) {
|
||||
return Response.success(portfolioService.update(portfolioDTO));
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.ai.da.controller;
|
||||
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.entity.Product;
|
||||
import com.ai.da.mapper.primary.entity.Product;
|
||||
import com.ai.da.service.ProductService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@@ -3,16 +3,18 @@ package com.ai.da.controller;
|
||||
import com.ai.da.common.enums.CollectionLevel1TypeEnum;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.mapper.entity.Library;
|
||||
import com.ai.da.mapper.primary.entity.Library;
|
||||
import com.ai.da.model.dto.ChatFlushDTO;
|
||||
import com.ai.da.model.dto.ChatRobotLibraryDTO;
|
||||
import com.ai.da.model.dto.ChatSendDTO;
|
||||
import com.ai.da.model.dto.SuperResolutionDTO;
|
||||
import com.ai.da.model.vo.ChatRobotVO;
|
||||
import com.ai.da.model.vo.PythonLibraryVo;
|
||||
import com.ai.da.model.vo.SysFileVO;
|
||||
import com.ai.da.python.PythonService;
|
||||
import com.ai.da.service.ChatRobotService;
|
||||
import com.ai.da.service.LibraryService;
|
||||
import com.ai.da.service.SuperResolutionService;
|
||||
import com.ai.da.service.SysFileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -41,10 +43,12 @@ public class PythonController {
|
||||
private SysFileService sysFileService;
|
||||
@Resource
|
||||
private LibraryService libraryService;
|
||||
|
||||
@Resource
|
||||
private ChatRobotService chatRobotService;
|
||||
|
||||
@Resource
|
||||
private SuperResolutionService superResolutionService;
|
||||
|
||||
@ApiOperation(value = "python服务保存图片到java服务")
|
||||
@PostMapping("/saveGeneratePicture")
|
||||
public Response<String> upload(@RequestParam("file") MultipartFile file,
|
||||
@@ -109,4 +113,10 @@ public class PythonController {
|
||||
return Response.success(chatRobotService.chatBufferFlush(chatFlushDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "超分辨率")
|
||||
@PostMapping("/prepareForSR")
|
||||
public Response<List<String>> superResolution(@RequestBody List<SuperResolutionDTO> superResolutionDTO) {
|
||||
return Response.success(superResolutionService.prepareForSR(superResolutionDTO));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.TDesignPythonOutfitMapper;
|
||||
import com.ai.da.mapper.entity.Account;
|
||||
import com.ai.da.mapper.entity.TDesignPythonOutfit;
|
||||
import com.ai.da.mapper.entity.UserLikeGroup;
|
||||
import com.ai.da.mapper.primary.TDesignPythonOutfitMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.Library;
|
||||
import com.ai.da.mapper.primary.entity.TDesignPythonOutfit;
|
||||
import com.ai.da.mapper.primary.entity.UserLikeGroup;
|
||||
import com.ai.da.model.dto.*;
|
||||
import com.ai.da.model.vo.*;
|
||||
import com.ai.da.service.*;
|
||||
@@ -27,10 +29,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -49,6 +48,8 @@ public class SavedCollectionController {
|
||||
private TDesignPythonOutfitMapper designPythonOutfitMapper;
|
||||
@Resource
|
||||
private MinioUtil minioUtil;
|
||||
@Resource
|
||||
private ClassificationService classificationService;
|
||||
|
||||
@ApiOperation(value = "History用户分页分组列表")
|
||||
@PostMapping("/queryUserGroup")
|
||||
@@ -67,7 +68,34 @@ public class SavedCollectionController {
|
||||
if (Objects.nonNull(query.getEndDate())) {
|
||||
queryWrapper.le("update_date", new Date(query.getEndDate()));
|
||||
}
|
||||
queryWrapper.orderByDesc("id");
|
||||
// 新增分类过滤
|
||||
if (CollectionUtil.isNotEmpty(query.getClassificationIdList())) {
|
||||
List<Long> historyIdList = new ArrayList<>();
|
||||
if (query.getIntersection() == 0) {
|
||||
for (Long classificationId : query.getClassificationIdList()) {
|
||||
historyIdList.addAll(classificationService.getLibraryIdListByClassificationId(classificationId));
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(historyIdList)) {
|
||||
queryWrapper.in("id", historyIdList);
|
||||
}else {
|
||||
return Response.success(PageBaseResponse.success(new Page<>()));
|
||||
}
|
||||
}else {
|
||||
for (int i = 0; i < query.getClassificationIdList().size(); i++) {
|
||||
List<Long> historyIdListByClassificationId = classificationService.getLibraryIdListByClassificationId(query.getClassificationIdList().get(i));
|
||||
if (i == 0) {
|
||||
historyIdList.addAll(historyIdListByClassificationId);
|
||||
}else {
|
||||
historyIdList.retainAll(historyIdListByClassificationId);
|
||||
}
|
||||
if (CollectionUtil.isEmpty(historyIdList)) {
|
||||
return Response.success(PageBaseResponse.success(new Page<>()));
|
||||
}
|
||||
}
|
||||
queryWrapper.in("id", historyIdList);
|
||||
}
|
||||
}
|
||||
queryWrapper.orderByDesc("update_date");
|
||||
IPage<UserLikeGroup> page = userLikeGroupService.getBaseMapper().selectPage(
|
||||
new Page<>(query.getPage(), query.getSize()), queryWrapper);
|
||||
if (CollectionUtils.isEmpty(page.getRecords())) {
|
||||
|
||||
40
src/main/java/com/ai/da/controller/TaskListController.java
Normal file
40
src/main/java/com/ai/da/controller/TaskListController.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.PageBaseResponse;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.model.dto.QueryTaskHistoryDTO;
|
||||
import com.ai.da.model.dto.SuperResolutionDTO;
|
||||
import com.ai.da.model.dto.TaskDTO;
|
||||
import com.ai.da.model.vo.TaskVO;
|
||||
import com.ai.da.service.TaskListService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "任务列表模块")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/tasks")
|
||||
public class TaskListController {
|
||||
|
||||
@Resource
|
||||
private TaskListService taskListService;
|
||||
|
||||
@PostMapping("/getList")
|
||||
@ApiOperation("获取未执行完的任务")
|
||||
public Response<List<TaskDTO<SuperResolutionDTO>>> getTaskList(@Valid @RequestBody List<String> taskIdList) {
|
||||
return Response.success(taskListService.getExecTask(taskIdList));
|
||||
}
|
||||
|
||||
@PostMapping("/getAllTask")
|
||||
@ApiOperation("获取所有任务")
|
||||
public Response<PageBaseResponse<TaskVO>> getAllTask(@Valid @RequestBody QueryTaskHistoryDTO queryTaskHistoryDTO) {
|
||||
return Response.success(taskListService.getAllTask(queryTaskHistoryDTO));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,8 +42,8 @@ public class ThirdPartyController {
|
||||
@CrossOrigin
|
||||
@ApiOperation(value = "Add user information")
|
||||
@PostMapping("/addTrialUser")
|
||||
public Response<Boolean> addTrialUser(@RequestBody AccountTrialDTO accountTrialDTO) {
|
||||
return Response.success(accountService.addTrialUser(accountTrialDTO));
|
||||
public Response<Boolean> addTrialUser(@RequestBody AccountTrialDTO accountTrialDTO, HttpServletRequest request) {
|
||||
return Response.success(accountService.addTrialUser(accountTrialDTO, request));
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.ai.da.controller;
|
||||
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.mapper.entity.Workspace;
|
||||
import com.ai.da.model.dto.ModelsDotDTO;
|
||||
import com.ai.da.mapper.primary.entity.Style;
|
||||
import com.ai.da.mapper.primary.entity.Workspace;
|
||||
import com.ai.da.model.dto.WorkspaceDTO;
|
||||
import com.ai.da.model.dto.WorkspaceSaveDTO;
|
||||
import com.ai.da.model.enums.BizJson;
|
||||
import com.ai.da.model.vo.ModelsVO;
|
||||
import com.ai.da.model.vo.StyleVO;
|
||||
import com.ai.da.model.vo.WorkspaceVO;
|
||||
import com.ai.da.service.WorkspaceService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -19,9 +20,7 @@ import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.List;
|
||||
@@ -48,8 +47,8 @@ public class WorkspaceController {
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@ApiOperation(value = "详情", notes = "传入workspace")
|
||||
public Response<Workspace> detail(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) {
|
||||
Workspace detail = workspaceService.getByIdNew(id);
|
||||
public Response<WorkspaceVO> detail(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) {
|
||||
WorkspaceVO detail = workspaceService.getByIdNew(id);
|
||||
return Response.success(detail);
|
||||
}
|
||||
|
||||
@@ -70,8 +69,8 @@ public class WorkspaceController {
|
||||
@PostMapping("/saveOrUpdate")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@ApiOperation(value = "新增或编辑", notes = "传入workspace")
|
||||
public Response saveOrUpdate(@Valid @RequestBody Workspace workspace) {
|
||||
return Response.success(workspaceService.saveOrUpdate(workspace));
|
||||
public Response saveOrUpdate(@Valid @RequestBody WorkspaceSaveDTO workspaceDTO) {
|
||||
return Response.success(workspaceService.saveOrUpdate(workspaceDTO));
|
||||
}
|
||||
|
||||
|
||||
@@ -119,10 +118,17 @@ public class WorkspaceController {
|
||||
}
|
||||
|
||||
@PostMapping("maleDataInsert")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@ApiOperationSupport(order = 8)
|
||||
@ApiOperation(value = "男装数据入库入minio")
|
||||
public Response<Boolean> maleDataInsert() throws FileNotFoundException {
|
||||
workspaceService.maleDataInsert();
|
||||
return Response.success(true);
|
||||
}
|
||||
|
||||
@PostMapping("styleList")
|
||||
@ApiOperationSupport(order = 9)
|
||||
@ApiOperation(value = "获取style列表")
|
||||
public Response<List<StyleVO>> styleList() {
|
||||
return Response.success(workspaceService.styleList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Collection;
|
||||
import com.ai.da.mapper.entity.Design;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface DesignMapper extends CommonMapper<Design> {
|
||||
|
||||
//返回插入数据后生成的主键
|
||||
Long insertDesign(Design design);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.ai.da.mapper.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class BaseEntity {
|
||||
|
||||
//定义主键策略:跟随数据库的主键自增
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private String id; //主键
|
||||
|
||||
private Date createTime;//创建时间
|
||||
|
||||
private Date updateTime;//更新时间
|
||||
}
|
||||
@@ -1,17 +1,14 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Account;
|
||||
import com.ai.da.mapper.entity.AccountLoginLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface AccountLoginLogMapper extends CommonMapper<AccountLoginLog> {
|
||||
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.AccountLoginLog;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface AccountLoginLogMapper extends CommonMapper<AccountLoginLog> {
|
||||
|
||||
}
|
||||
@@ -1,32 +1,32 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Account;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface AccountMapper extends CommonMapper<Account> {
|
||||
|
||||
/**
|
||||
* 手机号批量查询
|
||||
*
|
||||
* @param phoneList
|
||||
* @return
|
||||
*/
|
||||
List<Account> findByPhoneList(List<String> phoneList);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Account findById(String id);
|
||||
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface AccountMapper extends CommonMapper<Account> {
|
||||
|
||||
/**
|
||||
* 手机号批量查询
|
||||
*
|
||||
* @param phoneList
|
||||
* @return
|
||||
*/
|
||||
List<Account> findByPhoneList(List<String> phoneList);
|
||||
|
||||
/**
|
||||
* 主键查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Account findById(String id);
|
||||
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.ChatRobot;
|
||||
|
||||
import java.util.List;
|
||||
import com.ai.da.mapper.primary.entity.ChatRobot;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.ChatRobot;
|
||||
import com.ai.da.mapper.entity.Classification;
|
||||
import com.ai.da.mapper.primary.entity.Classification;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Classification;
|
||||
import com.ai.da.mapper.entity.ClassificationRelLibrary;
|
||||
import com.ai.da.mapper.primary.entity.ClassificationRelLibrary;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.CollectionElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2022-10-13
|
||||
*/
|
||||
public interface CollectionElementMapper extends CommonMapper<CollectionElement> {
|
||||
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.CollectionElement;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author yanglei
|
||||
* @since 2022-10-13
|
||||
*/
|
||||
public interface CollectionElementMapper extends CommonMapper<CollectionElement> {
|
||||
|
||||
}
|
||||
@@ -1,18 +1,15 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Account;
|
||||
import com.ai.da.mapper.entity.Collection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface CollectionMapper extends CommonMapper<Collection> {
|
||||
//返回插入数据后生成的主键
|
||||
Long insertCollection(Collection collection);
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Collection;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface CollectionMapper extends CommonMapper<Collection> {
|
||||
//返回插入数据后生成的主键
|
||||
Long insertCollection(Collection collection);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Collection;
|
||||
import com.ai.da.mapper.primary.entity.Collocation;
|
||||
import com.ai.da.python.vo.DesignPythonItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CollocationMapper extends CommonMapper<Collocation> {
|
||||
|
||||
List<Collocation> getCollocationListBySketch(String apparel, String styleCategory);
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.ColorLookupTable;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-09-30
|
||||
*/
|
||||
public interface ColorLoopUpTableMapper extends CommonMapper<ColorLookupTable> {
|
||||
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.ColorLookupTable;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-09-30
|
||||
*/
|
||||
public interface ColorLoopUpTableMapper extends CommonMapper<ColorLookupTable> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.CreditsDetail;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface CreditsDetailMapper extends BaseMapper<CreditsDetail> {
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.AccountLoginLog;
|
||||
import com.ai.da.mapper.entity.DesignHistory;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface DesignHistoryMapper extends CommonMapper<DesignHistory> {
|
||||
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.DesignHistory;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface DesignHistoryMapper extends CommonMapper<DesignHistory> {
|
||||
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.DesignItem;
|
||||
import com.ai.da.mapper.entity.DesignItemDetail;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface DesignItemDetailMapper extends CommonMapper<DesignItemDetail> {
|
||||
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.DesignItemDetail;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface DesignItemDetailMapper extends CommonMapper<DesignItemDetail> {
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.DesignItemDetailPrint;
|
||||
import com.ai.da.mapper.primary.entity.DesignItemDetailPrint;
|
||||
|
||||
|
||||
public interface DesignItemDetailPrintMapper extends CommonMapper<DesignItemDetailPrint> {
|
||||
@@ -1,16 +1,15 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Design;
|
||||
import com.ai.da.mapper.entity.DesignItem;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface DesignItemMapper extends CommonMapper<DesignItem> {
|
||||
|
||||
Long insertDesignItem(DesignItem designItem);
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.DesignItem;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface DesignItemMapper extends CommonMapper<DesignItem> {
|
||||
|
||||
Long insertDesignItem(DesignItem designItem);
|
||||
}
|
||||
22
src/main/java/com/ai/da/mapper/primary/DesignMapper.java
Normal file
22
src/main/java/com/ai/da/mapper/primary/DesignMapper.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
//import com.ai.da.mapper.entity.Design;
|
||||
import com.ai.da.model.dto.UserDesignStatisticDTO;
|
||||
|
||||
import java.util.List;
|
||||
import com.ai.da.mapper.primary.entity.Design;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface DesignMapper extends CommonMapper<Design> {
|
||||
|
||||
//返回插入数据后生成的主键
|
||||
Long insertDesign(Design design);
|
||||
|
||||
List<UserDesignStatisticDTO> getDesignStatistic(String startTime, String endTime);
|
||||
}
|
||||
11
src/main/java/com/ai/da/mapper/primary/DressingMapper.java
Normal file
11
src/main/java/com/ai/da/mapper/primary/DressingMapper.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Dressing;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DressingMapper extends CommonMapper<Dressing> {
|
||||
|
||||
List<String> getOtherSketchCategoryNameList(Long id, String styleCategory);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.GenerateCancel;
|
||||
import com.ai.da.mapper.primary.entity.GenerateCancel;
|
||||
|
||||
public interface GenerateCancelMapper extends CommonMapper<GenerateCancel> {
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.GenerateDetail;
|
||||
import com.ai.da.mapper.primary.entity.GenerateDetail;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Generate;
|
||||
import com.ai.da.mapper.primary.entity.Generate;
|
||||
|
||||
public interface GenerateMapper extends CommonMapper<Generate> {
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Library;
|
||||
import com.ai.da.mapper.entity.LibraryCopy;
|
||||
import com.ai.da.mapper.primary.entity.LibraryCopy;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Design;
|
||||
import com.ai.da.mapper.entity.Library;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface LibraryMapper extends CommonMapper<Library> {
|
||||
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Library;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface LibraryMapper extends CommonMapper<Library> {
|
||||
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.LibraryModelPoint;
|
||||
import com.ai.da.mapper.entity.LibraryModelPointCopy;
|
||||
import com.ai.da.mapper.primary.entity.LibraryModelPointCopy;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.LibraryModelPoint;
|
||||
import com.ai.da.mapper.entity.SysFile;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-11-11
|
||||
*/
|
||||
public interface LibraryModelPointMapper extends CommonMapper<LibraryModelPoint> {
|
||||
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.LibraryModelPoint;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-11-11
|
||||
*/
|
||||
public interface LibraryModelPointMapper extends CommonMapper<LibraryModelPoint> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.mapper.entity.OrderInfo;
|
||||
import com.ai.da.mapper.primary.entity.OrderInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
|
||||
@@ -1,20 +1,19 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.PanTone;
|
||||
import com.ai.da.model.dto.GetRgbByHsvBatchDTO;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface PanToneMapper extends CommonMapper<PanTone> {
|
||||
|
||||
List<PanTone> getRgbByHsvBatch(@Param("rgbByHsvBatch") List<GetRgbByHsvBatchDTO> rgbByHsvBatch);
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.PanTone;
|
||||
import com.ai.da.model.dto.GetRgbByHsvBatchDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface PanToneMapper extends CommonMapper<PanTone> {
|
||||
|
||||
List<PanTone> getRgbByHsvBatch(@Param("rgbByHsvBatch") List<GetRgbByHsvBatchDTO> rgbByHsvBatch);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.mapper.entity.PaymentInfo;
|
||||
import com.ai.da.mapper.primary.entity.PaymentInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface PaymentInfoMapper extends BaseMapper<PaymentInfo> {
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Portfolio;
|
||||
|
||||
public interface PortfolioMapper extends CommonMapper<Portfolio> {
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.mapper.entity.Product;
|
||||
import com.ai.da.mapper.primary.entity.Product;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface ProductMapper extends BaseMapper<Product> {
|
||||
@@ -1,11 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.PythonTAllInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import com.ai.da.mapper.primary.entity.PythonTAllInfo;
|
||||
|
||||
/**
|
||||
* (PythonTAllInfo)表数据库访问层
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
|
||||
import com.ai.da.mapper.entity.RefundInfo;
|
||||
import com.ai.da.mapper.primary.entity.RefundInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface RefundInfoMapper extends BaseMapper<RefundInfo> {
|
||||
17
src/main/java/com/ai/da/mapper/primary/StyleMapper.java
Normal file
17
src/main/java/com/ai/da/mapper/primary/StyleMapper.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Style;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface StyleMapper extends CommonMapper<Style> {
|
||||
|
||||
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Design;
|
||||
import com.ai.da.mapper.entity.SysFile;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-10-6
|
||||
*/
|
||||
public interface SysFileMapper extends CommonMapper<SysFile> {
|
||||
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.SysFile;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-10-6
|
||||
*/
|
||||
public interface SysFileMapper extends CommonMapper<SysFile> {
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.TCollectionElementRelation;
|
||||
import com.ai.da.mapper.primary.entity.TCollectionElementRelation;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.TDesignPythonOutfitDetail;
|
||||
import com.ai.da.mapper.primary.entity.TDesignPythonOutfitDetail;
|
||||
import com.ai.da.model.vo.TDesignPythonOutfitDetailVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.TDesignPythonOutfit;
|
||||
import com.ai.da.mapper.primary.entity.TDesignPythonOutfit;
|
||||
import com.ai.da.model.vo.TDesignPythonOutfitVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.TaskList;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface TaskListMapper extends BaseMapper<TaskList> {
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.ai.da.mapper;
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Account;
|
||||
import com.ai.da.mapper.entity.TrialOrder;
|
||||
|
||||
import java.util.List;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
@@ -1,16 +1,15 @@
|
||||
package com.ai.da.mapper;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.entity.Design;
|
||||
import com.ai.da.mapper.entity.UserLikeGroup;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface UserLikeGroupMapper extends CommonMapper<UserLikeGroup> {
|
||||
//返回插入数据后生成的主键
|
||||
Long insertUserLikeGroup(UserLikeGroup userLikeGroup);
|
||||
}
|
||||
package com.ai.da.mapper.primary;
|
||||
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.UserLikeGroup;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author easy-generator
|
||||
* @since 2022-06-13
|
||||
*/
|
||||
public interface UserLikeGroupMapper extends CommonMapper<UserLikeGroup> {
|
||||
//返回插入数据后生成的主键
|
||||
Long insertUserLikeGroup(UserLikeGroup userLikeGroup);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user