记得上下班打卡 | git大法好,push需谨慎

Commit 45d2109d authored by 张国柄's avatar 张国柄

fix:example;

parent 778819eb
liquidnet: liquidnet:
system:
updating:
switch: false
info: info:
port: 9000 port: 9000
context: /service-example context: /example
name: liquidnet-service-example name: liquidnet-service-example
logfile: logfile:
path: /data/logs path: /data/logs
name: service-example name: service-example
config: classpath:logback-spring.xml
file-max-size: 200MB
level: debug
mysql: mysql:
database-name: liquidnet_bus database-name: dev_ln_scene
\ No newline at end of file
...@@ -11,7 +11,6 @@ spring: ...@@ -11,7 +11,6 @@ spring:
profiles: profiles:
include: include:
- common-service - common-service
- liquidnet-common-redisson #这里加载management相关公共配置
# cloud: # cloud:
# bus: # bus:
# destination: springCloudBus.${liquidnet.info.name}.port${liquidnet.info.port} # destination: springCloudBus.${liquidnet.info.name}.port${liquidnet.info.port}
...@@ -43,25 +42,20 @@ spring: ...@@ -43,25 +42,20 @@ spring:
username: ${liquidnet.rabbitmq.username} username: ${liquidnet.rabbitmq.username}
password: ${liquidnet.rabbitmq.password} password: ${liquidnet.rabbitmq.password}
redis: redis:
database: 15
dbs: ${liquidnet.redis.dbs}
port: ${liquidnet.redis.port} port: ${liquidnet.redis.port}
host: ${liquidnet.redis.host} host: ${liquidnet.redis.host}
password: ${liquidnet.redis.password}
lettuce: lettuce:
pool: pool:
max-active: 8 max-active: 5
max-wait: -1 max-wait: -1
max-idle: 8 max-idle: 8
min-idle: 0 min-idle: 0
password: ${liquidnet.redis.password}
mvc:
static-path-pattern: /templates/**
# 定位模板的目录
view:
prefix: classpath:/templates/
suffix: .html
resources:
static-locations: classpath:/templates/,classpath:/static/page
# ----------------------------------------------------------- # -----------------------------------------------------------
knife4j: knife4j:
enable: true
production: ${liquidnet.knife4j.disable} production: ${liquidnet.knife4j.disable}
basic: basic:
enable: true enable: true
...@@ -105,4 +99,7 @@ info: ...@@ -105,4 +99,7 @@ info:
groupId: '@project.groupId@' groupId: '@project.groupId@'
artifactId: '@project.artifactId@' artifactId: '@project.artifactId@'
version: '@project.version@' version: '@project.version@'
# -----------------------------------------------------------
mybatis-plus:
mapper-locations: classpath*:com.liquidnet.service.*.mapper/*Mapper.xml
# ----------------------------------------------------------- # -----------------------------------------------------------
\ No newline at end of file
...@@ -9,14 +9,13 @@ ...@@ -9,14 +9,13 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>liquidnet-service-example-api</artifactId> <artifactId>liquidnet-service-example-api</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.liquidnet</groupId> <groupId>com.liquidnet</groupId>
<artifactId>liquidnet-service-example-do</artifactId> <artifactId>liquidnet-service-example-do</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -11,5 +11,21 @@ ...@@ -11,5 +11,21 @@
<artifactId>liquidnet-service-example-do</artifactId> <artifactId>liquidnet-service-example-do</artifactId>
<dependencies>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project> </project>
package com.liquidnet.service.example;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import java.util.ArrayList;
import java.util.List;
public class MybatisPlusCodeGenerator {
/**
* @param moduleRootPath 项目模块根路径 到 /src 之前 ex:E:\projects\trlabs-bus-v1\trlabs-bus-service\trlabs-common\trlabs-mybatis
* @param dsc 数据源
* @param parentName 相当于业务模块名 com.liquidnet.service.adam 全限定类名
* @param tableNames 表名
*/
public static void doGenerator(String moduleRootPath,
DataSourceConfig dsc,
String parentName,
String[] tableNames) {
AutoGenerator mpg = new AutoGenerator();
// 全局配置BankMybatisPlusCodeGenerator
GlobalConfig gc = new GlobalConfig();
gc.setOutputDir(moduleRootPath + "/src/main/java");
gc.setAuthor("liquidnet");
gc.setOpen(false);
// gc.setSwagger2(true); 实体属性 Swagger2 注解
mpg.setGlobalConfig(gc);
// 数据源配置
mpg.setDataSource(dsc);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setParent(parentName);
mpg.setPackageInfo(pc);
// 自定义配置
InjectionConfig cfg = new InjectionConfig() {
@Override
public void initMap() {
// to do nothing
}
};
// 如果模板引擎是 freemarker
String templatePath = "/templates/mapper.xml.ftl";
// 自定义输出配置
List<FileOutConfig> focList = new ArrayList<>();
// 自定义配置会被优先输出
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
return moduleRootPath + "/src/main/resources/com/liquidnet/service/example/mapper/" + pc.getModuleName()
+ "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
}
});
cfg.setFileOutConfigList(focList);
mpg.setCfg(cfg);
// 配置模板
TemplateConfig templateConfig = new TemplateConfig();
templateConfig.setXml(null);
mpg.setTemplate(templateConfig);
// 策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
// strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!");
strategy.setEntityLombokModel(true);
strategy.setRestControllerStyle(true);
strategy.setInclude(tableNames);
strategy.setControllerMappingHyphenStyle(true);
strategy.setTablePrefix(pc.getModuleName() + "_");
mpg.setStrategy(strategy);
mpg.setTemplateEngine(new FreemarkerTemplateEngine());
mpg.execute();
}
public static void main(String[] args) {
DataSourceConfig dsc = new DataSourceConfig();
// dsc.setSchemaName("public");
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
dsc.setUrl("jdbc:mysql://39.106.122.201:3308/dev_ln_scene?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=CST");
dsc.setUsername("testmall");
dsc.setPassword("zhengzai!mYT");
String resourcePath = "/Users/{?}/Downloads/tmp";
String directory = "com.liquidnet.service.example";
String[] dbTableArray = new String[]{"user"};
doGenerator(resourcePath, dsc, directory, dbTableArray);
}
}
...@@ -2,7 +2,6 @@ package com.liquidnet.service.example.mapper; ...@@ -2,7 +2,6 @@ package com.liquidnet.service.example.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liquidnet.service.example.entity.GeneratorIdExampleEntity; import com.liquidnet.service.example.entity.GeneratorIdExampleEntity;
import com.liquidnet.service.example.entity.LiquidnetStellarUser;
public interface GeneratorIdExampleEntityMapper extends BaseMapper<GeneratorIdExampleEntity> { public interface GeneratorIdExampleEntityMapper extends BaseMapper<GeneratorIdExampleEntity> {
} }
...@@ -12,48 +12,37 @@ ...@@ -12,48 +12,37 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.liquidnet</groupId> <groupId>com.liquidnet</groupId>
<artifactId>liquidnet-service-example-api</artifactId> <artifactId>liquidnet-common-swagger</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.liquidnet</groupId> <groupId>com.liquidnet</groupId>
<artifactId>liquidnet-common-cache-redis</artifactId> <artifactId>liquidnet-common-web</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.liquidnet</groupId>-->
<!-- <artifactId>liquidnet-api-feign-account</artifactId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.liquidnet</groupId>-->
<!-- <artifactId>liquidnet-api-feign-sequence</artifactId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.liquidnet</groupId> <groupId>com.liquidnet</groupId>
<artifactId>liquidnet-common-cache-redisson</artifactId> <artifactId>liquidnet-common-cache-redisson</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.liquidnet</groupId> <groupId>com.liquidnet</groupId>
<artifactId>liquidnet-common-mq</artifactId> <artifactId>liquidnet-common-mq</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mongodb</groupId> <groupId>com.liquidnet</groupId>
<artifactId>mongodb-driver</artifactId> <artifactId>liquidnet-service-example-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>
...@@ -26,20 +26,20 @@ public class ServiceExampleApplication implements CommandLineRunner { ...@@ -26,20 +26,20 @@ public class ServiceExampleApplication implements CommandLineRunner {
} }
@Override @Override
public void run(String... strings) throws Exception { public void run(String... strings) {
try { try {
log.info("\n----------------------------------------------------------\n\t" + log.info("\n----------------------------------------------------------\n\t" +
"Application '{}' is running! Access URLs:\n\t" + "Application '{}' is running! Access URLs:\n\t" +
"Local: \t\thttp://127.0.0.1:{}\n\t" + "Local: \t\thttp://127.0.0.1:{}\n\t" +
"External: \thttp://{}:{}\n\t" + "External: \thttp://{}:{}{}/doc.html\n\t" +
"Profile(s): \t{}\n----------------------------------------------------------", "Profile(s): \t{}\n----------------------------------------------------------",
environment.getProperty("spring.application.name"), environment.getProperty("spring.application.name"),
environment.getProperty("server.port"), environment.getProperty("server.port"),
InetAddress.getLocalHost().getHostAddress(), InetAddress.getLocalHost().getHostAddress(),
environment.getProperty("server.port"), environment.getProperty("server.port"),
environment.getProperty("server.servlet.context-path"),
Arrays.toString(environment.getActiveProfiles())); Arrays.toString(environment.getActiveProfiles()));
} catch (UnknownHostException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
......
package com.liquidnet.service.example.controller; package com.liquidnet.service.example.controller;
import com.alibaba.fastjson.JSON;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.liquidnet.service.api.sequence.feign.FeignSequenceClient;
import com.liquidnet.service.feign.account.api.FeignAccountClient;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -19,10 +15,6 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -19,10 +15,6 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("emp") @RequestMapping("emp")
public class ExampleController { public class ExampleController {
private final Logger log = LoggerFactory.getLogger(this.getClass()); private final Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
private FeignAccountClient feignAccountClient;
@Autowired
private FeignSequenceClient feignSequenceClient;
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "Simple test") @ApiOperation(value = "Simple test")
...@@ -31,46 +23,4 @@ public class ExampleController { ...@@ -31,46 +23,4 @@ public class ExampleController {
log.info("This is `service-example` api.test: {}", str); log.info("This is `service-example` api.test: {}", str);
return ResponseEntity.ok("This is `service-example` api.test: " + str); return ResponseEntity.ok("This is `service-example` api.test: " + str);
} }
@ApiOperationSupport(order = 2)
@ApiOperation(value = "Feign account api test")
@GetMapping(value = "test/feign-account")
public ResponseEntity<?> testFeignAccount(String str) {
log.info("This is `service-example` api.test:feign-account: {}", str);
Object feignAccountRst = null;
{
// WalletQueryParam walletQueryParam = new WalletQueryParam();
// walletQueryParam.setChannelId("50001");
// walletQueryParam.setBizType("000");
// walletQueryParam.setUserExtId("1001");
// feignAccountRst = feignAccountClient.trading(walletQueryParam.txData());
// log.info("This is the result of a remote call to the `service-account` api.query:\n\n{}\n", JSON.toJSONString(feignAccountRst));
}
{
feignAccountRst = feignAccountClient.queryOne(str);
log.info("This is the result of a remote call to the `service-account` api.queryOne:\n\n{}\n", JSON.toJSONString(feignAccountRst));
}
return ResponseEntity.ok(feignAccountRst);
}
@ApiOperationSupport(order = 3)
@ApiOperation(value = "Feign sequence api test")
@GetMapping(value = "test/feign-sequence")
public ResponseEntity<?> testFeignSequence(String str) {
log.info("This is `service-example` api.test:feign-sequence: {}", str);
Object feignSequenceRst = null;
{
feignSequenceRst = feignSequenceClient.nextIncrId(str);
log.info("This is the result of a remote call to the `service-sequence`.nextIncrId:\n\n{}\n", JSON.toJSONString(feignSequenceRst));
}
{
feignSequenceRst = feignSequenceClient.nextId();
log.info("This is the result of a remote call to the `service-sequence`.nextId:\n\n{}\n", JSON.toJSONString(feignSequenceRst));
}
{
feignSequenceRst = feignSequenceClient.nextId(10);
log.info("This is the result of a remote call to the `service-sequence`.test(10):\n\n{}\n", JSON.toJSONString(feignSequenceRst));
}
return ResponseEntity.ok(feignSequenceRst);
}
} }
package com.liquidnet.service.example.controller; package com.liquidnet.service.example.controller;
import com.liquidnet.service.example.service.ILiquidnetStellarUserService; import com.liquidnet.service.example.service.ILiquidnetStellarUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
......
...@@ -2,7 +2,7 @@ package com.liquidnet.service.example.controller; ...@@ -2,7 +2,7 @@ package com.liquidnet.service.example.controller;
import com.liquidnet.common.cache.redisson.util.RedisLockUtil; import com.liquidnet.common.cache.redisson.util.RedisLockUtil;
import com.liquidnet.common.swagger.config.SwaggerApiVersion; import com.liquidnet.common.swagger.config.SwaggerApiVersion;
import com.liquidnet.service.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.redisson.api.RLock; import org.redisson.api.RLock;
......
...@@ -6,7 +6,7 @@ liquidnet: ...@@ -6,7 +6,7 @@ liquidnet:
username: user username: user
password: user123 password: user123
eureka: eureka:
host: 127.0.0.1:7001 host: 39.106.122.201:7001
# end-dev-这里是配置信息基本值 # end-dev-这里是配置信息基本值
spring: spring:
......
#eurekaServer配置 #eurekaServer配置
eureka: eureka:
client: client:
register-with-eureka: true register-with-eureka: false
fetch-registry: true fetch-registry: true
serviceUrl: serviceUrl:
defaultZone: http://${liquidnet.security.username}:${liquidnet.security.password}@${liquidnet.eureka.host}/eureka-server/eureka defaultZone: http://${liquidnet.security.username}:${liquidnet.security.password}@${liquidnet.eureka.host}/eureka-server/eureka
...@@ -9,9 +9,9 @@ eureka: ...@@ -9,9 +9,9 @@ eureka:
spring: spring:
cloud: cloud:
config: config:
# uri: http://127.0.0.1:7002/support-config uri: http://127.0.0.1:7002/support-config
profile: ${liquidnet.cloudConfig.profile} # profile: ${liquidnet.cloudConfig.profile}
name: ${spring.application.name} #默认为spring.application.name # name: ${spring.application.name} #默认为spring.application.name
discovery: # discovery:
enabled: true # enabled: true
service-id: liquidnet-support-config # service-id: liquidnet-support-config
\ No newline at end of file \ No newline at end of file
...@@ -16,13 +16,5 @@ ...@@ -16,13 +16,5 @@
<module>liquidnet-service-example-impl</module> <module>liquidnet-service-example-impl</module>
</modules> </modules>
<dependencies>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-common-service-base</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project> </project>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment