This commit is contained in:
2023-07-27 15:33:41 +08:00
parent 27a422b841
commit 7bb52d2203
12 changed files with 2395 additions and 37 deletions

View File

@@ -0,0 +1,39 @@
services:
pg:
image: postgres
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: 'abc@123'
POSTGRES_USER: "postgres"
POSTGRES_DB: "coal"
networks:
- dn
volumes:
- pg_data:/var/lib/postgresql/data
redis:
image: redis:7
ports:
- "6379:6379"
volumes:
- ./redis.conf:/etc/redis/redis.conf
- redis_data:/data
networks:
- dn
command:
- redis-server
- /etc/redis/redis.conf
networks:
dn:
driver: bridge
volumes:
pg_data:
redis_data:

2276
docker/dev/redis.conf Normal file

File diff suppressed because it is too large Load Diff

27
pom.xml
View File

@@ -53,14 +53,18 @@
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-quartz -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-quartz</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>eu.bitwalker</groupId>
@@ -70,6 +74,17 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core -->
<dependency>

View File

@@ -2,6 +2,7 @@ package cn.lihongjie.coal;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@SpringBootApplication

View File

@@ -1,9 +1,18 @@
package cn.lihongjie.coal.config;
import org.springframework.boot.autoconfigure.cache.RedisCacheManagerBuilderCustomizer;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.RedisSerializer;
import java.time.Duration;
@@ -20,4 +29,7 @@ public class CacheConfig {
}
};
}
}

View File

@@ -0,0 +1,40 @@
package cn.lihongjie.coal.config;
import org.hibernate.boot.ResourceStreamLocator;
import org.hibernate.boot.spi.*;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.type.SqlTypes;
import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.sql.SQLType;
@Configuration
public class HibernateConfig {
@Bean
AdditionalMappingContributor metadataContributor(){
return new AdditionalMappingContributor() {
@Override
public void contribute(AdditionalMappingContributions contributions,
InFlightMetadataCollector metadata,
ResourceStreamLocator resourceStreamLocator,
MetadataBuildingContext buildingContext) {
buildingContext
.getBuildingOptions()
.getTypeConfiguration()
.getDdlTypeRegistry()
.addDescriptor(SqlTypes.VARCHAR, new DdlTypeImpl(SqlTypes.VARCHAR, "text", new PostgreSQLDialect()));
}
};
}
}

View File

@@ -7,6 +7,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/coalWashingDailyAnalysis")
@RequestMapping("/dictionary")
public class DictionaryController extends BaseController<DictionaryRepository, DictionaryService, DictionaryEntity> {
}

View File

@@ -7,6 +7,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/coalWashingDailyAnalysis")
@RequestMapping("/organization")
public class OrganizationController extends BaseController<OrganizationRepository, OrganizationService, OrganizationEntity> {
}

View File

@@ -23,7 +23,7 @@ public class DictionaryItemEntity extends CommonEntity {
@OneToMany(mappedBy = "parent")
@JsonManagedReference
private List<DictionaryEntity> children;
private List<DictionaryItemEntity> children;

View File

@@ -1,12 +0,0 @@
package cn.lihongjie.coal.job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
public class DemoJob extends QuartzJobBean {
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
}
}

View File

@@ -1,6 +1,8 @@
geolite2:
url: 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=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&suffix=tar.gz'
server:
port: 7456
spring:
jpa:
@@ -37,12 +39,7 @@ spring:
password: 'abc@123'
cache:
type: redis
redis:
enable-statistics: true
quartz:
auto-startup: true
job-store-type: jdbc
overwrite-existing-jobs: true
wait-for-jobs-to-complete-on-shutdown: true
startup-delay: 5

View File

@@ -1,10 +0,0 @@
<configuration>
<springProfile name="dev | test">
<!-- configuration to be enabled when the "dev" or "staging" profiles are active -->
<include ></include>
</springProfile>
<springProfile name="production">
<!-- configuration to be enabled when the "production" profile is not active -->
</springProfile>
</configuration>