From b642788dda56b058e2a4c40a9c43e29a5db85865 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期一, 14 八月 2023 09:35:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/UBCS/ubcs-codeApply/src/main/java/com/vci/ubcs/codeapply/CodeApplyFor410Dialog.java |   47 ++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/Source/UBCS/ubcs-codeApply/src/main/java/com/vci/ubcs/codeapply/CodeApplyFor410Dialog.java b/Source/UBCS/ubcs-codeApply/src/main/java/com/vci/ubcs/codeapply/CodeApplyFor410Dialog.java
index 11b60ee..69d7a80 100644
--- a/Source/UBCS/ubcs-codeApply/src/main/java/com/vci/ubcs/codeapply/CodeApplyFor410Dialog.java
+++ b/Source/UBCS/ubcs-codeApply/src/main/java/com/vci/ubcs/codeapply/CodeApplyFor410Dialog.java
@@ -1,16 +1,19 @@
 package com.vci.ubcs.codeapply;
 
-import com.vci.base.common.resource.CommonProperties;
+import com.alibaba.cloud.commons.lang.StringUtils;
+import com.alibaba.fastjson.JSONObject;
 import com.vci.base.ui.swing.VCIOptionPane;
 import com.vci.base.ui.swing.VCISwingUtil;
 import com.vci.base.ui.swing.components.VCIJButton;
 import com.vci.base.ui.swing.components.VCIJDialog;
 import com.vci.base.ui.swing.components.VCIJPanel;
+import com.vci.ubcs.codeapply.object.TokenUserObject;
+import com.vci.ubcs.codeapply.object.UserObject;
 import com.vci.ubcs.codeapply.utils.ConfigUtils;
-import com.vci.ubcs.system.user.entity.User;
-
+import com.vci.ubcs.codeapply.utils.HttpUtil;
 import javax.swing.*;
 import java.awt.*;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -18,7 +21,7 @@
 
 
 	private static final long serialVersionUID = -3286164100581857853L;
-	private static User userOb = new User();
+	private static TokenUserObject tokenUserObject = new TokenUserObject();
 	private String userName = null;
 	private String codeValue = null;
 	private CodeApplyFor410DialogActionListener actionListener = new CodeApplyFor410DialogActionListener(this);
@@ -27,6 +30,7 @@
 	private CodeApplyPanelFor410 mainPal = null;
 	private Component parentComponet = null;
 	private Map<String, String> attrNameAndValMap = new LinkedHashMap();//瀛樺偍灞炴�у悕绉帮紙鍖呭惈鍐呴儴鍚嶇О鍜屽閮ㄥ悕绉帮級鍜屽搴旂殑鍊�
+	private String tokenUrl= ConfigUtils.getConfigValue("410.code.token.url","http://127.0.0.1:37000/ubcs-auth/oauth/token");
 
 	/**
 	 * 瀛樺偍鍒嗙被鐨凪ap,key:鍒嗙被鍚嶇О锛寁alue锛氬垎绫诲��
@@ -47,6 +51,7 @@
 	}
 	public CodeApplyFor410Dialog(Frame frame, String userName, String clsfName, String deptName, String[] libName){
 		super(frame, true);
+		VCISwingUtil.setClientMainFrame(frame);
 		try {
 			this.setModal(true);
 			parentComponet = frame;
@@ -62,6 +67,7 @@
 
 	public CodeApplyFor410Dialog(JDialog dialog, String userName, String clsfName, String deptName, String[] libName) {
 		super(dialog, true);
+		VCISwingUtil.setClientMainFrame(new Frame());
 		try {
 			this.setModal(true);
 			parentComponet = dialog;
@@ -76,10 +82,33 @@
 		}
 	}
 
-	private void initUserInfo() {
-//		userOb.set("127.0.0.1");
-//		userOb.setModules("TC闆嗘垚浠g爜鐢宠");
-//		userOb.setUserName(userName);
+	private void initUserInfo() throws Exception {
+		/*userOb.set("127.0.0.1");
+		userOb.setModules("TC闆嗘垚浠g爜鐢宠");
+		userOb.setUserName(userName);*/
+		Map<String,String> headerMap=new HashMap<>();
+		headerMap.put("Tenant-Id",ConfigUtils.getConfigValue("410.code.token.tenantId","000000"));
+		headerMap.put("Authorization",ConfigUtils.getConfigValue("410.code.token.authorization","Basic c3dvcmQ6c3dvcmRfc2VjcmV0"));
+		headerMap.put("Content-Type",ConfigUtils.getConfigValue("410.code.token.contentType","application/x-www-form-urlencoded"));
+
+		UserObject userObject=new UserObject();
+		Map<String,String> parmarMap=new HashMap<>();
+		//userObject.set("Tenant-Id",ConfigUtils.getConfigValue("410.code.token.tenantId","000000"));
+		/*userObject.setUsername("admin");
+		userObject.setPassword("21232f297a57a5a743894a0e4a801fc3");
+		userObject.setGrant_type("password");
+		userObject.setScope("all");
+		Object object = JSONObject.toJSON(userObject);*/
+		parmarMap.put("username","admin");
+		parmarMap.put("password","21232f297a57a5a743894a0e4a801fc3");
+		parmarMap.put("scope","all");
+		parmarMap.put("grant_type","password");
+		String result=HttpUtil.sendFormPost(tokenUrl,parmarMap,headerMap);
+		if (StringUtils.isNotBlank(result)) {
+			tokenUserObject = JSONObject.toJavaObject(JSONObject.parseObject(result), TokenUserObject.class);
+		}else{
+			throw  new Exception("楠岃瘉鐢ㄦ埛閴存潈淇℃伅澶辫触!");
+		}
 	}
 
 	public void buildDialog() {
@@ -110,7 +139,7 @@
 	private void bulidPal() throws Exception {
 		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
 		this.setTitle("浠g爜鐢宠");
-		mainPal = new CodeApplyPanelFor410(this,userOb, true, clsfName, deptName,libName);
+		mainPal = new CodeApplyPanelFor410(this,tokenUserObject, true, clsfName, deptName,libName);
 
 		VCIJPanel btnPal = new VCIJPanel();
 		btnPal.add(okBtn);

--
Gitblit v1.9.3