Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
37e87b9b
提交
37e87b9b
authored
9月 12, 2020
作者:
Whispa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit
上级
0cd7de3d
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
553 行增加
和
7 行删除
+553
-7
pom.xml
pom.xml
+8
-0
AuthController.java
...a/com/example/afrishop_v3/controllers/AuthController.java
+5
-5
FlutterWaveController.java
...xample/afrishop_v3/controllers/FlutterWaveController.java
+4
-1
ProblemController.java
...om/example/afrishop_v3/controllers/ProblemController.java
+1
-1
UploadController.java
...com/example/afrishop_v3/controllers/UploadController.java
+59
-0
UserController.java
...a/com/example/afrishop_v3/controllers/UserController.java
+55
-0
OssUtil.java
src/main/java/com/example/afrishop_v3/util/OssUtil.java
+416
-0
application.properties
src/main/resources/application.properties
+5
-0
没有找到文件。
pom.xml
浏览文件 @
37e87b9b
...
...
@@ -72,6 +72,14 @@
<artifactId>
staxon
</artifactId>
<version>
1.3
</version>
</dependency>
<!-- OSS-->
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
3.8.0
</version>
</dependency>
<dependency>
<groupId>
com.google.firebase
</groupId>
<artifactId>
firebase-admin
</artifactId>
...
...
src/main/java/com/example/afrishop_v3/controllers/AuthController.java
浏览文件 @
37e87b9b
...
...
@@ -213,15 +213,15 @@ public class AuthController {
}
}
else
{
user
=
optional
.
get
();
if
(
user
.
getPassword
()
==
null
){
user
.
setPassword
(
encoder
.
encode
(
user
.
getFirebaseUid
()));
// Assign user from database to the user we have to return back to request
userRepository
.
save
(
user
);
}
}
// generate token codes has been moved downwards from if condition of checking if user doesn't exist in database, because even if
// user exist we have to generate token also
if
(
user
.
getPassword
()
==
null
){
user
.
setPassword
(
encoder
.
encode
(
user
.
getFirebaseUid
()));
// Assign user from database to the user we have to return back to request
}
user
.
setLastLoginTime
(
new
Date
());
userRepository
.
save
(
user
);
//注册成功 创建token
return
authenticateUser
(
new
LoginRequest
(
user
.
getFirebaseUid
(),
user
.
getFirebaseUid
()));
...
...
src/main/java/com/example/afrishop_v3/controllers/FlutterWaveController.java
浏览文件 @
37e87b9b
...
...
@@ -84,9 +84,12 @@ public class FlutterWaveController {
JSONObject
chargevisa
=
ch
.
chargeVisaAndIntl
();
JSONObject
object
=
chargevisa
.
getJSONObject
(
"data"
);
boolean
b
=
object
!=
null
&&
object
.
has
(
"authurl"
);
String
message
=
!
b
&&
object
!=
null
&&
object
.
has
(
"message"
)
?
object
.
getString
(
"message"
)
:
ResultCodeEnum
.
SERVICE_ERROR
.
getDesc
();
json
.
put
(
"data"
,
chargevisa
);
json
.
put
(
"code"
,
b
?
ResultCodeEnum
.
SUCCESS
.
getCode
()
:
ResultCodeEnum
.
SERVICE_ERROR
.
getCode
());
json
.
put
(
"message"
,
b
?
ResultCodeEnum
.
SUCCESS
.
getDesc
()
:
object
==
null
?
ResultCodeEnum
.
SERVICE_ERROR
.
getDesc
()
:
object
.
toString
()
);
json
.
put
(
"message"
,
b
?
ResultCodeEnum
.
SUCCESS
.
getDesc
()
:
message
);
}
catch
(
Exception
e
)
{
json
.
put
(
"code"
,
ResultCodeEnum
.
ORDER_PAY_ERROR
.
getCode
()).
put
(
"message"
,
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
(),
e
);
...
...
src/main/java/com/example/afrishop_v3/controllers/ProblemController.java
浏览文件 @
37e87b9b
...
...
@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/
search
"
)
@RequestMapping
(
"/
problem
"
)
public
class
ProblemController
{
private
final
TbCfProblemRepository
repository
;
...
...
src/main/java/com/example/afrishop_v3/controllers/UploadController.java
0 → 100644
浏览文件 @
37e87b9b
package
com
.
example
.
afrishop_v3
.
controllers
;
import
com.example.afrishop_v3.base.Result
;
import
com.example.afrishop_v3.enums.ResultCodeEnum
;
import
com.example.afrishop_v3.util.HttpClientUtil
;
import
com.example.afrishop_v3.util.OssUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @Auther: wudepeng
* @Date: 2020/01/09
* @Description:文件上传API
*/
@RestController
@RequestMapping
(
"/api/upload"
)
public
class
UploadController
{
@Value
(
"${upload.api}"
)
private
String
api
;
@PostMapping
(
"/uploadFile"
)
public
Result
uploadFile
(
@RequestBody
String
strImg
)
throws
Exception
{
Result
<
String
>
result
=
new
Result
<>();
try
{
if
(!
StringUtils
.
isBlank
(
strImg
))
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"file"
,
strImg
);
String
url
=
HttpClientUtil
.
sendPostWithBodyParameter
(
api
,
map
);
url
=
url
.
substring
(
1
,
url
.
length
()
-
1
);
result
.
setData
(
url
).
setMessage
(
ResultCodeEnum
.
SUCCESS
.
getDesc
());
}
else
{
result
.
setCode
(
ResultCodeEnum
.
SERVICE_ERROR
.
getCode
());
result
.
setMessage
(
"The parameter cannot be null"
);
}
}
catch
(
Exception
e
)
{
result
.
setCode
(
ResultCodeEnum
.
SERVICE_ERROR
.
getCode
());
result
.
setMessage
(
"Upload failed"
);
}
return
result
;
}
//@ApiOperation("删除文件")
@DeleteMapping
(
"/delFile"
)
public
Result
delFile
(
@RequestParam
(
"url"
)
String
url
)
{
Result
<
Map
<
String
,
Object
>>
result
=
new
Result
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
boolean
b
=
OssUtil
.
deleteFile
(
url
);
map
.
put
(
"isDeleted"
,
b
);
result
.
setData
(
map
).
setMessage
(
ResultCodeEnum
.
SUCCESS
.
getDesc
());
return
result
;
}
}
src/main/java/com/example/afrishop_v3/controllers/UserController.java
0 → 100644
浏览文件 @
37e87b9b
package
com
.
example
.
afrishop_v3
.
controllers
;
import
com.example.afrishop_v3.base.Result
;
import
com.example.afrishop_v3.enums.ResultCodeEnum
;
import
com.example.afrishop_v3.models.TbCfUserInfo
;
import
com.example.afrishop_v3.repository.UserRepository
;
import
com.example.afrishop_v3.security.services.AuthenticationUser
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"user"
)
public
class
UserController
{
private
final
UserRepository
repository
;
private
final
AuthenticationUser
user
;
public
UserController
(
UserRepository
repository
,
AuthenticationUser
user
)
{
this
.
repository
=
repository
;
this
.
user
=
user
;
}
@PutMapping
public
Result
updateUser
(
@RequestBody
TbCfUserInfo
info
)
{
TbCfUserInfo
user
=
this
.
user
.
user
();
if
(
info
==
null
)
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Empty body"
);
if
(
StringUtils
.
isNotBlank
(
info
.
getAvatar
())
){
user
.
setAvatar
(
info
.
getAvatar
());
}
if
(
StringUtils
.
isNotBlank
(
info
.
getBirthday
())
){
user
.
setBirthday
(
info
.
getBirthday
());
}
if
(
StringUtils
.
isNotBlank
(
info
.
getNick
())
){
user
.
setNick
(
info
.
getNick
());
}
if
(
info
.
getSex
()
!=
null
){
user
.
setSex
(
info
.
getSex
());
}
TbCfUserInfo
save
=
repository
.
save
(
user
);
return
new
Result
<>(
save
);
}
}
src/main/java/com/example/afrishop_v3/util/OssUtil.java
0 → 100644
浏览文件 @
37e87b9b
差异被折叠。
点击展开。
src/main/resources/application.properties
浏览文件 @
37e87b9b
...
...
@@ -22,3 +22,8 @@ spring.servlet.multipart.max-request-size=456128KB
# App Properties
bezkoder.app.jwtSecret
=
bezKoderSecretKey
bezkoder.app.jwtExpirationMs
=
86400000
upload.api
=
http://dev.diaosaas.com:8302/africa-shop/api/upload/uploadBase64
# upload.api = http://admin.afrieshop.com/api/upload/uploadBase64
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论