Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sh-ds
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
李良停
sh-ds
Commits
eb97f95a
Commit
eb97f95a
authored
May 04, 2022
by
wangsong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update api
parent
cbd73dbe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
236 deletions
+29
-236
AuthConfigController.java
...den/authcenter/agent/controller/AuthConfigController.java
+28
-23
LoginController.java
...all/eden/authcenter/agent/controller/LoginController.java
+1
-1
ResponseCode.java
...chineseall/eden/authcenter/agent/result/ResponseCode.java
+0
-129
ResultModel.java
.../chineseall/eden/authcenter/agent/result/ResultModel.java
+0
-83
No files found.
eden-authcenter-agent/src/main/java/com/chineseall/eden/authcenter/agent/controller/AuthConfigController.java
View file @
eb97f95a
package
com
.
chineseall
.
eden
.
authcenter
.
agent
.
controller
;
import
cn.sh.chineseall.framework.api.MapMessage
;
import
cn.sh.chineseall.framework.core.util.StringUtils
;
import
com.chineseall.eden.authcenter.agent.result.ResponseCode
;
import
com.chineseall.eden.authcenter.agent.result.ResultModel
;
import
com.chineseall.eden.authcenter.config.entity.AuthClient
;
import
com.chineseall.eden.authcenter.config.entity.AuthSource
;
import
com.chineseall.eden.authcenter.config.service.AuthClientService
;
...
...
@@ -12,7 +11,6 @@ import org.springframework.stereotype.Controller;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
@Controller
...
...
@@ -46,33 +44,36 @@ public class AuthConfigController {
@PostMapping
(
"authsource/save"
)
@ResponseBody
public
ResultModel
<
Boolean
>
saveAuthSource
(
@RequestBody
AuthSource
data
){
return
ResultModel
.
success
(
authSourceService
.
saveAuthSource
(
data
));
public
MapMessage
saveAuthSource
(
@RequestBody
AuthSource
data
){
boolean
result
=
authSourceService
.
saveAuthSource
(
data
);
return
result
?
MapMessage
.
successMessage
():
MapMessage
.
errorMessage
();
}
@GetMapping
(
"authsource/detail"
)
@ResponseBody
public
ResultModel
<
AuthSource
>
authSourceDetail
(
@RequestParam
(
"key"
)
String
key
){
public
MapMessage
authSourceDetail
(
@RequestParam
(
"key"
)
String
key
){
if
(
StringUtils
.
isBlank
(
key
)){
return
ResultModel
.
error
(
ResponseCode
.
ParamsNull
);
return
MapMessage
.
errorMessage
(
"参数不全"
);
}
AuthSource
data
=
authSourceService
.
getAuthSourceByKey
(
key
);
if
(
data
==
null
){
return
ResultModel
.
error
(
ResponseCode
.
RecordNotExist
);
return
MapMessage
.
errorMessage
(
"数据不存在"
);
}
return
ResultModel
.
success
(
data
);
return
MapMessage
.
successMessage
().
add
(
"data"
,
data
);
}
@
Ge
tMapping
(
"authsource/changestatus"
)
@
Pos
tMapping
(
"authsource/changestatus"
)
@ResponseBody
public
ResultModel
<
Boolean
>
changeAuthSourceStatus
(
@RequestParam
(
"key"
)
String
key
,
@RequestParam
(
"status"
)
Integer
status
){
public
MapMessage
changeAuthSourceStatus
(
@RequestParam
(
"key"
)
String
key
,
@RequestParam
(
"status"
)
Integer
status
){
if
(
StringUtils
.
isBlank
(
key
)
||
status
==
null
){
return
ResultModel
.
error
(
ResponseCode
.
ParamsNull
);
return
MapMessage
.
errorMessage
(
"参数不全"
);
}
return
ResultModel
.
success
(
authSourceService
.
changeStatus
(
key
,
status
));
MapMessage
message
=
new
MapMessage
();
message
.
setSuccess
(
authSourceService
.
changeStatus
(
key
,
status
));
return
message
;
}
...
...
@@ -93,33 +94,37 @@ public class AuthConfigController {
@PostMapping
(
"authclient/save"
)
@ResponseBody
public
ResultModel
<
Boolean
>
saveAuthClient
(
@RequestBody
AuthClient
data
){
return
ResultModel
.
success
(
authClientService
.
saveAuthClient
(
data
));
public
MapMessage
saveAuthClient
(
@RequestBody
AuthClient
data
){
MapMessage
message
=
new
MapMessage
();
message
.
setSuccess
(
authClientService
.
saveAuthClient
(
data
));
return
message
;
}
@GetMapping
(
"authclient/detail"
)
@ResponseBody
public
ResultModel
<
AuthClient
>
authClientDetail
(
@RequestParam
(
"key"
)
String
key
){
public
MapMessage
authClientDetail
(
@RequestParam
(
"key"
)
String
key
){
if
(
StringUtils
.
isBlank
(
key
)){
return
ResultModel
.
error
(
ResponseCode
.
ParamsNull
);
return
MapMessage
.
errorMessage
(
"参数不全"
);
}
AuthClient
data
=
authClientService
.
getAuthClientByKey
(
key
);
if
(
data
==
null
){
return
ResultModel
.
error
(
ResponseCode
.
RecordNotExist
);
return
MapMessage
.
errorMessage
(
"数据不存在"
);
}
return
ResultModel
.
success
(
data
);
return
MapMessage
.
successMessage
().
add
(
"data"
,
data
);
}
@
Ge
tMapping
(
"authclient/changestatus"
)
@
Pos
tMapping
(
"authclient/changestatus"
)
@ResponseBody
public
ResultModel
<
Boolean
>
changeAuthClientStatus
(
@RequestParam
(
"key"
)
String
key
,
@RequestParam
(
"status"
)
Integer
status
){
public
MapMessage
changeAuthClientStatus
(
@RequestParam
(
"key"
)
String
key
,
@RequestParam
(
"status"
)
Integer
status
){
if
(
StringUtils
.
isBlank
(
key
)
||
status
==
null
){
return
ResultModel
.
error
(
ResponseCode
.
ParamsNull
);
return
MapMessage
.
errorMessage
(
"参数不全"
);
}
return
ResultModel
.
success
(
authClientService
.
changeStatus
(
key
,
status
));
MapMessage
message
=
new
MapMessage
();
message
.
setSuccess
(
authClientService
.
changeStatus
(
key
,
status
));
return
message
;
}
...
...
eden-authcenter-agent/src/main/java/com/chineseall/eden/authcenter/agent/controller/LoginController.java
View file @
eb97f95a
...
...
@@ -25,7 +25,7 @@ public class LoginController {
@GetMapping
(
"index"
)
public
String
index
(){
return
"
login_page
"
;
return
"
/login/index
"
;
}
...
...
eden-authcenter-agent/src/main/java/com/chineseall/eden/authcenter/agent/result/ResponseCode.java
deleted
100644 → 0
View file @
cbd73dbe
package
com
.
chineseall
.
eden
.
authcenter
.
agent
.
result
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
java.util.Arrays
;
/**
* 状态码
*
*/
@AllArgsConstructor
@Getter
public
enum
ResponseCode
{
/**
* 所有失败的操作均指定为999,未知错误
*/
Error
(
999
,
"失败"
),
/**
* 令牌不合法
*/
TokenUnValidate
(
998
,
"令牌不合法"
),
/**
* 签名不合法
*/
SignUnValidate
(
997
,
"签名不合法"
),
/**
* 签名丢失
*/
SignHeaderMiss
(
996
,
"必须传递签名"
),
/**
* 用户类型缺失
*/
UserTypeMiss
(
990
,
"必须传递用户类型"
),
AppIdMiss
(
993
,
"缺少APPID"
),
/**
* 签名时间不正确
*/
SignTimeOver
(
995
,
"签名时间不正确"
),
/**
* 用户名或者密码不正确
*/
ErrorUserNameOrPassword
(
994
,
"用户名或者密码不正确"
),
UserNameInvalid
(
9941
,
"用户名无效"
),
PasswordIncorrect
(
9942
,
"密码不正确"
),
AccountDisabled
(
9943
,
"账户已冻结"
),
NoLogin
(
9945
,
"请登录后在操作"
),
/**
* 签名时间错误
*/
DeviceLocalTimeError
(
991
,
"签名时间错误"
),
/**
* 成功
*/
Success
(
1
,
"成功"
),
/**
* 数据库操作失败
*/
DBError
(
1015
,
"数据库操作错误"
),
/**
* 参数不全
*/
ParamsNull
(
1002
,
"参数不全"
),
/**
* 不支持的HTTP方法
*/
MethodNotSupport
(
1001
,
"不支持的HTTP方法"
),
NoHandlerFoundException
(
1003
,
"请求的方法不存在"
),
/**
* 请求数据错误
*/
DataInvalid
(
1500
,
"请求数据无效"
),
/**
* 验证码无效
*/
VerifyCodeError
(
2001
,
"验证码错误"
),
RecordNotExist
(
2002
,
"数据不存在"
),
RecordAlreadyExist
(
2000
,
"数据已存在"
),
RecordAlreadyProcess
(
2003
,
"数据已处理"
),
HasNoRight
(
2004
,
"您无权进行操作"
),
/**
* 未进行初始化
*/
NotInitialized
(
3001
,
"未进行初始化"
),
/**
* 不支持
*/
UnSupport
(
99999
,
"不支持"
),
;
public
final
Integer
code
;
public
final
String
desc
;
public
static
ResponseCode
of
(
Integer
code
)
{
return
Arrays
.
stream
(
values
()).
filter
(
i
->
i
.
code
.
equals
(
code
)).
findFirst
().
orElse
(
Error
);
}
}
eden-authcenter-agent/src/main/java/com/chineseall/eden/authcenter/agent/result/ResultModel.java
deleted
100644 → 0
View file @
cbd73dbe
package
com
.
chineseall
.
eden
.
authcenter
.
agent
.
result
;
import
cn.sh.chineseall.framework.core.repackaged.org.apache.commons.lang3.StringUtils
;
import
lombok.Data
;
import
java.util.Objects
;
/**
* 返回数据模型定义
* @param <T>
*/
@Data
public
class
ResultModel
<
T
>
{
private
Integer
code
;
private
String
msg
;
private
T
data
;
public
ResultModel
(){
}
public
boolean
isSuccess
(){
return
Objects
.
equals
(
getCode
(),
ResponseCode
.
Success
.
getCode
());
}
public
ResultModel
(
ResponseCode
responseCode
){
this
.
setCode
(
responseCode
.
code
);
this
.
setMsg
(
responseCode
.
desc
);
}
public
ResultModel
(
ResponseCode
responseCode
,
String
msg
){
this
.
setCode
(
responseCode
.
code
);
this
.
setMsg
(
StringUtils
.
isNotBlank
(
msg
)?
msg
:
responseCode
.
desc
);
}
public
ResultModel
(
Integer
code
,
String
msg
){
this
.
setCode
(
code
);
this
.
setMsg
(
msg
);
}
public
static
<
T
>
ResultModel
<
T
>
success
(){
return
success
(
null
);
}
public
static
<
T
>
ResultModel
<
T
>
ok
(){
return
success
();
}
public
static
<
T
>
ResultModel
<
T
>
ok
(
T
data
){
return
success
(
data
);
}
public
static
<
T
>
ResultModel
<
T
>
success
(
T
data
){
ResultModel
<
T
>
model
=
new
ResultModel
<
T
>();
model
.
setCode
(
1
);
model
.
setMsg
(
"成功"
);
model
.
setData
(
data
);
return
model
;
}
public
static
<
T
>
ResultModel
<
T
>
error
(){
return
error
(
ResponseCode
.
Error
);
}
public
static
<
T
>
ResultModel
<
T
>
error
(
ResponseCode
responseCode
){
return
new
ResultModel
<>(
responseCode
);
}
public
static
<
T
>
ResultModel
<
T
>
error
(
String
msg
){
return
new
ResultModel
<>(
ResponseCode
.
Error
,
msg
);
}
public
static
<
T
>
ResultModel
<
T
>
error
(
ResponseCode
responseCode
,
String
msg
){
return
new
ResultModel
<>(
responseCode
,
msg
);
}
public
static
<
T
>
ResultModel
<
T
>
error
(
Integer
code
,
String
msg
){
return
new
ResultModel
<>(
code
,
msg
);
}
}
\ 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