Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
matrix-sample
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mall
arch
matrix-sample
Commits
085f39e2
Commit
085f39e2
authored
Apr 08, 2020
by
共享中心代码生成
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'new-strut' into 'master'
New strut See merge request
!5
parents
31489dce
41d0a5a9
Hide whitespace changes
Inline
Side-by-side
Showing
54 changed files
with
1729 additions
and
38 deletions
+1729
-38
.gitignore
.gitignore
+1
-0
README.md
README.md
+8
-3
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-api/pom.xml
+1
-1
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-biz/pom.xml
+1
-1
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-spring/pom.xml
+1
-1
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-c/pom.xml
+1
-1
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-p/pom.xml
+1
-1
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-springboot/pom.xml
+1
-1
pom.xml
matrix-sample-dubbo/pom.xml
+3
-3
pom.xml
matrix-sample-hbase/matrix-sample-hbase-biz/pom.xml
+1
-1
pom.xml
matrix-sample-hbase/matrix-sample-hbase-springboot/pom.xml
+24
-2
SimpleHBase.java
matrix-sample-hbase/matrix-sample-hbase-springboot/src/main/java/com/secoo/mall/hbase/SimpleHBase.java
+3
-3
application.yml
matrix-sample-hbase/matrix-sample-hbase-springboot/src/main/resources/application.yml
+1
-2
pom.xml
matrix-sample-hbase/pom.xml
+1
-1
pom.xml
matrix-sample-mybatis/matrix-sample-mybatis-biz/pom.xml
+43
-0
Project.java
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/bean/entity/Project.java
+103
-0
User.java
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/bean/entity/User.java
+134
-0
UserProjectRelation.java
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/bean/entity/UserProjectRelation.java
+46
-0
UserProjectRelationVo.java
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/bean/vo/UserProjectRelationVo.java
+39
-0
DataConfig.java
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/config/DataConfig.java
+52
-0
UserMapper.java
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/dao/mapper/UserMapper.java
+36
-0
UserProjectRelationMapper.java
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/dao/mapper/UserProjectRelationMapper.java
+23
-0
UserProjectRelationMapper.xml
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/dao/mapper/UserProjectRelationMapper.xml
+30
-0
pom.xml
matrix-sample-mybatis/matrix-sample-mybatis-spring/pom.xml
+16
-0
pom.xml
matrix-sample-mybatis/matrix-sample-mybatis-springboot/pom.xml
+35
-0
MybatisSampleApplication.java
matrix-sample-mybatis/matrix-sample-mybatis-springboot/src/main/java/com/secoo/mall/mybatis/MybatisSampleApplication.java
+130
-0
application.yml
matrix-sample-mybatis/matrix-sample-mybatis-springboot/src/main/resources/application.yml
+5
-0
pom.xml
matrix-sample-mybatis/pom.xml
+31
-0
pom.xml
matrix-sample-redis/matrix-sample-redis-biz/pom.xml
+12
-1
Person.java
matrix-sample-redis/matrix-sample-redis-biz/src/main/java/com/secoo/mall/redis/Person.java
+71
-0
PersonService.java
matrix-sample-redis/matrix-sample-redis-biz/src/main/java/com/secoo/mall/redis/PersonService.java
+32
-0
pom.xml
matrix-sample-redis/matrix-sample-redis-spring/pom.xml
+50
-0
RedisClusterTest.java
matrix-sample-redis/matrix-sample-redis-spring/src/main/java/com/secoo/mall/redis/RedisClusterTest.java
+205
-0
RedisTest.java
matrix-sample-redis/matrix-sample-redis-spring/src/main/java/com/secoo/mall/redis/RedisTest.java
+59
-0
log4j2.xml
matrix-sample-redis/matrix-sample-redis-spring/src/main/resources/log4j2.xml
+16
-0
redis-cluster.properties
matrix-sample-redis/matrix-sample-redis-spring/src/main/resources/redis-cluster.properties
+18
-0
spring-jedis-alone-config-sample.xml
matrix-sample-redis/matrix-sample-redis-spring/src/main/resources/spring-jedis-alone-config-sample.xml
+63
-0
spring-jedis-cluster-config-sample.xml
matrix-sample-redis/matrix-sample-redis-spring/src/main/resources/spring-jedis-cluster-config-sample.xml
+92
-0
spring-lettuce-alone-config-sample.xml
matrix-sample-redis/matrix-sample-redis-spring/src/main/resources/spring-lettuce-alone-config-sample.xml
+76
-0
spring-lettuce-cluster-config-sample.xml
matrix-sample-redis/matrix-sample-redis-spring/src/main/resources/spring-lettuce-cluster-config-sample.xml
+104
-0
pom.xml
matrix-sample-redis/matrix-sample-redis-starter/pom.xml
+16
-1
RedisSampleApplication.java
matrix-sample-redis/matrix-sample-redis-starter/src/main/java/com/secoo/mall/redis/RedisSampleApplication.java
+40
-0
MuliRedisConfig.java
matrix-sample-redis/matrix-sample-redis-starter/src/main/java/com/secoo/mall/redis/config/MuliRedisConfig.java
+48
-0
application.yml
matrix-sample-redis/matrix-sample-redis-starter/src/main/resources/application.yml
+10
-0
pom.xml
matrix-sample-redis/pom.xml
+33
-1
pom.xml
matrix-sample-rocketmq/matrix-sample-rocketmq-biz/pom.xml
+1
-1
pom.xml
matrix-sample-rocketmq/matrix-sample-rocketmq-spring/pom.xml
+1
-1
pom.xml
matrix-sample-rocketmq/matrix-sample-rocketmq-springboot/pom.xml
+1
-1
pom.xml
matrix-sample-rocketmq/pom.xml
+2
-2
pom.xml
matrix-sample-xxl/matrix-sample-xxl-biz/pom.xml
+1
-1
pom.xml
matrix-sample-xxl/matrix-sample-xxl-spring/pom.xml
+1
-1
pom.xml
matrix-sample-xxl/matrix-sample-xxl-springboot/pom.xml
+1
-1
pom.xml
matrix-sample-xxl/pom.xml
+2
-2
pom.xml
pom.xml
+3
-4
No files found.
.gitignore
View file @
085f39e2
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
*.iml
*.iml
*.ipr
*.ipr
*.lst
*.lst
*.versionsBackup
### NetBeans ###
### NetBeans ###
/nbproject/private/
/nbproject/private/
...
...
README.md
View file @
085f39e2
#
简介
#
一、简介 ***
Matrix-sample是matrix组件的示例项目,包括redis、rocketmq等中间件以及提供通用util工具类使用方式等
Matrix-sample是matrix组件的示例项目,包括redis、rocketmq等中间件以及提供通用util工具类使用方式等
***
\ No newline at end of file
## 1.模块说明
-
matrix-sample-xxx-biz为业务的实现模块,公共模块
-
matrix-sample-xxx-spring为传统的spring项目的demo,主要参考如何进行配置和使用
-
matrix-sample-xxx-springboot为springboot的示例
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-api/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-dubbo
</artifactId>
<artifactId>
matrix-sample-dubbo
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-dubbo/matrix-sample-dubbo-biz/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-dubbo
</artifactId>
<artifactId>
matrix-sample-dubbo
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-dubbo/matrix-sample-dubbo-spring/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-dubbo
</artifactId>
<artifactId>
matrix-sample-dubbo
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-c/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-dubbo-springboot
</artifactId>
<artifactId>
matrix-sample-dubbo-springboot
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-p/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-dubbo-springboot
</artifactId>
<artifactId>
matrix-sample-dubbo-springboot
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-dubbo/matrix-sample-dubbo-springboot/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-dubbo
</artifactId>
<artifactId>
matrix-sample-dubbo
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-dubbo/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample
</artifactId>
<artifactId>
matrix-sample
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
@@ -22,12 +22,12 @@
...
@@ -22,12 +22,12 @@
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-dubbo-api
</artifactId>
<artifactId>
matrix-sample-dubbo-api
</artifactId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-dubbo-biz
</artifactId>
<artifactId>
matrix-sample-dubbo-biz
</artifactId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
...
...
matrix-sample-hbase/matrix-sample-hbase-biz/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-hbase
</artifactId>
<artifactId>
matrix-sample-hbase
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-hbase/matrix-sample-hbase-springboot/pom.xml
View file @
085f39e2
...
@@ -5,15 +5,37 @@
...
@@ -5,15 +5,37 @@
<parent>
<parent>
<artifactId>
matrix-sample-hbase
</artifactId>
<artifactId>
matrix-sample-hbase
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-hbase-s
tarter
</artifactId>
<artifactId>
matrix-sample-hbase-s
pringboot
</artifactId>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-bigdata-hbase-starter
</artifactId>
<artifactId>
matrix-bigdata-hbase-starter
</artifactId>
<exclusions>
<exclusion>
<artifactId>
log4j
</artifactId>
<groupId>
log4j
</groupId>
</exclusion>
<exclusion>
<artifactId>
jackson-core-asl
</artifactId>
<groupId>
org.codehaus.jackson
</groupId>
</exclusion>
<exclusion>
<artifactId>
log4j-api
</artifactId>
<groupId>
org.apache.logging.log4j
</groupId>
</exclusion>
<exclusion>
<artifactId>
log4j-to-slf4j
</artifactId>
<groupId>
org.apache.logging.log4j
</groupId>
</exclusion>
<exclusion>
<artifactId>
slf4j-log4j12
</artifactId>
<groupId>
org.slf4j
</groupId>
</exclusion>
</exclusions>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
...
...
matrix-sample-hbase/matrix-sample-hbase-springboot/src/main/java/com/secoo/mall/hbase/SimpleHBase.java
View file @
085f39e2
...
@@ -88,8 +88,8 @@ public class SimpleHBase implements InitializingBean {
...
@@ -88,8 +88,8 @@ public class SimpleHBase implements InitializingBean {
@Override
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
public
void
afterPropertiesSet
()
throws
Exception
{
//
createTable();
createTable
();
//
put();
put
();
get
();
get
();
}
}
}
}
matrix-sample-hbase/matrix-sample-hbase-springboot/src/main/resources/application.yml
View file @
085f39e2
...
@@ -3,7 +3,6 @@ spring:
...
@@ -3,7 +3,6 @@ spring:
name
:
matrix-bigdata-demo
name
:
matrix-bigdata-demo
server
:
server
:
port
:
6080
port
:
6080
hbase
:
hbase
:
zookeeper
:
zookeeper
:
quorum
:
1
0.4.3.236:2181,10.4.3.237:2181,10.4.3.235
:2181
quorum
:
1
72.17.105.72
:2181
matrix-sample-hbase/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample
</artifactId>
<artifactId>
matrix-sample
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-mybatis/matrix-sample-mybatis-biz/pom.xml
0 → 100644
View file @
085f39e2
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
matrix-sample-mybatis
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-mybatis-biz
</artifactId>
<dependencies>
<dependency>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-annotations
</artifactId>
<version>
1.5.22
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
common-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-mybatis-core
</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>
${project.basedir}/src/main/java
</directory>
<includes>
<include>
**/*.xml
</include>
</includes>
<filtering>
true
</filtering>
</resource>
</resources>
</build>
</project>
\ No newline at end of file
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/bean/entity/Project.java
0 → 100644
View file @
085f39e2
package
com
.
secoo
.
mall
.
mybatis
.
bean
.
entity
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.secoo.mall.common.core.bean.AbsBaseBean
;
import
com.secoo.mall.common.util.colletion.CollectionUtil
;
import
com.secoo.mall.common.util.json.FastJsonUtil
;
import
com.secoo.mall.common.util.string.StringUtil
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.List
;
//@ApiModel(value = "应用详细信息", description = "作用于project对象")
@Data
public
class
Project
extends
AbsBaseBean
{
@ApiModelProperty
(
value
=
"应用id"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"仓库id"
)
private
Long
repositoryId
;
@ApiModelProperty
(
value
=
"树id"
)
private
Long
opsTreeId
;
@ApiModelProperty
(
value
=
"应用唯一标识"
)
private
String
name
;
@ApiModelProperty
(
value
=
"应用中文名称"
)
private
String
cnName
;
/**
* 如果sorce唯一用时间戳创建编码
*/
@ApiModelProperty
(
value
=
"应用编码"
)
private
String
code
;
@ApiModelProperty
(
value
=
"应用等级:1-10,数值越大等级越低"
)
private
Integer
level
;
/**
* 冗余字段
*/
@ApiModelProperty
(
value
=
"分组"
,
position
=
30
)
private
String
groupName
;
/**
* 冗余字段
*/
@ApiModelProperty
(
value
=
"gitlab地址"
,
position
=
40
)
private
String
gitUrl
;
/**
* 冗余字段
*/
@ApiModelProperty
(
value
=
"开发语言:1.java;2.lua;10、其他"
,
position
=
50
)
private
Integer
language
;
@JSONField
(
serialize
=
false
)
private
String
tags
;
@ApiModelProperty
(
value
=
"标签tags的参数形式"
)
@TableField
(
exist
=
false
)
private
List
<
String
>
tagList
;
@ApiModelProperty
(
value
=
"备注"
)
private
String
remark
;
@ApiModelProperty
(
value
=
"状态:0、删除 1、正常;"
)
private
Integer
status
;
@ApiModelProperty
(
value
=
"负责人id"
)
private
Long
owner
;
@ApiModelProperty
(
value
=
"负责人"
)
private
String
ownerName
;
@ApiModelProperty
(
value
=
"创建人id"
)
private
Long
creater
;
@ApiModelProperty
(
value
=
"创建人"
)
private
String
createrName
;
@ApiModelProperty
(
value
=
"创建时间"
,
hidden
=
true
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
@ApiModelProperty
(
value
=
"修改时间"
,
hidden
=
true
)
private
Date
updateTime
;
public
List
<
String
>
getTagList
()
{
if
(
StringUtil
.
isNotEmpty
(
this
.
tags
))
{
tagList
=
FastJsonUtil
.
toList
(
this
.
tags
);
}
return
tagList
;
}
public
void
setTagList
(
List
<
String
>
tagList
)
{
if
(
CollectionUtil
.
isNotEmpty
(
tagList
))
{
String
tags
=
FastJsonUtil
.
toString
(
tagList
);
this
.
setTags
(
tags
);
}
this
.
tagList
=
tagList
;
}
}
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/bean/entity/User.java
0 → 100644
View file @
085f39e2
package
com
.
secoo
.
mall
.
mybatis
.
bean
.
entity
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.secoo.mall.common.core.bean.AbsBaseBean
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.util.Date
;
//@ApiModel(value = "用户登录信息", description = "作用于user对象")
public
class
User
extends
AbsBaseBean
{
@ApiModelProperty
(
value
=
"用户id"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"用户名"
)
private
String
name
;
@ApiModelProperty
(
value
=
"中文用户名"
)
private
String
cnName
;
@ApiModelProperty
(
value
=
"工号"
)
private
String
workNum
;
@ApiModelProperty
(
value
=
"邮箱"
)
private
String
email
;
@ApiModelProperty
(
value
=
"手机号"
)
private
String
mobile
;
@ApiModelProperty
(
value
=
"角色类型:1、admin;2、owner;3、dev;4、guest"
)
private
Integer
roleType
;
@ApiModelProperty
(
value
=
"备注"
)
private
String
remark
;
@ApiModelProperty
(
value
=
"状态:0、删除 1、正常;"
)
private
Integer
status
;
@ApiModelProperty
(
value
=
"创建时间"
,
hidden
=
true
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
@ApiModelProperty
(
value
=
"修改时间"
,
hidden
=
true
)
private
Date
updateTime
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
String
getEmail
()
{
return
email
;
}
public
String
getMobile
()
{
return
mobile
;
}
public
String
getRemark
()
{
return
remark
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
void
setMobile
(
String
mobile
)
{
this
.
mobile
=
mobile
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
String
getCnName
()
{
return
cnName
;
}
public
void
setCnName
(
String
cnName
)
{
this
.
cnName
=
cnName
;
}
public
Integer
getRoleType
()
{
return
roleType
;
}
public
void
setRoleType
(
Integer
roleType
)
{
this
.
roleType
=
roleType
;
}
public
String
getWorkNum
()
{
return
workNum
;
}
public
void
setWorkNum
(
String
workNum
)
{
this
.
workNum
=
workNum
;
}
}
\ No newline at end of file
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/bean/entity/UserProjectRelation.java
0 → 100644
View file @
085f39e2
package
com
.
secoo
.
mall
.
mybatis
.
bean
.
entity
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.secoo.mall.common.core.bean.AbsBaseBean
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
//@ApiModel(value = "用户应用关联关系表", description = "作用于user和project对象")
@Data
public
class
UserProjectRelation
extends
AbsBaseBean
{
@ApiModelProperty
(
value
=
"主键id"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"用户id"
)
private
Long
userId
;
@ApiModelProperty
(
value
=
"应用id"
)
private
Long
projectId
;
//冗余字段
@ApiModelProperty
(
value
=
"仓库id"
)
private
Long
repositoryId
;
@ApiModelProperty
(
value
=
"角色类型:10、admin;20、owner;30、dev;40、guest"
)
private
Integer
roleType
;
@ApiModelProperty
(
value
=
"接收报警标识。0、不接收,1、接收"
)
private
Integer
warnFlag
;
@JSONField
(
serialize
=
false
)
@ApiModelProperty
(
value
=
"报警接收渠道。用逗号分隔"
)
private
String
warnChannels
;
@ApiModelProperty
(
value
=
"修改时间"
,
hidden
=
true
)
private
Date
updateTime
;
@ApiModelProperty
(
value
=
"创建时间"
,
hidden
=
true
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
}
\ No newline at end of file
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/bean/vo/UserProjectRelationVo.java
0 → 100644
View file @
085f39e2
package
com
.
secoo
.
mall
.
mybatis
.
bean
.
vo
;
import
com.secoo.mall.common.util.colletion.CollectionUtil
;
import
com.secoo.mall.common.util.json.FastJsonUtil
;
import
com.secoo.mall.common.util.string.StringUtil
;
import
com.secoo.mall.mybatis.bean.entity.UserProjectRelation
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
UserProjectRelationVo
extends
UserProjectRelation
{
@ApiModelProperty
(
value
=
"用户Id"
)
private
Long
userId
;
@ApiModelProperty
(
value
=
"用户名"
)
private
String
userName
;
@ApiModelProperty
(
value
=
"中文用户名"
)
private
String
userCnName
;
@ApiModelProperty
(
value
=
"工号"
)
private
String
workNum
;
@ApiModelProperty
(
value
=
"邮箱"
)
private
String
email
;
@ApiModelProperty
(
value
=
"手机号"
)
private
String
mobile
;
@ApiModelProperty
(
value
=
"用于转换数组"
)
private
List
<
Integer
>
warnChannelList
;
}
\ No newline at end of file
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/config/DataConfig.java
0 → 100644
View file @
085f39e2
package
com
.
secoo
.
mall
.
mybatis
.
config
;
import
com.baomidou.mybatisplus.core.MybatisConfiguration
;
import
com.secoo.mall.datasource.bean.MatrixDataSource
;
import
com.secoo.mall.mybatis.bean.MatrixMybatisSqlSessionFactoryBean
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
javax.sql.DataSource
;
/**
* @Description:
* @Copyright: Copyright (c) 2020 ALL RIGHTS RESERVED.
* @Company: Secoo
* @Author: qiuwei.li
* @CreateDate: 2020/4/8 10:27
* @UpdateDate: 2020/4/8 10:27
* @UpdateRemark: init
* @Version: 1.0
* @menu ${description}
* @note 如果数据源中不存在多个sessionfactory示例,可以在mapper接口类直接使用@Mapper注解
*/
@Configuration
@MapperScan
(
value
=
"com.secoo.mall.mybatis.dao.mapper"
,
sqlSessionFactoryRef
=
"demoSqlSessionFactory"
)
public
class
DataConfig
{
/**
* 定义数据源
*
* @return
*/
@Bean
public
DataSource
demoDataSource
()
{
return
new
MatrixDataSource
(
"default"
);
}
@Bean
public
SqlSessionFactory
demoSqlSessionFactory
(
DataSource
demoDataSource
,
MatrixMybatisGlobalConfig
globalConfig
,
MybatisConfiguration
mybatisConfiguration
)
throws
Exception
{
MatrixMybatisSqlSessionFactoryBean
factory
=
new
MatrixMybatisSqlSessionFactoryBean
();
factory
.
setConfiguration
(
mybatisConfiguration
);
factory
.
setGlobalConfig
(
globalConfig
);
factory
.
setDataSource
(
demoDataSource
);
return
factory
.
getObject
();
}
}
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/dao/mapper/UserMapper.java
0 → 100644
View file @
085f39e2
package
com
.
secoo
.
mall
.
mybatis
.
dao
.
mapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.secoo.mall.common.util.string.StringUtil
;
import
com.secoo.mall.mybatis.bean.entity.User
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
public
interface
UserMapper
extends
BaseMapper
<
User
>
{
default
User
getByEmail
(
String
email
)
{
return
this
.
selectOne
(
new
QueryWrapper
<
User
>().
lambda
().
eq
(
User:
:
getEmail
,
email
).
last
(
"limit 1"
));
}
default
IPage
<
User
>
search
(
User
user
,
Page
page
)
{
LambdaQueryWrapper
<
User
>
queryWrapper
=
new
QueryWrapper
<
User
>().
lambda
();
if
(
StringUtil
.
isNotEmpty
(
user
.
getName
())
||
StringUtil
.
isNotEmpty
(
user
.
getCnName
())
||
StringUtil
.
isNotEmpty
(
user
.
getWorkNum
()))
{
queryWrapper
.
and
(
wapper
->
wapper
.
like
(
User:
:
getName
,
user
.
getName
())
.
or
().
like
(
User:
:
getCnName
,
user
.
getCnName
())
.
or
().
like
(
User:
:
getWorkNum
,
user
.
getWorkNum
()));
}
return
this
.
selectPage
(
page
,
queryWrapper
);
}
}
\ No newline at end of file
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/dao/mapper/UserProjectRelationMapper.java
0 → 100644
View file @
085f39e2
package
com
.
secoo
.
mall
.
mybatis
.
dao
.
mapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.secoo.mall.mybatis.bean.entity.UserProjectRelation
;
import
com.secoo.mall.mybatis.bean.vo.UserProjectRelationVo
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
UserProjectRelationMapper
extends
BaseMapper
<
UserProjectRelation
>
{
IPage
<
UserProjectRelationVo
>
searchByProjectId
(
Page
<
UserProjectRelationVo
>
page
,
@Param
(
"projectId"
)
Long
projectId
,
@Param
(
"relationVo"
)
UserProjectRelationVo
userProjectRelationVo
);
}
\ No newline at end of file
matrix-sample-mybatis/matrix-sample-mybatis-biz/src/main/java/com/secoo/mall/mybatis/dao/mapper/UserProjectRelationMapper.xml
0 → 100644
View file @
085f39e2
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.secoo.mall.mybatis.dao.mapper.UserProjectRelationMapper"
>
<sql
id=
"base_feild_List"
>
id, user_id , project_id, update_time, create_time
</sql>
<sql
id=
"user_map_field_List"
>
b.id,a.id as userId, a.name as userName,a.work_num,a.cn_name as userCnName,a.email ,a.mobile,b.role_type as roleType,b.warn_flag ,b.warn_channels
</sql>
<sql
id=
"search_where"
>
<where>
<if
test=
"relationVo.userName != null and relationVo.userName != ''"
>
AND a.name =TRIM(#{relationVo.userName,jdbcType=VARCHAR})
</if>
</where>
</sql>
<select
id=
"searchByProjectId"
resultType=
"com.secoo.mall.mybatis.bean.vo.UserProjectRelationVo"
>
select
<include
refid=
"user_map_field_List"
/>
from user a inner join user_project_relation b on a.id=b.user_id and b.project_id=#{projectId}
<include
refid=
"search_where"
/>
</select>
</mapper>
\ No newline at end of file
matrix-sample-mybatis/matrix-sample-mybatis-spring/pom.xml
0 → 100644
View file @
085f39e2
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
matrix-sample-mybatis
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-mybatis-spring
</artifactId>
</project>
\ No newline at end of file
matrix-sample-mybatis/matrix-sample-mybatis-springboot/pom.xml
0 → 100644
View file @
085f39e2
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
matrix-sample-mybatis
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-mybatis-springboot
</artifactId>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-mybatis-biz
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-mybatis-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
</dependency>
<!--接入日志组件-->
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
logger-starter
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
matrix-sample-mybatis/matrix-sample-mybatis-springboot/src/main/java/com/secoo/mall/mybatis/MybatisSampleApplication.java
0 → 100644
View file @
085f39e2
package
com
.
secoo
.
mall
.
mybatis
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.secoo.mall.common.core.bean.ReqPage
;
import
com.secoo.mall.mybatis.bean.entity.User
;
import
com.secoo.mall.mybatis.bean.entity.UserProjectRelation
;
import
com.secoo.mall.mybatis.bean.vo.UserProjectRelationVo
;
import
com.secoo.mall.mybatis.dao.mapper.UserMapper
;
import
com.secoo.mall.mybatis.dao.mapper.UserProjectRelationMapper
;
import
com.secoo.mall.mybatis.util.PageUtil
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
javax.annotation.Resource
;
/**
* @Description: 支持特性:
* <p>1.控制台直接打印sql</p>
* <p>2.分页封装</p>
* <p>3.关联表查询</p>
* @Author: liqiuwei
* @UpdateUser: liqiuwei
* @Param:
* @Return:
* @CreateDate: 2020/4/7 10:45
* @UpdateDate: 2020/4/7 10:45
* @version: 1.0
* @status: done
*/
@SpringBootApplication
//@MapperScan("com.secoo.mall.mybatis.dao.mapper")
public
class
MybatisSampleApplication
implements
ApplicationRunner
{
@Resource
private
UserMapper
userMapper
;
@Resource
private
UserProjectRelationMapper
userProjectRelationMapper
;
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
MybatisSampleApplication
.
class
)
.
run
(
args
);
}
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
// testGetByEmail("liqiuwei@secoo.com");
//测试查询分页
UserProjectRelationVo
vo
=
new
UserProjectRelationVo
();
vo
.
setUserName
(
"liqiuwei"
);
testSearch
(
1262L
,
vo
,
new
ReqPage
(
0L
,
10L
));
// testSave();
}
/**
* @Description: 按照固定条件查询,如邮箱
* @Author: liqiuwei
* @UpdateUser: liqiuwei
* @Param: [email] 邮箱
* @Return: {@link User}
* @CreateDate: 2020/4/7 10:15
* @UpdateDate: 2020/4/7 10:15
* @version: 1.0
* @status: done
*/
public
User
testGetByEmail
(
String
email
)
{
User
u1
=
userMapper
.
getByEmail
(
email
);
System
.
out
.
println
(
u1
);
return
u1
;
}
/**
* @Description: 按照id进行查询
* @Author: liqiuwei
* @UpdateUser: liqiuwei
* @Param: [id]
* @Return: com.secoo.mall.mybatis.bean.entity.User
* @CreateDate: 2020/4/7 10:40
* @UpdateDate: 2020/4/7 10:40
* @version: 1.0
* @status: done
*/
public
User
testGetById
(
Long
id
)
{
User
u1
=
userMapper
.
selectById
(
id
);
System
.
out
.
println
(
u1
);
return
u1
;
}
/***
* @Description:
* @Author: liqiuwei
* @UpdateUser: liqiuwei
* @Param: [id, reqPage] reqPage 为controller层传输参数
* @Return: com.secoo.mall.mybatis.bean.entity.User
* @CreateDate: 2020/4/7 11:31
* @UpdateDate: 2020/4/7 11:31
* @version: 1.0
* @status: done
*/
public
IPage
testSearch
(
Long
id
,
UserProjectRelationVo
userProjectRelationVo
,
ReqPage
reqPage
)
{
Page
<
UserProjectRelationVo
>
page
=
PageUtil
.
createPage
(
reqPage
);
IPage
<
UserProjectRelationVo
>
pageData
=
userProjectRelationMapper
.
searchByProjectId
(
page
,
id
,
userProjectRelationVo
);
System
.
out
.
println
(
pageData
.
getRecords
().
size
());
return
pageData
;
}
/**
* @Description: 保存数据.由于属性createTime使用@TableField(fill = FieldFill.INSERT),框架通过拦截器自动进行赋值
* @Author: liqiuwei
* @UpdateUser: liqiuwei
* @Param: []
* @Return: com.secoo.mall.mybatis.bean.entity.UserProjectRelation
* @CreateDate: 2020/4/8 9:56
* @UpdateDate: 2020/4/8 9:56
* @version: 1.0
* @status: done
*/
public
UserProjectRelation
testSave
()
{
UserProjectRelation
relation
=
new
UserProjectRelation
();
relation
.
setProjectId
(
1261L
);
relation
.
setUserId
(
1L
);
userProjectRelationMapper
.
insert
(
relation
);
return
relation
;
}
}
matrix-sample-mybatis/matrix-sample-mybatis-springboot/src/main/resources/application.yml
0 → 100644
View file @
085f39e2
spring
:
application
:
name
:
appms
profiles
:
active
:
dev
matrix-sample-mybatis/pom.xml
0 → 100644
View file @
085f39e2
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
matrix-sample
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-mybatis
</artifactId>
<packaging>
pom
</packaging>
<modules>
<module>
matrix-sample-mybatis-spring
</module>
<module>
matrix-sample-mybatis-springboot
</module>
<module>
matrix-sample-mybatis-biz
</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-mybatis-biz
</artifactId>
<version>
2.0.1-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
\ No newline at end of file
matrix-sample-redis/matrix-sample-redis-biz/pom.xml
View file @
085f39e2
...
@@ -5,11 +5,21 @@
...
@@ -5,11 +5,21 @@
<parent>
<parent>
<artifactId>
matrix-sample-redis
</artifactId>
<artifactId>
matrix-sample-redis
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-redis-biz
</artifactId>
<artifactId>
matrix-sample-redis-biz
</artifactId>
<dependencies>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
common-util
</artifactId>
</dependency>
</dependencies>
</project>
</project>
\ No newline at end of file
matrix-sample-redis/matrix-sample-redis-biz/src/main/java/com/secoo/mall/redis/Person.java
0 → 100644
View file @
085f39e2
/**
* Created by Administrator on 2018/1/16.
*/
package
com
.
secoo
.
mall
.
redis
;
import
lombok.Data
;
import
java.util.Date
;
/**
* test
*
* @author Administrator
* @create 2018-01-16 11:19
**/
@Data
public
class
Person
{
/**
* 用户ID
*/
private
Long
id
;
/**
* 用户登录名
*/
private
String
loginName
;
/**
* 用户名
*/
private
String
userName
;
/**
* 部门名称
*/
private
String
deptName
;
/**
* 操作时间
*/
private
Date
operDate
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getLoginName
()
{
return
loginName
;
}
public
void
setLoginName
(
String
loginName
)
{
this
.
loginName
=
loginName
;
}
public
Date
getOperDate
()
{
return
operDate
;
}
public
void
setOperDate
(
Date
operDate
)
{
this
.
operDate
=
operDate
;
}
}
matrix-sample-redis/matrix-sample-redis-biz/src/main/java/com/secoo/mall/redis/PersonService.java
0 → 100644
View file @
085f39e2
/**
* Created by Administrator on 2018/1/17.
*/
package
com
.
secoo
.
mall
.
redis
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
/**
* aa
*
* @author Administrator
* @create 2018-01-17 13:47
**/
@Service
public
class
PersonService
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
PersonService
.
class
);
public
Person
get
(
Long
id
)
{
logger
.
info
(
"get;{}"
,
id
);
Person
p
=
new
Person
();
p
.
setOperDate
(
new
Date
());
// p.setDeptName("ddd");
p
.
setId
(
id
);
return
p
;
}
}
matrix-sample-redis/matrix-sample-redis-spring/pom.xml
0 → 100644
View file @
085f39e2
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
matrix-sample-redis
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-redis-spring
</artifactId>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-datahelper-redis-core
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-redis-biz
</artifactId>
</dependency>
<dependency>
<groupId>
org.aspectj
</groupId>
<artifactId>
aspectjweaver
</artifactId>
</dependency>
<dependency>
<groupId>
io.lettuce
</groupId>
<artifactId>
lettuce-core
</artifactId>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-test
</artifactId>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
matrix-sample-redis/matrix-sample-redis-spring/src/main/java/com/secoo/mall/redis/RedisClusterTest.java
0 → 100644
View file @
085f39e2
package
com
.
secoo
.
mall
.
redis
;
import
com.secoo.mall.redis.helper.RedisHelper
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
/**
* Created by Administrator on 2018/1/15.
*/
//@ContextConfiguration({"classpath*:spring-jedis-cluster-config-sample.xml"})
@ContextConfiguration
({
"classpath*:spring-lettuce-cluster-config-sample.xml"
})
public
class
RedisClusterTest
extends
AbstractJUnit4SpringContextTests
{
@Resource
private
RedisHelper
redisClusterHelper
;
@Resource
private
PersonService
personService
;
@Test
public
void
testSet
()
throws
InterruptedException
{
redisClusterHelper
.
set
(
"aaa"
,
"bbb"
);
String
ret
=
redisClusterHelper
.
get
(
"aaa"
,
String
.
class
);
Assert
.
assertEquals
(
"bbb"
,
ret
);
redisClusterHelper
.
set
(
"aaa"
,
"ccc"
,
2
l
);
ret
=
redisClusterHelper
.
get
(
"aaa"
,
String
.
class
);
Assert
.
assertEquals
(
"ccc"
,
ret
);
Thread
.
sleep
(
3000
l
);
ret
=
redisClusterHelper
.
get
(
"aaa"
,
String
.
class
);
Assert
.
assertNull
(
ret
);
}
@Test
public
void
testSet2
()
throws
InterruptedException
{
//批量设置测试
Map
<
String
,
String
>
dtos1
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
dtos1
.
put
(
"testKey"
+
i
,
"testValue"
+
i
);
}
long
st
=
System
.
currentTimeMillis
();
redisClusterHelper
.
sets
(
dtos1
,
1000L
);
long
ed
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"耗时:"
+
(
ed
-
st
));
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
dtos1
.
put
(
"testKeyi"
+
i
,
"testValue"
+
i
);
}
st
=
System
.
currentTimeMillis
();
redisClusterHelper
.
sets
(
dtos1
,
1000L
);
ed
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"耗时:"
+
(
ed
-
st
));
List
<
String
>
list
=
redisClusterHelper
.
gets
(
new
ArrayList
<
String
>(
dtos1
.
keySet
()),
String
.
class
);
System
.
out
.
println
(
list
);
Map
<
String
,
String
>
dtos2
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
dtos2
.
put
(
"testKey2:"
+
i
,
"testValue2:"
+
i
);
}
st
=
System
.
currentTimeMillis
();
redisClusterHelper
.
pipelineSets
(
dtos2
,
1000L
);
ed
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"耗时2:"
+
(
ed
-
st
));
}
/**
* 测试多线程
*/
@Test
public
void
testThreads
()
throws
InterruptedException
{
ExecutorService
executorService
=
Executors
.
newCachedThreadPool
();
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
final
int
j
=
i
;
executorService
.
submit
(
new
Runnable
()
{
@Override
public
void
run
()
{
Map
<
String
,
String
>
dtos1
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
dtos1
.
put
(
"testKey"
+
j
+
":"
+
i
,
"testValue"
+
i
);
}
long
st
=
System
.
currentTimeMillis
();
redisClusterHelper
.
sets
(
dtos1
,
1000L
);
long
ed
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"耗时:"
+
j
+
":"
+
(
ed
-
st
));
}
});
}
Thread
.
sleep
(
5000L
);
for
(
int
i
=
20
;
i
<
40
;
i
++)
{
final
int
j
=
i
;
executorService
.
submit
(
new
Runnable
()
{
@Override
public
void
run
()
{
Map
<
String
,
String
>
dtos1
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
dtos1
.
put
(
"testKey"
+
j
+
":"
+
i
,
"testValue"
+
i
);
}
long
st
=
System
.
currentTimeMillis
();
redisClusterHelper
.
sets
(
dtos1
,
1000L
);
long
ed
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"耗时:"
+
j
+
":"
+
(
ed
-
st
));
}
});
}
Thread
.
sleep
(
5000L
);
}
@Test
public
void
testGet
()
{
Person
p
=
new
Person
();
p
.
setDeptName
(
"hhhhhh"
);
p
.
setOperDate
(
new
Date
());
redisClusterHelper
.
set
(
"zhangsan111"
,
p
);
Person
o
=
redisClusterHelper
.
get
(
"zhangsan111"
,
Person
.
class
);
Assert
.
assertEquals
(
"hhhhhh"
,
o
.
getDeptName
());
}
@Test
public
void
testGet2
()
throws
InterruptedException
{
//批量设置测试
Map
<
String
,
String
>
dtos2
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
dtos2
.
put
(
"testKey2:"
+
i
,
"testValue2:"
+
i
);
}
long
st
=
System
.
currentTimeMillis
();
redisClusterHelper
.
pipelineSets
(
dtos2
,
1000L
);
long
ed
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"耗时2:"
+
(
ed
-
st
));
st
=
System
.
currentTimeMillis
();
List
<
String
>
vList
=
redisClusterHelper
.
pipelineGets
(
new
ArrayList
<
String
>(
dtos2
.
keySet
()),
String
.
class
);
ed
=
System
.
currentTimeMillis
();
System
.
out
.
println
(
"耗时2:"
+
(
ed
-
st
));
System
.
out
.
println
(
vList
);
}
@Test
public
void
testH
()
{
Person
p
=
new
Person
();
p
.
setDeptName
(
"hhhhhh"
);
p
.
setOperDate
(
new
Date
());
redisClusterHelper
.
hSet
(
"hsetKey"
,
"f1"
,
p
);
Person
person
=
redisClusterHelper
.
hGet
(
"hsetKey"
,
"f1"
,
Person
.
class
);
Assert
.
assertEquals
(
"hhhhhh"
,
p
.
getDeptName
());
}
@Test
public
void
testAnn
()
{
Person
person
=
personService
.
get
(
1L
);
System
.
out
.
println
(
person
);
person
=
personService
.
get
(
1L
);
System
.
out
.
println
(
person
);
}
@Test
public
void
testIncr
()
{
redisClusterHelper
.
set
(
"incyKey"
,
1
);
System
.
out
.
println
(
redisClusterHelper
.
get
(
"incyKey"
,
Long
.
class
));
redisClusterHelper
.
incr
(
"incyKey"
,
1
);
System
.
out
.
println
(
redisClusterHelper
.
get
(
"incyKey"
,
Long
.
class
));
redisClusterHelper
.
incr
(
"incyKey"
,
10
);
System
.
out
.
println
(
redisClusterHelper
.
get
(
"incyKey"
,
Long
.
class
));
}
@Test
public
void
testTtl
()
throws
InterruptedException
{
redisClusterHelper
.
set
(
"incyKey"
,
1
,
100
);
System
.
out
.
println
(
redisClusterHelper
.
ttl
(
"incyKey"
,
TimeUnit
.
MILLISECONDS
));
Thread
.
sleep
(
444L
);
System
.
out
.
println
(
redisClusterHelper
.
ttl
(
"incyKey"
,
TimeUnit
.
MILLISECONDS
));
Thread
.
sleep
(
444L
);
System
.
out
.
println
(
redisClusterHelper
.
exists
(
"incyKey"
));
System
.
out
.
println
(
redisClusterHelper
.
exists
(
"incyKey111"
));
}
@Test
public
void
testHmset
()
{
Map
<
String
,
Integer
>
vv
=
new
HashMap
<>();
vv
.
put
(
"one"
,
1
);
vv
.
put
(
"two"
,
2
);
redisClusterHelper
.
hMSet
(
"hmsetNumKey"
,
vv
);
Map
<
String
,
Integer
>
ret
=
redisClusterHelper
.
hMGet
(
"hmsetNumKey"
,
new
String
[]{
"one"
,
"two"
},
Integer
.
class
);
System
.
out
.
println
(
ret
);
ret
=
redisClusterHelper
.
hGetAll
(
"hmsetNumKey"
,
String
.
class
,
Integer
.
class
);
System
.
out
.
println
(
ret
);
}
}
matrix-sample-redis/matrix-sample-redis-spring/src/main/java/com/secoo/mall/redis/RedisTest.java
0 → 100644
View file @
085f39e2
package
com
.
secoo
.
mall
.
redis
;
import
com.secoo.mall.redis.helper.RedisHelper
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
;
import
javax.annotation.Resource
;
import
javax.xml.crypto.Data
;
import
java.util.Date
;
/**
* Created by Administrator on 2018/1/15.
*/
//@ContextConfiguration({"classpath*:spring-jedis-alone-config-sample.xml"})
@ContextConfiguration
({
"classpath*:spring-lettuce-alone-config-sample.xml"
})
public
class
RedisTest
extends
AbstractJUnit4SpringContextTests
{
@Resource
private
RedisHelper
redisHelper
;
@Test
public
void
testSet
()
throws
InterruptedException
{
redisHelper
.
set
(
"aaa"
,
"bbb"
);
String
ret
=
redisHelper
.
get
(
"aaa"
,
String
.
class
);
Assert
.
assertEquals
(
"bbb"
,
ret
);
redisHelper
.
set
(
"aaa"
,
"ccc"
,
2
l
);
ret
=
redisHelper
.
get
(
"aaa"
,
String
.
class
);
Assert
.
assertEquals
(
"ccc"
,
ret
);
Thread
.
sleep
(
3000
l
);
ret
=
redisHelper
.
get
(
"aaa"
,
String
.
class
);
Assert
.
assertNull
(
ret
);
//对实体对象操作
Person
person
=
new
Person
();
Date
date
=
new
Date
();
person
.
setOperDate
(
date
);
person
.
setLoginName
(
"李四"
);
redisHelper
.
set
(
"person03"
,
person
);
Assert
.
assertEquals
(
"李四"
,
redisHelper
.
get
(
"person03"
,
Person
.
class
).
getLoginName
());
Assert
.
assertEquals
(
date
,
person
.
getOperDate
());
}
@Test
public
void
testIncr
()
{
redisHelper
.
set
(
"incyKey01"
,
1
);
redisHelper
.
incr
(
"incyKey01"
,
2
);
System
.
out
.
println
(
redisHelper
.
get
(
"incyKey01"
,
Long
.
class
));
}
/**
* 其他方法使用详见 @com.secoo.mall.redis.RedisClusterTest
*/
}
matrix-sample-redis/matrix-sample-redis-spring/src/main/resources/log4j2.xml
0 → 100644
View file @
085f39e2
<?xml version="1.0" encoding="UTF-8"?>
<Configuration
status=
"WARN"
>
<Appenders>
<Console
name=
"Console"
target=
"SYSTEM_OUT"
>
<PatternLayout
pattern=
"%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"
/>
</Console>
</Appenders>
<Loggers>
<Logger
name=
"com.secoo.archetype"
level=
"DEBUG"
/>
<Logger
name=
"org.springframework.beans.factory"
level=
"INFO"
/>
<Root
level=
"info"
>
<AppenderRef
ref=
"Console"
/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
matrix-sample-redis/matrix-sample-redis-spring/src/main/resources/redis-cluster.properties
0 → 100644
View file @
085f39e2
redis.maxRedirects
=
5
redis.host1
=
dev01-rediscluster01.secoolocal.com
redis.port1
=
7001
redis.host2
=
dev01-rediscluster01.secoolocal.com
redis.port2
=
7002
redis.host3
=
dev01-rediscluster02.secoolocal.com
redis.port3
=
7001
redis.host4
=
dev01-rediscluster02.secoolocal.com
redis.port4
=
7002
redis.host5
=
dev01-rediscluster03.secoolocal.com
redis.port5
=
7001
redis.host6
=
dev01-rediscluster03.secoolocal.com
redis.port6
=
7002
# connnet pool
redis.maxIdle
=
50
redis.maxTotal
=
100
redis.minIdle
=
10
\ No newline at end of file
matrix-sample-redis/matrix-sample-redis-spring/src/main/resources/spring-jedis-alone-config-sample.xml
0 → 100644
View file @
085f39e2
<?xml version="1.0" encoding="utf-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd"
>
<context:property-placeholder
ignore-unresolvable=
"true"
location=
"classpath:redis-cluster.properties"
/>
<context:component-scan
base-package=
"com.secoo.mall"
></context:component-scan>
<!--单主机配置-->
<bean
id=
"redisAloneConfiguration"
class=
"org.springframework.data.redis.connection.RedisStandaloneConfiguration"
>
<property
name=
"hostName"
value=
"127.0.0.1"
/>
<property
name=
"port"
value=
"6379"
/>
</bean>
<bean
id=
"jedisPoolConfig"
class=
"redis.clients.jedis.JedisPoolConfig"
>
<property
name=
"maxIdle"
value=
"${redis.maxIdle}"
/>
<property
name=
"maxTotal"
value=
"${redis.maxTotal}"
/>
<property
name=
"minIdle"
value=
"${redis.minIdle}"
/>
</bean>
<bean
id=
"jeidsConnectionFactory"
class=
"org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
>
<constructor-arg
ref=
"redisAloneConfiguration"
/>
<constructor-arg
ref=
"jedisPoolConfig"
/>
</bean>
<bean
id=
"redisTemplate"
class=
"org.springframework.data.redis.core.RedisTemplate"
>
<property
name=
"connectionFactory"
ref=
"jeidsConnectionFactory"
/>
</bean>
<bean
id=
"redisHelper"
class=
"com.secoo.mall.redis.helper.RedisHelper"
>
<constructor-arg
name=
"redisTemplate"
ref=
"redisTemplate"
/>
<!-- 序列化方式 key/hashKey采用StringRedisSerializer-->
<!--<property name="keySerializer">
<bean
class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="hashKeySerializer">
<bean
class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="valueSerializer">
<bean
class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>
</property>
<property name="hashValueSerializer">
<bean
class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>
</property>-->
</bean>
</beans>
matrix-sample-redis/matrix-sample-redis-spring/src/main/resources/spring-jedis-cluster-config-sample.xml
0 → 100644
View file @
085f39e2
<?xml version="1.0" encoding="utf-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx=
"http://www.springframework.org/schema/tx"
xmlns:aop=
"http://www.springframework.org/schema/aop"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:p=
"http://www.springframework.org/schema/p"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-txs-4.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd"
>
<context:property-placeholder
ignore-unresolvable=
"true"
location=
"classpath:redis-cluster.properties"
/>
<context:component-scan
base-package=
"com.secoo.mall"
></context:component-scan>
<bean
id=
"redisClusterConfiguration"
class=
"org.springframework.data.redis.connection.RedisClusterConfiguration"
>
<property
name=
"maxRedirects"
value=
"${redis.maxRedirects}"
></property>
<property
name=
"clusterNodes"
>
<set>
<bean
class=
"org.springframework.data.redis.connection.RedisClusterNode"
>
<constructor-arg
name=
"host"
value=
"${redis.host1}"
></constructor-arg>
<constructor-arg
name=
"port"
value=
"${redis.port1}"
></constructor-arg>
</bean>
<bean
class=
"org.springframework.data.redis.connection.RedisClusterNode"
>
<constructor-arg
name=
"host"
value=
"${redis.host2}"
></constructor-arg>
<constructor-arg
name=
"port"
value=
"${redis.port2}"
></constructor-arg>
</bean>
<bean
class=
"org.springframework.data.redis.connection.RedisClusterNode"
>
<constructor-arg
name=
"host"
value=
"${redis.host3}"
></constructor-arg>
<constructor-arg
name=
"port"
value=
"${redis.port3}"
></constructor-arg>
</bean>
<bean
class=
"org.springframework.data.redis.connection.RedisClusterNode"
>
<constructor-arg
name=
"host"
value=
"${redis.host4}"
></constructor-arg>
<constructor-arg
name=
"port"
value=
"${redis.port4}"
></constructor-arg>
</bean>
<bean
class=
"org.springframework.data.redis.connection.RedisClusterNode"
>
<constructor-arg
name=
"host"
value=
"${redis.host5}"
></constructor-arg>
<constructor-arg
name=
"port"
value=
"${redis.port5}"
></constructor-arg>
</bean>
<bean
class=
"org.springframework.data.redis.connection.RedisClusterNode"
>
<constructor-arg
name=
"host"
value=
"${redis.host6}"
></constructor-arg>
<constructor-arg
name=
"port"
value=
"${redis.port6}"
></constructor-arg>
</bean>
</set>
</property>
</bean>
<bean
id=
"jedisPoolConfig"
class=
"redis.clients.jedis.JedisPoolConfig"
>
<property
name=
"maxIdle"
value=
"${redis.maxIdle}"
/>
<property
name=
"maxTotal"
value=
"${redis.maxTotal}"
/>
<property
name=
"minIdle"
value=
"${redis.minIdle}"
/>
</bean>
<bean
id=
"jeidsConnectionFactory"
class=
"org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
>
<constructor-arg
ref=
"redisClusterConfiguration"
/>
<constructor-arg
ref=
"jedisPoolConfig"
/>
</bean>
<bean
id=
"redisClusterTemplate"
class=
"org.springframework.data.redis.core.RedisTemplate"
>
<property
name=
"connectionFactory"
ref=
"jeidsConnectionFactory"
/>
</bean>
<bean
id=
"secooRedisTemplate"
class=
"com.secoo.mall.redis.helper.RedisHelper"
>
<constructor-arg
name=
"redisTemplate"
ref=
"redisClusterTemplate"
/>
<!-- 序列化方式 key/hashKey采用StringRedisSerializer -->
<!-- <property name="keySerializer">
<bean
class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="hashKeySerializer">
<bean
class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="valueSerializer">
<bean
class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>
</property>
<property name="hashValueSerializer">
<bean
class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>
</property>-->
</bean>
</beans>
matrix-sample-redis/matrix-sample-redis-spring/src/main/resources/spring-lettuce-alone-config-sample.xml
0 → 100644
View file @
085f39e2
<?xml version="1.0" encoding="utf-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop=
"http://www.springframework.org/schema/aop"
xmlns:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd"
>
<context:property-placeholder
ignore-unresolvable=
"true"
location=
"classpath:redis-cluster.properties"
/>
<context:component-scan
base-package=
"com.secoo.mall"
></context:component-scan>
<aop:config
proxy-target-class=
"true"
></aop:config>
<aop:aspectj-autoproxy/>
<!--单主机配置-->
<bean
id=
"redisAloneConfiguration"
class=
"org.springframework.data.redis.connection.RedisStandaloneConfiguration"
>
<property
name=
"hostName"
value=
"127.0.0.1"
/>
<property
name=
"port"
value=
"6379"
/>
</bean>
<bean
id=
"lettuceConnectionFactory"
class=
"org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory"
>
<constructor-arg
ref=
"redisAloneConfiguration"
/>
</bean>
<bean
id=
"rediredisAloneConfigurationTemplate"
class=
"org.springframework.data.redis.core.RedisTemplate"
>
<property
name=
"connectionFactory"
ref=
"lettuceConnectionFactory"
/>
<property
name=
"keySerializer"
>
<bean
class=
"org.springframework.data.redis.serializer.StringRedisSerializer"
/>
</property>
<property
name=
"hashKeySerializer"
>
<bean
class=
"org.springframework.data.redis.serializer.StringRedisSerializer"
/>
</property>
<property
name=
"valueSerializer"
>
<bean
class=
"org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"
/>
</property>
<property
name=
"hashValueSerializer"
>
<bean
class=
"org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"
/>
</property>
</bean>
<bean
id=
"redisHelper"
class=
"com.secoo.mall.redis.helper.RedisHelper"
>
<constructor-arg
name=
"redisTemplate"
ref=
"rediredisAloneConfigurationTemplate"
/>
<!-- 序列化方式 key/hashKey采用StringRedisSerializer ,不指定可以使用默认的-->
<!-- <property name="keySerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="hashKeySerializer">
<bean
class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="valueSerializer">
<bean
class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>
</property>
<property name="hashValueSerializer">
<bean
class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>
</property>-->
</bean>
</beans>
matrix-sample-redis/matrix-sample-redis-spring/src/main/resources/spring-lettuce-cluster-config-sample.xml
0 → 100644
View file @
085f39e2
<?xml version="1.0" encoding="utf-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx=
"http://www.springframework.org/schema/tx"
xmlns:aop=
"http://www.springframework.org/schema/aop"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:p=
"http://www.springframework.org/schema/p"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-txs-4.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd"
>
<context:property-placeholder
ignore-unresolvable=
"true"
location=
"classpath:redis-cluster.properties"
/>
<context:component-scan
base-package=
"com.secoo.mall"
></context:component-scan>
<aop:config
proxy-target-class=
"true"
></aop:config>
<aop:aspectj-autoproxy/>
<bean
id=
"redisClusterConfiguration"
class=
"org.springframework.data.redis.connection.RedisClusterConfiguration"
>
<property
name=
"maxRedirects"
value=
"${redis.maxRedirects}"
></property>
<property
name=
"clusterNodes"
>
<set>
<bean
class=
"org.springframework.data.redis.connection.RedisClusterNode"
>
<constructor-arg
name=
"host"
value=
"${redis.host1}"
></constructor-arg>
<constructor-arg
name=
"port"
value=
"${redis.port1}"
></constructor-arg>
</bean>
<bean
class=
"org.springframework.data.redis.connection.RedisClusterNode"
>
<constructor-arg
name=
"host"
value=
"${redis.host2}"
></constructor-arg>
<constructor-arg
name=
"port"
value=
"${redis.port2}"
></constructor-arg>
</bean>
<bean
class=
"org.springframework.data.redis.connection.RedisClusterNode"
>
<constructor-arg
name=
"host"
value=
"${redis.host3}"
></constructor-arg>
<constructor-arg
name=
"port"
value=
"${redis.port3}"
></constructor-arg>
</bean>
<bean
class=
"org.springframework.data.redis.connection.RedisClusterNode"
>
<constructor-arg
name=
"host"
value=
"${redis.host4}"
></constructor-arg>
<constructor-arg
name=
"port"
value=
"${redis.port4}"
></constructor-arg>
</bean>
<bean
class=
"org.springframework.data.redis.connection.RedisClusterNode"
>
<constructor-arg
name=
"host"
value=
"${redis.host5}"
></constructor-arg>
<constructor-arg
name=
"port"
value=
"${redis.port5}"
></constructor-arg>
</bean>
<bean
class=
"org.springframework.data.redis.connection.RedisClusterNode"
>
<constructor-arg
name=
"host"
value=
"${redis.host6}"
></constructor-arg>
<constructor-arg
name=
"port"
value=
"${redis.port6}"
></constructor-arg>
</bean>
</set>
</property>
</bean>
<!--<bean id="clientResources" class="com.lambdaworks.redis.resource.DefaultClientResources"-->
<!--factory-method="create">-->
<!--</bean>-->
<bean
id=
"lettuceConnectionFactory"
class=
"org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory"
>
<constructor-arg
ref=
"redisClusterConfiguration"
/>
<!--<property name="clientResources" ref="clientResources"/>-->
</bean>
<!--可以注入一个mapper,默认的序列化会序列化类名-->
<!--ObjectMapper mapper = new ObjectMapper();-->
<!--mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);-->
<!--//日期格式-->
<!--mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));-->
<!--//null不序列化 减小报文大小-->
<!--mapper.setSerializationInclusion(Include.NON_NULL);-->
<bean
id=
"redisCluserTemplate"
class=
"org.springframework.data.redis.core.RedisTemplate"
>
<property
name=
"connectionFactory"
ref=
"lettuceConnectionFactory"
/>
</bean>
<bean
id=
"redisClusterHelper"
class=
"com.secoo.mall.redis.helper.RedisHelper"
>
<constructor-arg
name=
"redisTemplate"
ref=
"redisCluserTemplate"
/>
<!-- 序列化方式 key/hashKey采用StringRedisSerializer ,也可以使用默认的-->
<!--<property name="keySerializer">
<bean
class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="hashKeySerializer">
<bean
class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="valueSerializer">
<bean
class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>
</property>
<property name="hashValueSerializer">
<bean
class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"/>
</property>-->
</bean>
</beans>
matrix-sample-redis/matrix-sample-redis-starter/pom.xml
View file @
085f39e2
...
@@ -5,11 +5,25 @@
...
@@ -5,11 +5,25 @@
<parent>
<parent>
<artifactId>
matrix-sample-redis
</artifactId>
<artifactId>
matrix-sample-redis
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-redis-starter
</artifactId>
<artifactId>
matrix-sample-redis-starter
</artifactId>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-redis-biz
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-datahelper-redis-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
</dependency>
</dependencies>
</project>
</project>
\ No newline at end of file
matrix-sample-redis/matrix-sample-redis-starter/src/main/java/com/secoo/mall/redis/RedisSampleApplication.java
0 → 100644
View file @
085f39e2
package
com
.
secoo
.
mall
.
redis
;
import
com.secoo.mall.redis.helper.RedisHelper
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
javax.annotation.Resource
;
import
java.util.Date
;
@SpringBootApplication
public
class
RedisSampleApplication
implements
ApplicationRunner
{
@Resource
private
RedisHelper
redisHelper
;
@Resource
private
RedisHelper
productRedisHelper
;
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
RedisSampleApplication
.
class
).
run
(
args
);
}
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
redisHelper
.
set
(
"key01"
,
"word"
);
String
key01
=
redisHelper
.
get
(
"key01"
,
String
.
class
);
Person
person
=
new
Person
();
person
.
setId
(
2L
);
// person.setDeptName("技术部");
person
.
setLoginName
(
"zhangsan"
);
person
.
setOperDate
(
new
Date
());
redisHelper
.
set
(
"person05"
,
person
);
//1.通过测试,Fastjson,对象缺少属性后支持序列化
System
.
out
.
println
(
"person05::"
+
redisHelper
.
get
(
"person05"
,
Person
.
class
).
getLoginName
());
productRedisHelper
.
set
(
"p:01"
,
"帽子"
);
System
.
out
.
println
(
"p:01="
+
productRedisHelper
.
get
(
"p:01"
,
String
.
class
));
}
}
matrix-sample-redis/matrix-sample-redis-starter/src/main/java/com/secoo/mall/redis/config/MuliRedisConfig.java
0 → 100644
View file @
085f39e2
package
com
.
secoo
.
mall
.
redis
.
config
;
import
com.secoo.mall.redis.helper.RedisHelper
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
/**
* 多数据源配置
*/
@Configuration
@ConfigurationProperties
(
prefix
=
"redis.custom"
)
@Data
public
class
MuliRedisConfig
{
public
String
host
;
public
Integer
port
;
/**
* 仅仅提供简单配置demo
*
* @return
*/
@Bean
public
LettuceConnectionFactory
productConnectionFactory
()
{
LettuceConnectionFactory
connectionFactory
=
new
LettuceConnectionFactory
(
host
,
port
);
return
connectionFactory
;
}
@Bean
public
RedisTemplate
productRedisTemplate
(
LettuceConnectionFactory
productConnectionFactory
){
RedisTemplate
redisTemplate
=
new
RedisTemplate
();
redisTemplate
.
setConnectionFactory
(
productConnectionFactory
);
return
redisTemplate
;
}
@Bean
(
"productRedisHelper"
)
public
RedisHelper
productRedisHelper
(
RedisTemplate
productRedisTemplate
)
{
return
new
RedisHelper
(
productRedisTemplate
);
}
}
matrix-sample-redis/matrix-sample-redis-starter/src/main/resources/application.yml
0 → 100644
View file @
085f39e2
spring
:
redis
:
cluster
:
nodes
:
dev01-rediscluster01.secoolocal.com:7001,dev01-rediscluster01.secoolocal.com:7002,dev01-rediscluster02.secoolocal.com:7001,dev01-rediscluster02.secoolocal.com:7002,dev01-rediscluster03.secoolocal.com:7001,dev01-rediscluster03.secoolocal.com:7002
timeout
:
10000
# host: localhost
redis
:
custom
:
host
:
localhost
port
:
6379
matrix-sample-redis/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample
</artifactId>
<artifactId>
matrix-sample
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
@@ -14,7 +14,38 @@
...
@@ -14,7 +14,38 @@
<modules>
<modules>
<module>
matrix-sample-redis-starter
</module>
<module>
matrix-sample-redis-starter
</module>
<module>
matrix-sample-redis-biz
</module>
<module>
matrix-sample-redis-biz
</module>
<module>
matrix-sample-redis-spring
</module>
</modules>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-redis-biz
</artifactId>
<version>
2.0.1-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
<version>
3.2.0
</version>
</dependency>
<!-- 推荐使用 lettuce -->
<dependency>
<groupId>
io.lettuce
</groupId>
<artifactId>
lettuce-core
</artifactId>
<version>
5.2.2.RELEASE
</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
common-util
</artifactId>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
</dependency>
</dependencies>
</project>
</project>
\ No newline at end of file
matrix-sample-rocketmq/matrix-sample-rocketmq-biz/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-rocketmq
</artifactId>
<artifactId>
matrix-sample-rocketmq
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-rocketmq/matrix-sample-rocketmq-spring/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-rocketmq
</artifactId>
<artifactId>
matrix-sample-rocketmq
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-rocketmq/matrix-sample-rocketmq-springboot/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-rocketmq
</artifactId>
<artifactId>
matrix-sample-rocketmq
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-rocketmq/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample
</artifactId>
<artifactId>
matrix-sample
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-rocketmq-biz
</artifactId>
<artifactId>
matrix-sample-rocketmq-biz
</artifactId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
...
...
matrix-sample-xxl/matrix-sample-xxl-biz/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-xxl
</artifactId>
<artifactId>
matrix-sample-xxl
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-xxl/matrix-sample-xxl-spring/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-xxl
</artifactId>
<artifactId>
matrix-sample-xxl
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-xxl/matrix-sample-xxl-springboot/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample-xxl
</artifactId>
<artifactId>
matrix-sample-xxl
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
...
matrix-sample-xxl/pom.xml
View file @
085f39e2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<artifactId>
matrix-sample
</artifactId>
<artifactId>
matrix-sample
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
<dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-xxl-biz
</artifactId>
<artifactId>
matrix-sample-xxl-biz
</artifactId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
</dependencyManagement>
</dependencyManagement>
...
...
pom.xml
View file @
085f39e2
...
@@ -8,18 +8,18 @@
...
@@ -8,18 +8,18 @@
<parent>
<parent>
<groupId>
com.secoo.mall
</groupId>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix
</artifactId>
<artifactId>
matrix
</artifactId>
<version>
1.3.2.RELEASE
</version>
<version>
2.0.1-SNAPSHOT
</version>
</parent>
</parent>
<artifactId>
matrix-sample
</artifactId>
<artifactId>
matrix-sample
</artifactId>
<version>
2.0.1-SNAPSHOT
</version>
<modules>
<modules>
<module>
matrix-sample-xxl
</module>
<module>
matrix-sample-xxl
</module>
<module>
matrix-sample-dubbo
</module>
<module>
matrix-sample-dubbo
</module>
<module>
matrix-sample-hbase
</module>
<module>
matrix-sample-hbase
</module>
<module>
matrix-sample-rocketmq
</module>
<module>
matrix-sample-rocketmq
</module>
<module>
matrix-sample-redis
</module>
<module>
matrix-sample-redis
</module>
<module>
matrix-sample-mybatis
</module>
</modules>
</modules>
</project>
</project>
\ No newline at end of file
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