A股项目迁移

This commit is contained in:
dengli
2023-11-27 16:10:15 +08:00
parent b19c6ec31d
commit 53039f9055
259 changed files with 19419 additions and 0 deletions

38
.gitignore vendored Normal file
View File

@@ -0,0 +1,38 @@
HELP.md
target/
.DS_
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
*.mvn
/logger/
!**/logger/**
*mvnw*
*/logger/*
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/

57
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,57 @@
stages:
# 构建
- build
- webhook
build:
image: maven:3.6.3-openjdk-8
stage: build
only:
- main
- develop
before_script:
- echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>'$PWD'.m2</localRepository>
<servers>
<server>
<id>nexus</id>
<username>nexus_public</username>
<password>9SZ4KXFvGt9N7kRU</password>
</server>
</servers>
</settings>' > $HOME/.m2/settings.xml
artifacts:
name: stock-market.war
expire_in: 1 day
paths:
- ./target/stock-market.war
script:
- echo ">>>>>>Start Building<<<<<<"
- pwd
- java -version
- mvn -v
- mvn clean install -Dmaven.test.skip=true
- ls
#- apt-get install -y curl
#- curl --max-time 20 http://43.128.20.12:11113/api/webhook/justpull?project=api\&setenv_file=alpha.sh\&publish_env=alpha
- echo ">>>>>>Finish Building<<<<<<"
webhook:
stage: webhook
#tags:
# - gz
only:
- main
- develop
script:
- echo ">>>>>>Start Deploy<<<<<<"
- ls
- apt-get update
- apt-get install -y curl
- curl --max-time 30 http://43.139.146.165:11113/api/webhook/justpull?project=market\&setenv_file=alpha.sh\&publish_env=alpha\&shell=deploy-alpha.sh
- echo ">>>>>>Start Deploy Finish<<<<<<"

256
pom.xml Normal file
View File

@@ -0,0 +1,256 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<parent>
<groupId>cn.qutaojing</groupId>
<artifactId>qutaojing-micro-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<properties>
<docker.repostory>registry.cn-hangzhou.aliyuncs.com</docker.repostory>
<maven.compile.source>1.8</maven.compile.source>
<maven.compile.target>1.8</maven.compile.target>
<maven.build.timestamp.format>MMdd-HHmm</maven.build.timestamp.format>
</properties>
<groupId>cn.stock</groupId>
<artifactId>market</artifactId>
<name>股票行情</name>
<description>股票行情</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>cn.qutaojing</groupId>
<artifactId>qutaojing-common</artifactId>
<version>0.0.2-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.9</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>
io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.13.3</version>
</dependency>-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.9.6</version>
</dependency>
<!-- xxl-job-core -->
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>2.0.9</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<!--joda time-->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java</artifactId>
<version>3.1.322</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>cloudauth20200618</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>cloudauth20190307</artifactId>
<version>1.0.7</version>
</dependency>
<!-- jsoup 相关 -->
<dependency>
<!-- jsoup HTML parser library @ https://jsoup.org/ -->
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.15.2</version>
</dependency>
</dependencies>
<build>
<finalName>stock-market</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>src/main/generated</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>nexus</id>
<url>https://nexus.duofu88.com/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<!--<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>public</id>
<url>http://nexus.rplees.com/nexus/content/repositories/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>-->
</repositories>
</project>

View File

@@ -0,0 +1,57 @@
package cn.stock.market.infrastructure.db.po;
import static com.querydsl.core.types.PathMetadataFactory.*;
import com.querydsl.core.types.dsl.*;
import com.querydsl.core.types.PathMetadata;
import javax.annotation.Generated;
import com.querydsl.core.types.Path;
/**
* QCityPO is a Querydsl query type for CityPO
*/
@Generated("com.querydsl.codegen.EntitySerializer")
public class QCityPO extends EntityPathBase<CityPO> {
private static final long serialVersionUID = -1922934307L;
public static final QCityPO cityPO = new QCityPO("cityPO");
public final StringPath cityCode = createString("cityCode");
public final NumberPath<Integer> id = createNumber("id", Integer.class);
public final StringPath latitude = createString("latitude");
public final StringPath levelType = createString("levelType");
public final StringPath longitude = createString("longitude");
public final StringPath name = createString("name");
public final StringPath parentId = createString("parentId");
public final StringPath path = createString("path");
public final StringPath remark = createString("remark");
public final StringPath shortName = createString("shortName");
public final StringPath zipCode = createString("zipCode");
public QCityPO(String variable) {
super(CityPO.class, forVariable(variable));
}
public QCityPO(Path<? extends CityPO> path) {
super(path.getType(), path.getMetadata());
}
public QCityPO(PathMetadata metadata) {
super(CityPO.class, metadata);
}
}

View File

@@ -0,0 +1,47 @@
package cn.stock.market.infrastructure.db.po;
import static com.querydsl.core.types.PathMetadataFactory.*;
import com.querydsl.core.types.dsl.*;
import com.querydsl.core.types.PathMetadata;
import javax.annotation.Generated;
import com.querydsl.core.types.Path;
/**
* QCounter is a Querydsl query type for Counter
*/
@Generated("com.querydsl.codegen.EntitySerializer")
public class QCounter extends EntityPathBase<Counter> {
private static final long serialVersionUID = 690984745L;
public static final QCounter counter = new QCounter("counter");
public final NumberPath<Long> count = createNumber("count", Long.class);
public final DateTimePath<java.util.Date> createTime = createDateTime("createTime", java.util.Date.class);
public final StringPath fkId = createString("fkId");
public final StringPath k = createString("k");
public final StringPath type = createString("type");
public final DateTimePath<java.util.Date> updateTime = createDateTime("updateTime", java.util.Date.class);
public QCounter(String variable) {
super(Counter.class, forVariable(variable));
}
public QCounter(Path<? extends Counter> path) {
super(path.getType(), path.getMetadata());
}
public QCounter(PathMetadata metadata) {
super(Counter.class, metadata);
}
}

View File

@@ -0,0 +1,41 @@
package cn.stock.market.infrastructure.db.po;
import static com.querydsl.core.types.PathMetadataFactory.*;
import com.querydsl.core.types.dsl.*;
import com.querydsl.core.types.PathMetadata;
import javax.annotation.Generated;
import com.querydsl.core.types.Path;
/**
* QDic is a Querydsl query type for Dic
*/
@Generated("com.querydsl.codegen.EntitySerializer")
public class QDic extends EntityPathBase<Dic> {
private static final long serialVersionUID = -1801755605L;
public static final QDic dic = new QDic("dic");
public final DateTimePath<java.util.Date> createTime = createDateTime("createTime", java.util.Date.class);
public final StringPath k = createString("k");
public final StringPath val = createString("val");
public QDic(String variable) {
super(Dic.class, forVariable(variable));
}
public QDic(Path<? extends Dic> path) {
super(path.getType(), path.getMetadata());
}
public QDic(PathMetadata metadata) {
super(Dic.class, metadata);
}
}

View File

@@ -0,0 +1,45 @@
package cn.stock.market.infrastructure.db.po;
import static com.querydsl.core.types.PathMetadataFactory.*;
import com.querydsl.core.types.dsl.*;
import com.querydsl.core.types.PathMetadata;
import javax.annotation.Generated;
import com.querydsl.core.types.Path;
/**
* QJsonInfoPO is a Querydsl query type for JsonInfoPO
*/
@Generated("com.querydsl.codegen.EntitySerializer")
public class QJsonInfoPO extends EntityPathBase<JsonInfoPO> {
private static final long serialVersionUID = 537860584L;
public static final QJsonInfoPO jsonInfoPO = new QJsonInfoPO("jsonInfoPO");
public final DateTimePath<java.util.Date> createAt = createDateTime("createAt", java.util.Date.class);
public final StringPath ext = createString("ext");
public final NumberPath<Integer> id = createNumber("id", Integer.class);
public final StringPath type = createString("type");
public final DateTimePath<java.util.Date> updateAt = createDateTime("updateAt", java.util.Date.class);
public QJsonInfoPO(String variable) {
super(JsonInfoPO.class, forVariable(variable));
}
public QJsonInfoPO(Path<? extends JsonInfoPO> path) {
super(path.getType(), path.getMetadata());
}
public QJsonInfoPO(PathMetadata metadata) {
super(JsonInfoPO.class, metadata);
}
}

View File

@@ -0,0 +1,51 @@
package cn.stock.market.infrastructure.db.po;
import static com.querydsl.core.types.PathMetadataFactory.*;
import com.querydsl.core.types.dsl.*;
import com.querydsl.core.types.PathMetadata;
import javax.annotation.Generated;
import com.querydsl.core.types.Path;
/**
* QRealtimePO is a Querydsl query type for RealtimePO
*/
@Generated("com.querydsl.codegen.EntitySerializer")
public class QRealtimePO extends EntityPathBase<RealtimePO> {
private static final long serialVersionUID = -677602211L;
public static final QRealtimePO realtimePO = new QRealtimePO("realtimePO");
public final NumberPath<Integer> amounts = createNumber("amounts", Integer.class);
public final NumberPath<Double> averagePrice = createNumber("averagePrice", Double.class);
public final NumberPath<Integer> id = createNumber("id", Integer.class);
public final NumberPath<Double> price = createNumber("price", Double.class);
public final NumberPath<Double> rates = createNumber("rates", Double.class);
public final StringPath stockCode = createString("stockCode");
public final StringPath time = createString("time");
public final NumberPath<Integer> volumes = createNumber("volumes", Integer.class);
public QRealtimePO(String variable) {
super(RealtimePO.class, forVariable(variable));
}
public QRealtimePO(Path<? extends RealtimePO> path) {
super(path.getType(), path.getMetadata());
}
public QRealtimePO(PathMetadata metadata) {
super(RealtimePO.class, metadata);
}
}

View File

@@ -0,0 +1,61 @@
package cn.stock.market.infrastructure.db.po;
import static com.querydsl.core.types.PathMetadataFactory.*;
import com.querydsl.core.types.dsl.*;
import com.querydsl.core.types.PathMetadata;
import javax.annotation.Generated;
import com.querydsl.core.types.Path;
/**
* QSiteArticlePO is a Querydsl query type for SiteArticlePO
*/
@Generated("com.querydsl.codegen.EntitySerializer")
public class QSiteArticlePO extends EntityPathBase<SiteArticlePO> {
private static final long serialVersionUID = -38085285L;
public static final QSiteArticlePO siteArticlePO = new QSiteArticlePO("siteArticlePO");
public final DateTimePath<java.util.Date> addTime = createDateTime("addTime", java.util.Date.class);
public final StringPath artCnt = createString("artCnt");
public final StringPath artImg = createString("artImg");
public final StringPath artSummary = createString("artSummary");
public final StringPath artTitle = createString("artTitle");
public final StringPath artType = createString("artType");
public final StringPath author = createString("author");
public final NumberPath<Integer> hitTimes = createNumber("hitTimes", Integer.class);
public final NumberPath<Integer> id = createNumber("id", Integer.class);
public final NumberPath<Integer> isShow = createNumber("isShow", Integer.class);
public final StringPath sourceId = createString("sourceId");
public final StringPath spiderUrl = createString("spiderUrl");
public final NumberPath<Integer> views = createNumber("views", Integer.class);
public QSiteArticlePO(String variable) {
super(SiteArticlePO.class, forVariable(variable));
}
public QSiteArticlePO(Path<? extends SiteArticlePO> path) {
super(path.getType(), path.getMetadata());
}
public QSiteArticlePO(PathMetadata metadata) {
super(SiteArticlePO.class, metadata);
}
}

View File

@@ -0,0 +1,61 @@
package cn.stock.market.infrastructure.db.po;
import static com.querydsl.core.types.PathMetadataFactory.*;
import com.querydsl.core.types.dsl.*;
import com.querydsl.core.types.PathMetadata;
import javax.annotation.Generated;
import com.querydsl.core.types.Path;
/**
* QSiteNewsPO is a Querydsl query type for SiteNewsPO
*/
@Generated("com.querydsl.codegen.EntitySerializer")
public class QSiteNewsPO extends EntityPathBase<SiteNewsPO> {
private static final long serialVersionUID = 525777388L;
public static final QSiteNewsPO siteNewsPO = new QSiteNewsPO("siteNewsPO");
public final DateTimePath<java.util.Date> addTime = createDateTime("addTime", java.util.Date.class);
public final StringPath content = createString("content");
public final StringPath description = createString("description");
public final NumberPath<Integer> id = createNumber("id", Integer.class);
public final StringPath imgurl = createString("imgurl");
public final DateTimePath<java.util.Date> showTime = createDateTime("showTime", java.util.Date.class);
public final StringPath sourceId = createString("sourceId");
public final StringPath sourceName = createString("sourceName");
public final NumberPath<Integer> status = createNumber("status", Integer.class);
public final StringPath title = createString("title");
public final NumberPath<Integer> type = createNumber("type", Integer.class);
public final DateTimePath<java.util.Date> updateTime = createDateTime("updateTime", java.util.Date.class);
public final NumberPath<Integer> views = createNumber("views", Integer.class);
public QSiteNewsPO(String variable) {
super(SiteNewsPO.class, forVariable(variable));
}
public QSiteNewsPO(Path<? extends SiteNewsPO> path) {
super(path.getType(), path.getMetadata());
}
public QSiteNewsPO(PathMetadata metadata) {
super(SiteNewsPO.class, metadata);
}
}

View File

@@ -0,0 +1,63 @@
package cn.stock.market.infrastructure.db.po;
import static com.querydsl.core.types.PathMetadataFactory.*;
import com.querydsl.core.types.dsl.*;
import com.querydsl.core.types.PathMetadata;
import javax.annotation.Generated;
import com.querydsl.core.types.Path;
/**
* QSysLogPO is a Querydsl query type for SysLogPO
*/
@Generated("com.querydsl.codegen.EntitySerializer")
public class QSysLogPO extends EntityPathBase<SysLogPO> {
private static final long serialVersionUID = -2037818903L;
public static final QSysLogPO sysLogPO = new QSysLogPO("sysLogPO");
public final StringPath actionType = createString("actionType");
public final StringPath content = createString("content");
public final DateTimePath<java.util.Date> createAt = createDateTime("createAt", java.util.Date.class);
public final StringPath ext = createString("ext");
public final NumberPath<Integer> id = createNumber("id", Integer.class);
public final StringPath module = createString("module");
public final StringPath operatorId = createString("operatorId");
public final StringPath operatorName = createString("operatorName");
public final StringPath operatorPhone = createString("operatorPhone");
public final StringPath roleType = createString("roleType");
public final NumberPath<Integer> storeId = createNumber("storeId", Integer.class);
public final StringPath title = createString("title");
public final StringPath uniqueId = createString("uniqueId");
public final DateTimePath<java.util.Date> updateAt = createDateTime("updateAt", java.util.Date.class);
public QSysLogPO(String variable) {
super(SysLogPO.class, forVariable(variable));
}
public QSysLogPO(Path<? extends SysLogPO> path) {
super(path.getType(), path.getMetadata());
}
public QSysLogPO(PathMetadata metadata) {
super(SysLogPO.class, metadata);
}
}

View File

@@ -0,0 +1,39 @@
package cn.stock.market.infrastructure.stockdb.po;
import static com.querydsl.core.types.PathMetadataFactory.*;
import com.querydsl.core.types.dsl.*;
import com.querydsl.core.types.PathMetadata;
import javax.annotation.Generated;
import com.querydsl.core.types.Path;
/**
* QSiteSettingPO is a Querydsl query type for SiteSettingPO
*/
@Generated("com.querydsl.codegen.EntitySerializer")
public class QSiteSettingPO extends EntityPathBase<SiteSettingPO> {
private static final long serialVersionUID = -51441337L;
public static final QSiteSettingPO siteSettingPO = new QSiteSettingPO("siteSettingPO");
public final NumberPath<Integer> id = createNumber("id", Integer.class);
public final StringPath marketServerList = createString("marketServerList");
public QSiteSettingPO(String variable) {
super(SiteSettingPO.class, forVariable(variable));
}
public QSiteSettingPO(Path<? extends SiteSettingPO> path) {
super(path.getType(), path.getMetadata());
}
public QSiteSettingPO(PathMetadata metadata) {
super(SiteSettingPO.class, metadata);
}
}

View File

@@ -0,0 +1,61 @@
package cn.stock.market.infrastructure.stockdb.po;
import static com.querydsl.core.types.PathMetadataFactory.*;
import com.querydsl.core.types.dsl.*;
import com.querydsl.core.types.PathMetadata;
import javax.annotation.Generated;
import com.querydsl.core.types.Path;
/**
* QStockPO is a Querydsl query type for StockPO
*/
@Generated("com.querydsl.codegen.EntitySerializer")
public class QStockPO extends EntityPathBase<StockPO> {
private static final long serialVersionUID = -1246401708L;
public static final QStockPO stockPO = new QStockPO("stockPO");
public final DateTimePath<java.util.Date> addTime = createDateTime("addTime", java.util.Date.class);
public final NumberPath<Integer> id = createNumber("id", Integer.class);
public final NumberPath<java.math.BigDecimal> increaseRatio = createNumber("increaseRatio", java.math.BigDecimal.class);
public final NumberPath<Integer> isLock = createNumber("isLock", Integer.class);
public final NumberPath<Integer> isShow = createNumber("isShow", Integer.class);
public final NumberPath<java.math.BigDecimal> spreadRate = createNumber("spreadRate", java.math.BigDecimal.class);
public final StringPath stockCode = createString("stockCode");
public final StringPath stockGid = createString("stockGid");
public final StringPath stockName = createString("stockName");
public final StringPath stockPlate = createString("stockPlate");
public final StringPath stockSpell = createString("stockSpell");
public final NumberPath<Integer> stockState = createNumber("stockState", Integer.class);
public final StringPath stockType = createString("stockType");
public QStockPO(String variable) {
super(StockPO.class, forVariable(variable));
}
public QStockPO(Path<? extends StockPO> path) {
super(path.getType(), path.getMetadata());
}
public QStockPO(PathMetadata metadata) {
super(StockPO.class, metadata);
}
}

View File

@@ -0,0 +1,72 @@
package cn.stock.market;
import org.apache.commons.lang.StringUtils;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import com.alibaba.fastjson.JSON;
import cn.hutool.http.HttpGlobalConfig;
import cn.qutaojing.common.utils.MdcUtil;
import cn.stock.market.domain.basic.entity.SiteSetting;
import cn.stock.market.domain.basic.repository.SiteSettingRepository;
import lombok.extern.slf4j.Slf4j;
@SpringBootApplication(exclude = {
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class,
RedisAutoConfiguration.class,
// RedissonAutoConfiguration.class, RedisAutoConfiguration.class
})
@Slf4j
@ComponentScan(basePackages = { "cn.stock" })
public class StockMarketLaunch implements CommandLineRunner {
public static void main(String[] args) {
HttpGlobalConfig.setTimeout(45000);
SpringApplication.run(StockMarketLaunch.class, args);
}
@Autowired
private Environment env;
@Override
public void run(String... args) throws Exception {
MDC.put(MdcUtil.TRACE_ID, MdcUtil.getTraceId());
log.info("StockMarketLaunch RUNNING....");
String marketDomain = env.getProperty("market.domain");
if(StringUtils.isNotBlank(marketDomain)) {
log.info("发现marketDomain: {}", marketDomain);
SiteSetting siteSetting = SiteSettingRepository.of().get();
if(siteSetting == null) {
log.info("找不到siteSetting信息, 无法设置");
} else {
log.info("设置前: {}", JSON.toJSONString(siteSetting));
boolean flag = siteSetting.checkAndAddIfNoExists(marketDomain);
if(! flag) {
SiteSettingRepository.of().saveAndFlush(siteSetting);
log.info("已经设置: {}....", JSON.toJSONString(siteSetting));
} else {
log.info("包含, 跳过....");
}
}
}
}
// @Bean
// public TomcatServletWebServerFactory tomcatServletWebServerFactory() {
// TomcatServletWebServerFactory tomcatServletWebServerFactory = new TomcatServletWebServerFactory();
// tomcatServletWebServerFactory.addConnectorCustomizers((Connector connector) -> {
// connector.setProperty("relaxedPathChars", "\"{\\}^`{|}[|]");
// connector.setProperty("relaxedQueryChars", "\"{\\}^`{|}[|]");
// });
// return tomcatServletWebServerFactory;
// }
}

View File

@@ -0,0 +1,11 @@
package cn.stock.market;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class StockMarketServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(StockMarketLaunch.class);
}
}

View File

@@ -0,0 +1,78 @@
package cn.stock.market.application;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ag.utils.CollectionUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.constant.StockSource;
import cn.stock.market.domain.basic.entity.Stock;
import cn.stock.market.domain.basic.repository.StockRepository;
import cn.stock.market.dto.model.StockCode;
import cn.stock.market.dto.model.StockDetail;
import cn.stock.market.dto.model.StockVO;
import cn.stock.market.infrastructure.api.AStockApis;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CommonApis {
public StockDetail aStockDetail(String code) {
return AStockApis.qq(code);
}
public StockVO stockDetail(StockCode code) {
Map<String, StockVO> map = stockDetailMap(Lists.newArrayList(code));
return map.get(code.getCode());
}
public List<StockDetail> aStockDetail(List<String> code) {
return AStockApis.qq(code);
}
public Map<String, StockVO> stockDetailMap(List<StockCode> code) {
Function<StockSource, List<StockCode>> func = (source) -> {
return code.stream()
.filter(val -> val != null && source == val.getSource())
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StockCode::getCode))), ArrayList::new));
};
List<StockCode> aList = func.apply(StockSource.A);
// List<StockCode> hkList = func.apply(StockSource.HK);
// List<StockCode> usList = func.apply(StockSource.US);
Map<String, StockVO> map = Maps.newHashMap();
Collector<StockVO, ?, Map<String, StockVO>> collectorMap = Collectors.toMap(StockVO::getCode, Function.identity(), (u,v) -> { return v;}, HashMap::new);
Map<String, Stock> stockMap = StockRepository.of().cacheCodeMap();
if(CollectionUtils.isNotEmpty(aList)) {
Map<String, StockVO> m = aStockDetail(Lists.transform(aList, val -> val.getCode()))
.stream()
.map(val -> StockVO.from(val, stockMap.get(val.getCode())))
.collect(collectorMap);
map.putAll(m);
}
return map;
}
public static CommonApis of() {
return SpringUtils.getBean(CommonApis.class);
}
}

View File

@@ -0,0 +1,198 @@
//package cn.stock.market.application;
//
//import java.util.Date;
//import java.util.List;
//import java.util.Map;
//import java.util.concurrent.TimeUnit;
//import java.util.stream.Collectors;
//
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import com.ag.utils.CollectionUtils;
//import com.ag.utils.NumberUtils;
//import com.google.common.base.Joiner;
//import com.google.common.collect.Maps;
//import com.querydsl.core.types.dsl.CaseBuilder;
//import com.querydsl.core.types.dsl.CaseBuilder.Cases;
//import com.querydsl.core.types.dsl.NumberExpression;
//import com.querydsl.jpa.impl.JPAUpdateClause;
//
//import cn.qutaojing.common.utils.DslUtils;
//import cn.qutaojing.common.utils.SpringUtils;
//import cn.stock.market.infrastructure.db.po.Counter;
//import cn.stock.market.infrastructure.db.repo.CounterRepo;
//import cn.stock.market.infrastructure.db.po.QCounter;
//import lombok.extern.slf4j.Slf4j;
//
///**
// * 计数器
// *
// * @author xlfd
// * @email xlfd@gmail.com
// * @version 1.0
// * @created Apr 22, 2021 4:21:07 PM
// */
//@Service
//@SuppressWarnings("rawtypes")
//@Slf4j
//public class Counters {
// public static final String TYPE_USER = "USER";
// public static final String TYPE_SYS = "SYS";
//
// /**
// * 用户购买商品
// */
// public static final String USER_BUY_GOODS_COUNT_TMP = "USER_BUY_GOODS_COUNT_%s_%s";
// public static final String USER_EVERYDAY_BUY_GOODS_COUNT_TMP = "USER_EVERYDAY_BUY_GOODS_COUNT_%s_%s_%s";
// public static final String USER_STORE_BUY_COUNT_TMP = "USER_STORE_BUY_COUNT_%s_%s_%s";
//
// static final long EXPIRE_SEC = 60 * 60 * 24; // 默认一天
// @Autowired RedisTemplate redisTemplate;
// @Autowired CounterRepo repo;
//
// String COUNTER_OPERCOUNT_MAP = "counter::opercount::map";
// String COUNTER_MAP_PRE = "counter::count::";
//
// @SuppressWarnings("unchecked")
// public long getCount(String k) {
// Object obj = redisTemplate.opsForValue().get(key(k));
// if(obj != null) {
// if(obj instanceof Number) {
// return ((Number) obj).longValue();
// } else {
// log.error("获取的到值{}非数字类型, 删除", obj);
// redisTemplate.delete(key(k));
// }
// }
//
// Counter counter = repo.findById(k).orElse(null);
// if(counter != null) {
// redisTemplate.opsForValue().set(key(k), counter.getCount(), EXPIRE_SEC, TimeUnit.SECONDS);
// return counter.getCount();
// }
//
// return 0;
// }
//
// String key(String k) {
// return COUNTER_MAP_PRE + k;
// }
//
// /**
// * 返回add后的值
// * @return
// */
// @SuppressWarnings("unchecked")
// public long add(String k, long delta, String type, String fkId) {
// String key = key(k);
// if (redisTemplate.hasKey(key)) {
// Long increment = redisTemplate.opsForValue().increment(key, delta);
//
// if(redisTemplate.opsForHash().hasKey(COUNTER_OPERCOUNT_MAP, key)) {
// redisTemplate.opsForHash().increment(COUNTER_OPERCOUNT_MAP, key, 1);
// } else {
// redisTemplate.opsForHash().putIfAbsent(COUNTER_OPERCOUNT_MAP, key, 1);
// }
// return increment == null ? 0 : increment.longValue();
// }
//
// Counter counter = repo.findById(k).orElse(null);
// if(counter != null) {
// counter.setCount(counter.getCount() + delta);
// } else {
// counter = Counter.builder()
// .k(k)
// .count(delta)
// .type(type)
// .fkId(fkId)
// .build();
// }
// repo.save(counter);
// redisTemplate.opsForValue().set(key, counter.getCount(), EXPIRE_SEC, TimeUnit.SECONDS);
// return counter.getCount();
// }
//
// @SuppressWarnings("unchecked")
// public List<String> getStockOperList() {
// Map<Object, Object> map = redisTemplate.opsForHash().entries(COUNTER_OPERCOUNT_MAP);
// return
// map.entrySet()
// .stream()
// .filter(entry -> {
// return ((int) entry.getValue()) > 0;
// }).map(entry -> entry.getKey())
// .map(String::valueOf)
// .collect(Collectors.toList());
// }
//
// /**
// * 库存从redis回写到DB
// */
// @SuppressWarnings({ "unchecked"})
// @Transactional
// public long writebackToDB() {
// List<String> list = getStockOperList();
// if(CollectionUtils.isEmpty(list)) {
// return 0;
// }
//
// log.info("准备回写库存到DB, size:{}, {}", list.size(), Joiner.on(",").join(list));
// Map<String, Long> map = Maps.newConcurrentMap();
//
// List<Object> valueList = redisTemplate.opsForValue().multiGet(list);
// for (int i = 0; i < list.size(); i++) {
// String keyWithPre = list.get(i);
// Object value = valueList.get(i);
// if(value == null || ! (value instanceof Number)) {
// log.warn("{}-无效", keyWithPre, value);
// continue;
// }
//
// Long count = ((Number) valueList.get(i)).longValue();
// if(NumberUtils.isNotValidWithoutZero(count)) {
// log.warn("{}-无效值", keyWithPre, count);
// continue;
// }
//
// String k = StringUtils.replace(keyWithPre, COUNTER_MAP_PRE, "");
// if(StringUtils.isBlank(k)) {
// log.warn("{}-key-{}无效值", keyWithPre, k);
// continue;
// }
//
// map.put(k, count);
// }
//
// if(CollectionUtils.isNotEmpty(map)) {
// QCounter q = QCounter.counter;
//
// Cases<Long, NumberExpression<Long>> cases = null;
// for (Map.Entry<String, Long> entry : map.entrySet()) {
// if(cases == null) {
// cases = new CaseBuilder().when(q.k.eq(entry.getKey())).then(entry.getValue());
// } else {
// cases = cases.when(q.k.eq(entry.getKey())).then(entry.getValue());
// }
// }
//
// JPAUpdateClause updateClause = DslUtils.update(q)
// .set(q.count, cases.otherwise(-1L))
// .set(q.updateTime, new Date())
// .where(q.k.in(map.keySet()));
//
// long row = updateClause.execute();
// log.info("返回行数:{}, 执行SQL: {}", row, updateClause);
// }
//
// redisTemplate.delete(COUNTER_OPERCOUNT_MAP);
// return list.size();
// }
//
// public static Counters of() {
// return SpringUtils.getBean(Counters.class);
// }
//}

View File

