新增common、core

This commit is contained in:
付庆吉
2020-12-11 14:38:30 +08:00
parent b0e46351e1
commit 82fafc4f85
54 changed files with 3082 additions and 0 deletions

View File

@ -0,0 +1,19 @@
package com.chinaunicom.mall.ebtp.core;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
@MapperScan({"com.chinaunicom.mall.ebtp.core.**.dao"})
@SpringBootApplication
@ComponentScan(basePackages = {"com.chinaunicom.mall.ebtp.common"})
@EnableFeignClients
@EnableEurekaClient
public class UbootCoreApplication {
public static void main(String[] args) {
SpringApplication.run(UbootCoreApplication.class, args);
}
}

View File

@ -0,0 +1,36 @@
package com.chinaunicom.mall.ebtp.core.config;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 配置数据源
*/
@Configuration
//@MapperScan(basePackages = "com.chinaunicom.mall.ebtp.**.dao")
public class MybatisPlusConfig {
/**
* 分页插件
* @return
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
// 设置请求的页面大于最大页后操作, true调回到首页false 继续请求 默认false
// paginationInterceptor.setOverflow(false);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
// paginationInterceptor.setLimit(500);
// 开启 count 的 join 优化,只针对部分 left join
paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
return paginationInterceptor;
}
}

View File

@ -0,0 +1,76 @@
package com.chinaunicom.mall.ebtp.core.config;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseCacheUserServiceImpl;
import com.chinaunicom.mall.ebtp.common.constant.CommonConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* 自动填充公共字段
*
* @author: 付庆吉
* @program: mybatis-plus
* @date: 2019-09-03 20:01
**/
@Slf4j
@Component
public class MybatisPlusMetaObjectHandler implements MetaObjectHandler {
@Autowired
private BaseCacheUserServiceImpl userService;
/**
* 插入元对象字段填充(用于插入时对公共字段的填充)
*
* @param metaObject 元对象
*/
@Override
public void insertFill(MetaObject metaObject) {
Object obj = getFieldValByName("createBy", metaObject);
if (obj == null) {
setFieldValByName("createBy",userService.getCacheUser().getUserId() , metaObject);
}
obj = getFieldValByName("createDate", metaObject);
if (obj == null) {
setFieldValByName("createDate", LocalDateTime.now(), metaObject);
}
obj = getFieldValByName("updateBy", metaObject);
if (obj == null) {
setFieldValByName("updateBy", userService.getCacheUser().getUserId(), metaObject);
}
obj = getFieldValByName("updateDate", metaObject);
if (obj == null) {
setFieldValByName("updateDate", LocalDateTime.now(), metaObject);
}
obj = getFieldValByName("tenantId", metaObject);
if (obj == null) {
setFieldValByName("tenantId", "ebtp_mall", metaObject);
}
obj = getFieldValByName("tenantName", metaObject);
if (obj == null) {
setFieldValByName("tenantName", "ebtp_mall", metaObject);
}
setFieldValByName("deleteFlag", CommonConstants.STATUS_NORMAL, metaObject);
}
/**
* 更新元对象字段填充(用于更新时对公共字段的填充)
*
* @param metaObject 元对象
*/
@Override
public void updateFill(MetaObject metaObject) {
setFieldValByName("updateBy", userService.getCacheUser().getUserId(), metaObject);
setFieldValByName("updateDate", LocalDateTime.now(), metaObject);
setFieldValByName("lastUpdateTime", LocalDateTime.now(), metaObject);
}
}

View File

@ -0,0 +1,92 @@
server:
port: 8080
servlet:
context-path: /
spring:
aop:
auto: true #开启spring的aop配置
proxy-target-class: true
application:
name: uboot-core
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: mall3-ebtp-dev
password: mall3-ebtp-dev
url: jdbc:mysql://125.32.114.204:13306/ebtp-cloud?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
serialization:
write-dates-as-timestamps: false
kafka:
bootstrap-servers: 127.0.0.1:9092
producer:
# 写入失败时重试次数。当leader节点失效一个repli节点会替代成为leader节点此时可能出现写入失败
# 当retris为0时produce不会重复。retirs重发此时repli节点完全成为leader节点不会产生消息丢失。
retries: 0
# 每次批量发送消息的数量,produce积累到一定数据一次发送
batch-size: 2
# produce积累数据一次发送缓存大小达到buffer.memory就发送数据
buffer-memory: 33554432
#procedure要求leader在考虑完成请求之前收到的确认数用于控制发送记录在服务端的持久化其值可以为如下
#acks = 0 如果设置为零,则生产者将不会等待来自服务器的任何确认,该记录将立即添加到套接字缓冲区并视为已发送。在这种情况下,无法保证服务器已收到记录,并且重试配置将不会生效(因为客户端通常不会知道任何故障),为每条记录返回的偏移量始终设置为-1。
#acks = 1 这意味着leader会将记录写入其本地日志但无需等待所有副本服务器的完全确认即可做出回应在这种情况下如果leader在确认记录后立即失败但在将数据复制到所有的副本服务器之前则记录将会丢失。
#acks = all 这意味着leader将等待完整的同步副本集以确认记录这保证了只要至少一个同步副本服务器仍然存活记录就不会丢失这是最强有力的保证这相当于acks = -1的设置。
#可以设置的值为all, -1, 0, 1
acks: 1
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.apache.kafka.common.serialization.StringSerializer
consumer:
group-id: user-group
auto-offset-reset: earliest
enable-auto-commit: true
auto-commit-interval: 100
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
#=========redis基础配置=========
redis:
lettuce:
# jedis:
pool:
maxTotal: 50
minIdle: 1
maxWaitMillis: 5000
maxIdle: 5
testOnBorrow: true
testOnReturn: true
testWhileIdle: true
token:
database: 0
host: 125.32.114.204
port: 16379
password: redis@CC1234
timeout: 6000
uuid:
database: 1
host: 125.32.114.204
port: 16379
password: redis@CC1234
timeout: 6000
cache:
database: 2
host: 125.32.114.204
port: 16379
password: redis@CC1234
timeout: 6000
thymeleaf:
prefix: classpath:/templet/
cache: false
suffix: .html
mode: LEGACYHTML5
encoding: utf-8
servlet:
content-type: text/html
mconfig:
swagger-ui-open: true
exception-handle-enabled: true
seata-open-enabled: false

View File

@ -0,0 +1,66 @@
transport {
# tcp udt unix-domain-socket
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = true
# the client batch send request enable
enableClientBatchSendRequest = true
#thread factory for netty
threadFactory {
bossThreadPrefix = "NettyBoss"
workerThreadPrefix = "NettyServerNIOWorker"
serverExecutorThread-prefix = "NettyServerBizHandler"
shareBossWorker = false
clientSelectorThreadPrefix = "NettyClientSelector"
clientSelectorThreadSize = 1
clientWorkerThreadPrefix = "NettyClientWorkerThread"
# netty boss thread size,will not be used for UDT
bossThreadSize = 1
#auto default pin or 8
workerThreadSize = "default"
}
shutdown {
# when destroy server, wait seconds
wait = 3
}
serialization = "seata"
compressor = "none"
}
service {
#transaction service group mapping
vgroupMapping.uboot-core-fescar-service-group = "default"
#only support when registry.type=file, please don't set multiple addresses
default.grouplist = "127.0.0.1:8091"
#degrade, current not support
enableDegrade = false
#disable seata
disableGlobalTransaction = false
}
client {
rm {
asyncCommitBufferLimit = 10000
lock {
retryInterval = 10
retryTimes = 30
retryPolicyBranchRollbackOnConflict = true
}
reportRetryCount = 5
tableMetaCheckEnable = false
reportSuccessEnable = false
}
tm {
commitRetryCount = 5
rollbackRetryCount = 5
}
undo {
dataValidation = true
logSerialization = "jackson"
logTable = "undo_log"
}
log {
exceptionRate = 100
}
}

View File

@ -0,0 +1,21 @@
## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
client {
application.id = uboot-core
transaction.service.group = uboot-core-fescar-service-group
}