Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
e3c3ebb1
"...admin-console/src/main/resources/sql/console/dict.md" did not exist on "321361c91faf4b022639b8afaadd728ed12dc0c5"
Commit
e3c3ebb1
authored
Oct 24, 2019
by
dqjdda
Browse files
代码优化
parents
78f08353
f0211db0
Changes
58
Show whitespace changes
Inline
Side-by-side
eladmin-common/src/main/java/me/zhengjie/utils/ThrowableUtil.java
View file @
e3c3ebb1
...
@@ -2,30 +2,23 @@ package me.zhengjie.utils;
...
@@ -2,30 +2,23 @@ package me.zhengjie.utils;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.exception.BadRequestException
;
import
org.hibernate.exception.ConstraintViolationException
;
import
org.hibernate.exception.ConstraintViolationException
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
/**
/**
* 异常工具
* 异常工具
2019-01-06
* @author Zheng Jie
* @author Zheng Jie
* @date 2019-01-06
*/
*/
public
class
ThrowableUtil
{
public
class
ThrowableUtil
{
/**
/**
* 获取堆栈信息
* 获取堆栈信息
* @param throwable
* @return
*/
*/
public
static
String
getStackTrace
(
Throwable
throwable
){
public
static
String
getStackTrace
(
Throwable
throwable
){
StringWriter
sw
=
new
StringWriter
();
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
try
(
PrintWriter
pw
=
new
PrintWriter
(
sw
))
{
try
{
throwable
.
printStackTrace
(
pw
);
throwable
.
printStackTrace
(
pw
);
return
sw
.
toString
();
return
sw
.
toString
();
}
finally
{
pw
.
close
();
}
}
}
}
...
@@ -34,9 +27,10 @@ public class ThrowableUtil {
...
@@ -34,9 +27,10 @@ public class ThrowableUtil {
while
((
t
!=
null
)
&&
!(
t
instanceof
ConstraintViolationException
))
{
while
((
t
!=
null
)
&&
!(
t
instanceof
ConstraintViolationException
))
{
t
=
t
.
getCause
();
t
=
t
.
getCause
();
}
}
if
(
t
instanceof
ConstraintViolationException
)
{
if
(
t
!=
null
)
{
throw
new
BadRequestException
(
msg
);
throw
new
BadRequestException
(
msg
);
}
}
assert
false
;
throw
new
BadRequestException
(
"删除失败:"
+
t
.
getMessage
());
throw
new
BadRequestException
(
"删除失败:"
+
t
.
getMessage
());
}
}
}
}
eladmin-common/src/main/java/me/zhengjie/utils/TranslatorUtil.java
View file @
e3c3ebb1
package
me.zhengjie.utils
;
package
me.zhengjie.utils
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONArray
;
import
lombok.var
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
...
@@ -26,7 +24,7 @@ public class TranslatorUtil {
...
@@ -26,7 +24,7 @@ public class TranslatorUtil {
BufferedReader
in
=
new
BufferedReader
(
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
con
.
getInputStream
()));
new
InputStreamReader
(
con
.
getInputStream
()));
String
inputLine
;
String
inputLine
;
StringBu
ff
er
response
=
new
StringBu
ff
er
();
StringBu
ild
er
response
=
new
StringBu
ild
er
();
while
((
inputLine
=
in
.
readLine
())
!=
null
)
{
while
((
inputLine
=
in
.
readLine
())
!=
null
)
{
response
.
append
(
inputLine
);
response
.
append
(
inputLine
);
...
@@ -39,14 +37,11 @@ public class TranslatorUtil {
...
@@ -39,14 +37,11 @@ public class TranslatorUtil {
}
}
private
static
String
parseResult
(
String
inputJson
)
throws
Exception
{
private
static
String
parseResult
(
String
inputJson
)
throws
Exception
{
JSONArray
jsonArray
=
new
JSONArray
(
inputJson
);
JSONArray
jsonArray2
=
(
JSONArray
)
new
JSONArray
(
inputJson
).
get
(
0
);
JSONArray
jsonArray2
=
(
JSONArray
)
jsonArray
.
get
(
0
);
StringBuilder
result
=
new
StringBuilder
();
String
result
=
""
;
for
(
Object
o
:
jsonArray2
)
{
result
.
append
(((
JSONArray
)
o
).
get
(
0
).
toString
());
for
(
var
i
=
0
;
i
<
jsonArray2
.
size
();
i
++){
result
+=
((
JSONArray
)
jsonArray2
.
get
(
i
)).
get
(
0
).
toString
();
}
}
return
result
;
return
result
.
toString
()
;
}
}
}
}
eladmin-common/src/main/java/me/zhengjie/utils/ValidationUtil.java
View file @
e3c3ebb1
...
@@ -12,7 +12,6 @@ public class ValidationUtil{
...
@@ -12,7 +12,6 @@ public class ValidationUtil{
/**
/**
* 验证空
* 验证空
* @param optional
*/
*/
public
static
void
isNull
(
Optional
optional
,
String
entity
,
String
parameter
,
Object
value
){
public
static
void
isNull
(
Optional
optional
,
String
entity
,
String
parameter
,
Object
value
){
if
(!
optional
.
isPresent
()){
if
(!
optional
.
isPresent
()){
...
@@ -25,14 +24,12 @@ public class ValidationUtil{
...
@@ -25,14 +24,12 @@ public class ValidationUtil{
/**
/**
* 验证是否为邮箱
* 验证是否为邮箱
* @param string
* @return
*/
*/
public
static
boolean
isEmail
(
String
string
)
{
public
static
boolean
isEmail
(
String
string
)
{
if
(
string
==
null
){
if
(
string
==
null
){
return
false
;
return
false
;
}
}
String
regEx1
=
"^([a-z0-9A-Z]+[-|
\\
.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"
;
String
regEx1
=
"^([a-z0-9A-Z]+[-|.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"
;
return
string
.
matches
(
regEx1
);
return
string
.
matches
(
regEx1
);
}
}
}
}
eladmin-system/src/main/resources/config/application.yml
View file @
e3c3ebb1
...
@@ -22,7 +22,7 @@ spring:
...
@@ -22,7 +22,7 @@ spring:
redis
:
redis
:
#数据库索引
#数据库索引
database
:
0
database
:
1
host
:
127.0.0.1
host
:
127.0.0.1
port
:
6379
port
:
6379
password
:
password
:
...
...
eladmin-system/src/test/java/me/zhengjie/EladminSystemApplicationTests.java
View file @
e3c3ebb1
...
@@ -11,6 +11,7 @@ public class EladminSystemApplicationTests {
...
@@ -11,6 +11,7 @@ public class EladminSystemApplicationTests {
@Test
@Test
public
void
contextLoads
()
{
public
void
contextLoads
()
{
}
}
}
}
...
...
eladmin-tools/src/main/java/me/zhengjie/domain/AlipayConfig.java
View file @
e3c3ebb1
...
@@ -18,66 +18,46 @@ public class AlipayConfig implements Serializable {
...
@@ -18,66 +18,46 @@ public class AlipayConfig implements Serializable {
@Id
@Id
private
Long
id
;
private
Long
id
;
/**
// 应用ID,APPID,收款账号既是APPID对应支付宝账号
* 应用ID,APPID,收款账号既是APPID对应支付宝账号
*/
@NotBlank
@NotBlank
@Column
(
name
=
"app_id"
)
@Column
(
name
=
"app_id"
)
private
String
appID
;
private
String
appID
;
/**
// 商户私钥,您的PKCS8格式RSA2私钥
* 商户私钥,您的PKCS8格式RSA2私钥
*/
@NotBlank
@NotBlank
@Column
(
name
=
"private_key"
,
columnDefinition
=
"text"
)
@Column
(
name
=
"private_key"
,
columnDefinition
=
"text"
)
private
String
privateKey
;
private
String
privateKey
;
/**
// 支付宝公钥
* 支付宝公钥
*/
@NotBlank
@NotBlank
@Column
(
name
=
"public_key"
,
columnDefinition
=
"text"
)
@Column
(
name
=
"public_key"
,
columnDefinition
=
"text"
)
private
String
publicKey
;
private
String
publicKey
;
/**
// 签名方式,固定格式
* 签名方式,固定格式
*/
@Column
(
name
=
"sign_type"
)
@Column
(
name
=
"sign_type"
)
private
String
signType
=
"RSA2"
;
private
String
signType
=
"RSA2"
;
/**
// 支付宝开放安全地址,一般不会变
* 支付宝开放安全地址,一般不会变
*/
@Column
(
name
=
"gateway_url"
)
@Column
(
name
=
"gateway_url"
)
private
String
gatewayUrl
=
"https://openapi.alipaydev.com/gateway.do"
;
private
String
gatewayUrl
=
"https://openapi.alipaydev.com/gateway.do"
;
/**
// 编码,固定格式
* 编码,固定格式
*/
private
String
charset
=
"utf-8"
;
private
String
charset
=
"utf-8"
;
/**
// 异步通知地址
* 异步通知地址
*/
@NotBlank
@NotBlank
@Column
(
name
=
"notify_url"
)
@Column
(
name
=
"notify_url"
)
private
String
notifyUrl
;
private
String
notifyUrl
;
/**
// 订单完成后返回的页面
* 订单完成后返回的页面
*/
@NotBlank
@NotBlank
@Column
(
name
=
"return_url"
)
@Column
(
name
=
"return_url"
)
private
String
returnUrl
;
private
String
returnUrl
;
/**
// 类型,固定格式
* 类型,固定格式
*/
private
String
format
=
"JSON"
;
private
String
format
=
"JSON"
;
/**
// 商户号
* 商户号
*/
@NotBlank
@NotBlank
@Column
(
name
=
"sys_service_provider_id"
)
@Column
(
name
=
"sys_service_provider_id"
)
private
String
sysServiceProviderId
;
private
String
sysServiceProviderId
;
...
...
eladmin-tools/src/main/java/me/zhengjie/domain/EmailConfig.java
View file @
e3c3ebb1
...
@@ -19,30 +19,22 @@ public class EmailConfig implements Serializable {
...
@@ -19,30 +19,22 @@ public class EmailConfig implements Serializable {
@Id
@Id
private
Long
id
;
private
Long
id
;
/**
// 邮件服务器SMTP地址
*邮件服务器SMTP地址
*/
@NotBlank
@NotBlank
private
String
host
;
private
String
host
;
/**
// 邮件服务器SMTP端口
* 邮件服务器SMTP端口
*/
@NotBlank
@NotBlank
private
String
port
;
private
String
port
;
/**
// 发件者用户名,默认为发件人邮箱前缀
* 发件者用户名,默认为发件人邮箱前缀
*/
@NotBlank
@NotBlank
private
String
user
;
private
String
user
;
@NotBlank
@NotBlank
private
String
pass
;
private
String
pass
;
/**
// 收件人
* 收件人
*/
@NotBlank
@NotBlank
@Column
(
name
=
"from_user"
)
@Column
(
name
=
"from_user"
)
private
String
fromUser
;
private
String
fromUser
;
...
...
eladmin-tools/src/main/java/me/zhengjie/domain/Picture.java
View file @
e3c3ebb1
...
@@ -32,9 +32,6 @@ public class Picture implements Serializable {
...
@@ -32,9 +32,6 @@ public class Picture implements Serializable {
private
String
width
;
private
String
width
;
/**
* delete URl
*/
@Column
(
name
=
"delete_url"
)
@Column
(
name
=
"delete_url"
)
private
String
delete
;
private
String
delete
;
...
...
eladmin-tools/src/main/java/me/zhengjie/domain/QiniuConfig.java
View file @
e3c3ebb1
...
@@ -18,23 +18,17 @@ public class QiniuConfig implements Serializable {
...
@@ -18,23 +18,17 @@ public class QiniuConfig implements Serializable {
@Id
@Id
private
Long
id
;
private
Long
id
;
/**
// 一个账号最多拥有两对密钥(Access/Secret Key)
* 一个账号最多拥有两对密钥(Access/Secret Key)
*/
@NotBlank
@NotBlank
@Column
(
name
=
"access_key"
,
columnDefinition
=
"text"
)
@Column
(
name
=
"access_key"
,
columnDefinition
=
"text"
)
private
String
accessKey
;
private
String
accessKey
;
/**
// 一个账号最多拥有两对密钥(Access/Secret Key)
* 一个账号最多拥有两对密钥(Access/Secret Key)
*/
@NotBlank
@NotBlank
@Column
(
name
=
"secret_key"
,
columnDefinition
=
"text"
)
@Column
(
name
=
"secret_key"
,
columnDefinition
=
"text"
)
private
String
secretKey
;
private
String
secretKey
;
/**
// 存储空间名称作为唯一的 Bucket 识别符
* 存储空间名称作为唯一的 Bucket 识别符
*/
@NotBlank
@NotBlank
private
String
bucket
;
private
String
bucket
;
...
@@ -49,14 +43,10 @@ public class QiniuConfig implements Serializable {
...
@@ -49,14 +43,10 @@ public class QiniuConfig implements Serializable {
@NotBlank
@NotBlank
private
String
zone
;
private
String
zone
;
/**
// 外链域名,可自定义,需在七牛云绑定
* 外链域名,可自定义,需在七牛云绑定
*/
@NotBlank
@NotBlank
private
String
host
;
private
String
host
;
/**
// 空间类型:公开/私有
* 空间类型:公开/私有
*/
private
String
type
=
"公开"
;
private
String
type
=
"公开"
;
}
}
eladmin-tools/src/main/java/me/zhengjie/domain/QiniuContent.java
View file @
e3c3ebb1
...
@@ -21,37 +21,25 @@ public class QiniuContent implements Serializable {
...
@@ -21,37 +21,25 @@ public class QiniuContent implements Serializable {
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
private
Long
id
;
/**
// 文件名
* 文件名,如qiniu.jpg
*/
@Column
(
name
=
"name"
,
unique
=
false
)
@Column
(
name
=
"name"
,
unique
=
false
)
private
String
key
;
private
String
key
;
/**
// 空间名
* 空间名
*/
private
String
bucket
;
private
String
bucket
;
/**
// 大小
* 大小
*/
private
String
size
;
private
String
size
;
/**
// 文件地址
* 文件地址
*/
private
String
url
;
private
String
url
;
private
String
suffix
;
private
String
suffix
;
/**
// 空间类型:公开/私有
* 空间类型:公开/私有
*/
private
String
type
=
"公开"
;
private
String
type
=
"公开"
;
/**
// 更新时间
* 更新时间
*/
@UpdateTimestamp
@UpdateTimestamp
@Column
(
name
=
"update_time"
)
@Column
(
name
=
"update_time"
)
private
Timestamp
updateTime
;
private
Timestamp
updateTime
;
...
...
eladmin-tools/src/main/java/me/zhengjie/domain/VerificationCode.java
View file @
e3c3ebb1
...
@@ -26,32 +26,21 @@ public class VerificationCode {
...
@@ -26,32 +26,21 @@ public class VerificationCode {
private
String
code
;
private
String
code
;
/**
// 使用场景,自己定义
* 使用场景,自己定义
*/
private
String
scenes
;
private
String
scenes
;
/**
// true 为有效,false 为无效,验证时状态+时间+具体的邮箱或者手机号
* true 为有效,false 为无效,验证时状态+时间+具体的邮箱或者手机号
*/
private
Boolean
status
=
true
;
private
Boolean
status
=
true
;
// 类型 :phone 和 email
/**
* 类型 :phone 和 email
*/
@NotBlank
@NotBlank
private
String
type
;
private
String
type
;
/**
// 具体的phone与email
* 具体的phone与email
*/
@NotBlank
@NotBlank
private
String
value
;
private
String
value
;
/**
// 创建日期
* 创建日期
*/
@CreationTimestamp
@CreationTimestamp
@Column
(
name
=
"create_time"
)
@Column
(
name
=
"create_time"
)
private
Timestamp
createTime
;
private
Timestamp
createTime
;
...
...
eladmin-tools/src/main/java/me/zhengjie/domain/vo/EmailVo.java
View file @
e3c3ebb1
...
@@ -18,9 +18,7 @@ import java.util.List;
...
@@ -18,9 +18,7 @@ import java.util.List;
@NoArgsConstructor
@NoArgsConstructor
public
class
EmailVo
{
public
class
EmailVo
{
/**
// 收件人,支持多个收件人,用逗号分隔
* 收件人,支持多个收件人,用逗号分隔
*/
@NotEmpty
@NotEmpty
private
List
<
String
>
tos
;
private
List
<
String
>
tos
;
...
...
eladmin-tools/src/main/java/me/zhengjie/domain/vo/TradeVo.java
View file @
e3c3ebb1
...
@@ -15,51 +15,35 @@ import java.sql.Timestamp;
...
@@ -15,51 +15,35 @@ import java.sql.Timestamp;
@Data
@Data
public
class
TradeVo
{
public
class
TradeVo
{
/**
// (必填)商品描述
* (必填)商品描述
*/
@NotBlank
@NotBlank
private
String
body
;
private
String
body
;
/**
// (必填)商品名称
* (必填)商品名称
*/
@NotBlank
@NotBlank
private
String
subject
;
private
String
subject
;
/**
// (必填)商户订单号,应该由后台生成
* (必填)商户订单号,应该由后台生成
*/
@ApiModelProperty
(
hidden
=
true
)
@ApiModelProperty
(
hidden
=
true
)
private
String
outTradeNo
;
private
String
outTradeNo
;
/**
// (必填)第三方订单号
* (必填)第三方订单号
*/
@ApiModelProperty
(
hidden
=
true
)
@ApiModelProperty
(
hidden
=
true
)
private
String
tradeNo
;
private
String
tradeNo
;
/**
// (必填)价格
* (必填)价格
*/
@NotBlank
@NotBlank
private
String
totalAmount
;
private
String
totalAmount
;
/**
// 订单状态,已支付,未支付,作废
* 订单状态,已支付,未支付,作废
*/
@ApiModelProperty
(
hidden
=
true
)
@ApiModelProperty
(
hidden
=
true
)
private
String
state
;
private
String
state
;
/**
// 创建时间,存入数据库时需要
* 创建时间,存入数据库时需要
*/
@ApiModelProperty
(
hidden
=
true
)
@ApiModelProperty
(
hidden
=
true
)
private
Timestamp
createTime
;
private
Timestamp
createTime
;
/**
// 作废时间,存入数据库时需要
* 作废时间,存入数据库时需要
*/
@ApiModelProperty
(
hidden
=
true
)
@ApiModelProperty
(
hidden
=
true
)
private
Date
cancelTime
;
private
Date
cancelTime
;
}
}
eladmin-tools/src/main/java/me/zhengjie/repository/LocalStorageRepository.java
View file @
e3c3ebb1
...
@@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
...
@@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @author Zheng Jie
* @author Zheng Jie
* @date 2019-09-05
* @date 2019-09-05
*/
*/
public
interface
LocalStorageRepository
extends
JpaRepository
<
LocalStorage
,
Long
>,
JpaSpecificationExecutor
{
public
interface
LocalStorageRepository
extends
JpaRepository
<
LocalStorage
,
Long
>,
JpaSpecificationExecutor
<
LocalStorage
>
{
}
}
\ No newline at end of file
eladmin-tools/src/main/java/me/zhengjie/repository/PictureRepository.java
View file @
e3c3ebb1
...
@@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
...
@@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @author Zheng Jie
* @author Zheng Jie
* @date 2018-12-27
* @date 2018-12-27
*/
*/
public
interface
PictureRepository
extends
JpaRepository
<
Picture
,
Long
>,
JpaSpecificationExecutor
{
public
interface
PictureRepository
extends
JpaRepository
<
Picture
,
Long
>,
JpaSpecificationExecutor
<
Picture
>
{
}
}
eladmin-tools/src/main/java/me/zhengjie/repository/QiNiuConfigRepository.java
View file @
e3c3ebb1
...
@@ -12,6 +12,6 @@ import org.springframework.data.jpa.repository.Query;
...
@@ -12,6 +12,6 @@ import org.springframework.data.jpa.repository.Query;
public
interface
QiNiuConfigRepository
extends
JpaRepository
<
QiniuConfig
,
Long
>
{
public
interface
QiNiuConfigRepository
extends
JpaRepository
<
QiniuConfig
,
Long
>
{
@Modifying
@Modifying
@Query
(
value
=
"update
q
iniu
_content
set type = ?1"
,
nativeQuery
=
true
)
@Query
(
value
=
"update
Q
iniu
Config
set type = ?1"
)
void
update
(
String
type
);
void
update
(
String
type
);
}
}
eladmin-tools/src/main/java/me/zhengjie/repository/QiniuContentRepository.java
View file @
e3c3ebb1
...
@@ -8,12 +8,12 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
...
@@ -8,12 +8,12 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @author Zheng Jie
* @author Zheng Jie
* @date 2018-12-31
* @date 2018-12-31
*/
*/
public
interface
QiniuContentRepository
extends
JpaRepository
<
QiniuContent
,
Long
>,
JpaSpecificationExecutor
{
public
interface
QiniuContentRepository
extends
JpaRepository
<
QiniuContent
,
Long
>,
JpaSpecificationExecutor
<
QiniuContent
>
{
/**
/**
* 根据key查询
* 根据key查询
* @param key
* @param key
文件名
* @return
* @return
QiniuContent
*/
*/
QiniuContent
findByKey
(
String
key
);
QiniuContent
findByKey
(
String
key
);
}
}
eladmin-tools/src/main/java/me/zhengjie/rest/AliPayController.java
View file @
e3c3ebb1
package
me.zhengjie.rest
;
package
me.zhengjie.rest
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.aop.log.Log
;
...
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
import
springfox.documentation.annotations.ApiIgnore
;
import
springfox.documentation.annotations.ApiIgnore
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
...
@@ -24,22 +26,26 @@ import java.util.Map;
...
@@ -24,22 +26,26 @@ import java.util.Map;
*/
*/
@Slf4j
@Slf4j
@RestController
@RestController
@RequestMapping
(
"/api"
)
@RequestMapping
(
"/api/aliPay"
)
@Api
(
tags
=
"支付宝支付管理"
)
public
class
AliPayController
{
public
class
AliPayController
{
@Autowired
private
final
AlipayUtils
alipayUtils
;
AlipayUtils
alipayUtils
;
@Autowired
private
final
AlipayService
alipayService
;
private
AlipayService
alipayService
;
@GetMapping
(
value
=
"/aliPay"
)
public
AliPayController
(
AlipayUtils
alipayUtils
,
AlipayService
alipayService
)
{
this
.
alipayUtils
=
alipayUtils
;
this
.
alipayService
=
alipayService
;
}
@GetMapping
public
ResponseEntity
<
AlipayConfig
>
get
(){
public
ResponseEntity
<
AlipayConfig
>
get
(){
return
new
ResponseEntity
<>(
alipayService
.
find
(),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
alipayService
.
find
(),
HttpStatus
.
OK
);
}
}
@Log
(
"配置支付宝"
)
@Log
(
"配置支付宝"
)
@PutMapping
(
value
=
"/aliPay"
)
@PutMapping
public
ResponseEntity
payConfig
(
@Validated
@RequestBody
AlipayConfig
alipayConfig
){
public
ResponseEntity
payConfig
(
@Validated
@RequestBody
AlipayConfig
alipayConfig
){
alipayConfig
.
setId
(
1L
);
alipayConfig
.
setId
(
1L
);
alipayService
.
update
(
alipayConfig
);
alipayService
.
update
(
alipayConfig
);
...
@@ -48,7 +54,7 @@ public class AliPayController {
...
@@ -48,7 +54,7 @@ public class AliPayController {
@Log
(
"支付宝PC网页支付"
)
@Log
(
"支付宝PC网页支付"
)
@ApiOperation
(
value
=
"PC网页支付"
)
@ApiOperation
(
value
=
"PC网页支付"
)
@PostMapping
(
value
=
"/
aliPay/
toPayAsPC"
)
@PostMapping
(
value
=
"/toPayAsPC"
)
public
ResponseEntity
<
String
>
toPayAsPC
(
@Validated@RequestBody
TradeVo
trade
)
throws
Exception
{
public
ResponseEntity
<
String
>
toPayAsPC
(
@Validated@RequestBody
TradeVo
trade
)
throws
Exception
{
AlipayConfig
alipay
=
alipayService
.
find
();
AlipayConfig
alipay
=
alipayService
.
find
();
trade
.
setOutTradeNo
(
alipayUtils
.
getOrderCode
());
trade
.
setOutTradeNo
(
alipayUtils
.
getOrderCode
());
...
@@ -58,7 +64,7 @@ public class AliPayController {
...
@@ -58,7 +64,7 @@ public class AliPayController {
@Log
(
"支付宝手机网页支付"
)
@Log
(
"支付宝手机网页支付"
)
@ApiOperation
(
value
=
"手机网页支付"
)
@ApiOperation
(
value
=
"手机网页支付"
)
@PostMapping
(
value
=
"/
aliPay/
toPayAsWeb"
)
@PostMapping
(
value
=
"/toPayAsWeb"
)
public
ResponseEntity
<
String
>
toPayAsWeb
(
@Validated
@RequestBody
TradeVo
trade
)
throws
Exception
{
public
ResponseEntity
<
String
>
toPayAsWeb
(
@Validated
@RequestBody
TradeVo
trade
)
throws
Exception
{
AlipayConfig
alipay
=
alipayService
.
find
();
AlipayConfig
alipay
=
alipayService
.
find
();
trade
.
setOutTradeNo
(
alipayUtils
.
getOrderCode
());
trade
.
setOutTradeNo
(
alipayUtils
.
getOrderCode
());
...
@@ -67,7 +73,7 @@ public class AliPayController {
...
@@ -67,7 +73,7 @@ public class AliPayController {
}
}
@ApiIgnore
@ApiIgnore
@GetMapping
(
"/
aliPay/
return"
)
@GetMapping
(
"/return"
)
@ApiOperation
(
value
=
"支付之后跳转的链接"
)
@ApiOperation
(
value
=
"支付之后跳转的链接"
)
public
ResponseEntity
<
String
>
returnPage
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
public
ResponseEntity
<
String
>
returnPage
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
AlipayConfig
alipay
=
alipayService
.
find
();
AlipayConfig
alipay
=
alipayService
.
find
();
...
@@ -75,47 +81,39 @@ public class AliPayController {
...
@@ -75,47 +81,39 @@ public class AliPayController {
//内容验签,防止黑客篡改参数
//内容验签,防止黑客篡改参数
if
(
alipayUtils
.
rsaCheck
(
request
,
alipay
)){
if
(
alipayUtils
.
rsaCheck
(
request
,
alipay
)){
//商户订单号
//商户订单号
String
outTradeNo
=
new
String
(
request
.
getParameter
(
"out_trade_no"
).
getBytes
(
"
ISO
-
8859
-1"
),
"UTF-8"
);
String
outTradeNo
=
new
String
(
request
.
getParameter
(
"out_trade_no"
).
getBytes
(
StandardCharsets
.
ISO
_
8859
_1
),
StandardCharsets
.
UTF_8
);
//支付宝交易号
//支付宝交易号
String
tradeNo
=
new
String
(
request
.
getParameter
(
"trade_no"
).
getBytes
(
"
ISO
-
8859
-1"
),
"UTF-8"
);
String
tradeNo
=
new
String
(
request
.
getParameter
(
"trade_no"
).
getBytes
(
StandardCharsets
.
ISO
_
8859
_1
),
StandardCharsets
.
UTF_8
);
System
.
out
.
println
(
"商户订单号"
+
outTradeNo
+
" "
+
"第三方交易号"
+
tradeNo
);
System
.
out
.
println
(
"商户订单号"
+
outTradeNo
+
" "
+
"第三方交易号"
+
tradeNo
);
/**
// 根据业务需要返回数据,这里统一返回OK
* 根据业务需要返回数据,这里统一返回OK
*/
return
new
ResponseEntity
<>(
"payment successful"
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
"payment successful"
,
HttpStatus
.
OK
);
}
else
{
}
else
{
/**
// 根据业务需要返回数据
* 根据业务需要返回数据
*/
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
}
}
}
}
@ApiIgnore
@ApiIgnore
@RequestMapping
(
"/
aliPay/
notify"
)
@RequestMapping
(
"/notify"
)
@ApiOperation
(
value
=
"支付异步通知(要公网访问),接收异步通知,检查通知内容app_id、out_trade_no、total_amount是否与请求中的一致,根据trade_status进行后续业务处理"
)
@ApiOperation
(
value
=
"支付异步通知(要公网访问),接收异步通知,检查通知内容app_id、out_trade_no、total_amount是否与请求中的一致,根据trade_status进行后续业务处理"
)
public
ResponseEntity
notify
(
HttpServletRequest
request
)
throws
Exception
{
public
ResponseEntity
notify
(
HttpServletRequest
request
)
throws
Exception
{
AlipayConfig
alipay
=
alipayService
.
find
();
AlipayConfig
alipay
=
alipayService
.
find
();
Map
<
String
,
String
[]>
parameterMap
=
request
.
getParameterMap
();
Map
<
String
,
String
[]>
parameterMap
=
request
.
getParameterMap
();
StringBuilder
notifyBuild
=
new
StringBuilder
(
"/****************************** pay notify ******************************/\n"
);
parameterMap
.
forEach
((
key
,
value
)
->
notifyBuild
.
append
(
key
+
"="
+
value
[
0
]
+
"\n"
)
);
//内容验签,防止黑客篡改参数
//内容验签,防止黑客篡改参数
if
(
alipayUtils
.
rsaCheck
(
request
,
alipay
))
{
if
(
alipayUtils
.
rsaCheck
(
request
,
alipay
))
{
//交易状态
//交易状态
String
tradeStatus
=
new
String
(
request
.
getParameter
(
"trade_status"
).
getBytes
(
"
ISO
-
8859
-1"
),
"UTF-8"
);
String
tradeStatus
=
new
String
(
request
.
getParameter
(
"trade_status"
).
getBytes
(
StandardCharsets
.
ISO
_
8859
_1
),
StandardCharsets
.
UTF_8
);
// 商户订单号
// 商户订单号
String
outTradeNo
=
new
String
(
request
.
getParameter
(
"out_trade_no"
).
getBytes
(
"
ISO
-
8859
-1"
),
"UTF-8"
);
String
outTradeNo
=
new
String
(
request
.
getParameter
(
"out_trade_no"
).
getBytes
(
StandardCharsets
.
ISO
_
8859
_1
),
StandardCharsets
.
UTF_8
);
//支付宝交易号
//支付宝交易号
String
tradeNo
=
new
String
(
request
.
getParameter
(
"trade_no"
).
getBytes
(
"
ISO
-
8859
-1"
),
"UTF-8"
);
String
tradeNo
=
new
String
(
request
.
getParameter
(
"trade_no"
).
getBytes
(
StandardCharsets
.
ISO
_
8859
_1
),
StandardCharsets
.
UTF_8
);
//付款金额
//付款金额
String
totalAmount
=
new
String
(
request
.
getParameter
(
"total_amount"
).
getBytes
(
"
ISO
-
8859
-1"
),
"UTF-8"
);
String
totalAmount
=
new
String
(
request
.
getParameter
(
"total_amount"
).
getBytes
(
StandardCharsets
.
ISO
_
8859
_1
),
StandardCharsets
.
UTF_8
);
//验证
//验证
if
(
tradeStatus
.
equals
(
AliPayStatusEnum
.
SUCCESS
.
getValue
())||
tradeStatus
.
equals
(
AliPayStatusEnum
.
FINISHED
.
getValue
())){
// if(tradeStatus.equals(AliPayStatusEnum.SUCCESS.getValue())||tradeStatus.equals(AliPayStatusEnum.FINISHED.getValue())){
/**
// // 验证通过后应该根据业务需要处理订单
* 验证通过后应该根据业务需要处理订单
// }
*/
}
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
return
new
ResponseEntity
(
HttpStatus
.
BAD_REQUEST
);
return
new
ResponseEntity
(
HttpStatus
.
BAD_REQUEST
);
...
...
eladmin-tools/src/main/java/me/zhengjie/rest/EmailController.java
View file @
e3c3ebb1
package
me.zhengjie.rest
;
package
me.zhengjie.rest
;
import
lombok.extern.slf4j.Slf4j
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.domain.EmailConfig
;
import
me.zhengjie.domain.EmailConfig
;
import
me.zhengjie.domain.vo.EmailVo
;
import
me.zhengjie.domain.vo.EmailVo
;
import
me.zhengjie.service.EmailService
;
import
me.zhengjie.service.EmailService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
...
@@ -16,30 +16,34 @@ import org.springframework.web.bind.annotation.*;
...
@@ -16,30 +16,34 @@ import org.springframework.web.bind.annotation.*;
* @author 郑杰
* @author 郑杰
* @date 2018/09/28 6:55:53
* @date 2018/09/28 6:55:53
*/
*/
@Slf4j
@RestController
@RestController
@RequestMapping
(
"api"
)
@RequestMapping
(
"api/email"
)
@Api
(
tags
=
"邮件管理"
)
public
class
EmailController
{
public
class
EmailController
{
@Autowired
private
final
EmailService
emailService
;
private
EmailService
emailService
;
@GetMapping
(
value
=
"/email"
)
public
EmailController
(
EmailService
emailService
)
{
this
.
emailService
=
emailService
;
}
@GetMapping
public
ResponseEntity
get
(){
public
ResponseEntity
get
(){
return
new
ResponseEntity
(
emailService
.
find
(),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
emailService
.
find
(),
HttpStatus
.
OK
);
}
}
@Log
(
"配置邮件"
)
@Log
(
"配置邮件"
)
@PutMapping
(
value
=
"/email"
)
@PutMapping
@ApiOperation
(
value
=
"配置邮件"
)
public
ResponseEntity
emailConfig
(
@Validated
@RequestBody
EmailConfig
emailConfig
){
public
ResponseEntity
emailConfig
(
@Validated
@RequestBody
EmailConfig
emailConfig
){
emailService
.
update
(
emailConfig
,
emailService
.
find
());
emailService
.
update
(
emailConfig
,
emailService
.
find
());
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
@Log
(
"发送邮件"
)
@Log
(
"发送邮件"
)
@PostMapping
(
value
=
"/email"
)
@PostMapping
@ApiOperation
(
value
=
"发送邮件"
)
public
ResponseEntity
send
(
@Validated
@RequestBody
EmailVo
emailVo
)
throws
Exception
{
public
ResponseEntity
send
(
@Validated
@RequestBody
EmailVo
emailVo
)
throws
Exception
{
log
.
warn
(
"REST request to send Email : {}"
+
emailVo
);
emailService
.
send
(
emailVo
,
emailService
.
find
());
emailService
.
send
(
emailVo
,
emailService
.
find
());
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
...
...
eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java
View file @
e3c3ebb1
...
@@ -4,7 +4,6 @@ import me.zhengjie.aop.log.Log;
...
@@ -4,7 +4,6 @@ import me.zhengjie.aop.log.Log;
import
me.zhengjie.domain.LocalStorage
;
import
me.zhengjie.domain.LocalStorage
;
import
me.zhengjie.service.LocalStorageService
;
import
me.zhengjie.service.LocalStorageService
;
import
me.zhengjie.service.dto.LocalStorageQueryCriteria
;
import
me.zhengjie.service.dto.LocalStorageQueryCriteria
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
...
@@ -20,28 +19,31 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -20,28 +19,31 @@ import org.springframework.web.multipart.MultipartFile;
*/
*/
@Api
(
tags
=
"本地存储管理"
)
@Api
(
tags
=
"本地存储管理"
)
@RestController
@RestController
@RequestMapping
(
"api"
)
@RequestMapping
(
"
/
api
/localStorage
"
)
public
class
LocalStorageController
{
public
class
LocalStorageController
{
@Autowired
private
final
LocalStorageService
localStorageService
;
private
LocalStorageService
localStorageService
;
public
LocalStorageController
(
LocalStorageService
localStorageService
)
{
this
.
localStorageService
=
localStorageService
;
}
@ApiOperation
(
value
=
"查询文件"
)
@ApiOperation
(
value
=
"查询文件"
)
@GetMapping
(
value
=
"/localStorage"
)
@GetMapping
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_SELECT')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_SELECT')"
)
public
ResponseEntity
getLocalStorages
(
LocalStorageQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
getLocalStorages
(
LocalStorageQueryCriteria
criteria
,
Pageable
pageable
){
return
new
ResponseEntity
(
localStorageService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
localStorageService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
@ApiOperation
(
value
=
"上传文件"
)
@ApiOperation
(
value
=
"上传文件"
)
@PostMapping
(
value
=
"/localStorage"
)
@PostMapping
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_CREATE')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_CREATE')"
)
public
ResponseEntity
create
(
@RequestParam
String
name
,
@RequestParam
(
"file"
)
MultipartFile
file
){
public
ResponseEntity
create
(
@RequestParam
String
name
,
@RequestParam
(
"file"
)
MultipartFile
file
){
return
new
ResponseEntity
(
localStorageService
.
create
(
name
,
file
),
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>
(
localStorageService
.
create
(
name
,
file
),
HttpStatus
.
CREATED
);
}
}
@ApiOperation
(
value
=
"修改文件"
)
@ApiOperation
(
value
=
"修改文件"
)
@PutMapping
(
value
=
"/localStorage"
)
@PutMapping
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_EDIT')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_EDIT')"
)
public
ResponseEntity
update
(
@Validated
@RequestBody
LocalStorage
resources
){
public
ResponseEntity
update
(
@Validated
@RequestBody
LocalStorage
resources
){
localStorageService
.
update
(
resources
);
localStorageService
.
update
(
resources
);
...
@@ -49,20 +51,16 @@ public class LocalStorageController {
...
@@ -49,20 +51,16 @@ public class LocalStorageController {
}
}
@ApiOperation
(
value
=
"删除文件"
)
@ApiOperation
(
value
=
"删除文件"
)
@DeleteMapping
(
value
=
"/
localStorage/
{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_DELETE')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','LOCALSTORAGE_ALL','LOCALSTORAGE_DELETE')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
localStorageService
.
delete
(
id
);
localStorageService
.
delete
(
id
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
/**
@Log
(
"多选删除"
)
* 删除多张图片
@DeleteMapping
* @param ids
@ApiOperation
(
value
=
"多选删除"
)
* @return
*/
@Log
(
"删除图片"
)
@DeleteMapping
(
value
=
"/localStorage"
)
public
ResponseEntity
deleteAll
(
@RequestBody
Long
[]
ids
)
{
public
ResponseEntity
deleteAll
(
@RequestBody
Long
[]
ids
)
{
localStorageService
.
deleteAll
(
ids
);
localStorageService
.
deleteAll
(
ids
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
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