Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
leaf-hlcm
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
hlcm
leaf-hlcm
Commits
ac4602b5
Commit
ac4602b5
authored
Feb 08, 2023
by
Luochenglong
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop' into develop
parents
39d0d100
eb1c4262
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
198 additions
and
1 deletion
+198
-1
HttpPostUtil.java
src/main/java/com/hand/hlcm/HttpPostUtil.java
+55
-0
token_savelogs.lwm
.../webapp/WEB-INF/classes/token/TOKEN001/token_savelogs.lwm
+67
-0
token_record.js
src/main/webapp/WEB-INF/server-script/token_record.js
+14
-0
hls_journal_import_wfl.lview
...in/webapp/modules/hls/HLS536/hls_journal_import_wfl.lview
+1
-1
token_query.lsc
src/main/webapp/modules/token_query.lsc
+61
-0
No files found.
src/main/java/com/hand/hlcm/HttpPostUtil.java
0 → 100644
View file @
ac4602b5
package
com
.
hand
.
hlcm
;
import
org.apache.commons.httpclient.HttpClient
;
import
org.apache.commons.httpclient.NameValuePair
;
import
org.apache.commons.httpclient.methods.PostMethod
;
import
org.apache.commons.httpclient.methods.RequestEntity
;
import
org.apache.commons.httpclient.methods.StringRequestEntity
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.net.URLDecoder
;
import
java.nio.charset.Charset
;
import
java.util.Base64
;
/**
* description
*
* @author Administrator 2023/01/03 15:07
*/
public
class
HttpPostUtil
{
public
static
String
httpPostGetToken
(
String
postUrl
,
String
appId
,
String
appSecret
){
try
{
PostMethod
postMethod
=
null
;
postMethod
=
new
PostMethod
(
postUrl
)
;
postMethod
.
setRequestHeader
(
"Content-Type"
,
"application/x-www-form-urlencoded"
)
;
postMethod
.
setRequestHeader
(
"Authorization"
,
"Basic "
+
Base64
.
getUrlEncoder
().
encodeToString
((
appId
+
":"
+
appSecret
).
getBytes
()))
;
//参数设置,需要注意的就是里边不能传NULL,要传空字符串
NameValuePair
[]
data
=
{
new
NameValuePair
(
"grant_type"
,
"client_credentials"
),
new
NameValuePair
(
"scope"
,
"write"
)
};
postMethod
.
setRequestBody
(
data
);
HttpClient
httpClient
=
new
HttpClient
();
// 执行POST方法
int
response
=
httpClient
.
executeMethod
(
postMethod
);
String
result
=
postMethod
.
getResponseBodyAsString
()
;
return
result
;
}
catch
(
Exception
e
)
{
return
"{\n"
+
" \"error\": \"interError\",\n"
+
" \"message\": \"请求接口失败\",\n"
+
" \"path\": \"/oauth/token\"\n"
+
"}"
;
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
resPonse
=
httpPostGetToken
(
"http://apistage.huilianyi.com/gateway/oauth/token"
,
"a92074ce-ff45-409e-8ff9-3516415d8f82"
,
"NTY4ZmUyY2QtOTc3YS00MTU0LWIxNTEtYmZiNjQ5M2ZjYjY0"
);
System
.
out
.
println
(
resPonse
);
}
}
src/main/webapp/WEB-INF/classes/token/TOKEN001/token_savelogs.lwm
0 → 100644
View file @
ac4602b5
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: zhangxing5129
$Date: 2014-7-14 下午03:09:37
$Revision: 1.0
$Purpose:
-->
<bm:model
xmlns:o=
"leaf.database.local.oracle"
xmlns:bm=
"http://www.leaf-framework.org/schema/bm"
xmlns:f=
"leaf.database.features"
needAccessControl=
"false"
>
<bm:operations>
<bm:operation
name=
"query"
>
<bm:query-sql>
<![CDATA[
SELECT t.access_token
FROM (SELECT v.record_id, v.access_token
FROM token_record_info v
where v.start_time <= sysdate
and v.over_time >
= sysdate
order by v.record_id desc) t
where rownum = 1
]]>
</bm:query-sql>
</bm:operation>
<bm:operation
name=
"update"
>
<bm:update-sql>
<![CDATA[
begin
token_post_pkg.insert_token_recode(p_system_source =>
${@system_source},
p_expires_in =>${@expires_in},
p_access_token =>${@access_token},
p_user_id => ${/session/@user_id}
);
end;]]>
</bm:update-sql>
</bm:operation>
<bm:operation
name=
"execute"
>
<bm:update-sql>
<![CDATA[begin
${@check_token_valid}:= token_post_pkg.check_token_valid;
end;]]>
</bm:update-sql>
<bm:parameters>
<bm:parameter
name=
"check_token_valid"
output=
"true"
outputPath=
"@check_token_valid"
/>
</bm:parameters>
</bm:operation>
<bm:operation
name=
"insert"
>
<bm:update-sql>
<![CDATA[
begin
insert into token_response_logs
(
log_id,
response_json,
status,
created_by,
creation_date,
last_updated_by,
last_update_date
) values
(token_response_logs_s.nextval,
${@json},
${@status},
${/session/@user_id},
sysdate,
${/session/@user_id},
sysdate
);
commit;
end;]]>
</bm:update-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field
name=
"access_token"
/>
</bm:fields>
</bm:model>
src/main/webapp/WEB-INF/server-script/token_record.js
0 → 100644
View file @
ac4602b5
importClass
(
Packages
.
com
.
hand
.
hlcm
.
HttpPostUtil
);
importPackage
(
Packages
.
java
.
io
);
importPackage
(
Packages
.
java
.
util
);
//importClass(Packages.leaf.plugin.util.Base64);
function
httpPostGetToken
(
postUrl
,
appId
,
appSecret
)
{
try
{
var
result
=
new
HttpPostUtil
().
httpPostGetToken
(
postUrl
,
appId
,
appSecret
);
return
result
;
}
catch
(
e
)
{
println
(
e
);
return
false
;
}
}
\ No newline at end of file
src/main/webapp/modules/hls/HLS536/hls_journal_import_wfl.lview
View file @
ac4602b5
...
...
@@ -89,7 +89,7 @@
<a:field
name=
"wfl_status"
/>
</a:fields>
</a:dataSet>
<a:dataSet
id=
"hls_journal_header_result_ds"
autoPageSize=
"true"
autoQuery=
"true"
model=
"hls.HLS536.hls_journal_import_header"
queryDataSet=
"hls_journal_header_query"
selectable=
"true"
>
<a:dataSet
id=
"hls_journal_header_result_ds"
autoPageSize=
"true"
autoQuery=
"true"
model=
"hls.HLS536.hls_journal_import_header
_wfl
"
queryDataSet=
"hls_journal_header_query"
selectable=
"true"
>
</a:dataSet>
</a:dataSets>
<a:screenBody>
...
...
src/main/webapp/modules/token_query.lsc
0 → 100644
View file @
ac4602b5
<?xml version="1.0" encoding="UTF-8"?>
<a:service
xmlns:p=
"uncertain.proc"
xmlns:a=
"http://www.leaf-framework.org/application"
xmlns:s=
"leaf.plugin.script"
trace=
"true"
>
<a:init-procedure>
<s:server-script
import=
"token_record.js"
>
<![CDATA[
try {
var sys_url_bm = $bm('cont.CON4000.get_sys_url');
var parameter_code = 'TOKEN_POSTURL';
var SysposturlQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var posturl = SysposturlQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_APPID';
var SysappidQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_appid = SysappidQuery.getChildren()[0].parameter_value;
var parameter_code = 'TOKEN_APPSECRET';
var SysappsecretQuery = sys_url_bm.queryAsMap({
parameter_code: parameter_code
});
var token_appsecret = SysappsecretQuery.getChildren()[0].parameter_value;
var token_savelogs_bm = $bm('token.TOKEN001.token_savelogs');
token_savelogs_bm.execute;
var check_token_valid = $ctx.current_parameter.check_token_valid;
if (check_token_valid = 'true') {
var SystokenQuery = token_savelogs_bm.queryAsMap();
var access_token = SystokenQuery.getChildren()[0].access_token;
} else {
var data = httpPostGetToken(posturl, token_appid, token_appsecret);
var json = JSON.parse(data);
var access_token = json.access_token;
var status = json.status;
if (access_token) {
token_savelogs_bm.insert({
'json': data,
'status': 'success'
})
token_savelogs_bm.update({
'system_source': 'hlcm',
'expires_in': json.expires_in,
'access_token': access_token
})
}
if (status) {
var token_savelogs_bm = $bm('token.TOKEN001.token_savelogs');
token_savelogs_bm.insert({
'json': json,
'status': 'fail'
});
}
}
} catch (e) {
println('e:' + e);
}
]]>
</s:server-script>
</a:init-procedure>
</a:service>
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