Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #3179

Merged
merged 4 commits into from
Dec 22, 2024
Merged

Dev #3179

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions doc/db/kcloud_platform_generator.sql
Original file line number Diff line number Diff line change
Expand Up @@ -222,22 +222,3 @@ COMMENT ON COLUMN "public"."boot_generator_template"."api" IS 'API';
COMMENT ON COLUMN "public"."boot_generator_template"."view" IS '页面';
COMMENT ON COLUMN "public"."boot_generator_template"."form_view" IS '表单页面';
COMMENT ON TABLE "public"."boot_generator_template" IS '代码生成器模板';

-- ----------------------------
-- Records of boot_generator_template
-- ----------------------------

-- ----------------------------
-- Auto increment value for boot_generator_column
-- ----------------------------
SELECT setval('"public"."boot_generator_column_id_seq2"', 1, false);

-- ----------------------------
-- Auto increment value for boot_generator_info
-- ----------------------------
SELECT setval('"public"."boot_generator_info_id_seq2"', 1, false);

-- ----------------------------
-- Auto increment value for boot_generator_template
-- ----------------------------
SELECT setval('"public"."boot_generator_template_id_seq2"', 1, false);
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.alibaba.nacos.api.config.ConfigService;
import io.micrometer.common.lang.NonNullApi;
import lombok.extern.slf4j.Slf4j;
import org.laokou.common.core.utils.JacksonUtil;
import org.laokou.common.i18n.utils.JacksonUtil;
import org.laokou.common.i18n.common.exception.SystemException;
import org.laokou.common.i18n.utils.StringUtil;
import org.laokou.common.nacos.utils.ConfigUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,22 @@
@ExtractorManager.Extractor(httpExtractor = ConsoleDefaultHttpParamExtractor.class)
public class NamespaceControllerV2 {

private static final int NAMESPACE_ID_MAX_LENGTH = 128;

private final NamespaceOperationService namespaceOperationService;

private NamespacePersistService namespacePersistService;
private final NamespacePersistService namespacePersistService;

private final Pattern namespaceIdCheckPattern = Pattern.compile("^[\\w-]+");

private final Pattern namespaceNameCheckPattern = Pattern.compile("^[^@#$%^&*]+$");

public NamespaceControllerV2(NamespaceOperationService namespaceOperationService,
NamespacePersistService namespacePersistService) {
this.namespaceOperationService = namespaceOperationService;
this.namespacePersistService = namespacePersistService;
}

private final Pattern namespaceIdCheckPattern = Pattern.compile("^[\\w-]+");

private final Pattern namespaceNameCheckPattern = Pattern.compile("^[^@#$%^&*]+$");

private static final int NAMESPACE_ID_MAX_LENGTH = 128;

/**
* Get namespace list.
* @return namespace list
Expand Down
12 changes: 0 additions & 12 deletions laokou-common/laokou-common-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
Expand All @@ -65,10 +61,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
Expand All @@ -77,10 +69,6 @@
<groupId>org.lionsoul</groupId>
<artifactId>ip2region</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import jakarta.servlet.http.HttpServletRequest;
import org.laokou.common.i18n.utils.JacksonUtil;
import org.laokou.common.i18n.utils.ObjectUtil;
import org.laokou.common.i18n.utils.StringUtil;
import org.springframework.util.LinkedMultiValueMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import jakarta.servlet.http.HttpServletResponse;
import lombok.SneakyThrows;
import org.laokou.common.i18n.utils.JacksonUtil;
import org.springframework.http.HttpStatus;
import org.springframework.util.Assert;
import org.springframework.web.context.request.RequestAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

package org.laokou.common.domain.constant;
package org.laokou.common.data.cache.constant;

/**
* @author laokou
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

package org.laokou.common.domain.handler.event;
package org.laokou.common.data.cache.domainevent;

import lombok.Getter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

package org.laokou.common.domain.handler;
package org.laokou.common.data.cache.handler;

/**
* @author laokou
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

package org.laokou.common.domain.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.AutoConfiguration;

/**
* @author laokou
*/
@AutoConfiguration
@MapperScan("org.laokou.common.domain.mapper")
public class DomainAutoConfig {

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.laokou.common.core.utils.MDCUtil;
import org.laokou.common.domain.support.DomainEventPublisher;
import org.laokou.common.i18n.dto.DomainEvent;
import org.laokou.common.i18n.utils.JacksonUtil;
import org.laokou.common.i18n.utils.StringUtil;

import java.nio.charset.StandardCharsets;
import static org.laokou.common.i18n.common.constant.TraceConstant.SPAN_ID;
import static org.laokou.common.i18n.common.constant.TraceConstant.TRACE_ID;

/**
* @author laokou
Expand All @@ -39,9 +42,8 @@ public abstract class AbstractDomainEventHandler implements RocketMQListener<Mes
@Override
public void onMessage(MessageExt messageExt) {
try {
// putTrace(messageExt);
String msg = new String(messageExt.getBody(), StandardCharsets.UTF_8);
// handleDomainEvent(convert(msg));
putTrace(messageExt);
handleDomainEvent(JacksonUtil.toBean(messageExt.getBody(), DomainEvent.class));
}
catch (Exception e) {
log.error("消费失败,主题Topic:{},偏移量Offset:{},错误信息:{}", messageExt.getTopic(), messageExt.getCommitLogOffset(),
Expand All @@ -53,15 +55,13 @@ public void onMessage(MessageExt messageExt) {
}
}

// protected abstract void handleDomainEvent(DefaultDomainEvent domainEvent);
//
// protected abstract DefaultDomainEvent convert(String msg);
//
// private void putTrace(MessageExt messageExt) {
// String traceId = messageExt.getProperty(TRACE_ID);
// String spanId = messageExt.getProperty(SPAN_ID);
// MDCUtil.put(traceId, spanId);
// }
protected abstract void handleDomainEvent(DomainEvent domainEvent);

private void putTrace(MessageExt messageExt) {
String traceId = messageExt.getProperty(TRACE_ID);
String spanId = messageExt.getProperty(SPAN_ID);
MDCUtil.put(traceId, spanId);
}

private void clearTrace() {
MDCUtil.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.laokou.common.core.utils.JacksonUtil;
import org.laokou.common.i18n.utils.JacksonUtil;
import org.laokou.common.elasticsearch.annotation.*;
import org.laokou.common.elasticsearch.entity.Search;
import org.laokou.common.i18n.dto.Page;
Expand Down
12 changes: 12 additions & 0 deletions laokou-common/laokou-common-i18n/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@
<groupId>org.laokou</groupId>
<artifactId>laokou-common-banner</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>org.laokou</groupId>
<artifactId>laokou-common-test</artifactId>
Expand All @@ -63,6 +71,10 @@
<artifactId>laokou-common-log4j2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
*/
public enum EventType {

SEND_CAPTCHA, SEND_NOTICE
SEND_CAPTCHA, SEND_NOTICE, LOGIN

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,22 @@
package org.laokou.common.i18n.dto;

import lombok.Getter;
import lombok.Setter;
import org.laokou.common.i18n.common.constant.EventType;
import org.laokou.common.i18n.utils.DateUtil;
import org.laokou.common.i18n.utils.StringUtil;

import java.io.Serial;
import java.time.Instant;

import static org.laokou.common.i18n.common.constant.StringConstant.EMPTY;

/**
* 领域事件.
*
* @author laokou
*/
@Setter
@Getter
public class DomainEvent extends Identifier {

Expand Down Expand Up @@ -84,10 +90,22 @@ public class DomainEvent extends Identifier {
*/
private final String sourcePrefix;

public DomainEvent() {
this.payload = EMPTY;
this.type = EMPTY;
this.sourcePrefix = EMPTY;
this.tenantId = 0L;
this.userId = 0L;
this.aggregateId = 0L;
this.topic = EMPTY;
this.tag = EMPTY;
this.version = 0;
}

public DomainEvent(Long eventId, Long tenantId, Long userId, Long aggregateId, String topic, String tag,
int version, String payload, String type, String sourcePrefix) {
int version, String payload, EventType type, String sourcePrefix) {
this.payload = payload;
this.type = type;
this.type = StringUtil.convertUnder(type.name().toLowerCase());
this.sourcePrefix = sourcePrefix;
this.id = eventId;
this.tenantId = tenantId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

package org.laokou.common.core.utils;
package org.laokou.common.i18n.utils;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
Expand All @@ -27,8 +27,6 @@
import com.fasterxml.jackson.databind.type.MapType;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.InputStream;
import java.util.Collection;
Expand All @@ -41,7 +39,6 @@
* @author livk
* @author laokou
*/
@Slf4j
public final class JacksonUtil {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
import org.laokou.common.core.context.UserContextHolder;
import org.laokou.common.core.utils.*;
import org.laokou.common.i18n.utils.DateUtil;
import org.laokou.common.i18n.utils.JacksonUtil;
import org.laokou.common.i18n.utils.ObjectUtil;
import org.springframework.util.StopWatch;
import org.springframework.web.multipart.MultipartFile;

import java.time.Instant;
import java.util.*;

import static org.laokou.common.core.utils.JacksonUtil.EMPTY_JSON;
import static org.laokou.common.i18n.utils.JacksonUtil.EMPTY_JSON;
import static org.laokou.common.i18n.common.constant.StringConstant.*;
import static org.springframework.http.HttpHeaders.USER_AGENT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,15 @@ private AsyncPaginationInnerInterceptor asyncPaginationInnerInterceptor(DataSour
// 使用postgresql,如果使用其他数据库,需要修改DbType
// 使用postgresql,如果使用其他数据库,需要修改DbType
// 使用postgresql,如果使用其他数据库,需要修改DbType
ExecutorService executor = ThreadUtil.newVirtualTaskExecutor();
AsyncPaginationInnerInterceptor asyncPaginationInnerInterceptor = new AsyncPaginationInnerInterceptor(
DbType.POSTGRE_SQL, dataSource, executor);
// -1表示不受限制
asyncPaginationInnerInterceptor.setMaxLimit(-1L);
// 溢出总页数后是进行处理,查看源码就知道是干啥的
asyncPaginationInnerInterceptor.setOverflow(true);
return asyncPaginationInnerInterceptor;
try (ExecutorService executor = ThreadUtil.newVirtualTaskExecutor()) {
AsyncPaginationInnerInterceptor asyncPaginationInnerInterceptor = new AsyncPaginationInnerInterceptor(
DbType.POSTGRE_SQL, dataSource, executor);
// -1表示不受限制
asyncPaginationInnerInterceptor.setMaxLimit(-1L);
// 溢出总页数后是进行处理,查看源码就知道是干啥的
asyncPaginationInnerInterceptor.setOverflow(true);
return asyncPaginationInnerInterceptor;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ public DataAccessException translateExceptionIfPossible(RuntimeException e) {
// Batch exceptions come inside another PersistenceException
// recursion has a risk of infinite loop so better make another if
var msg = e.getMessage();
if (e.getCause() instanceof PersistenceException) {
e = (PersistenceException) e.getCause();
if (e.getCause() instanceof PersistenceException pe) {
if (msg == null) {
msg = e.getMessage();
msg = pe.getMessage();
}
}
if (e.getCause() instanceof SQLException se) {
Expand All @@ -110,8 +109,8 @@ public DataAccessException translateExceptionIfPossible(RuntimeException e) {
var dae = this.exceptionTranslator.translate(task, null, se);
return dae != null ? dae : new UncategorizedSQLException(task, null, se);
}
if (e.getCause() instanceof TransactionException) {
throw (TransactionException) e.getCause();
if (e.getCause() instanceof TransactionException te) {
throw te;
}
return new MyBatisSystemException(msg, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.laokou.common.nacos.utils;

import org.laokou.common.core.utils.JacksonUtil;
import org.laokou.common.i18n.utils.JacksonUtil;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand Down
Loading
Loading