Browse Source

服务器缓存undertow

tuonina 5 years ago
parent
commit
1e0b3ce392

+ 3 - 1
build.gradle

@@ -90,7 +90,7 @@ subprojects {
 
         compile('org.springframework.cloud:spring-cloud-config-server')
         compile('org.springframework.cloud:spring-cloud-config-monitor')
-        compile('org.springframework.boot:spring-boot-starter-jetty')
+        compile('org.springframework.boot:spring-boot-starter-undertow')
         compile('org.springframework.boot:spring-boot-starter-jdbc')
         compile('org.springframework.boot:spring-boot-starter-cache')
         compile("org.springframework.session:spring-session-data-redis")
@@ -118,6 +118,8 @@ subprojects {
         compile("io.springfox:springfox-swagger2:$swagger_version")
         compile("io.springfox:springfox-swagger-ui:$swagger_version")
 
+        compile('javax.xml.bind:jaxb-api:2.3.0')
+
         ext.jarTree = fileTree(dir: 'libs', include: '**/*.jar')
         compile jarTree
     }

+ 78 - 0
envir-config/src/main/kotlin/cn/gygxzc/cloud/config/controller/CommonConfigController.kt

@@ -0,0 +1,78 @@
+package cn.gygxzc.cloud.config.controller
+
+import cn.gygxzc.cloud.config.model.CommonConfig
+import cn.gygxzc.cloud.config.service.ICommonConfigService
+import cn.tonyandmoney.tuonq.core.req.PageReq
+import com.baomidou.mybatisplus.core.metadata.IPage
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.web.bind.annotation.*
+import reactor.core.publisher.Mono
+
+/**
+ * 通用配置信息,
+ * 删除采用物理删除,我的理解,这些数据并非说紧要到删除了不可修复的程度。
+ * 逻辑删除用在数据紧要,删除后无法进行恢复和还原,或者说还原代价较大的场景
+ */
+@RestController
+@RequestMapping("/v1/config/common")
+class CommonConfigController {
+
+    @Autowired
+    private lateinit var commonService: ICommonConfigService
+
+
+    /**
+     * 根据条件查询全部配置文件,可看全部
+     */
+    @GetMapping
+    fun searchByCond(pageReq: PageReq, entity: CommonConfig): Mono<IPage<CommonConfig>> {
+        return Mono.create {
+            it.success(commonService.queryByPage(pageReq, entity))
+        }
+    }
+
+    /**
+     * 给服务或者是前端客户端调用的,并非是应用于个人角色权限
+     */
+    @GetMapping("/application")
+    fun queryApplicationConfig(pageReq: PageReq,
+                               @RequestParam("server") isServer: Boolean,
+                               @RequestParam("application") application: String): Mono<List<CommonConfig>> {
+        return Mono.create { it.success(commonService.queryApplicationConfig(isServer, application)) }
+    }
+
+    /**
+     * 添加配置信息
+     */
+    @PostMapping
+    fun addConfig(@RequestBody entity: CommonConfig): Mono<Void> {
+        return Mono.create {
+            commonService.save(entity)
+            it.success()
+        }
+    }
+
+
+    /**
+     * 删除配置信息
+     */
+    @DeleteMapping("/{id}")
+    fun deleteConfig(@PathVariable("id") id: Int): Mono<Void> {
+        return Mono.create {
+            commonService.removeById(id)
+            it.success()
+        }
+    }
+
+    /**
+     * 更新配置信息
+     */
+    @PutMapping
+    fun updateConfig(@RequestBody entity: CommonConfig): Mono<Void> {
+        return Mono.create {
+            commonService.updateById(entity)
+            it.success()
+        }
+    }
+
+}

+ 9 - 0
envir-config/src/main/kotlin/cn/gygxzc/cloud/config/dao/ICommonConfigDao.kt

@@ -0,0 +1,9 @@
+package cn.gygxzc.cloud.config.dao
+
+import cn.gygxzc.cloud.config.model.CommonConfig
+import com.baomidou.mybatisplus.core.mapper.BaseMapper
+import org.springframework.stereotype.Repository
+
+@Repository
+interface ICommonConfigDao :BaseMapper<CommonConfig> {
+}

+ 24 - 0
envir-config/src/main/kotlin/cn/gygxzc/cloud/config/model/CommonConfig.kt

@@ -0,0 +1,24 @@
+package cn.gygxzc.cloud.config.model
+
+import com.baomidou.mybatisplus.annotation.TableId
+import com.baomidou.mybatisplus.annotation.TableName
+import java.util.*
+
+/**
+ * 通用的配置信息
+ * @property application 所属的主体名称
+ * @property isServer 是否为服务端的配置信息
+ */
+@TableName("common_config")
+data class CommonConfig(@TableId
+                        var id:Int?=null,
+                        var property:String?=null,
+                        var propValue:String?=null,
+                        var title:String?=null,
+                        var description:String?=null,
+                        var application:String?=null,
+                        var isServer:Boolean?=null,
+                        var createTime:Date?=null,
+                        var createBy:String?=null,
+                        var remark:String?=null) {
+}

+ 17 - 0
envir-config/src/main/kotlin/cn/gygxzc/cloud/config/service/ICommonConfigService.kt

@@ -0,0 +1,17 @@
+package cn.gygxzc.cloud.config.service
+
+import cn.gygxzc.cloud.config.model.CommonConfig
+import cn.tonyandmoney.tuonq.core.req.PageReq
+import com.baomidou.mybatisplus.core.metadata.IPage
+import com.baomidou.mybatisplus.extension.service.IService
+
+
+interface ICommonConfigService : IService<CommonConfig> {
+
+
+    fun queryByPage(req: PageReq, entity: CommonConfig): IPage<CommonConfig>
+
+
+    fun queryApplicationConfig(isServer:Boolean,application:String):List<CommonConfig>
+
+}

+ 44 - 0
envir-config/src/main/kotlin/cn/gygxzc/cloud/config/service/impl/CommonConfigService.kt

@@ -0,0 +1,44 @@
+package cn.gygxzc.cloud.config.service.impl
+
+import cn.gygxzc.cloud.config.dao.ICommonConfigDao
+import cn.gygxzc.cloud.config.model.CommonConfig
+import cn.gygxzc.cloud.config.service.ICommonConfigService
+import cn.tonyandmoney.tuonq.core.req.PageReq
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
+import com.baomidou.mybatisplus.core.metadata.IPage
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
+import org.springframework.stereotype.Service
+
+@Service
+class CommonConfigService : ICommonConfigService, ServiceImpl<ICommonConfigDao, CommonConfig>() {
+
+
+    override fun queryByPage(req: PageReq, entity: CommonConfig): IPage<CommonConfig> {
+        val wrapper = QueryWrapper<CommonConfig>()
+        if (!entity.property.isNullOrBlank()) {
+            wrapper.like("property", entity.property)
+        }
+        if (!entity.title.isNullOrBlank()) {
+            wrapper.like("title", entity.title)
+        }
+        if (!entity.application.isNullOrBlank()) {
+            wrapper.like("application", entity.application)
+        }
+        if (entity.isServer != null) {
+            wrapper.eq("is_server", entity.isServer)
+        }
+        return baseMapper.selectPage(req.page(), wrapper)
+    }
+
+    override fun queryApplicationConfig(isServer: Boolean, application: String): List<CommonConfig> {
+
+        val wrapper = QueryWrapper<CommonConfig>()
+        wrapper.eq("is_server", isServer)
+        wrapper.and {
+            it.eq("application", application).or().isNull("application")
+        }
+        wrapper.select("id", "property", "prop_value", "application")
+        return baseMapper.selectList(wrapper)
+    }
+
+}

+ 4 - 4
eureka-web/build.gradle

@@ -38,16 +38,16 @@ jar { enabled = false }
 docker{
     baseImage 'openjdk:8-jre-alpine'
     maintainer 'tina 976056042@qq.com'
-    registry 'registry.cn-qingdao.aliyuncs.com'
+    registry 'docker.tonyandmoney.cn'
 }
 
 task dockerBuilder(type: Docker) {
-    registry='registry.cn-qingdao.aliyuncs.com/gxzc-envir'
-    applicationName = 'registry'
+    registry='docker.tonyandmoney.cn'
+    applicationName = 'tuonq-config'
     tagVersion = jar.version
     addFile("./${jar.baseName}-${jar.version}.jar","app.jar")
     entryPoint(["java","-XX:+UnlockExperimentalVMOptions","-XX:+UseCGroupMemoryLimitForHeap","-Djava.security.egd=file:/dev/./urandom","-Duser.timezone=GMT+08","-jar",'app.jar'])
-    exposePort(11010)
+    exposePort(11111)
     doFirst {
         copy {
             from jar

+ 12 - 25
eureka-web/src/main/resources/application-prod.yml

@@ -1,36 +1,23 @@
 spring:
   datasource:
-    password: envir
-    username: envir
-    url: jdbc:mysql://47.107.123.88:3307/sys_config?useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull
+    username: root
+    password: tuonq520
+    url: jdbc:mysql://192.168.42.1:5201/tuonq_config?useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull
 
   session:
     store-type: redis
     redis:
-      host: 47.107.123.88
-      port: 11010
+      host: 192.168.42.1
+      port: 6379
       database: 0
-      password: envir20190511
+      password:
 
   rabbitmq:
-    username: envir
-    password: envir
-    host: 47.107.123.88
+    username: tuonq
+    password: tuonq520
+    host: 192.168.42.1
     port: 5672
-
-auth:
-  client:
-    key: 5ae40c929c9148e9a6570ecb1666e2f8
-    secret: 1640587797a74b35a1a95adac554ac6f
-
-
-security:
-  cros: true
-  shiro: false
-  scan: false
   redis:
-    database: 1 # redis数据库索引
-    hostName: 47.107.123.88
-    port: 11010
-    password: envir20190511
-    timeout: 5000 # 连接超时时间(毫秒)
+    host: 192.168.42.1
+    port: 6379
+    database: 0

+ 16 - 30
eureka-web/src/main/resources/application-sit.yml

@@ -1,46 +1,32 @@
 server:
-  port: 11002
-
+  port: 11111
 spring:
   datasource:
-    password: envir
-    username: envir
-    url: jdbc:mysql://172.18.167.76:3308/sys_config?useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull
+    password: tuonq
+    username: tuonq520
+    url: jdbc:mysql://192.168.42.1:5201/tuonq_config?useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull
 
   session:
     store-type: redis
     redis:
-      host: 172.18.167.76
-      port: 11010
+      host: 192.168.42.1
+      port: 6379
       database: 0
-      password: envir20190511
+      password:
 
   rabbitmq:
-    username: envir
-    password: envir
-    host: 172.18.167.76
+    username: tuonq
+    password: tuonq
+    host: 172.17.0.5
     port: 5672
-
-
-auth:
-  client:
-    key: 5ae40c929c9148e9a6570ecb1666e2f8
-    secret: 1640587797a74b35a1a95adac554ac6f
-
-
-security:
-  cros: true
-  shiro: false
-  scan: false
   redis:
-    database: 1 # redis数据库索引
-    hostName: 172.18.167.76
-    port: 11010
-    password: envir20190511
-    timeout: 5000 # 连接超时时间(毫秒)
+    host: 192.168.42.1
+    port: 6379
+    database: 0
+
 eureka:
   instance:
-    ip-address: 172.18.167.76
+    ip-address: 192.168.42.1
   client:
     service-url:
-      defaultZone: http://envir:envir@172.18.167.76:${server.port}/eureka/
+      defaultZone: http://envir:envir@192.168.42.1:${server.port}/eureka/

+ 9 - 2
eureka-web/src/main/resources/application.yml

@@ -1,3 +1,12 @@
+# 服务设置
+server:
+  port: 11111
+  undertow:
+    io-threads: 2
+    worker-threads: 10
+    buffer-size: 2048
+    direct-buffers: true
+
 spring:
   datasource:
     type: com.zaxxer.hikari.HikariDataSource
@@ -23,7 +32,6 @@ spring:
     servlet:
       content-type: text/html
 
-
 mybatis-plus:
   mapper-locations: classpath*:mapper/**/*.xml
   global-config:
@@ -74,4 +82,3 @@ management:
   endpoint:
     health:
       show-details: always
-