@@ -0,0 +1,264 @@
package cn.stock.market.application;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ag.utils.CollectionUtils;
import com.ag.utils.JsonUtils;
import com.ag.utils.Jsons;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.util.TypeUtils;
import com.google.common.base.Joiner;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.infrastructure.db.po.Dic;
import cn.stock.market.infrastructure.db.po.QDic;
import cn.stock.market.infrastructure.db.repo.DicRepo;
import lombok.extern.slf4j.Slf4j;
/**
* title: Dics.java
*
* @author xlfd
* @version 1.0
* @email xlfd@gmail.com
* @created Oct 15, 2020 11:00:46 AM
*/
@Slf4j
@Service
public class Dics {
@Autowired
DicRepo repository;
final static String SPLIT = "."; //分隔符
LoadingCache<String, Optional<Object>> keyCahce = CacheBuilder.newBuilder()
.maximumSize(20000)
.expireAfterWrite(60, TimeUnit.SECONDS)
.build(CacheLoader.from((prefix) -> {
return Optional.ofNullable(findByPrefix(prefix));
}));
public void refreshCache(String key) {
try {
keyCahce.refresh(key);
} catch(Exception e) {
log.warn("refreshCache error: {}", e.getLocalizedMessage());
}
}
@SuppressWarnings("unchecked")
public <T> T getFromCache(String prefix) {
try {
return (T) keyCahce.get(prefix).orElse(null);
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
}
@SuppressWarnings("unchecked")
public <T> T getFromCache(String prefix, Class<T> clazz) {
Object o = getFromCache(prefix);
if(o != null && clazz == null) {
return (T) o;
}
return Jsons.typeCast(o, clazz);
}
@SuppressWarnings("unchecked")
public <T> T getFromCache(String prefix, T defalutValue) {
Object o = getFromCache(prefix);
if (o == null) {
return defalutValue;
}
return (T) Jsons.typeCast(o, defalutValue.getClass());
// return (T) TypeUtils.cast(o, defalutValue.getClass(), ParserConfig.getGlobalInstance());
}
public static String pack(Object... strings) {
return Joiner.on(SPLIT).skipNulls().join(strings);
}
public static Dics of() {
return SpringUtils.getBean(Dics.class);
}
/**
* 降map的每键值对记录刷到DB中, 每组记录为一列
*
* @param prefix 键的前缀
* @param map
* @return
*/
public List<Dic> save(final String prefix, Object obj) {
JSONObject map = JsonUtils.formObject(obj);
return save(prefix, map);
}
/**
* 降map的每组记录刷到DB中, 每组记录为一列
*
* @param prefix 键的前缀
* @param map
* @return
*/
public List<Dic> save(final String prefix, Map<String, Object> map) {
Map<String, Object> m = Maps.newHashMap();
map.keySet().stream().forEach(k -> {
m.put(prefix + SPLIT + k, map.get(k));
});
return save(m);
}
public Dic saveOne(final String key, Object value) {
Map<String, Object> m = Maps.newHashMap();
m.put(key, value);
return save(m).get(0);
}
public List<Dic> save(Map<String, Object> map) {
List<Dic> list = Lists.newArrayList();
map.forEach((k, v) -> {
Dic dic = Dic.builder()
.k(k)
.val(String.valueOf(v))
.build();
list.add(dic);
});
repository.saveAll(list);
return list;
}
static String[] split(String str) {
return StringUtils.split(str, SPLIT);
}
/**
* 根据前缀查询到列表, 然后每列的k-val对应的 class.v=val封装成对象返回
* 适用于 key -> Object
*
* @param prefix 前缀
* @param clazz
* @return
*/
public <T> T findByPrefix(String prefix, Class<T> clazz) {
Object o = findByPrefix(prefix);
return TypeUtils.cast(o, clazz, ParserConfig.getGlobalInstance());
// return JsonUtils.convert(JsonUtils.formObject(o), clazz);
}
/**
* 根据前缀查询到列表
* 根据传入的prefix返回对应的保存数据库的结构
* 1, prefix -> Object
* 2, prefix -> Map<String, K> K可以是String也可以是Map
*
* @param prefix 前缀
* @return
*/
public <T> T findByPrefix(String prefix) {
return findByPrefix(prefix, Comparator.comparing(Dic::getCreateTime));
}
@SuppressWarnings("unchecked")
public <T> T findByPrefix(String prefix, Comparator<Dic> comparator) {
List<Dic> list = repository.findAll(QDic.dic.k.like(prefix + "%"));
list.sort(comparator);
Map<String, String> map = list.stream().collect(HashMap::new, (m, v) -> m.put(v.getK(), v.getVal()), HashMap::putAll);
Map<String, Object> structureMap = buildStructureMap(map);
return (T) getParameter(structureMap, split(prefix));
}
@SuppressWarnings("rawtypes")
static Object getParameter(Map<String, Object> map, String... settings) {
if (settings == null || settings.length < 1)
return null;
if (settings.length == 1) {
settings = StringUtils.split(settings[0], ".");
}
if (settings.length == 1)
return map.get(settings[0]);
Map tempMap = (Map) map.get(settings[0]);
for (int i = 1; i < settings.length - 1; i++) {
if (tempMap == null) {
return null;
}
tempMap = (Map) tempMap.get(settings[i]);
if (tempMap == null) {
return null;
}
}
if (tempMap == null) {
return null;
}
return tempMap.get(settings[settings.length - 1]);
}
@SuppressWarnings({"unchecked", "rawtypes"})
static Map<String, Object> buildStructureMap(Map<String, String> assembleMap) {
Map<String, Object> map = Maps.newLinkedHashMap();
if (CollectionUtils.isEmpty(assembleMap)) {
return map;
}
for (Map.Entry<String, String> set : assembleMap.entrySet()) {
String variable = set.getKey();
String value = set.getValue();
if (StringUtils.isBlank(variable)) {
continue;
}
String[] keys = StringUtils.split(variable, '.');
Map<String, Object> supMap = null;
Map<String, Object> subMap = null;
Object obj = null;
int len = keys.length - 1;
if (len < 1) { // only root node
map.put(variable, value);
continue;
}
supMap = (Map<String, Object>) map.get(keys[0]);
if (supMap == null) { // new root node
supMap = new LinkedHashMap<String, Object>();
map.put(keys[0], supMap);
}
for (int i = 1; i < len; i++) {
String key = keys[i];
obj = supMap.get(key);
if (obj != null && obj instanceof Map) {
supMap = (Map) obj;
} else {
subMap = Maps.newLinkedHashMap();
supMap.put(key, subMap);
supMap = subMap;
}
}
supMap.put(keys[len], value);
}
return map;
}
}

View File

@@ -0,0 +1,28 @@
package cn.stock.market.application.assembler;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import cn.qutaojing.common.utils.Beans;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.City;
import cn.stock.market.dto.CityDTO;
/**
* CityAssembler
*
* @author xlfd
* @email xlfd@gmail.com
* @created 2021/06/16
*/
@Component
@Lazy
public class CityAssembler {
public CityDTO toDTO(City entity) {
return Beans.mapper(entity, CityDTO.class);
}
public static CityAssembler of() {
return SpringUtils.getBean(CityAssembler.class);
}
}

View File

@@ -0,0 +1,36 @@
package cn.stock.market.application.assembler;
import cn.qutaojing.common.utils.Beans;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.JsonInfo;
import cn.stock.market.dto.JsonInfoDTO;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* JsonInfoAssembler
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2022/08/16
*/
@Component
@Lazy
public class JsonInfoAssembler {
public JsonInfoDTO toDTO(JsonInfo e) {
JsonInfoDTO dto = Beans.mapper(e, JsonInfoDTO.class);
if(dto == null) return dto;
fill(e, dto);
return dto;
}
protected void fill(JsonInfo e, JsonInfoDTO dto) {
if(dto == null) return;
return;
}
public static JsonInfoAssembler of() {
return SpringUtils.getBean(JsonInfoAssembler.class);
}
}

View File

@@ -0,0 +1,35 @@
package cn.stock.market.application.assembler;
import cn.qutaojing.common.utils.Beans;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.Realtime;
import cn.stock.market.dto.RealtimeDTO;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* RealtimeAssembler
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Component
@Lazy
public class RealtimeAssembler {
public RealtimeDTO toDTO(Realtime e) {
RealtimeDTO dto = Beans.mapper(e, RealtimeDTO.class);
if(dto == null) return dto;
fill(e, dto);
return dto;
}
protected void fill(Realtime e, RealtimeDTO dto) {
if(dto == null) return;
return;
}
public static RealtimeAssembler of() {
return SpringUtils.getBean(RealtimeAssembler.class);
}
}

View File

@@ -0,0 +1,35 @@
package cn.stock.market.application.assembler;
import cn.qutaojing.common.utils.Beans;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.SiteArticle;
import cn.stock.market.dto.SiteArticleDTO;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* SiteArticleAssembler
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Component
@Lazy
public class SiteArticleAssembler {
public SiteArticleDTO toDTO(SiteArticle e) {
SiteArticleDTO dto = Beans.mapper(e, SiteArticleDTO.class);
if(dto == null) return dto;
fill(e, dto);
return dto;
}
protected void fill(SiteArticle e, SiteArticleDTO dto) {
if(dto == null) return;
return;
}
public static SiteArticleAssembler of() {
return SpringUtils.getBean(SiteArticleAssembler.class);
}
}

View File

@@ -0,0 +1,35 @@
package cn.stock.market.application.assembler;
import cn.qutaojing.common.utils.Beans;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.SiteNews;
import cn.stock.market.dto.SiteNewsDTO;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* SiteNewsAssembler
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/19
*/
@Component
@Lazy
public class SiteNewsAssembler {
public SiteNewsDTO toDTO(SiteNews e) {
SiteNewsDTO dto = Beans.mapper(e, SiteNewsDTO.class);
if(dto == null) return dto;
fill(e, dto);
return dto;
}
protected void fill(SiteNews e, SiteNewsDTO dto) {
if(dto == null) return;
return;
}
public static SiteNewsAssembler of() {
return SpringUtils.getBean(SiteNewsAssembler.class);
}
}

View File

@@ -0,0 +1,35 @@
package cn.stock.market.application.assembler;
import cn.qutaojing.common.utils.Beans;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.Stock;
import cn.stock.market.dto.StockDTO;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* StockAssembler
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Component
@Lazy
public class StockAssembler {
public StockDTO toDTO(Stock e) {
StockDTO dto = Beans.mapper(e, StockDTO.class);
if(dto == null) return dto;
fill(e, dto);
return dto;
}
protected void fill(Stock e, StockDTO dto) {
if(dto == null) return;
return;
}
public static StockAssembler of() {
return SpringUtils.getBean(StockAssembler.class);
}
}

View File

@@ -0,0 +1,28 @@
package cn.stock.market.application.assembler;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import cn.qutaojing.common.utils.Beans;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.SysLog;
import cn.stock.market.dto.SysLogDTO;
/**
* SysLogAssembler
*
* @author xlfd
* @email xlfd@gmail.com
* @created 2021/06/18
*/
@Component
@Lazy
public class SysLogAssembler {
public SysLogDTO toDTO(SysLog entity) {
return Beans.mapper(entity, SysLogDTO.class);
}
public static SysLogAssembler of() {
return SpringUtils.getBean(SysLogAssembler.class);
}
}

View File

@@ -0,0 +1,66 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum AccountActionEnum {
SETTLEMENT("SETTLEMENT", "INCOME", "结算"),
COMMISSION_SETTLEMENT("COMMISSION_SETTLEMENT","INCOME", "佣金结算"),
FLOATING_SETTLEMENT("FLOATING_SETTLEMENT","INCOME", "浮动费结算"),
DELIVERY_SETTLEMENT("DELIVERY_SETTLEMENT", "INCOME", "配送费结算"),
WITHDRAWAL("WITHDRAWAL", "WITHDRAWAL", "提现"),
ORDER("ORDER", "INCOME", "订单"),
RECHARGE("RECHARGE", "RECHARGE", "充值"),
BAIL_RECHARGE("BAIL_RECHARGE", "BAIL_RECHARGE", "保证金充值"),
TRUST_BUY("TRUST_BUY", "TRUST_BUY", "买入冻结金额"),
TRUST_SELL("TRUST_SELL", "TRUST_SELL", "委托卖出"),
TRUST_SELL_ATTACH_BAIL("TRUST_SELL_ATTACH_BAIL", "TRUST_SELL_ATTACH_BAIL", "委托卖出附带保证金"),
// TRUST_BUY_UNDO("TRUST_BUY_UNDO", "TRUST_BUY_UNDO", "委托买入撤销"),
TRANSFER_OUT("TRANSFER_OUT", "TRANSFER_OUT", "兑换转出"),
TRANSFER_IN("TRANSFER_IN", "TRANSFER_IN", "兑换转入"),
PRE_TRADING_DAY("PRE_TRADING_DAY", "PRE_TRADING_DAY", "融资利息费"),
IPO_SUBSCRIBE("IPO_SUBSCRIBE", "IPO_SUBSCRIBE", "申购"),
;
String code;
String type;
String remark;
AccountActionEnum(String code, String type, String remark) {
this.code = code;
this.remark = remark;
this.type = type;
}
public String code() {
return code;
}
public String type() {
return type;
}
public String remark() {
return remark;
}
public static AccountActionEnum of(String code) {
AccountActionEnum[] values = AccountActionEnum.values();
for (AccountActionEnum e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
public static String remark(String code) {
AccountActionEnum of = of(code);
return of == null? "" : of.remark;
}
}

View File

@@ -0,0 +1,46 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum AccountLogType {
SUBTRACT("SUBTRACT", "扣除"),
ADD("ADD", "新增"),
LOCK("LOCK", "冻结"),
LOCK_SUBTRACT("LOCK_SUBTRACT", "扣除冻结"),
LOCK_CANCEL("LOCK_CANCEL", "取消冻结"),
WILL_INCOME("WILL_INCOME", "即将收入"),
WILL_INCOME_REFUND("WILL_INCOME_REFUND", "即将收入_退款"),
WILL_INCOME_SUCCESS("WILL_INCOME_SUCCESS", "即将收入_进账"),
;
String code;
String remark;
AccountLogType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static AccountLogType of(String code) {
AccountLogType[] values = AccountLogType.values();
for (AccountLogType e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,67 @@
package cn.stock.market.constant;
/**
* 资金类型
*
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum AccountType {
STOCK_LOAN("STOCK_LOAN", "融资融券", "300010", false),
STOCK("STOCK", "证券", "10", true),
FUND("FUND", "基金", "11", true),
CHANGE("CHANGE", "钱包账户", "3000", true),
;
String code;
String remark;
String prefix;
boolean withdrawFlag;
// Currency currency;
AccountType(String code, /**Currency currency,**/ String remark, String prefix, boolean withdrawFlag) {
this.code = code;
this.remark = remark;
this.prefix = prefix;
this.withdrawFlag = withdrawFlag;
// this.currency = currency;
}
// public Currency currency() {
// return currency;
// }
public String code() {
return code;
}
public String prefix() {
return prefix;
}
public boolean withdrawFlag() {
return withdrawFlag;
}
public String remark() {
return remark;
}
public static AccountType of(String code) {
AccountType[] values = AccountType.values();
for (AccountType e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
public static String remark(String code) {
AccountType of = of(code);
return of == null ? "" : of.remark;
}
}

View File

@@ -0,0 +1,47 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum AppVersionType {
USER_APP_ANDROID("user_app_android", "用户APP安卓端"),
USER_APP_IOS("user_app_ios", "用户APP苹果端"),
// SHOP_APP_ANDROID("shop_app_android", "商家APP安卓端"),
// SHOP_APP_IOS("shop_app_ios", "商家APPIOS"),
;
String code;
String remark;
AppVersionType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static String remark(String code) {
AppVersionType of = of(code);
return of == null ? "" : of.remark;
}
public static AppVersionType of(String code) {
AppVersionType[] values = AppVersionType.values();
for (AppVersionType e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,46 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum AppVersionUpdateTag {
LATEST("latest", "最新版本,无需更新"),
AUDIT("audit", "审核版本"),
UPDATE_CHOOSE("choose_update", "选择更新"),
UPDATE_MUST("must_update", "强制更新");
;
String code;
String remark;
AppVersionUpdateTag(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static String remark(String code) {
AppVersionUpdateTag of = of(code);
return of == null ? "" : of.remark;
}
public static AppVersionUpdateTag of(String code) {
AppVersionUpdateTag[] values = AppVersionUpdateTag.values();
for (AppVersionUpdateTag e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,45 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum BannerType {
INDEX("INDEX", "首页"),
INDEX_TOP4("INDEX_TOP4", "首页_4宫格"),
ACTI("ACTI", "活动中心"),
;
String code;
String remark;
BannerType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static String remark(String code) {
BannerType of = of(code);
return of == null ? "" : of.remark;
}
public static BannerType of(String code) {
BannerType[] values = BannerType.values();
for (BannerType e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,45 @@
package cn.stock.market.constant;
/**
* 动作产生1/n个BillOrderEvent
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum BillOrderAction {
CREATE("CREATE", "创建"),
REVOKE("REVOKE", "撤单"),
REFUND("REFUND", "退款"),
DILIVERY_CANCEL("DILIVERY_CANCEL", "骑手订单取消"),
DILIVERY_CREATE("DILIVERY_CREATE", "骑手订单创建"),
DILIVERY_ADD_TIP("DILIVERY_ADD_TIP", "加小费"),
;
String code;
String remark;
BillOrderAction(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static BillOrderAction of(String code) {
BillOrderAction[] enums = BillOrderAction.values();
for (BillOrderAction e : enums) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,55 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum BillOrderEvent {
CREATE("CREATE", "创建"),
USER_DELIVERY_FEE_TRANSFER("USER_DELIVERY_FEE_TRANSFER", "用户配送费转移"),
DELIVERY_FEE_CREATE("DELIVERY_CREATE", "配送费创建"),
DELIVERY_FEE_CANCEL("DELIVERY_CANCEL", "配送费取消"),
DELIVERY_CUSTOM_FEE_CANCEL("DELIVERY_CANCEL", "配送增值费取消"),
DELIVERY_TIP_FEE_CANCEL("DELIVERY_TIP_FEE_CANCEL", "小费取消"),
DELIVERY_TIP_FEE_ADD("DELIVERY_TIP_FEE_ADD", "小费增加"),
DELIVERY_DEDIT_ADD("DELIVERY_DEDIT_ADD", "违约金增加"),
FLOATING_REDUCE("FLOATING_REDUCE", "浮动费扣除"),
POUNDAGE_REDUCE("POUNDAGE_REDUCE", "交易费扣除"),
GOODS_REFUND("GOODS_REFUND", "商品退款"),
COMMISSION_REDUCE("COMMISSION_REDUCE", "佣金扣除"),
MERCHANT_COMMISSION_REDUCE("MERCHANT_COMMISSION_REDUCE", "商户佣金扣除"),
PACKINGFEE_REDUCE("PACKINGFEE_REDUCE", "打包费扣除"),
COUPONS_RETURN("COUPONS_RETURN", "优惠券返还"),
GOODS_ERROR_REDUCE("GOODS_ERROR_REDUCE", "商品误差扣除"),
;
String code;
String remark;
BillOrderEvent(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static BillOrderEvent of(String code) {
BillOrderEvent[] enums = BillOrderEvent.values();
for (BillOrderEvent e : enums) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,39 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum BillType {
ORDER("ORDER", "订单类"),
;
String code;
String remark;
BillType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static BillType of(String code) {
BillType[] enums = BillType.values();
for (BillType e : enums) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,47 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*
* @deprecated 参考 cn.stock.trade.application.processor.trade.calc.ITaxCalc
*/
@Deprecated
public enum CalcToValueType {
FIXED("FIXED", "固定"),
PERCENT("PERCENT", "百分比"),;
String code;
String remark;
CalcToValueType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static String remark(String code) {
CalcToValueType of = of(code);
return of == null ? "" : of.remark;
}
public static CalcToValueType of(String code) {
CalcToValueType[] enums = CalcToValueType.values();
for (CalcToValueType e : enums) {
if (e.code.equalsIgnoreCase(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,42 @@
package cn.stock.market.constant;
/**
* 资金方向
*
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum CapitalDirection {
IN("IN", ""),
OUT("OUT", ""),
;
String code;
String remark;
CapitalDirection(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static CapitalDirection of(String code) {
CapitalDirection[] values = CapitalDirection.values();
for (CapitalDirection e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,41 @@
package cn.stock.market.constant;
/**
* 资金组
*
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum CapitalGroup {
OTHER("OTHER", "其他"),
USER("USER", "用户"),
;
String code;
String remark;
CapitalGroup(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static CapitalGroup of(String code) {
CapitalGroup[] values = CapitalGroup.values();
for (CapitalGroup e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,64 @@
package cn.stock.market.constant;
/**
* 资金类型
*
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum CapitalType {
/**
* 订单支付成功
*/
// DELIVERY_FEE("DELIVERY_FEE", CapitalGroup.OTHER, "配送费"),
// COMMISSION("COMMISSION", CapitalGroup.OTHER, "佣金"),
// MERCHANT_COMMISSION("MERCHANT_COMMISSION", CapitalGroup.OTHER, "商家佣金"),
// TIP("TIP", CapitalGroup.OTHER, "小费"),
// DEDIT("DEDIT", CapitalGroup.OTHER, "违约金"),
// PACKING_FEE("PACKING_FEE", CapitalGroup.OTHER, "打包费"),
// GOODS("GOODS", CapitalGroup.OTHER, "商品"),
// FULL_REDUCTION("FULL_REDUCTION", CapitalGroup.OTHER, "满减"),
// COUPONS("COUPONS", CapitalGroup.OTHER, "优惠券"),
// FLOATING_FEE("FLOATING_FEE", CapitalGroup.OTHER, "浮动费"),
// DELIVERY_CUSTOM_FEE("DELIVERY_CUSTOM_FEE", CapitalGroup.OTHER, "配送增值费"),
// GOODS_ERROR("GOODS_ERROR", CapitalGroup.OTHER, "商品误差值"),
// POUNDAGE("POUNDAGE", CapitalGroup.OTHER, "手续费"), //默认平台承担, 可以配置成商家承担
CASH("CASH", CapitalGroup.OTHER, "现金"),
LOAN("LOAN", CapitalGroup.OTHER,"融资"),
;
String code;
String remark;
CapitalGroup group;
CapitalType(String code, CapitalGroup group, String remark) {
this.code = code;
this.remark = remark;
this.group = group;
}
public CapitalGroup group() {
return group;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static CapitalType of(String code) {
CapitalType[] values = CapitalType.values();
for (CapitalType e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,52 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum ClickAction {
WEB("WEB", "网页"),
APP_PAGE("APP_PAGE", "App页面"),
OPEN_OR_POSITION("OPEN_OR_POSITION", "开户/持仓"),
GOODS_DETAIL("GOODS_DETAIL", "商品详情"),
FRONT_CLASSIFY("FRONT_CLASSIFY", "前端分类"),
SUBJECT("SUBJECT", "专题"),
ORDER_DETAIL("ORDER_DETAIL", "订单详情"),
LOGIN("LOGIN", "登录"),
EXCLUSIVE_LIST("EXCLUSIVE_LIST", "独家列表"),
WITHDRAWAL_INDEX("WITHDRAWAL_INDEX", "提现首页"),
;
String code;
String remark;
ClickAction(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static String remark(String code) {
ClickAction of = of(code);
return of == null ? "" : of.remark;
}
public static ClickAction of(String code) {
ClickAction[] values = ClickAction.values();
for (ClickAction e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,43 @@
package cn.stock.market.constant;
import com.ag.utils.NumberUtils;
/**
* 送达时间类型
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum DeliveryTimeType {
NOW(1, "立即送达"),
SUBSCRIBE(2, "预约时间"),
;
int status;
String remark;
DeliveryTimeType(int status, String remark) {
this.status = status;
this.remark = remark;
}
public int status() {
return status;
}
public String remark() {
return remark;
}
public static DeliveryTimeType of(Integer s) {
DeliveryTimeType[] enums = DeliveryTimeType.values();
for (DeliveryTimeType e : enums) {
if (NumberUtils.equals(e.status, s)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,39 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum JsonInfoType {
PARTNER("PARTNER", "合伙人"),
;
String code;
String remark;
JsonInfoType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static JsonInfoType of(String code) {
JsonInfoType[] enums = JsonInfoType.values();
for (JsonInfoType e : enums) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,56 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum OrderAfterSaleBizStatus {
CREATED("CREATED", "已申请", OrderAfterSaleStatus.CREATED),
PASSED("PASSED", "已同意", OrderAfterSaleStatus.PASSED),
USER_SENDED("USER_SENDED", "用户已发货", OrderAfterSaleStatus.USER_SENDED),
MERCHANT_CONFIRMED("MERCHANT_CONFIRMED", "商家收货", OrderAfterSaleStatus.MERCHANT_CONFIRMED),
MERCHANT_SENDED("MERCHANT_SENDED", "商家已发货", OrderAfterSaleStatus.MERCHANT_SENDED),
USER_CONFIRMED("USER_CONFIRMED", "用户已收货", OrderAfterSaleStatus.USER_CONFIRMED),
REJECTED("REJECTED", "拒绝", OrderAfterSaleStatus.REJECTED),
;
String code;
String remark;
OrderAfterSaleStatus os;
OrderAfterSaleBizStatus(String code, String remark, OrderAfterSaleStatus os) {
this.code = code;
this.remark = remark;
this.os = os;
}
public String code() {
return code;
}
public OrderAfterSaleStatus os() {
return os;
}
public String remark() {
return remark;
}
public static String remark(String code) {
OrderAfterSaleBizStatus of = of(code);
return of == null ? "" : of.remark;
}
public static OrderAfterSaleBizStatus of(String code) {
OrderAfterSaleBizStatus[] enums = OrderAfterSaleBizStatus.values();
for (OrderAfterSaleBizStatus e : enums) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,67 @@
package cn.stock.market.constant;
import java.util.List;
import com.google.common.collect.Lists;
import cn.qutaojing.common.constant.RoleEnum;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum OrderAfterSaleNode {
CREATED("CREATED", "用户申请", RoleEnum.USER, Lists.newArrayList(OrderAfterSaleBizStatus.CREATED)),
SYS_AUDIT("SYS_AUDIT", "平台审核", RoleEnum.SYS, Lists.newArrayList(OrderAfterSaleBizStatus.PASSED, OrderAfterSaleBizStatus.REJECTED)),
USER_SENDED("USER_SENDED", "用户已发货", RoleEnum.USER, Lists.newArrayList(OrderAfterSaleBizStatus.USER_SENDED)),
MERCHANT_CONFIRMED("MERCHANT_CONFIRMED", "商家收货", RoleEnum.SHOP, Lists.newArrayList(OrderAfterSaleBizStatus.MERCHANT_CONFIRMED)),
MERCHANT_SENDED("MERCHANT_SENDED", "商家已发货", RoleEnum.SHOP, Lists.newArrayList(OrderAfterSaleBizStatus.MERCHANT_SENDED)),
USER_CONFIRMED("USER_CONFIRMED", "用户已收货", RoleEnum.USER, Lists.newArrayList(OrderAfterSaleBizStatus.USER_CONFIRMED)),
;
String code;
String remark;
RoleEnum role;
List<OrderAfterSaleBizStatus> statusList;
OrderAfterSaleNode(String code, String remark, RoleEnum role, List<OrderAfterSaleBizStatus> statusList) {
this.code = code;
this.remark = remark;
this.role = role;
this.statusList = statusList;
}
public List<OrderAfterSaleBizStatus> statusList() {
return statusList;
}
public String code() {
return code;
}
public RoleEnum role() {
return role;
}
public String remark() {
return remark;
}
public static String remark(String code) {
OrderAfterSaleNode of = of(code);
return of == null? "" : of.remark;
}
public static OrderAfterSaleNode of(String code) {
OrderAfterSaleNode[] enums = OrderAfterSaleNode.values();
for (OrderAfterSaleNode e : enums) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,53 @@
package cn.stock.market.constant;
import com.ag.utils.NumberUtils;
/**
*
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum OrderAfterSaleStatus {
CREATED(0, "已创建"),
PASSED(4, "已同意"),
USER_SENDED(10, "用户已发货"),
MERCHANT_CONFIRMED(20, "商家收货"),
MERCHANT_SENDED(30, "商家已发货"),
USER_CONFIRMED(40, "用户已收货"),
REJECTED(-4, "拒绝"),
;
int status;
String remark;
OrderAfterSaleStatus(int status, String remark) {
this.status = status;
this.remark = remark;
}
public int status() {
return status;
}
public String remark() {
return remark;
}
public static String remark(Integer v) {
OrderAfterSaleStatus of = of(v);
return of == null ? "" : of.remark;
}
public static OrderAfterSaleStatus of(Integer s) {
OrderAfterSaleStatus[] enums = OrderAfterSaleStatus.values();
for (OrderAfterSaleStatus e : enums) {
if(NumberUtils.equals(e.status, s)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,47 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum OrderAfterSaleType {
DIRECTLY("DIRECTLY", "直接退款"),
REFUND_GOODS_MONEY("REFUND_GOODS_MONEY", "退货/退款"),
EXCHANGE_GOODS("EXCHANGE_GOODS", "换货"),
RECHARGE_GOODS("RECHARGE_GOODS", "补货"),
;
String code;
String remark;
OrderAfterSaleType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static String remark(String code) {
OrderAfterSaleType of = of(code);
return of == null? "" : of.remark;
}
public static OrderAfterSaleType of(String code) {
OrderAfterSaleType[] enums = OrderAfterSaleType.values();
for (OrderAfterSaleType e : enums) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,78 @@
package cn.stock.market.constant;
import java.util.List;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum OrderBizStatus {
CREATED("CREATED", "已创建", OrderStatus.CREATED),
PAYED("PAYED", "已支付", OrderStatus.PAYED),
SENDED("SENDED", "已发货", OrderStatus.SENDED),
CONFIRMED("CONFIRMED", "已收货", OrderStatus.CONFIRMED),
REFUNDED("REFUNDED", "已退款", OrderStatus.REFUNDED),
CANCELED("CANCELED", "已撤销", OrderStatus.CANCELED), ;
String code;
String remark;
OrderStatus os;
public static List<OrderBizStatus> NORMAL_PROGESS_LIST = Lists.newArrayList(CREATED, PAYED, SENDED, CONFIRMED);
public static Map<OrderBizStatus, Integer> NORMAL_PROGESS_MAP = normalProgessMap();
public static Map<OrderBizStatus, Integer> normalProgessMap() {
Map<OrderBizStatus, Integer> m = Maps.newHashMap();
for(int i = 0; i < NORMAL_PROGESS_LIST.size(); i++) {
OrderBizStatus ob = NORMAL_PROGESS_LIST.get(i);
m.put(ob, i);
}
return ImmutableMap.copyOf(m);
}
public static int toIndex(OrderBizStatus ob) {
return NORMAL_PROGESS_MAP.getOrDefault(ob, -1);
}
OrderBizStatus(String code, String remark, OrderStatus os) {
this.code = code;
this.remark = remark;
this.os = os;
}
public String code() {
return code;
}
public OrderStatus os() {
return os;
}
public String remark() {
return remark;
}
public static String remark(String code) {
OrderBizStatus of = of(code);
return of == null ? "" : of.remark;
}
public static OrderBizStatus of(String code) {
OrderBizStatus[] enums = OrderBizStatus.values();
for (OrderBizStatus e : enums) {
if(e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,45 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum OrderModel {
GRAP("GRAP", "抢单模式"),
GATHER("GATHER", "集散模式"),
;
String code;
String remark;
OrderModel(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static String remark(String code) {
OrderModel of = of(code);
return of == null ? "" : of.remark;
}
public static OrderModel of(String code) {
OrderModel[] enums = OrderModel.values();
for (OrderModel e : enums) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,72 @@
package cn.stock.market.constant;
/**
*
* title: OrderOperButtonEnum.java
*
* 订单操作按钮
*
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Mar 24, 2021 2:54:38 PM
*/
public enum OrderOperButtonEnum {
CAN_CANCEL("CAN_CANCEL", "取消订单"),
CAN_CONTACT_MERCHANT("CAN_CONTACT_MERCHANT", "联系商家"),
CAN_PAY("CAN_PAY", "立即支付"),
CAN_MODIFY("CAN_MODIFY", "修改订单信息"),
CAN_REFUND("CAN_REFUND", "可以退款 (支付成功后的取消订单)"),
CAN_CONFIRM("CAN_CONFIRM", "确认收货"),
CAN_SHOW_EXP_INFO("CAN_SHOW_EXP_INFO", "快递查询"),
// BROWSE_OTHER("BROWSE_OTHER", "逛逛别家"),
// CAN_REORDER("CAN_REORDER", "再来一单"),
// CAN_APPLY_REFUND("CAN_APPLY_REFUND", "申请退款"),
// CAN_CONTACT_DELIVERYER("CAN_CONTACT_DELIVERYER", "联系骑手"),
// CAN_COMMENT("CAN_COMMENT", "去评价"),
// CAN_APPEAL("CAN_APPEAL", "去申诉"),
CAN_APPEAL_DETAIL("CAN_APPEAL_DETAIL", "申诉详情"),
CAN_REFUND_DETAIL("CAN_REFUND_DETAIL", "退款详情"),
//商家
// CAN_MERCHANT_CONFIRM("CAN_MERCHANT_CONFIRM", "商户接单"),
// CAN_MERCHANT_CANCEL("CAN_MERCHANT_CANCEL", "商户取消"),
// CAN_MERCHANT_REFUND("CAN_MERCHANT_REFUND", "商家退款"),
// CAN_MERCHANT_AGREE_APPLY_REFUND("CAN_MERCHANT_AGREE_APPLY_REFUND", "商家同意退款申请"),
// CAN_MERCHANT_REFUSE_APPLY_REFUND("CAN_MERCHANT_REFUSE_APPLY_REFUND", "商家拒绝退款申请"),
// CAN_MERCHANT_CONTACT_DELIVERYER("CAN_MERCHANT_CONTACT_DELIVERYER", "商家联系骑手"),
// CAN_MERCHANT_DO_FETCH("CAN_MERCHANT_DO_FETCH", "商家取餐"),
// CAN_MERCHANT_DO_ARRIVED_CUSTOMER("CAN_MERCHANT_DO_ARRIVED_CUSTOMER", "商家送达"),
// CAN_SWITCH_MERCHANT_DELIVERY_PLATFORM("CAN_SWITCH_MERCHANT_DELIVERY_PLATFORM", "切换商家自配送"),
// CAN_DELIVERY_ADDTIP("CAN_DELIVERY_ADDTIP", "加小费"),
// CAN_DELIVERY_REORDER("CAN_DELIVERY_REORDER", "重发配送"),
// CAN_DELIVERY_CANCEL_AND_REORDER("CAN_DELIVERY_CANCEL_AND_REORDER", "配送取消重发骑手单"),
CAN_MERCHANT_SEND("CAN_MERCHANT_SEND", "商户发货"),
CAN_TIP_SEND("CAN_TIP_SEND", "提醒发货"),
;
String code;
String remark;
OrderOperButtonEnum(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
@Override
public String toString() {
return code;
}
}

View File

@@ -0,0 +1,52 @@
package cn.stock.market.constant;
import com.ag.utils.NumberUtils;
/**
*
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum OrderStatus {
CREATED(0, "已创建"),
PAYED(4, "已支付"),
SENDED(10, "已发货"),
CONFIRMED(20, "已收货"),
CANCELED(-5, "已撤销"),
REFUNDED(-4, "已退款"),
;
int status;
String remark;
OrderStatus(int status, String remark) {
this.status = status;
this.remark = remark;
}
public int status() {
return status;
}
public String remark() {
return remark;
}
public static String remark(Integer v) {
OrderStatus of = of(v);
return of == null ? "" : of.remark;
}
public static OrderStatus of(Integer s) {
OrderStatus[] enums = OrderStatus.values();
for (OrderStatus e : enums) {
if(NumberUtils.equals(e.status, s)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,39 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum OrderType {
CUSTOM_PULL("CUSTOM_PULL", "主动拉取"),
;
String code;
String remark;
OrderType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static OrderType of(String code) {
OrderType[] enums = OrderType.values();
for (OrderType e : enums) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,49 @@
package cn.stock.market.constant;
/**
* 资金类型
*
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum RechargeType {
/**
* 线下转账
*/
OFFLINE("OFFLINE", "线下转账"),
ALIPAY_WAP("ALIPAY_WAP", "支付宝WAP"),
;
String code;
String remark;
RechargeType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static String remark(String code) {
RechargeType of = of(code);
return of == null ? "" : of.remark;
}
public static RechargeType of(String code) {
RechargeType[] values = RechargeType.values();
for (RechargeType e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,48 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum SMSChannelType {
RIDER_LOGIN("RIDER_LOGIN", "骑手端登录"),
SORTER_LOGIN("SORTER_LOGIN", "分拣员登录"),
SHOP_LOGIN("SHOP_LOGIN", "商家登录"),
SHOP_REGIST("SHOP_REGIST", "商家注册"),
USER_LOGIN("USER_LOGIN", "用户登录"),
USER_REGIST("USER_REGIST", "用户注册"),
USER_REMOVE("USER_REMOVE", "用户注销"),
FORGET_PWD_SMS("FORGET_PWD_SMS", "忘记密码"),
FORGET_PAYPWD_SMS("FORGET_PAYPWD_SMS", "忘记支付密码"),
WTHDRAWAL("WTHDRAWAL", "提现验证码"),
;
String code;
String remark;
SMSChannelType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static SMSChannelType of(String code) {
SMSChannelType[] enums = SMSChannelType.values();
for (SMSChannelType e : enums) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,35 @@
package cn.stock.market.constant;
import com.ag.utils.NumberUtils;
public enum SettlementStatus {
SETTLEMENTED(4, "已结算"),
UNSETTLEMENT(0, "未结算"),
CLOSE(-4, "已关闭");
Integer v;
String remark;
SettlementStatus(Integer v,String remark) {
this.remark = remark;
this.v = v;
}
public Integer v() {
return v;
}
public String remark() {
return remark;
}
public static SettlementStatus of(Integer value) {
SettlementStatus[] values = SettlementStatus.values();
for (SettlementStatus e : values) {
if(NumberUtils.equals(e.v, value)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,39 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum SettlementType {
TO_ACCOUNT("TO_ACCOUNT", "结算到账户"),
TO_DIV("TO_DIV", "分账"),;
String code;
String remark;
SettlementType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static SettlementType of(String code) {
SettlementType[] values = SettlementType.values();
for (SettlementType e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,59 @@
package cn.stock.market.constant;
import com.ag.exception.SysTipsException;
import cn.qutaojing.common.constant.Currency;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum StockSource {
A("A", "A股"), HK("HK", "港股"), US("US", "美股"),;
String code;
String remark;
StockSource(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static String remark(String code) {
StockSource of = of(code);
return of == null ? "" : of.remark;
}
public static StockSource of(String code) {
StockSource[] values = StockSource.values();
for (StockSource e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
public Currency currency() {
if (this == A) {
return Currency.CNY;
} else if (this == HK) {
return Currency.HKD;
} else if (this == US) {
return Currency.USD;
}
throw new SysTipsException("无法转换到对应币种.");
}
}

View File

@@ -0,0 +1,43 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum SysModule {
ADMIN("ADMIN", "后台"),
;
String code;
String remark;
SysModule(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static String remark(String code) {
SysModule of = of(code);
return of == null ? "" : of.remark;
}
public static SysModule of(String code) {
SysModule[] values = SysModule.values();
for (SysModule e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,41 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum ThirdAuthType {
MINIAPP("MINIAPP", "小程序"),
WX("WX", "微信"),
;
String code;
String remark;
ThirdAuthType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static ThirdAuthType of(String code) {
ThirdAuthType[] enums = ThirdAuthType.values();
for (ThirdAuthType e : enums) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,40 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:14 AM
*/
public enum TrustDealType {
MARKET_ORDER("MARKET_ORDER", "市价单"),
LIMIT_ORDER("LIMIT_ORDER", "限价单"),
;
String code;
String remark;
TrustDealType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static TrustDealType of(String code) {
TrustDealType[] enums = TrustDealType.values();
for (TrustDealType e : enums) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,43 @@
package cn.stock.market.constant;
/**
* @author xlfd
* @email xlfd@gmail.com
* @version 1.0
* @created Jan 13, 2021 11:53:31 AM
*/
public enum TrustType {
SELL("SELL", "证券卖出"), BUY("BUY", "证券买入"),;
String code;
String remark;
TrustType(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static String remark(String code) {
TrustType of = of(code);
return of == null ? "" : of.remark;
}
public static TrustType of(String code) {
TrustType[] values = TrustType.values();
for (TrustType e : values) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@@ -0,0 +1,24 @@
package cn.stock.market.domain.basic.convert;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import cn.qutaojing.common.domain.convert.SimpleEntityPOConvert;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.City;
import cn.stock.market.infrastructure.db.po.CityPO;
/**
* CityConvert
*
* @author xlfd
* @email xlfd@gmail.com
* @created 2021/06/16
*/
@Component
@Lazy
public class CityConvert extends SimpleEntityPOConvert<City, CityPO> {
public static CityConvert of() {
return SpringUtils.getBean(CityConvert.class);
}
}

View File

@@ -0,0 +1,24 @@
package cn.stock.market.domain.basic.convert;
import cn.qutaojing.common.domain.convert.SimpleEntityPOConvert;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.JsonInfo;
import cn.stock.market.infrastructure.db.po.JsonInfoPO;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* JsonInfoConvert
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2022/08/16
*/
@Component
@Lazy
public class JsonInfoConvert extends SimpleEntityPOConvert<JsonInfo, JsonInfoPO> {
public static JsonInfoConvert of() {
return SpringUtils.getBean(JsonInfoConvert.class);
}
}

View File

@@ -0,0 +1,23 @@
package cn.stock.market.domain.basic.convert;
import cn.qutaojing.common.domain.convert.SimpleEntityPOConvert;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.Realtime;
import cn.stock.market.infrastructure.db.po.RealtimePO;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* RealtimeConvert
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Component
@Lazy
public class RealtimeConvert extends SimpleEntityPOConvert<Realtime, RealtimePO> {
public static RealtimeConvert of() {
return SpringUtils.getBean(RealtimeConvert.class);
}
}

View File

@@ -0,0 +1,23 @@
package cn.stock.market.domain.basic.convert;
import cn.qutaojing.common.domain.convert.SimpleEntityPOConvert;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.SiteArticle;
import cn.stock.market.infrastructure.db.po.SiteArticlePO;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* SiteArticleConvert
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Component
@Lazy
public class SiteArticleConvert extends SimpleEntityPOConvert<SiteArticle, SiteArticlePO> {
public static SiteArticleConvert of() {
return SpringUtils.getBean(SiteArticleConvert.class);
}
}

View File

@@ -0,0 +1,23 @@
package cn.stock.market.domain.basic.convert;
import cn.qutaojing.common.domain.convert.SimpleEntityPOConvert;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.SiteNews;
import cn.stock.market.infrastructure.db.po.SiteNewsPO;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* SiteNewsConvert
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/19
*/
@Component
@Lazy
public class SiteNewsConvert extends SimpleEntityPOConvert<SiteNews, SiteNewsPO> {
public static SiteNewsConvert of() {
return SpringUtils.getBean(SiteNewsConvert.class);
}
}

View File

@@ -0,0 +1,24 @@
package cn.stock.market.domain.basic.convert;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import cn.qutaojing.common.domain.convert.SimpleEntityPOConvert;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.SiteSetting;
import cn.stock.market.infrastructure.stockdb.po.SiteSettingPO;
/**
* StockConvert
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Component
@Lazy
public class SiteSettingConvert extends SimpleEntityPOConvert<SiteSetting, SiteSettingPO> {
public static SiteSettingConvert of() {
return SpringUtils.getBean(SiteSettingConvert.class);
}
}

View File

@@ -0,0 +1,24 @@
package cn.stock.market.domain.basic.convert;
import cn.qutaojing.common.domain.convert.SimpleEntityPOConvert;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.Stock;
import cn.stock.market.infrastructure.stockdb.po.StockPO;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* StockConvert
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Component
@Lazy
public class StockConvert extends SimpleEntityPOConvert<Stock, StockPO> {
public static StockConvert of() {
return SpringUtils.getBean(StockConvert.class);
}
}

View File

@@ -0,0 +1,24 @@
package cn.stock.market.domain.basic.convert;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import cn.qutaojing.common.domain.convert.SimpleEntityPOConvert;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.SysLog;
import cn.stock.market.infrastructure.db.po.SysLogPO;
/**
* SysLogConvert
*
* @author xlfd
* @email xlfd@gmail.com
* @created 2021/06/18
*/
@Component
@Lazy
public class SysLogConvert extends SimpleEntityPOConvert<SysLog, SysLogPO> {
public static SysLogConvert of() {
return SpringUtils.getBean(SysLogConvert.class);
}
}

View File

@@ -0,0 +1,50 @@
package cn.stock.market.domain.basic.entity;
import java.util.List;
import com.ag.utils.JsonUtils;
import com.ag.utils.JsonUtils.IListToTreeWrapper;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import cn.stock.market.infrastructure.db.po.CityPO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* CityEntity
*
* @author xlfd
* @email xlfd@gmail.com
* @created 2021/06/16
*/
@Data
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public class City extends CityPO {
public static JSONArray tree(List<City> list, int level) {
return JsonUtils.listToTree(list, new IListToTreeWrapper<City>() {
@Override
public Object getParentValue(City t) {
return t.getParentId();
}
@Override
public Object getPkValue(City t) {
return String.valueOf(t.getId());
}
@Override
public JSONObject doConvertJson(City t) {
JSONObject json = new JSONObject(true);
json.put("id", t.getId());
json.put("name", t.getName());
json.put("path", t.getPath());
return json;
}
}, level);
}
}

View File

@@ -0,0 +1,28 @@
package cn.stock.market.domain.basic.entity;
import cn.qutaojing.common.utils.Beans;
import cn.stock.market.dto.command.JsonInfoCreateCommand;
import cn.stock.market.infrastructure.db.po.JsonInfoPO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* JsonInfo
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2022/08/16
*/
@Data
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(
callSuper = false
)
public class JsonInfo extends JsonInfoPO {
public void update(JsonInfoCreateCommand cmd) {
Beans.copyPropertiesIgnoreNull(cmd, this);
}
}

View File

@@ -0,0 +1,28 @@
package cn.stock.market.domain.basic.entity;
import cn.qutaojing.common.utils.Beans;
import cn.stock.market.dto.command.RealtimeCreateCommand;
import cn.stock.market.infrastructure.db.po.RealtimePO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* Realtime
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Data
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(
callSuper = false
)
public class Realtime extends RealtimePO {
public void update(RealtimeCreateCommand cmd) {
Beans.copyPropertiesIgnoreNull(cmd, this);
}
}

View File

@@ -0,0 +1,26 @@
package cn.stock.market.domain.basic.entity;
import cn.qutaojing.common.utils.Beans;
import cn.stock.market.dto.command.SiteArticleCreateCommand;
import cn.stock.market.infrastructure.db.po.SiteArticlePO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* SiteArticle
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Data
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public class SiteArticle extends SiteArticlePO {
public void update(SiteArticleCreateCommand cmd) {
Beans.copyPropertiesIgnoreNull(cmd, this);
}
}

View File

@@ -0,0 +1,28 @@
package cn.stock.market.domain.basic.entity;
import cn.qutaojing.common.utils.Beans;
import cn.stock.market.dto.command.SiteNewsCreateCommand;
import cn.stock.market.infrastructure.db.po.SiteNewsPO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* SiteNews
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/19
*/
@Data
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(
callSuper = false
)
public class SiteNews extends SiteNewsPO {
public void update(SiteNewsCreateCommand cmd) {
Beans.copyPropertiesIgnoreNull(cmd, this);
}
}

View File

@@ -0,0 +1,51 @@
package cn.stock.market.domain.basic.entity;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import com.ag.utils.Jsons;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import cn.qutaojing.common.utils.Beans;
import cn.stock.market.dto.command.StockCreateCommand;
import cn.stock.market.infrastructure.stockdb.po.SiteSettingPO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* Stock
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Data
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public class SiteSetting extends SiteSettingPO {
public void update(StockCreateCommand cmd) {
Beans.copyPropertiesIgnoreNull(cmd, this);
}
public boolean checkAndAddIfNoExists(String marketDomain) {
List<String> list = Jsons.toListAnyway(getMarketServerList(), String.class);
boolean contain = list.stream()
.filter(val -> StringUtils.startsWith(val, marketDomain))
.count() > 0;
if(! contain) { //改成覆盖
list = Lists.newArrayList();
list.add(marketDomain);
setMarketServerList(JSON.toJSONString(list));
}
return contain;
}
}

View File

@@ -0,0 +1,28 @@
package cn.stock.market.domain.basic.entity;
import cn.qutaojing.common.utils.Beans;
import cn.stock.market.dto.command.StockCreateCommand;
import cn.stock.market.infrastructure.stockdb.po.StockPO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* Stock
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Data
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(
callSuper = false
)
public class Stock extends StockPO {
public void update(StockCreateCommand cmd) {
Beans.copyPropertiesIgnoreNull(cmd, this);
}
}

View File

@@ -0,0 +1,23 @@
package cn.stock.market.domain.basic.entity;
import cn.stock.market.infrastructure.db.po.SysLogPO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* SysLogEntity
*
* @author xlfd
* @email xlfd@gmail.com
* @created 2021/06/18
*/
@Data
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(
callSuper = false
)
public class SysLog extends SysLogPO {
}

View File

@@ -0,0 +1,25 @@
package cn.stock.market.domain.basic.event;
import java.util.Date;
import java.util.UUID;
import lombok.Data;
import lombok.experimental.SuperBuilder;
@SuperBuilder
@Data
public class DomainEvent {
String id;
Date createAt;
public DomainEvent() {
init();
}
@SuppressWarnings("unchecked")
public <T extends DomainEvent> T init() {
this.id = String.valueOf(UUID.randomUUID());
this.createAt = new Date();
return (T) this;
}
}

View File

@@ -0,0 +1,20 @@
package cn.stock.market.domain.basic.factory;
import cn.qutaojing.common.utils.SpringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* CityFactory
*
* @author xlfd
* @email xlfd@gmail.com
* @created 2021/06/16
*/
@Component
@Lazy
public class CityFactory {
public static CityFactory of() {
return SpringUtils.getBean(CityFactory.class);
}
}

View File

@@ -0,0 +1,29 @@
package cn.stock.market.domain.basic.factory;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.JsonInfo;
import cn.stock.market.dto.command.JsonInfoCreateCommand;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* JsonInfoFactory
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2022/08/16
*/
@Component
@Lazy
public class JsonInfoFactory {
public static JsonInfoFactory of() {
return SpringUtils.getBean(JsonInfoFactory.class);
}
public JsonInfo from(JsonInfoCreateCommand cmd) {
JsonInfo e = JsonInfo.builder().build();
e.update(cmd);
return e;
}
}

View File

@@ -0,0 +1,195 @@
package cn.stock.market.domain.basic.factory;
import org.apache.commons.lang.StringUtils;
import com.alibaba.fastjson.JSONObject;
import cn.qutaojing.common.OperInfo;
import cn.qutaojing.common.constant.RoleEnum;
import cn.stock.market.domain.basic.entity.SysLog;
import cn.stock.market.domain.basic.service.SysLogService;
import lombok.Data;
@Data
public class LogBuilder {
public static LogBuilder builder() {
return new LogBuilder();
}
public static enum ActionTypeEnum {
INERT("INSERT", "新增"),
UPDATE("UPDATE", "更新"),
DELETE("DELETE", "删除"),
ENABLE("ENABLE", "启用"),
DISABLE("DISABLE", "禁用"),
RECORD("RECORD", "记录"),
;
String code;
String remark;
ActionTypeEnum(String code, String remark) {
this.code = code;
this.remark = remark;
}
}
public static enum ModuleEnum {
UNKNOWN("UNKNOWN", "未知"),
SYS_ROLE("SYS_ROLE", "系统角色"),
ADMIN_LOGIN("ADMIN_LOGIN", "后台登录"),
DEVICE_MAINTAINER_LOGIN("DEVICE_MAINTAINER_LOGIN", "设备维护员登录"),
RIDER_LOGIN("RIDER_LOGIN", "骑手登录"),
ADMIN_LOGIN_RESET_PWD("ADMIN_LOGIN_RESET_PWD", "后台重置密码"),
ADMIN_LOGIN_CHANGE_PWD("ADMIN_LOGIN_CHANGE_PWD", "后台修改密码"),
SYS_MENU("SYS_MENU", "系统菜单"),
COUPONS_ALERT_STLYE("COUPONS_ALERT_STLYE", "优惠券弹窗"),
OTO_SALE_DEVILERY_FEE("OTO_SALE_DEVILERY_FEE", "运费补贴"),
SALE_STORE_FULL_REDUCTION("SALE_STORE_FULL_REDUCTION", "店铺满减"),
;
String code;
String remark;
ModuleEnum(String code, String remark) {
this.code = code;
this.remark = remark;
}
public String code() {
return code;
}
public String remark() {
return remark;
}
public static ModuleEnum of(String code) {
ModuleEnum[] values = ModuleEnum.values();
for (ModuleEnum e : values) {
if(e.code.equalsIgnoreCase(code)) {
return e;
}
}
return UNKNOWN;
}
}
ModuleEnum moduleEnum;
ActionTypeEnum actionTypeEnum;
RoleEnum re;
Integer storeId;
String operatorId;
String operatorName;
String operatorPhone;
String uniqueId;
String title;
String content;
JSONObject ext = new JSONObject();
public LogBuilder actionEnable(Object o) {
this.actionTypeEnum = ActionTypeEnum.ENABLE;
this.ext.put("obj", o);
return this;
}
public LogBuilder actionDisable(Object o) {
this.actionTypeEnum = ActionTypeEnum.DISABLE;
this.ext.put("obj", o);
return this;
}
public LogBuilder actionInsert(Object o) {
this.actionTypeEnum = ActionTypeEnum.INERT;
this.ext.put("obj", o);
return this;
}
public LogBuilder actionDelete(Object o) {
this.actionTypeEnum = ActionTypeEnum.DELETE;
this.ext.put("obj", o);
return this;
}
public LogBuilder actionRecord(Object o) {
this.actionTypeEnum = ActionTypeEnum.RECORD;
this.ext.put("obj", o);
return this;
}
public LogBuilder actionUpdate(Object pre, Object after) {
this.actionTypeEnum = ActionTypeEnum.UPDATE;
this.ext.put("pre", pre);
this.ext.put("after", after);
return this;
}
public LogBuilder title(String title) {
this.title = title;
return this;
}
public LogBuilder content(String content) {
this.content = content;
return this;
}
public LogBuilder module(ModuleEnum moduleEnum) {
this.moduleEnum = moduleEnum;
return this;
}
public LogBuilder operator(OperInfo operInfo) {
this.re = operInfo.getRe();
return operator(operInfo.getOperatorId(), operInfo.getOperatorName(), operInfo.getOperatorPhone());
}
public LogBuilder operator(String operatorName, Object operatorId, String operatorPhone) {
this.operatorName = operatorName;
this.operatorId = String.valueOf(operatorId);
return this;
}
public LogBuilder re(RoleEnum re) {
this.re = re;
return this;
}
public LogBuilder uniqueId(Object uniqueId) {
this.uniqueId = String.valueOf(uniqueId);
return this;
}
public LogBuilder storeId(Integer storeId) {
this.storeId = storeId;
return this;
}
public void save() {
SysLogService.of().log(this);
}
public SysLog build() {
String title = this.title;
if(StringUtils.isBlank(title)) {
title = actionTypeEnum.remark + moduleEnum.remark;
}
return SysLog.builder()
.storeId(storeId)
.actionType(actionTypeEnum.code)
.content(content)
.ext(ext.toJSONString())
.module(moduleEnum.code)
.operatorId(operatorId)
.operatorName(operatorName)
.roleType(re.code())
.title(title)
.uniqueId(uniqueId)
.build();
}
public static LogBuilder of() {
return new LogBuilder();
}
}

View File

@@ -0,0 +1,28 @@
package cn.stock.market.domain.basic.factory;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.Realtime;
import cn.stock.market.dto.command.RealtimeCreateCommand;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* RealtimeFactory
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Component
@Lazy
public class RealtimeFactory {
public static RealtimeFactory of() {
return SpringUtils.getBean(RealtimeFactory.class);
}
public Realtime from(RealtimeCreateCommand cmd) {
Realtime e = Realtime.builder().build();
e.update(cmd);
return e;
}
}

View File

@@ -0,0 +1,43 @@
package cn.stock.market.domain.basic.factory;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.SiteArticle;
import cn.stock.market.dto.command.SiteArticleCreateCommand;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import com.ag.exception.SysTipsException;
/**
* SiteArticleFactory
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Component
@Lazy
public class SiteArticleFactory {
public static SiteArticleFactory of() {
return SpringUtils.getBean(SiteArticleFactory.class);
}
public SiteArticle from(SiteArticleCreateCommand cmd) {
if (StringUtils.isBlank(cmd.getArtTitle()) ||
StringUtils.isBlank(cmd.getArtType()) ||
StringUtils.isBlank(cmd.getArtCnt()) || cmd
.getIsShow() == null) {
throw new SysTipsException("标题正文类型必填");
}
cmd.setAddTime(new Date());
SiteArticle e = SiteArticle.builder().build();
e.update(cmd);
return e;
}
}

View File

@@ -0,0 +1,28 @@
package cn.stock.market.domain.basic.factory;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.SiteNews;
import cn.stock.market.dto.command.SiteNewsCreateCommand;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* SiteNewsFactory
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/19
*/
@Component
@Lazy
public class SiteNewsFactory {
public static SiteNewsFactory of() {
return SpringUtils.getBean(SiteNewsFactory.class);
}
public SiteNews from(SiteNewsCreateCommand cmd) {
SiteNews e = SiteNews.builder().build();
e.update(cmd);
return e;
}
}

View File

@@ -0,0 +1,28 @@
package cn.stock.market.domain.basic.factory;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.Stock;
import cn.stock.market.dto.command.StockCreateCommand;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* StockFactory
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Component
@Lazy
public class StockFactory {
public static StockFactory of() {
return SpringUtils.getBean(StockFactory.class);
}
public Stock from(StockCreateCommand cmd) {
Stock e = Stock.builder().build();
e.update(cmd);
return e;
}
}

View File

@@ -0,0 +1,20 @@
package cn.stock.market.domain.basic.factory;
import cn.qutaojing.common.utils.SpringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* SysLogFactory
*
* @author xlfd
* @email xlfd@gmail.com
* @created 2021/06/18
*/
@Component
@Lazy
public class SysLogFactory {
public static SysLogFactory of() {
return SpringUtils.getBean(SysLogFactory.class);
}
}

View File

@@ -0,0 +1,135 @@
package cn.stock.market.domain.basic.repository;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import cn.qutaojing.common.utils.SpringUtils;
public interface CacheRepository {
boolean set(final String key, Object value);
/**
* 写入缓存设置时效时间
*
* @param key
* @param value
* @param expireTime
* @return
*/
boolean set(final String key, Object value, long expireTime);
boolean set(final String key, Object value, long expireTime, TimeUnit timeUnit);
/**
* 批量删除对应的value
*
* @param keys
*/
void remove(final String... keys);
/**
* 批量删除key
*
* @param pattern
*/
void removePattern(final String pattern);
/**
* 删除对应的value
*
* @param key
*/
void remove(final String key);
/**
* 判断缓存中是否有对应的value
*
* @param key
* @return
*/
boolean exists(final String key);
/**
* 读取缓存
*
* @param key
* @return
*/
Object get(final String key);
/**
* 哈希 添加
*
* @param key
* @param hashKey
* @param value
*/
void hmSet(String key, Object hashKey, Object value);
/**
* 哈希获取数据
*
* @param key
* @param hashKey
* @return
*/
Object hmGet(String key, Object hashKey);
/**
* 列表添加
*
* @param k
* @param v
*/
void lPush(String k, Object v);
/**
* 列表获取
*
* @param k
* @param l
* @param l1
* @return
*/
List<Object> lRange(String k, long l, long l1);
/**
* 集合添加
*
* @param key
* @param value
*/
void add(String key, Object value);
/**
* 集合获取
*
* @param key
* @return
*/
Set<Object> setMembers(String key);
/**
* 有序集合添加
*
* @param key
* @param value
* @param scoure
*/
void zAdd(String key, Object value, double scoure);
/**
* 有序集合获取
*
* @param key
* @param scoure
* @param scoure1
* @return
*/
Set<Object> rangeByScore(String key, double scoure, double scoure1);
public static CacheRepository of() {
return SpringUtils.getBean(CacheRepository.class);
}
}

View File

@@ -0,0 +1,67 @@
package cn.stock.market.domain.basic.repository;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.rp.spring.jpa.GenericJpaRepository;
import cn.qutaojing.common.domain.convert.IEntityPOConvert;
import cn.qutaojing.common.domain.respostory.LocalCacheRepository;
import cn.qutaojing.common.utils.SpringUtils;
import cn.qutaojing.common.utils.TreePathUtils;
import cn.stock.market.domain.basic.convert.CityConvert;
import cn.stock.market.domain.basic.entity.City;
import cn.stock.market.infrastructure.db.po.CityPO;
import cn.stock.market.infrastructure.db.repo.CityRepo;
import lombok.RequiredArgsConstructor;
/**
* CityRepository
*
* @author xlfd
* @email xlfd@gmail.com
* @created 2021/06/16
*/
@Repository
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CityRepository extends LocalCacheRepository<City, CityPO, Integer> {
final CityRepo repo;
final CityConvert convert;
@Override
public GenericJpaRepository<CityPO, Integer> repo() {
return repo;
}
public String names(String path) {
return Joiner.on("/").join(names(TreePathUtils.splitAsInt(path)));
}
public String[] names(Integer[] ids) {
List<City> list = Lists.newArrayList();
for (Integer id : ids) {
list.add(findCacheById(id));
}
String[] array = list.stream().map(val -> {
if (val == null)
return "";
return val.getName();
}).toArray(String[]::new);
return array;
}
@Override
public IEntityPOConvert<City, CityPO> convert() {
return convert;
}
public static CityRepository of() {
return SpringUtils.getBean(CityRepository.class);
}
}

View File

@@ -0,0 +1,44 @@
package cn.stock.market.domain.basic.repository;
import cn.qutaojing.common.domain.convert.IEntityPOConvert;
import cn.qutaojing.common.domain.respostory.SimplePoConvertEntityRepository;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.convert.JsonInfoConvert;
import cn.stock.market.domain.basic.entity.JsonInfo;
import cn.stock.market.infrastructure.db.po.JsonInfoPO;
import cn.stock.market.infrastructure.db.repo.JsonInfoRepo;
import com.rp.spring.jpa.GenericJpaRepository;
import java.lang.Integer;
import java.lang.Override;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
/**
* JsonInfoRepository
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2022/08/16
*/
@Repository
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class JsonInfoRepository extends SimplePoConvertEntityRepository<JsonInfo, JsonInfoPO, Integer> {
final JsonInfoRepo repo;
final JsonInfoConvert convert;
@Override
public GenericJpaRepository<JsonInfoPO, Integer> repo() {
return repo;
}
@Override
public IEntityPOConvert<JsonInfo, JsonInfoPO> convert() {
return convert;
}
public static JsonInfoRepository of() {
return SpringUtils.getBean(JsonInfoRepository.class);
}
}

View File

@@ -0,0 +1,46 @@
package cn.stock.market.domain.basic.repository;
import cn.qutaojing.common.domain.convert.IEntityPOConvert;
import cn.qutaojing.common.domain.respostory.SimplePoConvertEntityRepository;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.convert.RealtimeConvert;
import cn.stock.market.domain.basic.entity.Realtime;
import cn.stock.market.infrastructure.db.po.RealtimePO;
import cn.stock.market.infrastructure.db.repo.RealtimeRepo;
import com.rp.spring.jpa.GenericJpaRepository;
import java.lang.Integer;
import java.lang.Override;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
/**
* RealtimeRepository
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Repository
@RequiredArgsConstructor(
onConstructor = @__(@Autowired)
)
public class RealtimeRepository extends SimplePoConvertEntityRepository<Realtime, RealtimePO, Integer> {
final RealtimeRepo repo;
final RealtimeConvert convert;
@Override
public GenericJpaRepository<RealtimePO, Integer> repo() {
return repo;
}
@Override
public IEntityPOConvert<Realtime, RealtimePO> convert() {
return convert;
}
public static RealtimeRepository of() {
return SpringUtils.getBean(RealtimeRepository.class);
}
}

View File

@@ -0,0 +1,46 @@
package cn.stock.market.domain.basic.repository;
import cn.qutaojing.common.domain.convert.IEntityPOConvert;
import cn.qutaojing.common.domain.respostory.SimplePoConvertEntityRepository;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.convert.SiteArticleConvert;
import cn.stock.market.domain.basic.entity.SiteArticle;
import cn.stock.market.infrastructure.db.po.SiteArticlePO;
import cn.stock.market.infrastructure.db.repo.SiteArticleRepo;
import com.rp.spring.jpa.GenericJpaRepository;
import java.lang.Integer;
import java.lang.Override;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
/**
* SiteArticleRepository
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Repository
@RequiredArgsConstructor(
onConstructor = @__(@Autowired)
)
public class SiteArticleRepository extends SimplePoConvertEntityRepository<SiteArticle, SiteArticlePO, Integer> {
final SiteArticleRepo repo;
final SiteArticleConvert convert;
@Override
public GenericJpaRepository<SiteArticlePO, Integer> repo() {
return repo;
}
@Override
public IEntityPOConvert<SiteArticle, SiteArticlePO> convert() {
return convert;
}
public static SiteArticleRepository of() {
return SpringUtils.getBean(SiteArticleRepository.class);
}
}

View File

@@ -0,0 +1,55 @@
package cn.stock.market.domain.basic.repository;
import cn.qutaojing.common.domain.convert.IEntityPOConvert;
import cn.qutaojing.common.domain.respostory.SimplePoConvertEntityRepository;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.convert.SiteNewsConvert;
import cn.stock.market.domain.basic.entity.SiteNews;
import cn.stock.market.infrastructure.db.po.QSiteNewsPO;
import cn.stock.market.infrastructure.db.po.SiteNewsPO;
import cn.stock.market.infrastructure.db.repo.SiteNewsRepo;
import com.rp.spring.jpa.GenericJpaRepository;
import java.lang.Integer;
import java.lang.Override;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
/**
* SiteNewsRepository
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/19
*/
@Repository
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SiteNewsRepository extends SimplePoConvertEntityRepository<SiteNews, SiteNewsPO, Integer> {
final SiteNewsRepo repo;
final SiteNewsConvert convert;
static final QSiteNewsPO q = QSiteNewsPO.siteNewsPO;
public long getNewsBySourceIdCount(String newsId) {
return count(q.sourceId.eq(newsId));
}
@Override
public GenericJpaRepository<SiteNewsPO, Integer> repo() {
return repo;
}
@Override
public IEntityPOConvert<SiteNews, SiteNewsPO> convert() {
return convert;
}
public static SiteNewsRepository of() {
return SpringUtils.getBean(SiteNewsRepository.class);
}
public long updateViews(Integer id) {
return getJPAQueryFactory()
.update(q)
.set(q.views, q.views.add(1))
.where(q.id.eq(id)).execute();
}
}

View File

@@ -0,0 +1,50 @@
package cn.stock.market.domain.basic.repository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.rp.spring.jpa.GenericJpaRepository;
import cn.qutaojing.common.domain.convert.IEntityPOConvert;
import cn.qutaojing.common.domain.respostory.LocalCacheRepository;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.convert.SiteSettingConvert;
import cn.stock.market.domain.basic.entity.SiteSetting;
import cn.stock.market.infrastructure.stockdb.po.SiteSettingPO;
import cn.stock.market.infrastructure.stockdb.repo.SiteSettingRepo;
import lombok.RequiredArgsConstructor;
/**
* StockRepository
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Repository
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SiteSettingRepository extends LocalCacheRepository<SiteSetting, SiteSettingPO, Integer> {
final SiteSettingRepo repo;
final SiteSettingConvert convert;
public static SiteSettingRepository of() {
return SpringUtils.getBean(SiteSettingRepository.class);
}
public SiteSetting get() {
return findAll()
.stream()
.findAny()
.orElse(null);
}
@Override
public GenericJpaRepository<SiteSettingPO, Integer> repo() {
return repo;
}
@Override
public IEntityPOConvert<SiteSetting, SiteSettingPO> convert() {
return convert;
}
}

View File

@@ -0,0 +1,143 @@
package cn.stock.market.domain.basic.repository;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;
import com.google.common.cache.CacheBuilder;
import com.rp.spring.jpa.GenericJpaRepository;
import cn.qutaojing.common.domain.convert.IEntityPOConvert;
import cn.qutaojing.common.domain.respostory.LocalCacheBean;
import cn.qutaojing.common.domain.respostory.LocalCacheRepository;
import cn.qutaojing.common.jpa.ConditionBuilder;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.convert.StockConvert;
import cn.stock.market.domain.basic.entity.Stock;
import cn.stock.market.infrastructure.stockdb.po.QStockPO;
import cn.stock.market.infrastructure.stockdb.po.StockPO;
import cn.stock.market.infrastructure.stockdb.repo.StockRepo;
import lombok.RequiredArgsConstructor;
/**
* StockRepository
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Repository
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class StockRepository extends LocalCacheRepository<Stock, StockPO, Integer> {
final StockRepo repo;
final StockConvert convert;
final static QStockPO q = QStockPO.stockPO;
@Override
protected LocalCacheBean<StockPO, Integer> buildLocalCache() {
/**
* 缓存10分钟
*/
return new LocalCacheBean<>(repo(), val -> repo().findAll(), CacheBuilder.newBuilder().maximumSize(2000000).expireAfterWrite(10 * 60, TimeUnit.SECONDS));
}
public Map<String, Stock> cacheCodeMap() {
Map<String, Stock> map = cacheList()
.stream().collect(Collectors.toMap(Stock::getStockCode, val -> val, (u, v) -> u));
return map;
}
public Map<String, Stock> cacheNameMap() {
Map<String, Stock> map = cacheList()
.stream().collect(Collectors.toMap(Stock::getStockName, val -> val, (u, v) -> u));
return map;
}
public Page<Stock> listByAdmin(Integer showState, Integer lockState, String code, String name, String stockPlate,
String stockType, Pageable pageable) {
ConditionBuilder builder = ConditionBuilder.builder();
if(showState != null) {
builder.and(q.isShow.eq(showState));
}
if(lockState != null) {
builder.and(q.isLock.eq(lockState));
}
if(StringUtils.isNotBlank(code)) {
builder.and(q.stockCode.like("%" + code + "%"));
}
if(StringUtils.isNotBlank(name)) {
builder.and(q.stockName.like("%" + name + "%"));
}
if(StringUtils.isNotBlank(stockPlate)) {
builder.and(q.stockPlate.eq(stockPlate));
}
if(StringUtils.isNotBlank(stockType)) {
builder.and(q.stockType.eq(stockType));
}
return findAll(builder.build(), pageable);
}
public Page<Stock> findStockListByKeyWords(String keyWords, String stockPlate,String stockType, Integer isShow, Pageable pageable) {
ConditionBuilder builder = ConditionBuilder.builder();
if(isShow != null) {
builder.and(q.isShow.eq(isShow));
}
if(StringUtils.isNotBlank(keyWords)) {
builder.and(q.stockCode.like("%" + keyWords + "%").or(q.stockSpell.like("%" + keyWords + "%")));
}
if(StringUtils.isNotBlank(stockPlate)) {
builder.and(q.stockPlate.isNull().or(q.stockPlate.eq("").or(q.stockPlate.eq("科创").or(q.stockPlate.eq("创业")))));
}
if(StringUtils.isNotBlank(stockType)) {
builder.and(q.stockType.eq(stockType));
}
return findAll(builder.build(), pageable);
}
public List<Stock> findStockCode(String stockType, Integer start, Integer count) {
List<StockPO> list = getJPAQueryFactory()
.select(q)
.where(q.stockType.eq(stockType))
.fetch();
return transform(list);
}
public Stock findStockByCode(String code) {
return findOneIfMutil(q.stockCode.eq(code));
}
public Stock findStockByName(String name) {
return findOneIfMutil(q.stockName.eq(name));
}
@Override
public GenericJpaRepository<StockPO, Integer> repo() {
return repo;
}
@Override
public IEntityPOConvert<Stock, StockPO> convert() {
return convert;
}
public static StockRepository of() {
return SpringUtils.getBean(StockRepository.class);
}
}

View File

@@ -0,0 +1,41 @@
package cn.stock.market.domain.basic.repository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.rp.spring.jpa.GenericJpaRepository;
import cn.qutaojing.common.domain.convert.IEntityPOConvert;
import cn.qutaojing.common.domain.respostory.SimplePoConvertEntityRepository;
import cn.stock.market.domain.basic.convert.SysLogConvert;
import cn.stock.market.domain.basic.entity.SysLog;
import cn.stock.market.infrastructure.db.po.SysLogPO;
import cn.stock.market.infrastructure.db.repo.SysLogRepo;
import lombok.RequiredArgsConstructor;
/**
* SysLogRepository
*
* @author xlfd
* @email xlfd@gmail.com
* @created 2021/06/18
*/
@Repository
@RequiredArgsConstructor(
onConstructor = @__(@Autowired)
)
public class SysLogRepository extends SimplePoConvertEntityRepository<SysLog, SysLogPO, Integer> {
final SysLogRepo repo;
final SysLogConvert convert;
@Override
public GenericJpaRepository<SysLogPO, Integer> repo() {
return repo;
}
@Override
public IEntityPOConvert<SysLog, SysLogPO> convert() {
return convert;
}
}

View File

@@ -0,0 +1,36 @@
package cn.stock.market.domain.basic.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.City;
import cn.stock.market.domain.basic.factory.CityFactory;
import cn.stock.market.domain.basic.repository.CityRepository;
import lombok.RequiredArgsConstructor;
/**
* CityService
*
* @author xlfd
* @email xlfd@gmail.com
* @created 2021/06/16
*/
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CityService {
final CityRepository repository;
final CityFactory factory;
public City findById(Integer id) {
return repository.findCacheById(id);
}
public CityRepository repository() {
return repository;
}
public static CityService of() {
return SpringUtils.getBean(CityService.class);
}
}

View File

@@ -0,0 +1,40 @@
package cn.stock.market.domain.basic.service;
import cn.qutaojing.common.enhance.validator.ValidationFacade;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.JsonInfo;
import cn.stock.market.domain.basic.factory.JsonInfoFactory;
import cn.stock.market.domain.basic.repository.JsonInfoRepository;
import cn.stock.market.dto.command.JsonInfoCreateCommand;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* JsonInfoService
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2022/08/16
*/
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class JsonInfoService {
final JsonInfoRepository repository;
final JsonInfoFactory factory;
public JsonInfo create(JsonInfoCreateCommand cmd) {
ValidationFacade.of().validate(cmd);
JsonInfo from = factory.from(cmd);
repository.save(from);
return from;
}
public JsonInfoRepository repository() {
return repository;
}
public static JsonInfoService of() {
return SpringUtils.getBean(JsonInfoService.class);
}
}

View File

@@ -0,0 +1,74 @@
package cn.stock.market.domain.basic.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.Realtime;
import cn.stock.market.domain.basic.factory.RealtimeFactory;
import cn.stock.market.domain.basic.repository.RealtimeRepository;
import cn.stock.market.infrastructure.db.po.QRealtimePO;
import cn.stock.market.utils.Utils;
import lombok.RequiredArgsConstructor;
/**
* RealtimeService
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class RealtimeService {
final RealtimeRepository repository;
final RealtimeFactory factory;
@SuppressWarnings({ "unchecked", "rawtypes" })
public Map<String, Object> findStock(String stockCode) {
List<Realtime> list = repository.findAll(QRealtimePO.realtimePO.stockCode.eq(Utils.jys(stockCode)));
Map<String, Object> map = new HashMap<>();
List<Double> price = new ArrayList();
List<Double> averagePrice = new ArrayList();
List<Double> rates = new ArrayList();
List<String> time = new ArrayList();
List<Integer> volumes = new ArrayList();
List<Integer> amounts = new ArrayList();
map.put("stockCode", stockCode);
map.put("size", Integer.valueOf(list.size()));
for (Realtime realTime : list) {
double p = realTime.getPrice();
price.add(Double.valueOf(p));
/*double avg = realTime.getAveragePrice();
averagePrice.add(Double.valueOf(avg));*/
double r = realTime.getRates();
rates.add(Double.valueOf(r));
String t = realTime.getTime();
time.add(t);
int v = realTime.getVolumes();
volumes.add(Integer.valueOf(v));
int a = realTime.getAmounts();
amounts.add(Integer.valueOf(a));
}
map.put("time", time);
map.put("volumes", volumes);
map.put("price", price);
map.put("averagePrice", averagePrice);
map.put("rates", rates);
map.put("amounts", amounts);
return map;
}
public RealtimeRepository repository() {
return repository;
}
public static RealtimeService of() {
return SpringUtils.getBean(RealtimeService.class);
}
}

View File

@@ -0,0 +1,176 @@
package cn.stock.market.domain.basic.service;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import cn.qutaojing.common.PageParam;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.SiteArticle;
import cn.stock.market.domain.basic.factory.SiteArticleFactory;
import cn.stock.market.domain.basic.repository.SiteArticleRepository;
import cn.stock.market.dto.command.SiteArticleCreateCommand;
import cn.stock.market.dto.query.SiteArticleQuery;
import cn.stock.market.infrastructure.db.po.QSiteArticlePO;
import cn.stock.market.utils.DateTimeUtil;
import cn.stock.market.utils.HttpRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
/**
* SiteArticleService
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Slf4j
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SiteArticleService {
final SiteArticleRepository repository;
final SiteArticleFactory factory;
public Page<SiteArticle> listByAdmin(String artTitle, String artType, int pageNum, int pageSize) {
SiteArticleQuery query = new SiteArticleQuery();
query.setArtTitle(artTitle);
query.setArtType(artType);
return repository.findAll(query.where(), PageParam.of(pageNum, pageSize));
}
public SiteArticle add(SiteArticleCreateCommand cmd) {
SiteArticle siteArticle = factory.from(cmd);
repository.saveAndFlush(siteArticle);
return siteArticle;
}
// public ServerResponse update(SiteArticle siteArticle) {
// if (siteArticle.getId() == null) {
// return ServerResponse.createByErrorMsg("修改id必传");
// }
// int updateCount = this.siteArticleMapper.updateByPrimaryKeySelective(siteArticle);
// if (updateCount > 0) {
// return ServerResponse.createBySuccessMsg("修改成功");
// }
// return ServerResponse.createByErrorMsg("修改失败");
// }
public Page<SiteArticle> list(String artTitle, String artType, int pageNum, int pageSize) {
//is_show
SiteArticleQuery query = new SiteArticleQuery();
query.setIsShow(0);
query.setArtTitle(artTitle);
query.setArtType(artType);
return repository.findAll(query.where(), PageParam.of(pageNum, pageSize));
}
/*top最新公告*/
public List<SiteArticle> getTopArtList(int pageSize){
SiteArticleQuery query = new SiteArticleQuery();
query.setIsShow(0);
return repository.findAll(query.where(), pageSize, QSiteArticlePO.siteArticlePO.id.desc());
}
public long getArtBySourceIdCount(String newsId) {
return repository.count(QSiteArticlePO.siteArticlePO.sourceId.eq(newsId));
}
/*公告-抓取*/
public int grabArticle() {
int ret = 0;
try {
Date date = DateTimeUtil.addDay(new Date(),2);
String time = DateTimeUtil.dateToStr(date,"yyyy-MM-dd HH:mm:ss");
String smap = DateTimeUtil.dateToStamp(time);
String url = "http://eminfo.eastmoney.com/pc_news/Notice/GetNoticeList?uid=&columnType=002&securityType=100&pageNumber=1&pageSize=50&startTime=1589904000000&endTime="+ smap +"&securityCodeMarket=&searchType=001&searchCondition=&fundIdList=&isfund=";
String newlist = HttpRequest.doGrabGet(url);
JSONObject data = JSONObject.fromObject(newlist);
JSONObject json = JSONObject.fromObject(data.get("data"));
if(json != null && json.getJSONArray("items") != null && json.getJSONArray("items").size() > 0){
for (int i = 0; i < json.getJSONArray("items").size(); i++){
JSONObject model = JSONObject.fromObject(json.getJSONArray("items").getString(i));
String newsId = model.getString("infoCode");
//新闻不存在则添加
if(getArtBySourceIdCount(newsId) == 0){
//获取新闻详情
String newdata = HttpRequest.doGrabGet("https://np-cnotice-pc.eastmoney.com/api/content/ann/rich?client_source=pc&page_index=1&is_rich=1&req_trace=&art_code="+ newsId);
JSONObject jsonnew = JSONObject.fromObject(newdata);
if(jsonnew != null && jsonnew.get("data") != null){
JSONObject news = JSONObject.fromObject(jsonnew.get("data"));
SiteArticle siteArticle = new SiteArticle();
siteArticle.setSourceId(newsId);
siteArticle.setAuthor(news.getString("short_name"));
siteArticle.setArtTitle(news.getString("notice_title"));
siteArticle.setAddTime(DateTimeUtil.getCurrentDate());
siteArticle.setArtSummary(news.getString("notice_title"));
String content = news.getString("notice_content");
siteArticle.setIsShow(0);
siteArticle.setViews(10);
siteArticle.setArtType(news.getString("short_name"));
if(!content.contains("{") && !content.contains("}")){
siteArticle.setArtCnt(content);
try {
repository.saveAndFlush(siteArticle);
} catch(Exception e) {
log.warn("siteArticleMapper insert error: {}", e.getLocalizedMessage());
}
ret++;
} else if (content.contains("{") && content.contains("pages")){
JSONObject pagelist = JSONObject.fromObject(news.get("notice_content"));
String contStr = "";
if(pagelist != null && pagelist.getJSONArray("pages") != null && pagelist.getJSONArray("pages").size() > 0){
for (int k=0;k<pagelist.getJSONArray("pages").size();k++){
JSONObject pageslist = JSONObject.fromObject(pagelist.getJSONArray("pages").getString(k));
if(pageslist != null && pageslist.getJSONArray("pageContent") != null && pageslist.getJSONArray("pageContent").size() > 0){
for (int r=0;r<pageslist.getJSONArray("pageContent").size();r++){
JSONObject cont = JSONObject.fromObject(pageslist.getJSONArray("pageContent").getString(r));
if(!cont.toString().contains("kids")){
contStr = contStr + cont.get("content");
} else {
JSONObject contkids = JSONObject.fromObject(cont.getJSONArray("kids").get(0));
contStr = contStr + contkids.get("content");
}
}
}
}
if(StringUtils.isNotEmpty(contStr)){
siteArticle.setArtCnt(contStr);
try {
repository.saveAndFlush(siteArticle);
} catch(Exception e) {
log.warn("siteArticleMapper insert error: {}", e.getLocalizedMessage());
}
ret++;
}
}
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
log.info("公告抓取条数:" + ret);
return ret;
}
public SiteArticleRepository repository() {
return repository;
}
public static SiteArticleService of() {
return SpringUtils.getBean(SiteArticleService.class);
}
}

View File

@@ -0,0 +1,170 @@
package cn.stock.market.domain.basic.service;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.qutaojing.common.PageParam;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.SiteNews;
import cn.stock.market.domain.basic.factory.SiteNewsFactory;
import cn.stock.market.domain.basic.repository.SiteNewsRepository;
import cn.stock.market.dto.query.SiteNewsQuery;
import cn.stock.market.utils.DateTimeUtil;
import cn.stock.market.utils.HttpRequest;
import cn.stock.market.utils.PropertiesUtil;
import cn.stock.market.utils.ServerResponse;
import cn.stock.market.utils.StringUtils;
import cn.stock.market.utils.Utils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
/**
* SiteNewsService
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/19
*/
@Slf4j
@Service
@SuppressWarnings("rawtypes")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SiteNewsService {
final SiteNewsRepository repository;
final SiteNewsFactory factory;
/*新闻资讯-查询列表*/
public ServerResponse<PageInfo> getList(int pageNum, int pageSize, Integer type, String sort, String keyword, HttpServletRequest request){
SiteNewsQuery query = new SiteNewsQuery();
query.setStatus(1);
query.setType(type);
query.setOrderSpecifier(sort);
query.setKeyword(keyword);
Page<SiteNews> page = repository.findAll(query.where(), PageParam.of(pageNum, pageSize), query.orderSpecifier());
return ServerResponse.createBySuccess(Utils.toPageHelperInfo(page));
}
/*新闻资讯-查询详情*/
public ServerResponse getDetail(int id) {
return ServerResponse.createBySuccess(repository.find(id));
}
/*新闻资讯-修改新闻浏览量*/
public ServerResponse updateViews(Integer id) {
return ServerResponse.createBySuccess(repository.updateViews(id));
}
/*新闻资讯-top最新新闻资讯*/
public ServerResponse getTopNewsList(int pageSize){
SiteNewsQuery query = new SiteNewsQuery();
query.setStatus(1);
List<SiteNews> list = repository.findAll(query.where(), pageSize, query.orderSpecifier());
PageInfo pageInfo = new PageInfo();
pageInfo.setList(list);
return ServerResponse.createBySuccess(pageInfo);
}
/*新闻资讯-抓取*/
public int grabNews() {
int ret = 0;
//新闻类型1、财经要闻2、经济数据3、全球股市4、7*24全球5、商品资讯6、上市公司7、全球央行
ret = addNews(1, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetImportantNewsList");
log.info("财经要闻-抓取条数:" + ret);
ret = addNews(2, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=125&pageNumber=1&pagesize=20&condition=&r=");
log.info("经济数据-抓取条数:" + ret);
ret = addNews(3, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=105&pageNumber=1&pagesize=20&condition=&r=");
log.info("全球股市-抓取条数:" + ret);
ret = addNews(4, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=100&pageNumber=1&pagesize=20&condition=&r=");
log.info("7*24全球-抓取条数:" + ret);
ret = addNews(5, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=106&pageNumber=1&pagesize=20&condition=&r=");
log.info("商品资讯-抓取条数:" + ret);
ret = addNews(6, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=103&pageNumber=1&pagesize=20&condition=&r=");
log.info("上市公司-抓取条数:" + ret);
ret = addNews(7, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=118&pageNumber=1&pagesize=20&condition=&r=");
log.info("全球央行-抓取条数:" + ret);
return ret;
}
/*
*抓取新闻专用
* type新闻类型1、财经要闻2、经济数据3、全球股市4、7*24全球5、商品资讯6、上市公司7、全球央行
* */
private int addNews(Integer type, String url){
int k = 0;
try {
String newlist = HttpRequest.doGrabGet(url);
JSONObject json = JSONObject.fromObject(newlist);
if(json != null && json.getJSONArray("items") != null && json.getJSONArray("items").size() > 0){
for (int i = 0; i < json.getJSONArray("items").size(); i++){
JSONObject model = JSONObject.fromObject(json.getJSONArray("items").getString(i));
String newsId = model.getString("code");
String imgUrl = null;
if(model.has("imgUrl")){
imgUrl = model.getString("imgUrl");
}
//新闻不存在则添加
if(repository.getNewsBySourceIdCount(newsId) == 0){
//获取新闻详情
String newdata = HttpRequest.doGrabGet(PropertiesUtil.getProperty("news.main.url") + "/PC_News/Detail/GetDetailContent?id="+ newsId +"&type=1");
newdata = newdata.substring(1,newdata.length()-1).replace("\\\\\\\"","\"");
newdata = newdata.replace("\\\"","\"");
newdata = StringUtils.UnicodeToCN(newdata);
newdata = StringUtils.delHTMLTag(newdata);
JSONObject jsonnew = JSONObject.fromObject(newdata);
if(jsonnew != null && jsonnew.get("data") != null){
JSONObject news = JSONObject.fromObject(jsonnew.get("data"));
SiteNews siteNews = new SiteNews();
siteNews.setSourceId(newsId);
siteNews.setSourceName(news.getString("source"));
siteNews.setTitle(news.getString("title"));
String showTime = news.getString("showTime");
siteNews.setShowTime(DateTimeUtil.strToDate(showTime));
siteNews.setImgurl(imgUrl);
siteNews.setDescription(news.getString("description"));
siteNews.setContent(news.getString("content"));
siteNews.setStatus(1);
siteNews.setType(type);
try {
repository.saveAndFlush(siteNews);
} catch(Exception e) {
log.warn("siteNewsMapper insert error: {}", e.getLocalizedMessage());
}
k++;
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return k;
}
public SiteNewsRepository repository() {
return repository;
}
public static SiteNewsService of() {
return SpringUtils.getBean(SiteNewsService.class);
}
}

View File

@@ -0,0 +1,628 @@
package cn.stock.market.domain.basic.service;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import javax.persistence.EntityExistsException;
import javax.servlet.http.HttpServletRequest;
import cn.stock.market.dto.model.HKStockNewInfo;
import cn.stock.market.infrastructure.api.sina.vo.HotSearchVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import com.ag.exception.EntityNotFoundException;
import com.ag.exception.SysTipsException;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import cn.qutaojing.common.PageParam;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.entity.Stock;
import cn.stock.market.domain.basic.factory.StockFactory;
import cn.stock.market.domain.basic.repository.StockRepository;
import cn.stock.market.dto.model.StockAdminListVO;
import cn.stock.market.dto.model.StockListVO;
import cn.stock.market.dto.model.StockVO;
import cn.stock.market.infrastructure.api.qq.QqStockApi;
import cn.stock.market.infrastructure.api.sina.SinaStockApi;
import cn.stock.market.infrastructure.api.sina.vo.MarketVO;
import cn.stock.market.infrastructure.api.sina.vo.MarketVOResult;
import cn.stock.market.infrastructure.api.sina.vo.k.MinDataVO;
import cn.stock.market.infrastructure.api.sina.vo.k.echarts.EchartsDataVO;
import cn.stock.market.infrastructure.stockdb.po.QStockPO;
import cn.stock.market.utils.GetPyByChinese;
import cn.stock.market.utils.HttpClientRequest;
import cn.stock.market.utils.PropertiesUtil;
import cn.stock.market.utils.ServerResponse;
import cn.stock.market.utils.Utils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.client.RestTemplate;
/**
* StockService
*
* @author rplees
* @email rplees.i.ly@gmail.com
* @created 2023/06/17
*/
@Slf4j
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class StockService {
final StockRepository repository;
final StockFactory factory;
final RestTemplate restTemplate;
public ServerResponse getMarket() {
String market_url = "https://hq.sinajs.cn/rn=1520407404627&list=s_sh000001,s_sz399001,s_sz399006,s_sz399300,s_sz399005,s_sz399673,s_sz399106,s_sz399004,s_sz399100";
String result = null;
try {
result = HttpClientRequest.doGet(market_url);
} catch (Exception e) {
log.error("e = {}", e);
}
String[] marketArray = result.split(";");
List<MarketVO> marketVOS = Lists.newArrayList();
for (int i = 0; i < marketArray.length; i++) {
String hqstr = marketArray[i];
try {
if (StringUtils.isNotBlank(hqstr)) {
hqstr = hqstr.substring(hqstr.indexOf("\"") + 1, hqstr.lastIndexOf("\""));
MarketVO marketVO = new MarketVO();
String[] sh01_arr = hqstr.split(",");
marketVO.setName(sh01_arr[0]);
marketVO.setNowPrice(sh01_arr[1]);
marketVO.setIncrease(sh01_arr[2]);
marketVO.setIncreaseRate(sh01_arr[3]);
marketVOS.add(marketVO);
}
} catch (Exception e) {
log.error("str = {} , e = {}", hqstr, e);
}
}
MarketVOResult marketVOResult = new MarketVOResult();
marketVOResult.setMarket(marketVOS);
return ServerResponse.createBySuccess(marketVOResult);
}
public ServerResponse getHotSearch() {
String market_url = "https://finance.sina.com.cn/hq/analysis/pc_hot_search.js";
String result = null;
try {
result = HttpClientRequest.doGet(market_url);
} catch (Exception e) {
log.error("e = {}", e);
}
JSONArray json = JSONArray.parseArray(result.replace("var hot_a_stock=", ""));
List<HotSearchVO> hotSearchVOS = Lists.newArrayList();
for (int i = 0; i < json.size(); i++) {
JSONObject hot = json.getJSONObject(i);
HotSearchVO hotSearchVO = new HotSearchVO();
hotSearchVO.setSymbol(hot.getString("symbol"));
hotSearchVO.setWeight(hot.getInteger("weight"));
Stock stock = repository.cacheCodeMap().get(hotSearchVO.getSymbol().substring(2));
if (Objects.isNull(stock)) {
continue;
}
hotSearchVO.setCode(stock.getStockCode());
hotSearchVO.setName(stock.getStockName());
hotSearchVOS.add(hotSearchVO);
}
return ServerResponse.createBySuccess(hotSearchVOS);
}
public ServerResponse getNorthIn() {
String market_url = "https://datacenter-web.eastmoney.com/api/data/v1/get?callback=jQuery112305686722141887519_1700033208129&reportName=RPT_MUTUAL_QUOTA&columns=TRADE_DATE,MUTUAL_TYPE,BOARD_TYPE,MUTUAL_TYPE_NAME,FUNDS_DIRECTION,INDEX_CODE,INDEX_NAME,BOARD_CODE&quoteColumns=status~07~BOARD_CODE,dayNetAmtIn~07~BOARD_CODE,dayAmtRemain~07~BOARD_CODE,dayAmtThreshold~07~BOARD_CODE,f104~07~BOARD_CODE,f105~07~BOARD_CODE,f106~07~BOARD_CODE,f3~03~INDEX_CODE~INDEX_f3,netBuyAmt~07~BOARD_CODE&quoteType=0&pageNumber=1&pageSize=200&sortTypes=1&sortColumns=MUTUAL_TYPE&source=WEB&client=WEB&_="+System.currentTimeMillis();
String result = null;
try {
result = HttpClientRequest.doGet(market_url);
} catch (Exception e) {
log.error("e = {}", e);
}
result = result.replace("jQuery112305686722141887519_1700033208129(","");
result = result.substring(0,result.length()-2);
JSONObject json = JSONObject.parseObject(result);
Integer code = json.getInteger("code");
if (code == 0) {
BigDecimal ret = BigDecimal.ZERO;
JSONArray dataAry = json.getJSONObject("result").getJSONArray("data");
for (int i = 0; i < dataAry.size(); i++) {
JSONObject data = dataAry.getJSONObject(i);
String fundsDirection = data.getString("FUNDS_DIRECTION");
if ("北向".equals(fundsDirection)){
ret = ret.add(data.getBigDecimal("netBuyAmt"));
}
}
return ServerResponse.createBySuccess(ret);
}
return ServerResponse.createByErrorMsg("查不到数据");
}
public ServerResponse getMainIn() {
String url = "https://push2his.eastmoney.com/api/qt/stock/fflow/daykline/get?cb=jQuery1123044920609862794136_1700037243016&lmt=0&klt=101&fields1=f1,f2,f3,f7&fields2=f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64,f65&ut=b2884a393a59ad64002292a3e90d46a5&secid=1.000001&secid2=0.399001&_="+System.currentTimeMillis();
String result = null;
try {
result = HttpClientRequest.doGet(url);
} catch (Exception e) {
log.error("e = {}", e);
}
result = result.replace("jQuery1123044920609862794136_1700037243016(","");
result = result.substring(0,result.length()-2);
JSONObject json = JSONObject.parseObject(result);
JSONObject data = json.getJSONObject("data");
if (Objects.nonNull(data)){
JSONArray klines = data.getJSONArray("klines");
if (Objects.nonNull(klines) && !klines.isEmpty()){
String last = klines.getString(klines.size()-1);
String[] arry = last.split(",");
return ServerResponse.createBySuccess(arry[1]);
}
}
return ServerResponse.createByErrorMsg("查不到数据");
}
public ServerResponse getMarketByStockGid(String stockGid) {
String market_url = "https://qt.gtimg.cn/?q=marketStat,stockcode,usDJI,r_hkHSI";
String result = null;
try {
market_url = market_url.replace("stockcode", stockGid);
//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//System.out.print("指数请求开始,时间:"+sdf.format(new Date())+"market_url"+market_url + "\n");
result = HttpClientRequest.doGet(market_url);
//System.out.print("指数请求结束,时间:"+sdf.format(new Date())+"result"+result + "\n");
} catch (Exception e) {
log.error("获取 大盘指数 出错 e = {}", e);
}
MarketVO marketVO = null;
if (!StringUtils.contains(result, "=")) {
log.info("将使用行情模块兜底: {}", stockGid);
try {
result = HttpClientRequest.doGet(market_url);
marketVO = JSONObject.parseObject(result, MarketVO.class);
log.info("兜底返回信息: {}", result);
} catch (Exception e2) {
log.info("将使用行情{}模块兜底错误...", stockGid, e2);
}
return ServerResponse.createBySuccess(marketVO);
}
try {
if (StringUtils.isNotBlank(result)) {
result = result.substring(result.indexOf("\"") + 1, result.lastIndexOf("\""));
marketVO = new MarketVO();
if (result.contains(";")) {
String[] indexAry = result.split(";");
if (indexAry.length > 1) {
String[] sh01_arr = indexAry[1].split("~");
marketVO.setName(sh01_arr[1]);
marketVO.setMaxHigh(sh01_arr[33]);
marketVO.setMinLow(sh01_arr[34]);
marketVO.setNowPrice(sh01_arr[3]);
marketVO.setOpenPrice(sh01_arr[5]);
marketVO.setClosePrice(sh01_arr[4]);
marketVO.setIncrease(sh01_arr[31]);
marketVO.setIncreaseRate(sh01_arr[32]);
String[] turnAry = sh01_arr[35].split("/");
marketVO.setTurnOver(turnAry[1]);
marketVO.setTurnNum(turnAry[2]);
}
}
}
} catch (Exception e) {
log.error("转换大盘指数出错 str = {} , e = {}", result, e);
}
return ServerResponse.createBySuccess(marketVO);
}
public ServerResponse getStock(int pageNum, int pageSize, String keyWords, String stockPlate, String stockType,
HttpServletRequest request) {
Page<Stock> page = repository.findStockListByKeyWords(keyWords, stockPlate, stockType, 0, PageParam.of(pageNum, pageSize));
List<StockListVO> stockListVOS = Lists.newArrayList();
if (page.getContent().size() > 0)
for (Stock stock : page.getContent()) {
StockListVO stockListVO = SinaStockApi
.assembleStockListVO(SinaStockApi.getSinaStock(stock.getStockGid()));
stockListVO.setCode(stock.getStockCode());
stockListVO.setSpell(stock.getStockSpell());
stockListVO.setGid(stock.getStockGid());
// BigDecimal day3Rate = (BigDecimal) selectRateByDaysAndStockCode(stock.getStockCode(), 3).getData();
BigDecimal day3Rate = BigDecimal.ZERO;
stockListVO.setDay3Rate(day3Rate);
stockListVO.setStock_plate(stock.getStockPlate());
stockListVO.setStock_type(stock.getStockType());
// 是否添加自选 //TODO:
// if (user == null) {
stockListVO.setIsOption("0");
// } else {
// stockListVO.setIsOption(iStockOptionService.isMyOption(user.getId(), stock.getStockCode()));
// }
stockListVOS.add(stockListVO);
}
com.github.pagehelper.PageInfo pageInfo = Utils.toPageHelperInfo(page);
pageInfo.setList(stockListVOS);
return ServerResponse.createBySuccess(pageInfo);
}
public ServerResponse getSingleStock(String code) {
if (StringUtils.isBlank(code))
return ServerResponse.createByErrorMsg("");
Stock stock = new Stock();
Integer depositAmt = 0;
// 期货
// if (code.contains("hf")) {
// StockFutures futmodel = stockFuturesMapper.selectFuturesByCode(code.replace("hf_", ""));
// stock.setStockGid(futmodel.getFuturesGid());
// stock.setStockCode(futmodel.getFuturesCode());
// stock.setStockName(futmodel.getFuturesName());
// stock.setAddTime(futmodel.getAddTime());
// stock.setId(futmodel.getId());
// stock.setStockSpell("0");
// depositAmt = futmodel.getDepositAmt();
// } else if (code.contains("sh") || code.contains("sz")) { // 指数
// StockIndex model = stockIndexMapper.selectIndexByCode(code.replace("sh", "").replace("sz", ""));
// stock.setStockGid(model.getIndexGid());
// stock.setStockCode(model.getIndexCode());
// stock.setStockName(model.getIndexName());
// stock.setAddTime(model.getAddTime());
// stock.setId(model.getId());
// stock.setStockSpell("0");
// depositAmt = model.getDepositAmt();
// } else {// 股票
// }
stock = repository.findStockByCode(code);
if (stock == null)
return ServerResponse.createByErrorMsg("");
String gid = stock.getStockGid();
String sinaResult = SinaStockApi.getSinaStock(gid);
StockVO stockVO = new StockVO();
if (code.contains("hf")) {
stockVO = SinaStockApi.assembleStockFuturesVO(sinaResult);
} else {
stockVO = SinaStockApi.assembleStockVO(sinaResult);
}
stockVO.setDepositAmt(depositAmt);
stockVO.setId(stock.getId().intValue());
stockVO.setCode(stock.getStockCode());
stockVO.setSpell(stock.getStockSpell());
stockVO.setGid(stock.getStockGid());
stockVO.setMinImg(PropertiesUtil.getProperty("sina.single.stock.min.url") + stock.getStockGid() + ".jpg");
stockVO.setDayImg(PropertiesUtil.getProperty("sina.single.stock.day.url") + stock.getStockGid() + ".jpg");
stockVO.setWeekImg(PropertiesUtil.getProperty("sina.single.stock.week.url") + stock.getStockGid() + ".jpg");
stockVO.setMonthImg(PropertiesUtil.getProperty("sina.single.stock.month.url") + stock.getStockGid() + ".jpg");
return ServerResponse.createBySuccess(stockVO);
}
public ServerResponse getMinK(String code, Integer time, Integer ma, Integer size) {
if (StringUtils.isBlank(code) || time == null || ma == null || size == null)
return ServerResponse.createByErrorMsg("");
Stock stock = repository.findStockByCode(code);
if (stock == null)
return ServerResponse.createByErrorMsg("");
return SinaStockApi.getStockMinK(stock, time.intValue(), ma.intValue(), size.intValue());
}
public ServerResponse getKLine(String code) {
return SinaStockApi.getKLine(code);
}
public ServerResponse getMinK_Echarts(String code, Integer time, Integer ma, Integer size) {
if (StringUtils.isBlank(code) || time == null || ma == null || size == null)
return ServerResponse.createByErrorMsg("");
Stock stock = repository.findStockByCode(code);
if (stock == null)
return ServerResponse.createByErrorMsg("");
ServerResponse<MinDataVO> serverResponse = SinaStockApi.getStockMinK(stock, time.intValue(), ma.intValue(),
size.intValue());
MinDataVO minDataVO = (MinDataVO) serverResponse.getData();
EchartsDataVO echartsDataVO = SinaStockApi.assembleEchartsDataVO(minDataVO);
return ServerResponse.createBySuccess(echartsDataVO);
}
/* 指数分时-k线 */
public ServerResponse getIndexMinK_Echarts(String code, Integer time, Integer size) {
if (StringUtils.isBlank(code) || time == null)
return ServerResponse.createByErrorMsg("");
ServerResponse<MinDataVO> serverResponse = QqStockApi.getIndexMinK(code, time.intValue(), size.intValue());
MinDataVO minDataVO = (MinDataVO) serverResponse.getData();
EchartsDataVO echartsDataVO = SinaStockApi.assembleEchartsDataVO(minDataVO);
return ServerResponse.createBySuccess(echartsDataVO);
}
/* 股票日线-K线 */
public ServerResponse getDayK_Echarts(String code) {
return kEcharts(code, "day");
}
ServerResponse kEcharts(String code, String type) {
if (StringUtils.isBlank(code))
return ServerResponse.createByErrorMsg("");
Stock stock = repository.findStockByCode(code);
if (stock == null)
return ServerResponse.createByErrorMsg("");
ServerResponse<MinDataVO> serverResponse = null;
if (stock.getStockType().equals("bj")) {
serverResponse = QqStockApi.getBjsStockMonthK(stock, type);
} else {
serverResponse = QqStockApi.getGpStockMonthK(stock, type);
}
MinDataVO minDataVO = (MinDataVO) serverResponse.getData();
EchartsDataVO echartsDataVO = SinaStockApi.assembleEchartsDataVO(minDataVO);
return ServerResponse.createBySuccess(echartsDataVO);
}
/* 股票周线-K线 */
public ServerResponse getWeekK_Echarts(String code) {
return kEcharts(code, "week");
}
/* 股票月线-K线 */
public ServerResponse getMonthK_Echarts(String code) {
return kEcharts(code, "month");
}
public StockRepository repository() {
return repository;
}
public ServerResponse<PageInfo> listByAdmin(Integer showState, Integer lockState, String code, String name,
String stockPlate, String stockType, int pageNum, int pageSize, HttpServletRequest request) {
Page<Stock> page = this.repository.listByAdmin(showState, lockState, code, name, stockPlate, stockType, PageParam.of(pageNum, pageSize));
List<StockAdminListVO> stockAdminListVOS = Lists.newArrayList();
for (Stock stock : page.getContent()) {
StockAdminListVO stockAdminListVO = assembleStockAdminListVO(stock);
stockAdminListVOS.add(stockAdminListVO);
}
PageInfo pageInfo = Utils.toPageHelperInfo(page);
pageInfo.setList(stockAdminListVOS);
return ServerResponse.createBySuccess(pageInfo);
}
private StockAdminListVO assembleStockAdminListVO(Stock stock) {
StockAdminListVO stockAdminListVO = new StockAdminListVO();
stockAdminListVO.setId(stock.getId());
stockAdminListVO.setStockName(stock.getStockName());
stockAdminListVO.setStockCode(stock.getStockCode());
stockAdminListVO.setStockSpell(stock.getStockSpell());
stockAdminListVO.setStockType(stock.getStockType());
stockAdminListVO.setStockGid(stock.getStockGid());
stockAdminListVO.setStockPlate(stock.getStockPlate());
stockAdminListVO.setIsLock(stock.getIsLock());
stockAdminListVO.setIsShow(stock.getIsShow());
stockAdminListVO.setAddTime(stock.getAddTime());
StockListVO stockListVO = SinaStockApi.assembleStockListVO(SinaStockApi.getSinaStock(stock.getStockGid()));
stockAdminListVO.setNowPrice(stockListVO.getNowPrice());
stockAdminListVO.setHcrate(stockListVO.getHcrate());
stockAdminListVO.setSpreadRate(stock.getSpreadRate());
// ServerResponse serverResponse = selectRateByDaysAndStockCode(stock.getStockCode(), 3);
BigDecimal day3Rate = new BigDecimal("0");
// if (serverResponse.isSuccess())
// day3Rate = (BigDecimal) serverResponse.getData();
stockAdminListVO.setDay3Rate(day3Rate);
return stockAdminListVO;
}
public void updateLock(Integer stockId) {
Stock stock = this.repository.find(stockId);
if (stock == null) {
throw new EntityNotFoundException();
}
if (stock.getIsLock().intValue() == 1) {
stock.setIsLock(Integer.valueOf(0));
} else {
stock.setIsLock(Integer.valueOf(1));
}
this.repository.saveAndFlush(stock);
}
public void updateShow(Integer stockId) {
Stock stock = this.repository.find(stockId);
if (stock == null) {
throw new EntityNotFoundException();
}
if (stock.getIsShow().intValue() == 0) {
stock.setIsShow(Integer.valueOf(1));
} else {
stock.setIsShow(Integer.valueOf(0));
}
this.repository.saveAndFlush(stock);
}
public void addStock(String stockName, String stockCode, String stockType, String stockPlate,
Integer isLock, Integer isShow) {
if (StringUtils.isBlank(stockName) || StringUtils.isBlank(stockCode) || StringUtils.isBlank(stockType)
|| isLock == null || isShow == null)
throw new SysTipsException("参数非法");
Stock cstock = repository.findStockByCode(stockCode);
if (cstock != null) {
throw new EntityExistsException();
}
Stock nstock = repository.findStockByName(stockName);
if (nstock != null)
throw new EntityExistsException();
Stock stock = new Stock();
stock.setStockName(stockName);
stock.setStockCode(stockCode);
stock.setStockSpell(GetPyByChinese.converterToFirstSpell(stockName));
stock.setStockType(stockType);
stock.setStockGid(stockType + stockCode);
stock.setIsLock(isLock);
stock.setIsShow(isShow);
stock.setAddTime(new Date());
if (stockPlate != null)
stock.setStockPlate(stockPlate);
if (stockPlate != null && StringUtils.isNotEmpty(stockPlate) && stockCode.startsWith("300"))
stock.setStockPlate("创业");
else if (stockPlate != null && StringUtils.isNotEmpty(stockPlate) && stockCode.startsWith("688"))
stock.setStockPlate("科创");
else
stock.setStockPlate(null);
this.repository.saveAndFlush(stock);
}
public long CountStockNum() {
return this.repository.count();
}
public long CountShowNum(Integer showState) {
return this.repository.count(QStockPO.stockPO.isShow.eq(showState));
}
public long CountUnLockNum(Integer lockState) {
return this.repository.count(QStockPO.stockPO.isLock.eq(lockState));
}
public List<Stock> findStockList() {
return this.repository.findAll();
}
public void updateStock(Stock model) {
if (StringUtils.isBlank(model.getId().toString()) || StringUtils.isBlank(model.getStockName()))
throw new SysTipsException("参数非法");
Stock stock = this.repository.find(model.getId());
if (stock == null)
throw new EntityNotFoundException();
stock.setStockName(model.getStockName());
if (model.getSpreadRate() != null)
stock.setSpreadRate(model.getSpreadRate());
repository.saveAndFlush(stock);
}
public void deleteByPrimaryKey(Integer id) {
repository.deleteById(id);
}
public static StockService of() {
return SpringUtils.getBean(StockService.class);
}
/* 指数日线-K线 */
public ServerResponse getIndexDayK(String code) {
return getIndexK(code, "day");
}
/* 指数周线-K线 */
public ServerResponse getIndexWeekK(String code) {
return getIndexK(code, "week");
}
/* 指数月线-K线 */
public ServerResponse getIndexMonthK(String code) {
return getIndexK(code, "month");
}
/* 指数月线-K线 */
public ServerResponse getIndexK(String code, String type) {
if (StringUtils.isBlank(code))
return ServerResponse.createByErrorMsg("");
ServerResponse<MinDataVO> serverResponse = QqStockApi.getQqIndexDayK(code, type);
MinDataVO minDataVO = (MinDataVO) serverResponse.getData();
EchartsDataVO echartsDataVO = SinaStockApi.assembleEchartsDataVO(minDataVO);
return ServerResponse.createBySuccess(echartsDataVO);
}
public ServerResponse getNewStock() {
String sina_result = "";
try {
List<HKStockNewInfo> stockNewInfos = new ArrayList<>();
sina_result = HttpClientRequest.doGet("https://datacenter-web.eastmoney.com/api/data/v1/get?sortColumns=APPLY_DATE%2CSECURITY_CODE&sortTypes=-1%2C-1&pageSize=10&pageNumber=1&reportName=RPTA_APP_IPOAPPLY&columns=SECURITY_CODE%2CSECURITY_NAME%2CTRADE_MARKET_CODE%2CAPPLY_CODE%2CTRADE_MARKET%2CMARKET_TYPE%2CORG_TYPE%2CISSUE_NUM%2CONLINE_ISSUE_NUM%2COFFLINE_PLACING_NUM%2CTOP_APPLY_MARKETCAP%2CPREDICT_ONFUND_UPPER%2CONLINE_APPLY_UPPER%2CPREDICT_ONAPPLY_UPPER%2CISSUE_PRICE%2CLATELY_PRICE%2CCLOSE_PRICE%2CAPPLY_DATE%2CBALLOT_NUM_DATE%2CBALLOT_PAY_DATE%2CLISTING_DATE%2CAFTER_ISSUE_PE%2CONLINE_ISSUE_LWR%2CINITIAL_MULTIPLE%2CINDUSTRY_PE_NEW%2COFFLINE_EP_OBJECT%2CCONTINUOUS_1WORD_NUM%2CTOTAL_CHANGE%2CPROFIT%2CLIMIT_UP_PRICE%2CINFO_CODE%2COPEN_PRICE%2CLD_OPEN_PREMIUM%2CLD_CLOSE_CHANGE%2CTURNOVERRATE%2CLD_HIGH_CHANG%2CLD_AVERAGE_PRICE%2COPEN_DATE%2COPEN_AVERAGE_PRICE%2CPREDICT_PE%2CPREDICT_ISSUE_PRICE2%2CPREDICT_ISSUE_PRICE%2CPREDICT_ISSUE_PRICE1%2CPREDICT_ISSUE_PE%2CPREDICT_PE_THREE%2CONLINE_APPLY_PRICE%2CMAIN_BUSINESS%2CPAGE_PREDICT_PRICE1%2CPAGE_PREDICT_PRICE2%2CPAGE_PREDICT_PRICE3%2CPAGE_PREDICT_PE1%2CPAGE_PREDICT_PE2%2CPAGE_PREDICT_PE3%2CSELECT_LISTING_DATE%2CIS_BEIJING%2CINDUSTRY_PE_RATIO%2CIS_REGISTRATION&quoteColumns=f2~01~SECURITY_CODE~NEWEST_PRICE&quoteType=0");
com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(sina_result);
com.alibaba.fastjson.JSONArray jsonArray = json.getJSONObject("result").getJSONArray("data");
for (Object o : jsonArray) {
com.alibaba.fastjson.JSONObject jsonObject = (com.alibaba.fastjson.JSONObject) o;
HKStockNewInfo info = new HKStockNewInfo();
info.setSymbol(jsonObject.getString("SECURITY_CODE"));
info.setName(jsonObject.getString("SECURITY_NAME"));
info.setLotWinRate(jsonObject.getString("ONLINE_ISSUE_LWR"));
info.setPrice(jsonObject.getString("ISSUE_PRICE"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (new Date(jsonObject.getLong("APPLY_DATE")).before(new Date())) {
break;
}
String formattedDate = sdf.format(new Date(jsonObject.getLong("APPLY_DATE")));
info.setApplyBeginDate(formattedDate);
info.setType(3);
//判断深沪类型
if (jsonObject.getString("TRADE_MARKET").contains("深证")) {
info.setType(1);
}
if (jsonObject.getString("TRADE_MARKET").contains("上海")) {
info.setType(2);
}
stockNewInfos.add(info);
}
return ServerResponse.createBySuccess(stockNewInfos);
} catch (Exception e) {
log.error("获取出错,错误信息 = {}", e);
}
return null;
}
public ServerResponse getNewStockList() {
try {
JSONObject jsonParam = new JSONObject();
jsonParam.put("Czxt", "HUAWEI BNE-AL00 12");
jsonParam.put("Sblx", "RNandroid");
jsonParam.put("Sjhm", "LIP:NA;MAC:NA;IMEI:NA;RMPN:NA;UMPN:NA;ICCID:NA;OSV:12;IMSI:NA");
jsonParam.put("Type", "QueryIpoToBeListed");
jsonParam.put("User_id_lx", "Z");
jsonParam.put("User_id", "666666666666");
jsonParam.put("emtoken", "EMRNV1");
jsonParam.put("svrid", "em-secutrade-service");
jsonParam.put("gw_reqtimestamp", System.currentTimeMillis());
jsonParam.put("startIndex", 1);
jsonParam.put("pageSize", 20);
jsonParam.put("Kzzbz", "0");
jsonParam.put("Version", "10.12.1");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> requestEntity = new HttpEntity<>(jsonParam.toString(), headers);
ResponseEntity<String> response = restTemplate.postForEntity("https://nhtradegateway.18.cn/api/NewStk/QueryIpoToBeListed", requestEntity, String.class);
com.alibaba.fastjson.JSONArray data = JSON.parseObject(response.getBody()).getJSONArray("Data");
return ServerResponse.createBySuccess(data);
} catch (Exception e) {
e.printStackTrace();
}
return ServerResponse.createByErrorMsg("请求失败");
}
}

View File

@@ -0,0 +1,36 @@
package cn.stock.market.domain.basic.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.qutaojing.common.utils.SpringUtils;
import cn.stock.market.domain.basic.factory.LogBuilder;
import cn.stock.market.domain.basic.factory.SysLogFactory;
import cn.stock.market.domain.basic.repository.SysLogRepository;
import lombok.RequiredArgsConstructor;
/**
* SysLogService
*
* @author xlfd
* @email xlfd@gmail.com
* @created 2021/06/18
*/
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SysLogService {
final SysLogRepository repository;
final SysLogFactory factory;
public SysLogRepository repository() {
return repository;
}
public static SysLogService of() {
return SpringUtils.getBean(SysLogService.class);
}
public void log(LogBuilder builder) {
repository.save(builder.build());
}
}

Some files were not shown because too many files have changed in this diff Show More