Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
loit-seata-order-example
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
loit-Infrastructure-example
loit-seata-order-example
Commits
f38e9686
提交
f38e9686
authored
3月 04, 2020
作者:
陈世营
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【修改】公共common
上级
747232ef
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
369 行增加
和
25 行删除
+369
-25
.gitignore
.gitignore
+0
-1
pom.xml
loit-seata-order-example-dependencies/pom.xml
+1
-13
pom.xml
loit-seata-order-example-main/pom.xml
+0
-9
BaseResponse.java
...main/java/com/loit/build/spi/common/dto/BaseResponse.java
+54
-0
PageFeign.java
...rc/main/java/com/loit/build/spi/common/dto/PageFeign.java
+41
-0
ResponseStatusEnum.java
...ava/com/loit/build/spi/common/dto/ResponseStatusEnum.java
+30
-0
BusinessException.java
...om/loit/build/spi/common/exception/BusinessException.java
+85
-0
package-info.java
...src/main/java/com/loit/build/spi/common/package-info.java
+2
-0
RangeParam.java
...java/com/loit/build/web/common/annotation/RangeParam.java
+15
-0
ArgumentInvalidResult.java
...uild/web/common/exception/base/ArgumentInvalidResult.java
+22
-0
package-info.java
...src/main/java/com/loit/build/web/common/package-info.java
+2
-0
HttpUtil.java
...c/main/java/com/loit/build/web/common/utils/HttpUtil.java
+115
-0
file.conf
loit-seata-order-example-main/src/main/resources/file.conf
+2
-2
没有找到文件。
.gitignore
浏览文件 @
f38e9686
...
...
@@ -25,7 +25,6 @@ target/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/
loit-seata-order-example-dependencies/pom.xml
浏览文件 @
f38e9686
...
...
@@ -30,9 +30,6 @@
<modelmapper.version>
1.1.0
</modelmapper.version>
<spring-tuple.version>
1.0.0.RELEASE
</spring-tuple.version>
<loit-build-spi-common.version>
1.0-SNAPSHOT
</loit-build-spi-common.version>
<loit-build-web-common.version>
1.0-SNAPSHOT
</loit-build-web-common.version>
</properties>
...
...
@@ -41,16 +38,7 @@
<dependencies>
<!--Own dependencies -->
<dependency>
<groupId>
com.timeloit.project
</groupId>
<artifactId>
loit-build-spi-common
</artifactId>
<version>
${loit-build-spi-common.version}
</version>
</dependency>
<dependency>
<groupId>
com.timeloit.project
</groupId>
<artifactId>
loit-build-web-common
</artifactId>
<version>
${loit-build-web-common.version}
</version>
</dependency>
<dependency>
<groupId>
com.timeloit.project
</groupId>
...
...
loit-seata-order-example-main/pom.xml
浏览文件 @
f38e9686
...
...
@@ -14,15 +14,6 @@
<dependencies>
<dependency>
<groupId>
com.timeloit.project
</groupId>
<artifactId>
loit-build-spi-common
</artifactId>
</dependency>
<dependency>
<groupId>
com.timeloit.project
</groupId>
<artifactId>
loit-build-web-common
</artifactId>
</dependency>
<!--common-->
<dependency>
...
...
loit-seata-order-example-main/src/main/java/com/loit/build/spi/common/dto/BaseResponse.java
0 → 100644
浏览文件 @
f38e9686
package
com
.
loit
.
build
.
spi
.
common
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.HashMap
;
import
java.util.Map
;
@Data
@ApiModel
(
value
=
"响应消息类"
)
public
class
BaseResponse
<
T
>
{
@ApiModelProperty
(
value
=
"响应码"
,
required
=
true
)
private
String
code
;
@ApiModelProperty
(
value
=
"响应消息"
,
required
=
true
)
private
String
message
;
@ApiModelProperty
(
value
=
"返回数据"
)
private
T
data
;
private
Map
<
String
,
T
>
properties
=
new
HashMap
<>();
public
BaseResponse
()
{
}
public
BaseResponse
(
String
code
,
String
message
,
T
data
)
{
this
.
code
=
code
;
this
.
message
=
message
;
this
.
data
=
data
;
}
public
static
BaseResponse
<
Object
>
ofMessage
(
String
code
,
String
message
)
{
return
new
BaseResponse
<>(
code
,
message
,
null
);
}
public
static
BaseResponse
<
Object
>
ofSuccess
(
Object
data
)
{
return
new
BaseResponse
<>(
ResponseStatusEnum
.
SUCCESS
.
getCode
(),
ResponseStatusEnum
.
SUCCESS
.
getMessage
(),
data
);
}
public
static
BaseResponse
<
Object
>
ofSuccess
(
Object
data
,
String
message
)
{
return
new
BaseResponse
<>(
ResponseStatusEnum
.
SUCCESS
.
getCode
(),
message
,
data
);
}
public
static
BaseResponse
<
Object
>
ofStatus
(
ResponseStatusEnum
status
)
{
return
new
BaseResponse
<>(
status
.
getCode
(),
status
.
getMessage
(),
null
);
}
public
BaseResponse
addProperties
(
String
key
,
T
value
)
{
this
.
properties
.
put
(
key
,
value
);
return
this
;
}
}
loit-seata-order-example-main/src/main/java/com/loit/build/spi/common/dto/PageFeign.java
0 → 100644
浏览文件 @
f38e9686
package
com
.
loit
.
build
.
spi
.
common
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel
(
"分页数据"
)
public
class
PageFeign
<
T
>
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
List
<
T
>
content
=
new
ArrayList
<>();
@ApiModelProperty
(
value
=
"是否最后一页"
)
private
boolean
last
;
private
int
totalPages
;
@ApiModelProperty
(
value
=
"总条数"
)
private
int
totalElements
;
@ApiModelProperty
(
value
=
"当前页的条数"
)
private
int
numberOfElements
;
@ApiModelProperty
(
value
=
"每页显示条数"
)
private
int
size
;
@ApiModelProperty
(
value
=
"当前页码"
)
private
int
number
;
}
loit-seata-order-example-main/src/main/java/com/loit/build/spi/common/dto/ResponseStatusEnum.java
0 → 100644
浏览文件 @
f38e9686
package
com
.
loit
.
build
.
spi
.
common
.
dto
;
public
enum
ResponseStatusEnum
{
SUCCESS
(
"success"
,
"成功"
),
PARAMETER_ERROR
(
"parameter.error"
,
"参数错误"
),
PARAMETER_VALIDATION
(
"parameter.validation"
,
"参数验证失败-{0}"
),
DATA_INPUT_ERROR
(
"data.input.error"
,
"数据未输入"
),
DATA_CREATE_FAILURE
(
"data.create.failure"
,
"新增数据失败"
),
DATA_QUERY_FAILURE
(
"data.query.failure"
,
"查询数据失败"
),
DATA_UPDATE_FAILURE
(
"data.update.failure"
,
"更新数据失败"
),
DATA_DELETE_FAILURE
(
"data.delete.failure"
,
"删除数据失败"
),
FALL_BACK
(
"fall.back"
,
"异常发生,进入fallback方法,接收的参数"
);
private
String
code
;
private
String
message
;
ResponseStatusEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getMessage
()
{
return
message
;
}
}
loit-seata-order-example-main/src/main/java/com/loit/build/spi/common/exception/BusinessException.java
0 → 100644
浏览文件 @
f38e9686
package
com
.
loit
.
build
.
spi
.
common
.
exception
;
/**
* 基础异常
*/
public
class
BusinessException
extends
RuntimeException
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
//所属模块
private
String
module
;
/**
* 错误码
*/
private
String
code
;
/**
* Ba
* 错误码对应的参数
*/
private
Object
[]
args
;
/**
* 错误消息
*/
private
String
defaultMessage
;
public
BusinessException
(
String
module
,
String
code
,
Object
[]
args
,
String
defaultMessage
)
{
this
.
module
=
module
;
this
.
code
=
code
;
this
.
args
=
args
;
this
.
defaultMessage
=
defaultMessage
;
}
public
BusinessException
(
String
module
,
String
code
,
Object
[]
args
)
{
this
(
module
,
code
,
args
,
null
);
}
public
BusinessException
(
String
module
,
String
defaultMessage
)
{
this
(
module
,
null
,
null
,
defaultMessage
);
}
public
BusinessException
(
String
code
,
Object
[]
args
)
{
this
(
null
,
code
,
args
,
null
);
}
public
BusinessException
(
String
defaultMessage
)
{
this
(
null
,
null
,
null
,
defaultMessage
);
}
public
String
getModule
()
{
return
module
;
}
public
String
getCode
()
{
return
code
;
}
public
Object
[]
getArgs
()
{
return
args
;
}
public
String
getDefaultMessage
()
{
return
defaultMessage
;
}
public
String
getMessage
()
{
return
defaultMessage
;
}
@Override
public
String
toString
()
{
return
this
.
getClass
()
+
"{"
+
"module='"
+
module
+
'\''
+
", message='"
+
getMessage
()
+
'\''
+
'}'
;
}
}
loit-seata-order-example-main/src/main/java/com/loit/build/spi/common/package-info.java
0 → 100644
浏览文件 @
f38e9686
package
com
.
loit
.
build
.
spi
.
common
;
\ No newline at end of file
loit-seata-order-example-main/src/main/java/com/loit/build/web/common/annotation/RangeParam.java
0 → 100644
浏览文件 @
f38e9686
package
com
.
loit
.
build
.
web
.
common
.
annotation
;
import
java.lang.annotation.*
;
@Target
({
ElementType
.
PARAMETER
,
ElementType
.
ANNOTATION_TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
RangeParam
{
String
value
();
Class
<?>
elementClass
()
default
Object
.
class
;
String
split
()
default
" - "
;
}
loit-seata-order-example-main/src/main/java/com/loit/build/web/common/exception/base/ArgumentInvalidResult.java
0 → 100644
浏览文件 @
f38e9686
package
com
.
loit
.
build
.
web
.
common
.
exception
.
base
;
import
lombok.Data
;
/**
* 参数验证异常结果
*/
@Data
public
class
ArgumentInvalidResult
{
/**
* 字段名
*/
private
String
field
;
private
Object
rejectedValue
;
/**
* 默认消息
*/
private
String
defaultMessage
;
}
loit-seata-order-example-main/src/main/java/com/loit/build/web/common/package-info.java
0 → 100644
浏览文件 @
f38e9686
package
com
.
loit
.
build
.
web
.
common
;
\ No newline at end of file
loit-seata-order-example-main/src/main/java/com/loit/build/web/common/utils/HttpUtil.java
0 → 100644
浏览文件 @
f38e9686
package
com
.
loit
.
build
.
web
.
common
.
utils
;
import
lombok.extern.slf4j.Slf4j
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.util.Collection
;
import
java.util.Enumeration
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* Http 工具类
* 用于对HttpServletRequest或HttpServletResponse进行操作
*/
@Slf4j
public
class
HttpUtil
{
private
static
final
Pattern
PATTERN_HEADER
=
Pattern
.
compile
(
"(^|-)([a-zA-Z])([a-zA-Z]*)"
);
/**
* 转换 Http 请求头 或 响应头
*
* @param headerName
* @return
*/
public
static
String
convertHeaderName
(
String
headerName
)
{
Matcher
matcher
=
PATTERN_HEADER
.
matcher
(
headerName
);
StringBuffer
sb
=
new
StringBuffer
();
while
(
matcher
.
find
())
{
matcher
.
appendReplacement
(
sb
,
matcher
.
group
(
1
)
+
matcher
.
group
(
2
).
toUpperCase
()
+
matcher
.
group
(
3
).
toLowerCase
());
}
matcher
.
appendTail
(
sb
);
return
sb
.
toString
();
}
/**
* 打印请求参数
*
* @param request
*/
public
static
void
printRequestParameter
(
HttpServletRequest
request
)
{
request
.
getParameterMap
().
forEach
((
k
,
v
)
->
log
.
info
(
" {}=\"{}\""
,
k
,
request
.
getParameter
(
k
)
)
);
}
/**
* 打印请求头
*
* @param request
*/
public
static
void
printRequestHeader
(
HttpServletRequest
request
)
{
Enumeration
<
String
>
headerNames
=
request
.
getHeaderNames
();
while
(
headerNames
.
hasMoreElements
())
{
String
key
=
headerNames
.
nextElement
();
log
.
info
(
" {}: \"{}\""
,
convertHeaderName
(
key
),
request
.
getHeader
(
key
)
);
}
}
/**
* 打印响应头
*
* @param response
*/
public
static
void
printResponseHeader
(
HttpServletResponse
response
)
{
Collection
<
String
>
headerNames
=
response
.
getHeaderNames
();
headerNames
.
forEach
(
key
->
log
.
info
(
" {}: \"{}\""
,
convertHeaderName
(
key
),
response
.
getHeader
(
key
)
)
);
}
/**
* 打印cookie
*
* @param request
*/
public
static
void
printRequestCookie
(
HttpServletRequest
request
)
{
Cookie
[]
cookies
=
request
.
getCookies
();
if
(
null
==
cookies
)
{
return
;
}
for
(
Cookie
cookie
:
cookies
)
{
try
{
log
.
info
(
" {Domain:{}, Path:{}, Name:{}, Value:{}, MaxAge:{}, Comment:{}, Version:{}, Secure:{}}"
,
cookie
.
getDomain
(),
cookie
.
getPath
(),
cookie
.
getName
(),
null
!=
cookie
.
getValue
()
?
URLDecoder
.
decode
(
cookie
.
getValue
(),
"UTF-8"
)
:
null
,
cookie
.
getMaxAge
(),
cookie
.
getComment
(),
cookie
.
getVersion
(),
cookie
.
getSecure
()
);
}
catch
(
UnsupportedEncodingException
e
)
{
log
.
error
(
"不支持的编码"
,
e
);
}
}
}
}
loit-seata-order-example-main/src/main/resources/file.conf
浏览文件 @
f38e9686
...
...
@@ -94,9 +94,9 @@ store {
## mysql/oracle/h2/oceanbase etc.
db
-
type
=
"mysql"
driver
-
class
-
name
=
"com.mysql.jdbc.Driver"
url
=
"jdbc:mysql://
39.98.202.173:3306
/seata_server"
url
=
"jdbc:mysql://
192.168.66.40:3321
/seata_server"
user
=
"root"
password
=
"
abcd1234A!
"
password
=
"
loit2019ABC
"
min
-
conn
=
1
max
-
conn
=
10
global
.
table
=
"global_table"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论