Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projectArtifacture
Project
Project
Details
Activity
Releases
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
yangzhaojun
projectArtifacture
Commits
059e996e
Commit
059e996e
authored
Nov 01, 2018
by
xfxmcy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename 结构后导致的bug,现在启动正常
parent
94ef35ff
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
1091 additions
and
32 deletions
+1091
-32
CyMultipleDruidConfig.java
src/main/java/org/rcisoft/config/CyMultipleDruidConfig.java
+0
-7
CyTransactionConfig.java
src/main/java/org/rcisoft/config/CyTransactionConfig.java
+51
-0
CyDecryptParamAspect.java
src/main/java/org/rcisoft/core/aop/CyDecryptParamAspect.java
+16
-1
CyDsPowerAspect.java
src/main/java/org/rcisoft/core/aop/CyDsPowerAspect.java
+52
-0
CyEntityParamAspect.java
src/main/java/org/rcisoft/core/aop/CyEntityParamAspect.java
+2
-0
CyIdGenAspect.java
src/main/java/org/rcisoft/core/aop/CyIdGenAspect.java
+6
-2
CyRedisOperateAspect.java
src/main/java/org/rcisoft/core/aop/CyRedisOperateAspect.java
+151
-0
CyDsPowerAnno.java
.../java/org/rcisoft/core/datasource/anno/CyDsPowerAnno.java
+25
-0
CyResult.java
src/main/java/org/rcisoft/core/result/CyResult.java
+3
-3
CyResultCode.java
src/main/java/org/rcisoft/core/result/CyResultCode.java
+9
-1
CyResultSystemExceptionEnums.java
...org/rcisoft/core/result/CyResultSystemExceptionEnums.java
+5
-5
CyRedisService.java
src/main/java/org/rcisoft/core/service/CyRedisService.java
+317
-0
CyRedisServiceImpl.java
...ava/org/rcisoft/core/service/impl/CyRedisServiceImpl.java
+419
-0
application-dev.yml
src/main/resources/application-dev.yml
+19
-0
controller.ftl
src/main/resources/templates/codeftl/controller.ftl
+10
-10
mapper.ftl
src/main/resources/templates/codeftl/mapper.ftl
+5
-2
serviceimpl.ftl
src/main/resources/templates/codeftl/serviceimpl.ftl
+1
-1
No files found.
src/main/java/org/rcisoft/config/CyMultipleDruidConfig.java
View file @
059e996e
...
...
@@ -103,13 +103,6 @@ public class CyMultipleDruidConfig {
return
fb
.
getObject
();
}
/**
* 配置事务管理器
*/
@Bean
public
DataSourceTransactionManager
transactionManager
(
CyDynamicDataSource
dataSource
)
throws
Exception
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
}
src/main/java/org/rcisoft/config/CyTransactionConfig.java
0 → 100644
View file @
059e996e
package
org
.
rcisoft
.
config
;
import
org.rcisoft.core.doc.anno.CyDoc
;
import
org.rcisoft.core.doc.enums.CyDocEnum
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.springframework.transaction.annotation.TransactionManagementConfigurer
;
import
javax.sql.DataSource
;
/*
@Configuration
@EnableTransactionManagement
*/
@CyDoc
(
CyDocEnum
.
USELESS
)
public
class
CyTransactionConfig
implements
TransactionManagementConfigurer
{
@Autowired
@Qualifier
(
"txManagerOracle"
)
private
PlatformTransactionManager
txManagerOracle
;
// 创建Mysql事务管理器
@Bean
(
name
=
"txManagerMysql"
)
public
PlatformTransactionManager
txManagerMysql
(
@Qualifier
(
"power"
)
DataSource
power
)
{
return
new
DataSourceTransactionManager
(
power
);
}
// 创建Oracle事务管理器
@Bean
(
name
=
"txManagerOracle"
)
public
PlatformTransactionManager
txManagerOracle
(
@Qualifier
(
"pmiss"
)
DataSource
pmiss
)
{
return
new
DataSourceTransactionManager
(
pmiss
);
}
@Override
public
PlatformTransactionManager
annotationDrivenTransactionManager
()
{
return
txManagerOracle
;
}
/**
* 配置事务管理器
*/
/*@Bean
public DataSourceTransactionManager transactionManager(CyDynamicDataSource dataSource) throws Exception {
return new DataSourceTransactionManager(dataSource);
}*/
}
src/main/java/org/rcisoft/core/aop/CyDecryptParamAspect.java
View file @
059e996e
...
...
@@ -6,6 +6,8 @@ import org.aspectj.lang.ProceedingJoinPoint;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.rcisoft.common.component.CyGlobal
;
import
org.rcisoft.core.doc.anno.CyDoc
;
import
org.rcisoft.core.doc.enums.CyDocEnum
;
import
org.rcisoft.core.exception.CyServiceException
;
import
org.rcisoft.core.result.CyResultSystemExceptionEnums
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -25,15 +27,28 @@ import java.util.Map;
* author: cy
* Date: 18/10/25
* Time: 下午8:06
* description:
* description: 对称解密参数,防止报文被篡改
*
*
* Aopconfig.java 使用
*
* @Bean
* public CyDecryptParamAspect cyDecryptParamAspect(){
* return new CyDecryptParamAspect();
* }
*/
@Aspect
@Slf4j
@CyDoc
(
CyDocEnum
.
USELESS
)
public
class
CyDecryptParamAspect
{
@Autowired
private
CyGlobal
cyGlobal
;
/**
* 解密拦截
* @param proceedingJoinPoint
...
...
src/main/java/org/rcisoft/core/aop/CyDsPowerAspect.java
0 → 100644
View file @
059e996e
package
org
.
rcisoft
.
core
.
aop
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.rcisoft.core.component.CyContextHolder
;
import
org.rcisoft.core.doc.anno.CyDoc
;
import
org.rcisoft.core.doc.enums.CyDocEnum
;
import
org.rcisoft.core.druid.CyDsEnum
;
/**
* 数据源切换
*/
@Aspect
@Slf4j
@CyDoc
(
CyDocEnum
.
USELESS
)
public
class
CyDsPowerAspect
{
/**
*
* Aopconfig.java 使用
*
* @Bean
* public PowerDsAspect powerDsAspect(){
* return new PowerDsAspect();
* }
*
*
*
*
*
* 切换数据源
* @param proceedingJoinPoint
* @return
* @throws Throwable
*/
@Around
(
"@annotation(org.rcisoft.core.datasource.anno.CyDsPowerAnno)"
)
public
Object
powerDs
(
ProceedingJoinPoint
proceedingJoinPoint
)
throws
Throwable
{
try
{
CyContextHolder
.
setDatabaseType
(
CyDsEnum
.
POWER
);
Object
obj
=
proceedingJoinPoint
.
proceed
();
return
obj
;
}
catch
(
Throwable
var5
){
log
.
error
(
var5
.
getMessage
());
throw
var5
;
}
finally
{
CyContextHolder
.
setDatabaseType
(
CyDsEnum
.
PMISS
);
}
}
}
src/main/java/org/rcisoft/core/aop/CyEntityParamAspect.java
View file @
059e996e
...
...
@@ -12,6 +12,8 @@ import org.springframework.validation.BindingResult;
/**
* Created by lcy on 18/1/21.
*
* description: 参数格式验证 hibernate validator
*/
@Aspect
@Slf4j
...
...
src/main/java/org/rcisoft/core/aop/CyIdGenAspect.java
View file @
059e996e
package
org
.
rcisoft
.
core
.
aop
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.rcisoft.core.entity.CyIdEntity
;
import
org.rcisoft.core.util.CyIdGenUtil
;
...
...
@@ -10,9 +12,11 @@ import java.util.Date;
/**
* Created by lcy on 17/11/23.
*
* description: id 构建切面
*/
//
@Aspect
//@Component
@Aspect
@Slf4j
public
class
CyIdGenAspect
{
/**
* 插入前 判断是否 存在id
...
...
src/main/java/org/rcisoft/core/aop/CyRedisOperateAspect.java
0 → 100644
View file @
059e996e
package
org
.
rcisoft
.
core
.
aop
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.rcisoft.core.doc.anno.CyDoc
;
import
org.rcisoft.core.doc.enums.CyDocEnum
;
import
org.rcisoft.core.exception.CyServiceException
;
import
org.rcisoft.core.result.CyResultCode
;
import
org.rcisoft.core.result.CyResultSystemExceptionEnums
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
import
java.lang.reflect.TypeVariable
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
/**
* Created with family.
* author: cy
* Date: 18/11/1
* Time: 上午11:00
* description: redis 操作切面
*/
@Aspect
@Slf4j
@CyDoc
(
CyDocEnum
.
USELESS
)
public
class
CyRedisOperateAspect
{
/**
* 拦截CyRedisServiceImpl 中所有方法,打印相关日志
* @param proceedingJoinPoint
*
*/
@Around
(
"execution (* org.rcisoft.core.service.impl.CyRedisServiceImpl.*(..))"
)
public
Object
redisOperateAspect
(
ProceedingJoinPoint
proceedingJoinPoint
)
throws
InstantiationException
,
IllegalAccessException
{
String
methodName
=
proceedingJoinPoint
.
getSignature
().
getName
();
Type
type
=
null
;
Class
className
=
proceedingJoinPoint
.
getTarget
().
getClass
();
//获取类中所有的方法
Method
[]
methods
=
className
.
getMethods
();
//拦截到方法的参数
Object
[]
args
=
proceedingJoinPoint
.
getArgs
();
//获取 cyRedisServiceImpl 中对应方法的参数列表
Class
<?>[]
paramsCls
=
this
.
getParamList
(
type
,
methods
,
methodName
,
args
);
try
{
//获取方法
Method
method
=
proceedingJoinPoint
.
getTarget
().
getClass
()
.
getMethod
(
proceedingJoinPoint
.
getSignature
().
getName
(),
paramsCls
);
//获取返回值类型
type
=
method
.
getAnnotatedReturnType
().
getType
();
//返回值
Object
result
=
proceedingJoinPoint
.
proceed
();
//打印日志
this
.
dealwithResult
(
type
,
result
,
args
,
methodName
);
return
result
;
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
throw
new
CyServiceException
(
CyResultCode
.
REDIS_OPERATE_ERROR
.
getCode
()
,
"redis - "
+
methodName
+
"-error-"
+
e
.
getMessage
());
}
}
//获取形参方法的参数列表
private
Class
<?>[]
getParamList
(
Type
type
,
Method
[]
methods
,
String
methodName
,
Object
[]
args
)
throws
IllegalAccessException
,
InstantiationException
{
Class
<?>[]
paramsCls
=
new
Class
<?>[
args
.
length
];
for
(
int
i
=
0
;
i
<
args
.
length
;
++
i
)
{
paramsCls
[
i
]
=
args
[
i
].
getClass
();
}
for
(
Method
m:
methods
){
if
(
m
.
getName
().
equals
(
methodName
)){
//获取返回类型
Class
<?>[]
parameterTypes
=
m
.
getParameterTypes
();
//当形参为Object时,将实参的参数类型转为Object
if
(
parameterTypes
.
length
==
args
.
length
){
for
(
int
i
=
0
;
i
<
parameterTypes
.
length
;
++
i
){
if
(
"object"
.
equals
(
parameterTypes
[
i
].
getSimpleName
().
toLowerCase
()))
paramsCls
[
i
]
=
parameterTypes
[
i
];
else
if
(
"arraylist"
.
equals
(
paramsCls
[
i
].
getSimpleName
().
toLowerCase
()))
paramsCls
[
i
]
=
java
.
util
.
List
.
class
;
}
break
;
}
else
continue
;
}
}
return
paramsCls
;
}
//处理数据
private
void
dealwithResult
(
Type
type
,
Object
result
,
Object
[]
args
,
String
methodName
)
throws
ClassNotFoundException
,
IllegalAccessException
,
InstantiationException
{
String
typeName
=
getParamClssName
(
type
);
//判断返回值类型是 boolean 的情况
if
(
"boolean"
.
equals
(
typeName
)){
if
(
"true"
.
equals
(
result
))
log
.
info
(
"redis "
+
methodName
+
" success - "
+
args
[
0
]);
else
if
(
"false"
.
equals
(
result
))
log
.
error
(
"redis "
+
methodName
+
" error - "
+
args
[
0
]);
}
//判断返回值类型是 long/double 的情况
else
if
((
"long"
.
equals
(
typeName
)
||
"double"
.
equals
(
typeName
)))
{
if
(
Double
.
parseDouble
(
result
.
toString
())
>
0
)
log
.
info
(
"redis "
+
methodName
+
" success - "
+
args
[
0
]);
else
log
.
error
(
"redis "
+
methodName
+
" failed or key already exists - "
+
args
[
0
]);
}
//判断返回值类型是 list/Map/Object/Set 的情况
else
if
(
"list"
.
equals
(
typeName
))
{
if
(((
List
)
result
).
size
()
>
0
)
log
.
info
(
"redis "
+
methodName
+
" success - "
+
args
[
0
]);
else
if
(((
List
)
result
).
size
()
<=
0
)
log
.
error
(
"redis "
+
methodName
+
" failed or get zero info - "
+
args
[
0
]);
else
if
(
null
!=
result
)
log
.
info
(
"redis "
+
methodName
+
" success - "
+
args
[
0
]);
}
else
if
(
"map"
.
equals
(
typeName
))
{
if
(((
Map
)
result
).
size
()
>
0
)
log
.
info
(
"redis "
+
methodName
+
" success - "
+
args
[
0
]);
else
if
(((
Map
)
result
).
size
()
<=
0
)
log
.
error
(
"redis "
+
methodName
+
" failed or get zero info - "
+
args
[
0
]);
else
if
(
null
!=
result
)
log
.
info
(
"redis "
+
methodName
+
" success - "
+
args
[
0
]);
}
else
if
(
"set"
.
equals
(
typeName
))
{
if
(((
Set
)
result
).
size
()
>
0
)
log
.
info
(
"redis "
+
methodName
+
" success - "
+
args
[
0
]);
else
if
(((
Set
)
result
).
size
()
<=
0
)
log
.
error
(
"redis "
+
methodName
+
" failed or get zero info - "
+
args
[
0
]);
else
if
(
null
!=
result
)
log
.
info
(
"redis "
+
methodName
+
" success - "
+
args
[
0
]);
}
else
if
(
"object"
.
equals
(
typeName
))
{
if
(
null
!=
result
)
log
.
info
(
"redis "
+
methodName
+
" success - "
+
args
[
0
]);
else
log
.
error
(
"redis "
+
methodName
+
" failed or get zero info - "
+
args
[
0
]);
}
}
//获取String类型的类名 将 java.lang.reflect.Type 转成String
public
String
getParamClssName
(
Type
type
)
throws
ClassNotFoundException
,
IllegalAccessException
,
InstantiationException
{
if
(
type
instanceof
ParameterizedType
)
{
return
((
Class
)
((
ParameterizedType
)
type
).
getRawType
()).
getSimpleName
().
toLowerCase
();
}
else
if
(
type
instanceof
TypeVariable
)
{
return
((
TypeVariable
)
type
).
getGenericDeclaration
().
toString
().
toLowerCase
();
}
else
{
return
((
Class
)
type
).
getSimpleName
().
toLowerCase
();
}
}
}
src/main/java/org/rcisoft/core/datasource/anno/CyDsPowerAnno.java
0 → 100644
View file @
059e996e
package
org
.
rcisoft
.
core
.
datasource
.
anno
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Target
;
import
static
java
.
lang
.
annotation
.
ElementType
.
METHOD
;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
RUNTIME
;
/**
* Created with family.
* author: cy
* Date: 18/11/1
* Time: 上午10:51
* description:
*/
@Target
({
METHOD
})
@Retention
(
RUNTIME
)
public
@interface
CyDsPowerAnno
{
/**
* 修改数据源为 mysql
* @return
*/
public
boolean
enabled
()
default
true
;
}
src/main/java/org/rcisoft/core/result/CyResult.java
View file @
059e996e
...
...
@@ -18,13 +18,13 @@ public class CyResult {
* @return
*/
public
void
setErrorMessage
(
String
message
,
Object
data
)
{
this
.
code
=
CyResultCode
.
FAIL
.
code
;
this
.
code
=
CyResultCode
.
FAIL
.
getCode
()
;
this
.
message
=
message
;
this
.
data
=
data
;
}
public
void
setSucessMessage
(
String
message
,
Object
data
)
{
this
.
code
=
CyResultCode
.
SUCCESS
.
code
;
this
.
code
=
CyResultCode
.
SUCCESS
.
getCode
()
;
this
.
message
=
message
;
this
.
data
=
data
;
}
...
...
@@ -33,7 +33,7 @@ public class CyResult {
public
CyResult
setCode
(
CyResultCode
cyResultCode
)
{
this
.
code
=
cyResultCode
.
code
;
this
.
code
=
cyResultCode
.
getCode
()
;
return
this
;
}
...
...
src/main/java/org/rcisoft/core/result/CyResultCode.java
View file @
059e996e
package
org
.
rcisoft
.
core
.
result
;
import
lombok.Getter
;
/**
* 响应码枚举,参考HTTP状态码的语义
*/
@Getter
public
enum
CyResultCode
{
SUCCESS
(
200
),
//成功
...
...
@@ -16,9 +19,14 @@ public enum CyResultCode {
PARAMETER_ERROR
(
601
),
//参数错误
PARAMETER_DECRYPT_ERROR
(
603
),
//参数解密错误
REDIS_OPERATE_ERROR
(
700
),
//redis 操作失败
DATA_EXISTS
(
602
);
//数据已存在
public
int
code
;
private
int
code
;
CyResultCode
(
int
code
)
{
this
.
code
=
code
;
...
...
src/main/java/org/rcisoft/core/result/CyResultSystemExceptionEnums.java
View file @
059e996e
...
...
@@ -16,15 +16,15 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
public
enum
CyResultSystemExceptionEnums
implements
CyResultExceptionEnum
{
ERROR
(
CyResultCode
.
INTERNAL_SERVER_ERROR
.
code
,
"系统错误"
),
ERROR
(
CyResultCode
.
INTERNAL_SERVER_ERROR
.
getCode
()
,
"系统错误"
),
FAIL
(
CyResultCode
.
FAIL
.
code
,
"操作失败"
),
FAIL
(
CyResultCode
.
FAIL
.
getCode
()
,
"操作失败"
),
PARAMETER_ERROR
(
CyResultCode
.
PARAMETER_ERROR
.
code
,
"参数错误"
),
PARAMETER_ERROR
(
CyResultCode
.
PARAMETER_ERROR
.
getCode
()
,
"参数错误"
),
DATA_EXISTS
(
CyResultCode
.
DATA_EXISTS
.
code
,
"数据已存在"
),
DATA_EXISTS
(
CyResultCode
.
DATA_EXISTS
.
getCode
()
,
"数据已存在"
),
PARAMETER_DECRYPT_ERROR
(
CyResultCode
.
PARAMETER_
ERROR
.
code
,
"参数加密错误"
),
PARAMETER_DECRYPT_ERROR
(
CyResultCode
.
PARAMETER_
DECRYPT_ERROR
.
getCode
()
,
"参数加密错误"
),
/**
* 系统常用 1000起
...
...
src/main/java/org/rcisoft/core/service/CyRedisService.java
0 → 100644
View file @
059e996e
package
org
.
rcisoft
.
core
.
service
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
/**
* Created with family.
* author: cy
* Date: 18/10/25
* Time: 下午4:12
* description:
*/
public
interface
CyRedisService
{
/**
* 指定缓存失效时间
* @param key 键
* @param time 时间(秒)
* @return
*/
// public boolean expire(String key,long time);
/**
* 根据key 获取过期时间
*
* @param key 键 不能为null
* @return 时间(秒) 返回0代表为永久有效
*/
public
long
getExpire
(
String
key
);
/**
* 判断key是否存在
*
* @param key 键
* @return true 存在 false不存在
*/
public
boolean
hasKey
(
String
key
);
/**
* 删除缓存
*
* @param key 可以传一个值 或多个
*/
public
boolean
del
(
String
...
key
);
//============================String=============================
/**
* 普通缓存获取
*
* @param key 键
* @return 值
*/
public
Object
get
(
String
key
);
/**
* 普通缓存放入
*
* @param key 键
* @param value 值
* @return true成功 false失败
*/
public
boolean
set
(
String
key
,
Object
value
);
/**
* 普通缓存放入并设置时间
*
* @param key 键
* @param value 值
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
* @return true成功 false 失败
*/
public
boolean
set
(
String
key
,
Object
value
,
Long
time
);
/**
* 递增
*
* @param key 键
* @param
* @return
* @desc by 要增加几(大于0)
*/
public
long
incr
(
String
key
,
Long
delta
);
/**
* 递减
*
* @param key 键
* @param
* @return
* @desc by 要减少几(小于0)
*/
public
long
decr
(
String
key
,
Long
delta
);
//================================Map=================================
/**
* HashGet
*
* @param key 键 不能为null
* @param item 项 不能为null
* @return 值
*/
public
Object
hget
(
String
key
,
String
item
);
/**
* 获取hashKey对应的所有键值
*
* @param key 键
* @return 对应的多个键值
*/
public
Map
<
Object
,
Object
>
hmget
(
String
key
);
/**
* HashSet
*
* @param key 键
* @param map 对应多个键值
* @return true 成功 false 失败
*/
public
boolean
hmset
(
String
key
,
Map
<
String
,
Object
>
map
);
/**
* HashSet 并设置时间
*
* @param key 键
* @param map 对应多个键值
* @param time 时间(秒)
* @return true成功 false失败
*/
public
boolean
hmset
(
String
key
,
Map
<
String
,
Object
>
map
,
Long
time
);
/**
* 向一张hash表中放入数据,如果不存在将创建
*
* @param key 键
* @param item 项
* @param value 值
* @return true 成功 false失败
*/
public
boolean
hset
(
String
key
,
String
item
,
Object
value
);
/**
* 向一张hash表中放入数据,如果不存在将创建
*
* @param key 键
* @param item 项
* @param value 值
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
* @return true 成功 false失败
*/
public
boolean
hset
(
String
key
,
String
item
,
Object
value
,
Long
time
);
/**
* 删除hash表中的值
*
* @param key 键 不能为null
* @param item 项 可以使多个 不能为null
*/
public
void
hdel
(
String
key
,
Object
...
item
);
/**
* 判断hash表中是否有该项的值
*
* @param key 键 不能为null
* @param item 项 不能为null
* @return true 存在 false不存在
*/
public
boolean
hHasKey
(
String
key
,
String
item
);
/**
* hash递增 如果不存在,就会创建一个 并把新增后的值返回
*
* @param key 键
* @param item 项
* @param by 要增加几(大于0)
* @return
*/
public
double
hincr
(
String
key
,
String
item
,
Double
by
);
/**
* hash递减
*
* @param key 键
* @param item 项
* @param by 要减少记(小于0)
* @return
*/
public
double
hdecr
(
String
key
,
String
item
,
Double
by
);
//============================set=============================
/**
* 根据key获取Set中的所有值
*
* @param key 键
* @return
*/
public
Set
<
Object
>
sGet
(
String
key
);
/**
* 根据value从一个set中查询,是否存在
*
* @param key 键
* @param value 值
* @return true 存在 false不存在
*/
public
boolean
sHasKey
(
String
key
,
Object
value
);
/**
* 将数据放入set缓存
*
* @param key 键
* @param values 值 可以是多个
* @return 成功个数
*/
public
long
sSet
(
String
key
,
Object
...
values
);
/**
* 将set数据放入缓存
*
* @param key 键
* @param time 时间(秒)
* @param values 值 可以是多个
* @return 成功个数
*/
public
long
sSetAndTime
(
String
key
,
Long
time
,
Object
...
values
);
/**
* 获取set缓存的长度
*
* @param key 键
* @return
*/
public
long
sGetSetSize
(
String
key
);
/**
* 移除值为value的
*
* @param key 键
* @param values 值 可以是多个
* @return 移除的个数
*/
public
long
setRemove
(
String
key
,
Object
...
values
);
//===============================list=================================
/**
* 获取list缓存的内容
*
* @param key 键
* @param start 开始
* @param end 结束 0 到 -1代表所有值
* @return
*/
public
List
<
Object
>
lGet
(
String
key
,
Long
start
,
Long
end
);
/**
* 获取list缓存的长度
*
* @param key 键
* @return
*/
public
long
lGetListSize
(
String
key
);
/**
* 通过索引 获取list中的值
*
* @param key 键
* @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
* @return
*/
public
Object
lGetIndex
(
String
key
,
Long
index
);
/**
* 将list放入缓存
*
* @param key 键
* @param value 值
* @param
* @return
* @desc time 时间(秒)
*/
public
boolean
lSet
(
String
key
,
Object
value
);
/**
* 将list放入缓存
*
* @param key 键
* @param value 值
* @param time 时间(秒)
* @return
*/
public
boolean
lSet
(
String
key
,
List
value
,
Long
time
);
/**
* 根据索引修改list中的某条数据
*
* @param key 键
* @param index 索引
* @param value 值
* @return
*/
public
boolean
lUpdateIndex
(
String
key
,
Long
index
,
Object
value
);
/**
* 移除N个值为value
*
* @param key 键
* @param count 移除多少个
* @param value 值
* @return 移除的个数
*/
public
long
lRemove
(
String
key
,
Long
count
,
Object
value
);
}
src/main/java/org/rcisoft/core/service/impl/CyRedisServiceImpl.java
0 → 100644
View file @
059e996e
This diff is collapsed.
Click to expand it.
src/main/resources/application-dev.yml
View file @
059e996e
...
...
@@ -23,6 +23,25 @@ druid:
min-idle
:
1
max-active
:
20
test-on-borrow
:
true
# power:
# url: jdbc:mysql://127.0.0.1:3306/powerstation?useUnicode=true&characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
# username: root
# password: 123456
# initial-size: 1
# min-idle: 1
# max-active: 20
# test-on-borrow: true
# driverClass: com.mysql.jdbc.Driver
# pmiss:
# url: jdbc:mysql://127.0.0.1:3306/powerstation2?useUnicode=true&characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
# username: root
# password: 123456
# initial-size: 1
# min-idle: 1
# max-active: 20
# test-on-borrow: true
# driverClass: com.mysql.jdbc.Driver
mybatis
:
...
...
src/main/resources/templates/codeftl/controller.ftl
View file @
059e996e
...
...
@@ -30,7 +30,7 @@ import java.util.List;
*/
@
RestController
@
RequestMapping
(
"/${table.entityName?lower_case}"
)
public
class
${
table
.
entityName
!}Controller extends PaginationController<${table.entityName!}> {
public
class
${
table
.
entityName
!}Controller extends
Cy
PaginationController<${table.entityName!}> {
@
Autowired
private
${
table
.
entityName
!}Service ${table.entityName?uncap_first}ServiceImpl;
...
...
@@ -39,7 +39,7 @@ public class ${table.entityName!}Controller extends PaginationController<${table
@
ApiOperation
(
value
=
"添加${table.tableRemark!}"
,
notes
=
"添加${table.tableRemark!}"
)
//@
ApiImplicitParams
({@
ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
false
,
dataType
=
"varchar"
)})
@
PostMapping
(
value
=
"/add"
)
public
Result
add
(@
Valid
${
table
.
entityName
!} ${table.entityName?uncap_first}, BindingResult bindingResult) {
public
Cy
Result
add
(@
Valid
${
table
.
entityName
!} ${table.entityName?uncap_first}, BindingResult bindingResult) {
CyPersistModel
data
=
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
save
(${
table
.
entityName
?
uncap_first
});
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
...
...
@@ -50,7 +50,7 @@ public class ${table.entityName!}Controller extends PaginationController<${table
@
ApiOperation
(
value
=
"逻辑删除${table.tableRemark!}"
,
notes
=
"逻辑删除${table.tableRemark!}"
)
@
ApiImplicitParams
({@
ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
)})
@
DeleteMapping
(
"/deleteLogical/{businessId:
\\
w+}"
)
public
Result
deleteLogical
(@
PathVariable
String
businessId
,${
table
.
entityName
!} ${table.entityName?uncap_first}) {
public
Cy
Result
deleteLogical
(@
PathVariable
String
businessId
,${
table
.
entityName
!} ${table.entityName?uncap_first}) {
${
table
.
entityName
?
uncap_first
}.
setBusinessId
(
businessId
);
CyPersistModel
data
=
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
removeLogical
(${
table
.
entityName
?
uncap_first
});
return
CyResultGenUtil
.
builder
(
data
,
...
...
@@ -62,7 +62,7 @@ public class ${table.entityName!}Controller extends PaginationController<${table
@
ApiOperation
(
value
=
"删除${table.tableRemark!}"
,
notes
=
"删除${table.tableRemark!}"
)
@
ApiImplicitParams
({@
ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
)})
@
DeleteMapping
(
"/delete/{businessId:
\\
w+}"
)
public
Result
delete
(@
PathVariable
String
businessId
,${
table
.
entityName
!} ${table.entityName?uncap_first}) {
public
Cy
Result
delete
(@
PathVariable
String
businessId
,${
table
.
entityName
!} ${table.entityName?uncap_first}) {
${
table
.
entityName
?
uncap_first
}.
setBusinessId
(
businessId
);
CyPersistModel
data
=
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
remove
(${
table
.
entityName
?
uncap_first
});
return
CyResultGenUtil
.
builder
(
data
,
...
...
@@ -74,7 +74,7 @@ public class ${table.entityName!}Controller extends PaginationController<${table
@
ApiOperation
(
value
=
"修改${table.tableRemark!}"
,
notes
=
"修改${table.tableRemark!}"
)
@
ApiImplicitParams
({@
ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
false
,
dataType
=
"varchar"
)})
@
PutMapping
(
"/update/{businessId:
\\
w+}"
)
public
Result
update
(@
PathVariable
String
businessId
,
@
Valid
${
table
.
entityName
!} ${table.entityName?uncap_first}, BindingResult bindingResult) {
public
Cy
Result
update
(@
PathVariable
String
businessId
,
@
Valid
${
table
.
entityName
!} ${table.entityName?uncap_first}, BindingResult bindingResult) {
${
table
.
entityName
?
uncap_first
}.
setBusinessId
(
businessId
);
CyPersistModel
data
=
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
merge
(${
table
.
entityName
?
uncap_first
});
return
CyResultGenUtil
.
builder
(
data
,
...
...
@@ -86,8 +86,8 @@ public class ${table.entityName!}Controller extends PaginationController<${table
@
ApiOperation
(
value
=
"查询单一${table.tableRemark!}"
,
notes
=
"查询单一${table.tableRemark!}"
)
@
ApiImplicitParams
({@
ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
)})
@
GetMapping
(
"/detail/{businessId:
\\
w+}"
)
public
Result
detail
(@
PathVariable
String
businessId
)
{
return
CyResultGenUtil
.
builder
(
new
PersistModel
(
1
),
public
Cy
Result
detail
(@
PathVariable
String
businessId
)
{
return
CyResultGenUtil
.
builder
(
new
Cy
PersistModel
(
1
),
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
findById
(
businessId
));
...
...
@@ -95,8 +95,8 @@ public class ${table.entityName!}Controller extends PaginationController<${table
@
ApiOperation
(
value
=
"查询${table.tableRemark!}集合"
,
notes
=
"查询${table.tableRemark!}集合"
)
@
GetMapping
(
value
=
"/query${table.entityName!}s"
)
public
Result
query
${
table
.
entityName
!}s(${table.entityName!} ${table.entityName?uncap_first}) {
return
ResultGenerator
.
builder
(
new
PersistModel
(
1
),
public
Cy
Result
query
${
table
.
entityName
!}s(${table.entityName!} ${table.entityName?uncap_first}) {
return
CyResultGenUtil
.
builder
(
new
Cy
PersistModel
(
1
),
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
findAll
(${
table
.
entityName
?
uncap_first
}));
...
...
@@ -104,7 +104,7 @@ public class ${table.entityName!}Controller extends PaginationController<${table
@
ApiOperation
(
value
=
"分页查询${table.tableRemark!}集合"
,
notes
=
"分页查询${table.tableRemark!}集合"
)
@
GetMapping
(
value
=
"/query${table.entityName!}ByPagination"
)
public
GridModel
listByPagination
(${
table
.
entityName
!} ${table.entityName?uncap_first}) {
public
Cy
GridModel
listByPagination
(${
table
.
entityName
!} ${table.entityName?uncap_first}) {
${
table
.
entityName
?
uncap_first
}
ServiceImpl
.
findAllByPagination
(
getPaginationUtility
(),
${
table
.
entityName
?
uncap_first
});
return
getGridModelResponse
();
}
...
...
src/main/resources/templates/codeftl/mapper.ftl
View file @
059e996e
...
...
@@ -4,10 +4,13 @@
<resultMap
id=
"BaseResultMap"
type=
"org.rcisoft.business.${table.entityName?lower_case}.entity.${table.entityName}"
>
<
#list table.columnModels as item>
<
#if item.isKey>
<id
column=
"${item.colName!}"
jdbcType=
"${item.typeNameUpper}"
property=
"${item.columnNameLowerCamel}"
/>
<id
column=
"${item.colName!}"
jdbcType=
"${item.typeNameUpper}"
property=
"${item.columnNameLowerCamel}"
/>
<
/#if>
<
/#list>
<
#list table.columnModels as item>
<
#if !item.isKey>
<cyR
esult
column=
"${item.colName!}"
jdbcType=
"${item.typeNameUpper}"
property=
"${item.columnNameLowerCamel}"
/>
<r
esult
column=
"${item.colName!}"
jdbcType=
"${item.typeNameUpper}"
property=
"${item.columnNameLowerCamel}"
/>
<
/#if>
<
/#list>
</resultMap>
...
...
src/main/resources/templates/codeftl/serviceimpl.ftl
View file @
059e996e
...
...
@@ -107,7 +107,7 @@ public class ${table.entityName!}ServiceImpl implements ${table.entityName!}Serv
*
@
return
*/
@
Override
public
List
<${
table
.
entityName
!}> findAllByPagination(PageUtil<${table.entityName!}> paginationUtility,
public
List
<${
table
.
entityName
!}> findAllByPagination(
Cy
PageUtil<${table.entityName!}> paginationUtility,
${
table
.
entityName
!} ${table.entityName?uncap_first}){
${
table
.
entityName
?
uncap_first
}.
setStart
();
${
table
.
entityName
?
uncap_first
}.
setNotDeleted
();
...
...
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