Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dict
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈文顺
dict
Commits
2315161b
Commit
2315161b
authored
May 17, 2019
by
陈文顺
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jsj
parent
c78812d4
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
97 additions
and
29 deletions
+97
-29
demo-sdk/pom.xml
+5
-0
demo-sdk/src/main/java/com/freemud/demo/service/IDictService.java
+14
-10
demo-service/src/main/java/com/freemud/demo/service/impl/DictTypeServiceImpl.java
+2
-0
pom.xml
+3
-3
springboot-demo/pom.xml
+4
-4
springboot-demo/src/main/java/com/freemud/springbootdemo/SpringbootDemoApplication.java
+4
-1
springboot-demo/src/main/java/com/freemud/springbootdemo/config/DataSourceConfig.java
+1
-1
springboot-demo/src/main/java/com/freemud/springbootdemo/config/FastjsonCodec.java
+48
-0
springboot-demo/src/main/java/com/freemud/springbootdemo/controller/DictController.java
+7
-5
springboot-demo/src/main/resources/application.yml
+8
-4
springboot-demo/src/main/resources/logback.xml
+1
-1
No files found.
demo-sdk/pom.xml
View file @
2315161b
...
...
@@ -23,6 +23,11 @@
<artifactId>
fastjson
</artifactId>
<version>
1.2.32
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
</dependencies>
...
...
demo-sdk/src/main/java/com/freemud/demo/service/IDictService.java
View file @
2315161b
package
com
.
freemud
.
demo
.
service
;
import
com.freemud.demo.dto.DictDataDto
;
import
com.freemud.demo.dto.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -9,18 +10,21 @@ import java.util.Map;
/**
* Created by chenwenshun on 2017/1/4.
*/
@RequestMapping
(
value
=
"/dict"
,
produces
=
"application/json"
)
public
interface
IDictService
{
/** 根据主表cd获取数据列表 */
public
List
<
DictDataDto
>
loadDatasByTypeCd
(
String
dictTypeCd
);
@PostMapping
(
"/page"
)
ResDto
page
(
@RequestBody
PageReq
pageReq
);
/** 根据dictTypeCd取得数据map,用于填充下拉框 */
public
Map
<
String
,
String
>
loadDataMap
(
String
dictTypeCd
);
/** 根据cd取得数据字典
* @param dictTypeCd
* @param dictCd
* */
public
DictDataDto
getDictDataByCd
(
String
dictTypeCd
,
String
dictCd
);
@GetMapping
(
"/getById"
)
ResDto
getById
(
@RequestParam
(
"id"
)
Long
id
);
@GetMapping
(
value
=
"/dictDatas/{dictTypeCd}"
)
ResDto
dictDatas
(
@PathVariable
(
"dictTypeCd"
)
String
dictTypeCd
);
@GetMapping
(
"/dictData/{dictTypeCd}/{dictCd}"
)
ResDto
<
DictDataDto
>
dictData
(
@PathVariable
(
"dictTypeCd"
)
String
dictTypeCd
,
@PathVariable
(
"dictCd"
)
String
dictCd
);
}
demo-service/src/main/java/com/freemud/demo/service/impl/DictTypeServiceImpl.java
View file @
2315161b
...
...
@@ -16,6 +16,7 @@ import com.github.pagehelper.PageHelper;
import
com.google.common.collect.Lists
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
tk.mybatis.mapper.entity.Example
;
...
...
@@ -75,6 +76,7 @@ public class DictTypeServiceImpl implements IDictTypeService{
@Override
@Async
public
void
saveDict
(
DictTypeDto
dto
)
{
TDictType
dictTypeEntity
=
new
TDictType
();
BeanUtils
.
copyProperties
(
dto
,
dictTypeEntity
);
...
...
pom.xml
View file @
2315161b
...
...
@@ -7,7 +7,7 @@
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
1.5.10
.RELEASE
</version>
<version>
2.1.4
.RELEASE
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
...
...
@@ -27,9 +27,9 @@
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<java.version>
1.8
</java.version>
<spring-cloud.version>
Edgware.SR2
</spring-cloud.version>
<spring-cloud.version>
Greenwich.SR1
</spring-cloud.version>
<mybatis3.version>
1.3.2
</mybatis3.version>
<mapper.version>
1.
1.1
</mapper.version>
<mapper.version>
1.
2.3
</mapper.version>
<elasticSearch.version>
3.1.5.RELEASE
</elasticSearch.version>
</properties>
...
...
springboot-demo/pom.xml
View file @
2315161b
...
...
@@ -79,10 +79,10 @@
<artifactId>
spring-cloud-starter-sleuth
</artifactId>
</dependency>
<
!--<dependency>--
>
<
!--<groupId>org.springframework.cloud</groupId>--
>
<
!--<artifactId>spring-cloud-starter-eureka</artifactId>--
>
<
!--</dependency>--
>
<
dependency
>
<
groupId>
org.springframework.cloud
</groupId
>
<
artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId
>
<
/dependency
>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
...
...
springboot-demo/src/main/java/com/freemud/springbootdemo/SpringbootDemoApplication.java
View file @
2315161b
...
...
@@ -4,9 +4,11 @@ import com.alibaba.fastjson.support.spring.FastJsonpHttpMessageConverter4;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
...
...
@@ -14,7 +16,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@SpringBootApplication
@ComponentScan
(
basePackages
=
"com.freemud, cn.freemud"
)
@MapperScan
(
basePackages
=
"com.freemud.demo.mapper"
)
//@EnableEurekaClient
@EnableEurekaClient
@EnableAsync
public
class
SpringbootDemoApplication
extends
WebMvcConfigurerAdapter
{
public
static
void
main
(
String
[]
args
)
{
...
...
springboot-demo/src/main/java/com/freemud/springbootdemo/config/DataSourceConfig.java
View file @
2315161b
...
...
@@ -4,8 +4,8 @@ import com.alibaba.druid.pool.DruidDataSource;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.jdbc.DataSourceBuilder
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
...
...
springboot-demo/src/main/java/com/freemud/springbootdemo/config/FastjsonCodec.java
0 → 100644
View file @
2315161b
package
com
.
freemud
.
springbootdemo
.
config
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.buffer.ByteBufAllocator
;
import
io.netty.buffer.ByteBufInputStream
;
import
io.netty.buffer.ByteBufOutputStream
;
import
org.redisson.client.codec.BaseCodec
;
import
org.redisson.client.protocol.Decoder
;
import
org.redisson.client.protocol.Encoder
;
import
java.io.IOException
;
/**
* Created by chenwenshun on 2019/4/25.
*/
public
class
FastjsonCodec
extends
BaseCodec
{
private
final
Encoder
encoder
=
in
->
{
ByteBuf
out
=
ByteBufAllocator
.
DEFAULT
.
buffer
();
try
{
ByteBufOutputStream
os
=
new
ByteBufOutputStream
(
out
);
JSON
.
writeJSONString
(
os
,
in
,
SerializerFeature
.
WriteClassName
);
return
os
.
buffer
();
}
catch
(
IOException
e
)
{
out
.
release
();
throw
e
;
}
catch
(
Exception
e
)
{
out
.
release
();
throw
new
IOException
(
e
);
}
};
private
final
Decoder
<
Object
>
decoder
=
(
buf
,
state
)
->
JSON
.
parseObject
(
new
ByteBufInputStream
(
buf
),
Object
.
class
);
@Override
public
Decoder
<
Object
>
getValueDecoder
()
{
return
decoder
;
}
@Override
public
Encoder
getValueEncoder
()
{
return
encoder
;
}
}
springboot-demo/src/main/java/com/freemud/springbootdemo/controller/DictController.java
View file @
2315161b
...
...
@@ -2,6 +2,7 @@ package com.freemud.springbootdemo.controller;
import
com.freemud.demo.cache.DictRedisCache
;
import
com.freemud.demo.dto.*
;
import
com.freemud.demo.service.IDictService
;
import
com.freemud.demo.service.IDictTypeService
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -14,8 +15,7 @@ import java.util.List;
* Created by chenwenshun on 2018/11/2.
*/
@RestController
@RequestMapping
(
value
=
"/dict"
,
produces
=
"application/json"
)
public
class
DictController
{
public
class
DictController
implements
IDictService
{
@Autowired
IDictTypeService
dictTypeService
;
...
...
@@ -23,8 +23,8 @@ public class DictController {
@Autowired
DictRedisCache
dictRedisCache
;
@Override
@ApiOperation
(
"分页查询列表"
)
@PostMapping
(
"/page"
)
public
ResDto
page
(
@RequestBody
PageReq
pageReq
){
PageData
<
DictTypeDto
>
pageData
=
dictTypeService
.
findPageDict
(
pageReq
);
...
...
@@ -32,6 +32,7 @@ public class DictController {
}
@Override
@GetMapping
(
"/getById"
)
public
ResDto
getById
(
@RequestParam
(
"id"
)
Long
id
){
DictTypeDto
dictTypeDto
=
dictRedisCache
.
getCache
(
id
);
...
...
@@ -40,9 +41,10 @@ public class DictController {
}
@Override
@ApiOperation
(
"typeCd获取字典数据"
)
@GetMapping
(
value
=
"/dictDatas/{dictTypeCd}"
)
public
ResDto
dictDatas
(
@PathVariable
String
dictTypeCd
){
public
ResDto
dictDatas
(
@PathVariable
(
"dictTypeCd"
)
String
dictTypeCd
){
List
<
DictDataDto
>
list
=
this
.
dictTypeService
.
loadDatasByTypeCd
(
dictTypeCd
,
true
);
return
new
ResDto
(
list
);
...
...
@@ -50,7 +52,7 @@ public class DictController {
@ApiOperation
(
"typeCd & dataCd获取字典数据"
)
@GetMapping
(
"/dictData/{dictTypeCd}/{dictCd}"
)
public
ResDto
<
DictDataDto
>
dictData
(
@PathVariable
String
dictTypeCd
,
@PathVariable
String
dictCd
){
public
ResDto
<
DictDataDto
>
dictData
(
@PathVariable
(
"dictTypeCd"
)
String
dictTypeCd
,
@PathVariable
(
"dictCd"
)
String
dictCd
){
DictDataDto
dictDataDto
=
this
.
dictTypeService
.
loadDictDataByCd
(
dictTypeCd
,
dictCd
,
true
);
return
new
ResDto
(
dictDataDto
);
}
...
...
springboot-demo/src/main/resources/application.yml
View file @
2315161b
...
...
@@ -68,10 +68,14 @@ logging:
# ignored: /**,/swagger*,/webjars/**,/v2/**,/swagger-resources/**
swagger_enable
:
true
#eureka:
# client:
# service-url:
# defaultZone: http://localhost:10001/eureka
eureka
:
client
:
service-url
:
defaultZone
:
http://localhost:10001/eureka
healthcheck
:
enabled
instance
:
lease-expiration-duration-in-seconds
:
90
lease-renewal-interval-in-seconds
:
30
#apollo:
# bootstrap:
...
...
springboot-demo/src/main/resources/logback.xml
View file @
2315161b
...
...
@@ -15,7 +15,7 @@
<appender
name =
"STDOUT_tid"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<layout
class =
"ch.qos.logback.classic.PatternLayout"
>
<!--<Pattern >%d{HH:mm} %-5level %logger{36} - [springAppName:${springAppName:-}, TxId : %X{X-B3-TraceId:-} , SpanId : %X{X-B3-SpanId:-}] %msg%n</Pattern >-->
<Pattern
>
%d{HH:mm} %-5level %logger{36} - [spring-demo,%X{X-B3-TraceId:-},%X{X-B3-SpanId:-}] %msg%n
</Pattern >
<Pattern
>
%d{HH:mm
:ss.SSS
} %-5level %logger{36} - [spring-demo,%X{X-B3-TraceId:-},%X{X-B3-SpanId:-}] %msg%n
</Pattern >
</layout >
</appender >
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment