Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
tool
/
xxl-job
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 55f0f8aa
authored
Nov 24, 2019
by
xuxueli
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
optimize
1 parent
37f97516
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
10 deletions
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobApiController.java
View file @
55f0f8a
...
@@ -2,6 +2,7 @@ package com.xxl.job.admin.controller;
...
@@ -2,6 +2,7 @@ package com.xxl.job.admin.controller;
import
com.xxl.job.admin.controller.annotation.PermissionLimit
;
import
com.xxl.job.admin.controller.annotation.PermissionLimit
;
import
com.xxl.job.admin.core.conf.XxlJobAdminConfig
;
import
com.xxl.job.admin.core.conf.XxlJobAdminConfig
;
import
com.xxl.job.admin.core.util.JacksonUtil
;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.biz.AdminBiz
;
import
com.xxl.job.core.biz.model.HandleCallbackParam
;
import
com.xxl.job.core.biz.model.HandleCallbackParam
;
import
com.xxl.job.core.biz.model.RegistryParam
;
import
com.xxl.job.core.biz.model.RegistryParam
;
...
@@ -32,20 +33,30 @@ public class JobApiController {
...
@@ -32,20 +33,30 @@ public class JobApiController {
/**
/**
* callback
* callback
*
*
* @param
callbackParamList
* @param
data
* @return
* @return
*/
*/
@RequestMapping
(
"/callback"
)
@RequestMapping
(
"/callback"
)
@ResponseBody
@ResponseBody
@PermissionLimit
(
limit
=
false
)
@PermissionLimit
(
limit
=
false
)
public
ReturnT
<
String
>
callback
(
HttpServletRequest
request
,
@RequestBody
List
<
HandleCallbackParam
>
callbackParamList
)
{
public
ReturnT
<
String
>
callback
(
HttpServletRequest
request
,
@RequestBody
(
required
=
false
)
String
data
)
{
// valid
if
(
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
()!=
null
if
(
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
()!=
null
&&
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
trim
().
length
()>
0
&&
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
trim
().
length
()>
0
&&
!
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
equals
(
request
.
getHeader
(
XxlJobRemotingUtil
.
XXL_RPC_ACCESS_TOKEN
)))
{
&&
!
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
equals
(
request
.
getHeader
(
XxlJobRemotingUtil
.
XXL_RPC_ACCESS_TOKEN
)))
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"The access token is wrong."
);
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"The access token is wrong."
);
}
}
// param
List
<
HandleCallbackParam
>
callbackParamList
=
null
;
try
{
callbackParamList
=
JacksonUtil
.
readValue
(
data
,
List
.
class
,
HandleCallbackParam
.
class
);
}
catch
(
Exception
e
)
{
}
if
(
callbackParamList
==
null
||
callbackParamList
.
size
()==
0
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"The request data invalid."
);
}
// invoke
return
adminBiz
.
callback
(
callbackParamList
);
return
adminBiz
.
callback
(
callbackParamList
);
}
}
...
@@ -54,43 +65,62 @@ public class JobApiController {
...
@@ -54,43 +65,62 @@ public class JobApiController {
/**
/**
* registry
* registry
*
*
* @param
registryParam
* @param
data
* @return
* @return
*/
*/
@RequestMapping
(
"/registry"
)
@RequestMapping
(
"/registry"
)
@ResponseBody
@ResponseBody
@PermissionLimit
(
limit
=
false
)
@PermissionLimit
(
limit
=
false
)
public
ReturnT
<
String
>
registry
(
HttpServletRequest
request
,
@RequestBody
RegistryParam
registryParam
)
{
public
ReturnT
<
String
>
registry
(
HttpServletRequest
request
,
@RequestBody
(
required
=
false
)
String
data
)
{
// valid
if
(
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
()!=
null
if
(
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
()!=
null
&&
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
trim
().
length
()>
0
&&
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
trim
().
length
()>
0
&&
!
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
equals
(
request
.
getHeader
(
XxlJobRemotingUtil
.
XXL_RPC_ACCESS_TOKEN
)))
{
&&
!
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
equals
(
request
.
getHeader
(
XxlJobRemotingUtil
.
XXL_RPC_ACCESS_TOKEN
)))
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"The access token is wrong."
);
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"The access token is wrong."
);
}
}
// param
RegistryParam
registryParam
=
null
;
try
{
registryParam
=
JacksonUtil
.
readValue
(
data
,
RegistryParam
.
class
);
}
catch
(
Exception
e
)
{}
if
(
registryParam
==
null
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"The request data invalid."
);
}
// invoke
return
adminBiz
.
registry
(
registryParam
);
return
adminBiz
.
registry
(
registryParam
);
}
}
/**
/**
* registry remove
* registry remove
*
*
* @param
registryParam
* @param
data
* @return
* @return
*/
*/
@RequestMapping
(
"/registryRemove"
)
@RequestMapping
(
"/registryRemove"
)
@ResponseBody
@ResponseBody
@PermissionLimit
(
limit
=
false
)
@PermissionLimit
(
limit
=
false
)
public
ReturnT
<
String
>
registryRemove
(
HttpServletRequest
request
,
@RequestBody
RegistryParam
registryParam
)
{
public
ReturnT
<
String
>
registryRemove
(
HttpServletRequest
request
,
@RequestBody
(
required
=
false
)
String
data
)
{
// valid
if
(
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
()!=
null
if
(
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
()!=
null
&&
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
trim
().
length
()>
0
&&
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
trim
().
length
()>
0
&&
!
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
equals
(
request
.
getHeader
(
XxlJobRemotingUtil
.
XXL_RPC_ACCESS_TOKEN
)))
{
&&
!
XxlJobAdminConfig
.
getAdminConfig
().
getAccessToken
().
equals
(
request
.
getHeader
(
XxlJobRemotingUtil
.
XXL_RPC_ACCESS_TOKEN
)))
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"The access token is wrong."
);
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"The access token is wrong."
);
}
}
return
adminBiz
.
registryRemove
(
registryParam
);
// param
RegistryParam
registryParam
=
null
;
try
{
registryParam
=
JacksonUtil
.
readValue
(
data
,
RegistryParam
.
class
);
}
catch
(
Exception
e
)
{}
if
(
registryParam
==
null
)
{
return
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"The request data invalid."
);
}
}
// invoke
return
adminBiz
.
registryRemove
(
registryParam
);
}
// ---------------------- job biz ----------------------
// ---------------------- job biz ----------------------
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment