21 changed files with 1203 additions and 1 deletions
Binary file not shown.
@ -1,3 +1,6 @@ |
|||||||
# open-JSD-9302 |
# open-JSD-9302 |
||||||
|
|
||||||
JSD-9302 OAuth2 + 用户同步 |
JSD-9302 OAuth2 + 用户同步\ |
||||||
|
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||||
|
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||||
|
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 |
Binary file not shown.
@ -0,0 +1,29 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<plugin> |
||||||
|
<id>com.fr.plugin.icjb.sso</id> |
||||||
|
<name><![CDATA[单点登陆&用户同步]]></name> |
||||||
|
<active>yes</active> |
||||||
|
<version>1.3</version> |
||||||
|
<env-version>10.0</env-version> |
||||||
|
<jartime>2018-07-31</jartime> |
||||||
|
<vendor>fr.open</vendor> |
||||||
|
<description><![CDATA[单点登陆&用户同步]]></description> |
||||||
|
<change-notes><![CDATA[单点登陆&用户同步]]></change-notes> |
||||||
|
<main-package>com.fr.plugin.icjb</main-package> |
||||||
|
<prefer-packages> |
||||||
|
<prefer-package>com.fanruan.api</prefer-package> |
||||||
|
</prefer-packages> |
||||||
|
<lifecycle-monitor class="com.fr.plugin.icjb.PluginMonitor"/> |
||||||
|
<extra-core> |
||||||
|
<LocaleFinder class="com.fr.plugin.icjb.LocaleFinder"/> |
||||||
|
</extra-core> |
||||||
|
<extra-designer> |
||||||
|
<TableDataDefineProvider class="com.fr.plugin.icjb.provider.UsersTableDataDefine"/> |
||||||
|
<ServerTableDataDefineProvider class="com.fr.plugin.icjb.provider.UsersTableDataDefine"/> |
||||||
|
</extra-designer> |
||||||
|
<extra-decision> |
||||||
|
<GlobalRequestFilterProvider class="com.fr.plugin.icjb.request.OAuthLogin"/> |
||||||
|
<LogInOutEventProvider class="com.fr.plugin.icjb.CustomLogInOut"/> |
||||||
|
</extra-decision> |
||||||
|
<function-recorder class="com.fr.plugin.icjb.LocaleFinder"/> |
||||||
|
</plugin> |
@ -0,0 +1,52 @@ |
|||||||
|
/** |
||||||
|
* Copyright (C), 2015-2021 |
||||||
|
* FileName: CustomLogInOut |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2019/6/19 16:25 |
||||||
|
* Description: CustomLogInOut |
||||||
|
* History: |
||||||
|
* <author> <time> <version> <desc> |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb; |
||||||
|
|
||||||
|
import com.fanruan.api.log.LogKit; |
||||||
|
import com.fanruan.api.util.StringKit; |
||||||
|
import com.fr.decision.fun.impl.AbstractLogInOutEventProvider; |
||||||
|
import com.fr.decision.webservice.login.LogInOutResultInfo; |
||||||
|
import com.fr.plugin.icjb.config.IcjbConfig; |
||||||
|
|
||||||
|
import static com.fr.plugin.icjb.request.OAuthLogin.SSO_ACCESS_TOKEN; |
||||||
|
|
||||||
|
/** |
||||||
|
* 〈Function Description〉<br> |
||||||
|
* 〈CustomLogInOut〉 |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class CustomLogInOut extends AbstractLogInOutEventProvider { |
||||||
|
|
||||||
|
public static final String LOGOUT_PATH = "/logout"; |
||||||
|
private final IcjbConfig config; |
||||||
|
|
||||||
|
public CustomLogInOut() { |
||||||
|
this.config = IcjbConfig.getInstance(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 用户登出处理 |
||||||
|
* |
||||||
|
* @param result |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public String logoutAction(LogInOutResultInfo result) { |
||||||
|
String accessToken = String.valueOf(result.getRequest().getSession().getAttribute(SSO_ACCESS_TOKEN)); |
||||||
|
if (StringKit.isNotBlank(accessToken) && !StringKit.equals(accessToken, "null")) { |
||||||
|
String url = this.config.getUriBase() + LOGOUT_PATH + "?access_token=" + accessToken; |
||||||
|
LogKit.info("ijbd-CustomLogInOut-logoutAction-logoutUrl:{}", url); |
||||||
|
return url; |
||||||
|
} |
||||||
|
return StringKit.EMPTY; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2020 |
||||||
|
* Project: starter |
||||||
|
* FileName: LocaleFinder |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2020/8/31 22:19 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb; |
||||||
|
|
||||||
|
import com.fr.intelli.record.Focus; |
||||||
|
import com.fr.intelli.record.Original; |
||||||
|
import com.fr.record.analyzer.EnableMetrics; |
||||||
|
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||||
|
|
||||||
|
import static com.fr.plugin.icjb.config.IcjbConfig.PLUGIN_ID; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <LocaleFinder> |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
@EnableMetrics |
||||||
|
public class LocaleFinder extends AbstractLocaleFinder { |
||||||
|
|
||||||
|
@Override |
||||||
|
@Focus(id = PLUGIN_ID, text = "Plugin-icjb", source = Original.PLUGIN) |
||||||
|
public String find() { |
||||||
|
return "com/fr/plugin/icjb/locale/lang"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: PluginMonitor |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2021/3/30 15:10 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb; |
||||||
|
|
||||||
|
import com.fr.plugin.context.PluginContext; |
||||||
|
import com.fr.plugin.icjb.config.IcjbConfig; |
||||||
|
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <PluginMonitor> |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class PluginMonitor extends AbstractPluginLifecycleMonitor { |
||||||
|
public PluginMonitor() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void afterRun(PluginContext pluginContext) { |
||||||
|
IcjbConfig.getInstance(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void beforeStop(PluginContext pluginContext) { |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,74 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: SsoConfig |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2021/3/30 9:38 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb.config; |
||||||
|
|
||||||
|
import com.fanruan.api.util.StringKit; |
||||||
|
import com.fr.config.*; |
||||||
|
import com.fr.config.holder.Conf; |
||||||
|
import com.fr.config.holder.factory.Holders; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <SsoConfig> |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
@Visualization(category = "Plugin-icjb_Group") |
||||||
|
public class IcjbConfig extends DefaultConfiguration { |
||||||
|
public static final String PLUGIN_ID = "com.fr.plugin.icjb.sso"; |
||||||
|
|
||||||
|
private static volatile IcjbConfig config = null; |
||||||
|
@Identifier(value = "uriBase", name = "Plugin-icjb_Config_UriBase", description = "Plugin-icjb_Config_UriBase_Description", status = Status.SHOW) |
||||||
|
private final Conf<String> uriBase = Holders.simple(StringKit.EMPTY); |
||||||
|
@Identifier(value = "clientId", name = "Plugin-icjb_Config_ClientId", description = "Plugin-icjb_Config_ClientId_Description", status = Status.SHOW) |
||||||
|
private Conf<String> clientId = Holders.simple(StringKit.EMPTY); |
||||||
|
@Identifier(value = "clientSecret", name = "Plugin-icjb_Config_ClientSecret", description = "Plugin-icjb_Config_ClientSecret_Description", status = Status.SHOW) |
||||||
|
private Conf<String> clientSecret = Holders.simple(StringKit.EMPTY); |
||||||
|
@Identifier(value = "frUri", name = "Plugin-icjb_Config_FrUri", description = "Plugin-icjb_Config_FrUri_Description", status = Status.SHOW) |
||||||
|
private Conf<String> frUri = Holders.simple(StringKit.EMPTY); |
||||||
|
|
||||||
|
public static IcjbConfig getInstance() { |
||||||
|
if (config == null) { |
||||||
|
config = ConfigContext.getConfigInstance(IcjbConfig.class); |
||||||
|
} |
||||||
|
return config; |
||||||
|
} |
||||||
|
|
||||||
|
public String getUriBase() { |
||||||
|
return uriBase.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setUriBase(String uriBase) { |
||||||
|
this.uriBase.set(uriBase); |
||||||
|
} |
||||||
|
|
||||||
|
public String getClientId() { |
||||||
|
return clientId.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setClientId(String clientId) { |
||||||
|
this.clientId.set(clientId); |
||||||
|
} |
||||||
|
|
||||||
|
public String getClientSecret() { |
||||||
|
return clientSecret.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setClientSecret(String clientSecret) { |
||||||
|
this.clientSecret.set(clientSecret); |
||||||
|
} |
||||||
|
|
||||||
|
public String getFrUri() { |
||||||
|
return frUri.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setFrUri(String frUri) { |
||||||
|
this.frUri.set(frUri); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,113 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: DeptTableDataModel |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2021/12/16 8:35 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb.data; |
||||||
|
|
||||||
|
import com.fanruan.api.design.DesignKit; |
||||||
|
import com.fanruan.api.log.LogKit; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.http.HttpToolbox; |
||||||
|
import com.fr.json.JSONArray; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.plugin.context.PluginContexts; |
||||||
|
import com.fr.stable.ParameterProvider; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <DeptTableDataModel> |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class DeptTableDataModel extends WebTableDataModel { |
||||||
|
private static final long serialVersionUID = 7967179724805496262L; |
||||||
|
|
||||||
|
public DeptTableDataModel(ParameterProvider[] parameters) { |
||||||
|
super(parameters); |
||||||
|
this.columnNames = new String[]{"createDate", "updateDate", "status", "treeSort", "officeCode", "officeName", "parentCode", "parentCodes"}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void init() { |
||||||
|
if (!PluginContexts.currentContext().isAvailable()) { |
||||||
|
LogKit.error(DesignKit.i18nText("Plugin-icjb_Licence_Expired")); |
||||||
|
return; |
||||||
|
} |
||||||
|
if (this.valueList != null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
this.valueList = new ArrayList(); |
||||||
|
// 域名
|
||||||
|
this.host = this.parameters[0].getValue().toString(); |
||||||
|
// 登录名(盟拓方提供)
|
||||||
|
String code = this.parameters[1].getValue().toString(); |
||||||
|
// 密钥固定分配:Qazxsw4321)
|
||||||
|
String secret = this.parameters[2].getValue().toString(); |
||||||
|
// 第三方应用分配的唯一标识(盟拓方提供)
|
||||||
|
String clientId = this.parameters[3].getValue().toString(); |
||||||
|
// 开始日期
|
||||||
|
String startDate = this.parameters[4].getValue().toString(); |
||||||
|
// 结束日期
|
||||||
|
String endDate = this.parameters[5].getValue().toString(); |
||||||
|
|
||||||
|
try { |
||||||
|
String accessToken = this.getAccessToken(code, secret, clientId); |
||||||
|
JSONArray deptInfo = getDeptInfo(accessToken, startDate, endDate); |
||||||
|
addFRDeptInfo2List(deptInfo); |
||||||
|
} catch (IOException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 人员获取 |
||||||
|
* |
||||||
|
* @param accessToken |
||||||
|
* @param startDate |
||||||
|
* @param endDate |
||||||
|
* @return |
||||||
|
* @throws IOException |
||||||
|
*/ |
||||||
|
private JSONArray getDeptInfo(String accessToken, String startDate, String endDate) throws IOException { |
||||||
|
JSONObject resultJson; |
||||||
|
Map<String, String> header = new HashMap<>(); |
||||||
|
header.put("Authorization", "Bearer " + accessToken); |
||||||
|
Map<String, String> params = new HashMap<>(); |
||||||
|
params.put("startDate", startDate); |
||||||
|
params.put("endDate", endDate); |
||||||
|
String result = HttpToolbox.get(this.host + "sync/open-api/office-list", params, header); |
||||||
|
FineLoggerFactory.getLogger().info("icjb-DeptTableDataModel-getDeptInfo-result:{}", result); |
||||||
|
if (StringUtils.isNotBlank(result) && ComparatorUtils.equals(0, (resultJson = new JSONObject(result)).getInt("code"))) { |
||||||
|
return resultJson.getJSONArray("data"); |
||||||
|
} |
||||||
|
throw new RuntimeException("DeptTableDataModel getDeptInfo 获取结果异常"); |
||||||
|
} |
||||||
|
|
||||||
|
private void addFRDeptInfo2List(JSONArray deptInfo) { |
||||||
|
ArrayList<String> frDeptInfo; |
||||||
|
for (Object o : deptInfo) { |
||||||
|
JSONObject userInfo = (JSONObject) o; |
||||||
|
frDeptInfo = new ArrayList<>(); |
||||||
|
frDeptInfo.add(userInfo.getString("createDate")); |
||||||
|
frDeptInfo.add(userInfo.getString("updateDate")); |
||||||
|
frDeptInfo.add(userInfo.getString("status")); |
||||||
|
frDeptInfo.add(userInfo.getString("treeSort")); |
||||||
|
frDeptInfo.add(userInfo.getString("officeCode")); |
||||||
|
frDeptInfo.add(userInfo.getString("officeName")); |
||||||
|
frDeptInfo.add(userInfo.getString("parentCode")); |
||||||
|
frDeptInfo.add(userInfo.getString("parentCodes")); |
||||||
|
this.valueList.add(frDeptInfo.toArray()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,93 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: WechatTableData |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2021/12/8 16:55 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb.data; |
||||||
|
|
||||||
|
import com.fanruan.api.conf.HolderKit; |
||||||
|
import com.fanruan.api.data.open.BaseTableData; |
||||||
|
import com.fanruan.api.util.AssistKit; |
||||||
|
import com.fanruan.api.util.GeneralKit; |
||||||
|
import com.fr.base.TableData; |
||||||
|
import com.fr.config.Identifier; |
||||||
|
import com.fr.config.holder.Conf; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.data.DataModel; |
||||||
|
import com.fr.script.Calculator; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <UsersTableData> |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class UsersTableData extends BaseTableData { |
||||||
|
private static final long serialVersionUID = -7456007025209900779L; |
||||||
|
@Identifier("searchType") |
||||||
|
private Conf<Integer> searchType = HolderKit.simple(0); |
||||||
|
|
||||||
|
@Override |
||||||
|
public DataModel createDataModel(Calculator calculator) { |
||||||
|
return createDataModel(calculator, TableData.RESULT_ALL); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DataModel createDataModel(Calculator calculator, int rowCount) { |
||||||
|
if (ComparatorUtils.equals(this.getSearchType(), 1)) { |
||||||
|
return new DeptTableDataModel(Calculator.processParameters(calculator, super.getParameters(calculator))); |
||||||
|
} else { |
||||||
|
return new UsersTableDataModel(Calculator.processParameters(calculator, super.getParameters(calculator))); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
super.readXML(reader); |
||||||
|
if (reader.isChildNode()) { |
||||||
|
String tmpName = reader.getTagName(); |
||||||
|
if ("Attributes".equals(tmpName)) { |
||||||
|
this.setSearchType(reader.getAttrAsInt("searchType", 0)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeXML(XMLPrintWriter writer) { |
||||||
|
super.writeXML(writer); |
||||||
|
writer.startTAG("Attributes"); |
||||||
|
writer.attr("searchType", GeneralKit.objectToString(this.getSearchType())); |
||||||
|
writer.end(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object clone() throws CloneNotSupportedException { |
||||||
|
UsersTableData cloned = (UsersTableData) super.clone(); |
||||||
|
cloned.searchType = (Conf<Integer>) searchType.clone(); |
||||||
|
return cloned; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean equals(Object obj) { |
||||||
|
return obj instanceof UsersTableData |
||||||
|
&& AssistKit.equals(this.searchType, ((UsersTableData) obj).searchType); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int hashCode() { |
||||||
|
return AssistKit.hashCode(this.searchType.get()); |
||||||
|
} |
||||||
|
|
||||||
|
public int getSearchType() { |
||||||
|
return this.searchType.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setSearchType(int searchType) { |
||||||
|
this.searchType.set(searchType); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,120 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: WechatTableDataModel |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2021/12/8 19:09 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb.data; |
||||||
|
|
||||||
|
import com.fanruan.api.design.DesignKit; |
||||||
|
import com.fanruan.api.log.LogKit; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.http.HttpToolbox; |
||||||
|
import com.fr.json.JSONArray; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.plugin.context.PluginContexts; |
||||||
|
import com.fr.stable.ParameterProvider; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <UsersTableDataModel> |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class UsersTableDataModel extends WebTableDataModel { |
||||||
|
private static final long serialVersionUID = 8191435706966886501L; |
||||||
|
|
||||||
|
public UsersTableDataModel(ParameterProvider[] parameters) { |
||||||
|
super(parameters); |
||||||
|
this.columnNames = new String[]{"id", "createDate", "updateDate", "status", "userCode", "loginCode", "phone", "email", "sex", "userWeight", "mobile", "userName"}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void init() { |
||||||
|
if (!PluginContexts.currentContext().isAvailable()) { |
||||||
|
LogKit.error(DesignKit.i18nText("Plugin-icjb_Licence_Expired")); |
||||||
|
return; |
||||||
|
} |
||||||
|
if (this.valueList != null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
this.valueList = new ArrayList(); |
||||||
|
// 域名
|
||||||
|
this.host = this.parameters[0].getValue().toString(); |
||||||
|
// 登录名(盟拓方提供)
|
||||||
|
String code = this.parameters[1].getValue().toString(); |
||||||
|
// 密钥固定分配:Qazxsw4321)
|
||||||
|
String secret = this.parameters[2].getValue().toString(); |
||||||
|
// 第三方应用分配的唯一标识(盟拓方提供)
|
||||||
|
String clientId = this.parameters[3].getValue().toString(); |
||||||
|
// 开始日期
|
||||||
|
String startDate = this.parameters[4].getValue().toString(); |
||||||
|
// 结束日期
|
||||||
|
String endDate = this.parameters[5].getValue().toString(); |
||||||
|
|
||||||
|
try { |
||||||
|
String accessToken = this.getAccessToken(code, secret, clientId); |
||||||
|
JSONArray usersInfo = getUserInfo(accessToken, startDate, endDate); |
||||||
|
addFRUserInfo2List(usersInfo); |
||||||
|
} catch (IOException e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 人员获取 |
||||||
|
* |
||||||
|
* @param accessToken |
||||||
|
* @param startDate |
||||||
|
* @param endDate |
||||||
|
* @return |
||||||
|
* @throws IOException |
||||||
|
*/ |
||||||
|
private JSONArray getUserInfo(String accessToken, String startDate, String endDate) throws IOException { |
||||||
|
JSONObject resultJson; |
||||||
|
Map<String, String> header = new HashMap<>(); |
||||||
|
header.put("Authorization", "Bearer " + accessToken); |
||||||
|
Map<String, String> params = new HashMap<>(); |
||||||
|
params.put("startDate", startDate); |
||||||
|
params.put("endDate", endDate); |
||||||
|
String result = HttpToolbox.get(this.host + "sync/open-api/user-list", params, header); |
||||||
|
FineLoggerFactory.getLogger().info("icjb-UsersTableDataModel-getUserInfo-result:{}", result); |
||||||
|
if (StringUtils.isNotBlank(result) && ComparatorUtils.equals(0, (resultJson = new JSONObject(result)).getInt("code"))) { |
||||||
|
return resultJson.getJSONArray("data"); |
||||||
|
} |
||||||
|
throw new RuntimeException("icjb-UsersTableDataModel-getUserInfo 获取结果异常"); |
||||||
|
} |
||||||
|
|
||||||
|
private void addFRUserInfo2List(JSONArray usersInfo) { |
||||||
|
ArrayList<String> frUserInfo; |
||||||
|
for (Object o : usersInfo) { |
||||||
|
JSONObject userInfo = (JSONObject) o; |
||||||
|
frUserInfo = new ArrayList<>(); |
||||||
|
if (!StringUtils.equals(userInfo.getString("status"), "0")) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
frUserInfo.add(userInfo.getString("id")); |
||||||
|
frUserInfo.add(userInfo.getString("createDate")); |
||||||
|
frUserInfo.add(userInfo.getString("updateDate")); |
||||||
|
frUserInfo.add(userInfo.getString("status")); |
||||||
|
frUserInfo.add(userInfo.getString("userCode")); |
||||||
|
frUserInfo.add(userInfo.getString("loginCode")); |
||||||
|
frUserInfo.add(userInfo.getString("phone")); |
||||||
|
frUserInfo.add(userInfo.getString("email")); |
||||||
|
frUserInfo.add(userInfo.getString("sex")); |
||||||
|
frUserInfo.add(userInfo.getString("userWeight")); |
||||||
|
frUserInfo.add(userInfo.getString("mobile")); |
||||||
|
frUserInfo.add(userInfo.getString("userName")); |
||||||
|
this.valueList.add(frUserInfo.toArray()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,91 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: WebTableDataModel |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2021/12/16 8:17 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb.data; |
||||||
|
|
||||||
|
import com.fanruan.api.data.open.BaseDataModel; |
||||||
|
import com.fanruan.api.err.TableDataException; |
||||||
|
import com.fr.base.Base64; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.http.HttpToolbox; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.stable.CodeUtils; |
||||||
|
import com.fr.stable.ParameterProvider; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.ArrayList; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <WebTableDataModel> |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public abstract class WebTableDataModel extends BaseDataModel { |
||||||
|
private static final long serialVersionUID = 5010918328453603247L; |
||||||
|
protected ParameterProvider[] parameters; |
||||||
|
protected String[] columnNames; |
||||||
|
protected ArrayList valueList = null; |
||||||
|
protected String host; |
||||||
|
|
||||||
|
public WebTableDataModel(ParameterProvider[] parameters) { |
||||||
|
this.parameters = parameters; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getColumnCount() throws TableDataException { |
||||||
|
return this.columnNames.length; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getColumnName(int i) throws TableDataException { |
||||||
|
return columnNames[i]; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getRowCount() throws TableDataException { |
||||||
|
init(); |
||||||
|
return valueList.size(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object getValueAt(int row, int col) throws TableDataException { |
||||||
|
init(); |
||||||
|
return ((Object[]) valueList.get(row))[col]; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void release() throws Exception { |
||||||
|
this.parameters = null; |
||||||
|
} |
||||||
|
|
||||||
|
protected abstract void init(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取访问令牌接口(Token) |
||||||
|
* |
||||||
|
* @param code |
||||||
|
* @param secret |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
protected String getAccessToken(String code, String secret, String clientId) throws IOException { |
||||||
|
JSONObject resultJson; |
||||||
|
String timestamp = String.valueOf(System.currentTimeMillis()); |
||||||
|
String sign = Base64.encode(CodeUtils.md5Encode(code + timestamp + secret, StringUtils.EMPTY, "MD5").getBytes()); |
||||||
|
String url = this.host + "token/signLogin?code=" + code + "&type=0&clientId=" + clientId + "×tamp=" + timestamp + "&sign=" + sign; |
||||||
|
FineLoggerFactory.getLogger().info("icjb-UsersTableDataModel-getAccessToken-url:{}", url); |
||||||
|
String result = HttpToolbox.get(url); |
||||||
|
FineLoggerFactory.getLogger().info("icjb-UsersTableDataModel-getAccessToken-result:{}", result); |
||||||
|
if (StringUtils.isNotBlank(result) && ComparatorUtils.equals(0, (resultJson = new JSONObject(result)).getInt("code"))) { |
||||||
|
return resultJson.getJSONObject("data").getString("access_token"); |
||||||
|
} |
||||||
|
throw new RuntimeException("icjb-UsersTableDataModel-getAccessToken 获取结果异常"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: WechatTableDataDefine |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2021/12/8 16:41 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb.provider; |
||||||
|
|
||||||
|
import com.fanruan.api.design.DesignKit; |
||||||
|
import com.fr.base.TableData; |
||||||
|
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; |
||||||
|
import com.fr.design.fun.ServerTableDataDefineProvider; |
||||||
|
import com.fr.design.fun.impl.AbstractTableDataDefineProvider; |
||||||
|
import com.fr.plugin.icjb.data.UsersTableData; |
||||||
|
import com.fr.plugin.icjb.ui.UsersTableDataPane; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <WechatTableDataDefine> |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class UsersTableDataDefine extends AbstractTableDataDefineProvider implements ServerTableDataDefineProvider { |
||||||
|
public static final String ICON_PATH = "/com/fr/plugin/icjb/images/logo16.png"; |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends TableData> classForTableData() { |
||||||
|
return UsersTableData.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends TableData> classForInitTableData() { |
||||||
|
return UsersTableData.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends AbstractTableDataPane> appearanceForTableData() { |
||||||
|
return UsersTableDataPane.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String nameForTableData() { |
||||||
|
return DesignKit.i18nText("Plugin-icjb_Users_Table_Data"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String prefixForTableData() { |
||||||
|
return DesignKit.i18nText("Plugin-icjb_Users_Table_Data"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String iconPathForTableData() { |
||||||
|
return ICON_PATH; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,199 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: OAuthLogin |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2021/3/30 22:09 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb.request; |
||||||
|
|
||||||
|
import com.fanruan.api.decision.login.LoginKit; |
||||||
|
import com.fanruan.api.decision.user.UserKit; |
||||||
|
import com.fanruan.api.i18n.I18nKit; |
||||||
|
import com.fanruan.api.log.LogKit; |
||||||
|
import com.fanruan.api.net.NetworkKit; |
||||||
|
import com.fanruan.api.net.http.HttpKit; |
||||||
|
import com.fanruan.api.util.StringKit; |
||||||
|
import com.fr.decision.fun.impl.AbstractGlobalRequestFilterProvider; |
||||||
|
import com.fr.decision.mobile.terminal.TerminalHandler; |
||||||
|
import com.fr.decision.webservice.utils.DecisionServiceConstants; |
||||||
|
import com.fr.decision.webservice.v10.login.LoginService; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.plugin.context.PluginContexts; |
||||||
|
import com.fr.plugin.icjb.config.IcjbConfig; |
||||||
|
import com.fr.stable.fun.Authorize; |
||||||
|
import com.fr.third.org.apache.http.client.utils.URIBuilder; |
||||||
|
import com.fr.web.utils.WebUtils; |
||||||
|
|
||||||
|
import javax.servlet.FilterChain; |
||||||
|
import javax.servlet.FilterConfig; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
import java.net.URISyntaxException; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import static com.fr.plugin.icjb.config.IcjbConfig.PLUGIN_ID; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <OAuthLogin> |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
@Authorize(callSignKey = PLUGIN_ID) |
||||||
|
public class OAuthLogin extends AbstractGlobalRequestFilterProvider { |
||||||
|
public static final String CODE_PATH = "/oauth/authorize"; |
||||||
|
public static final String TOKEN_PATH = "/token/codeInfo"; |
||||||
|
public static final String CODE = "code"; |
||||||
|
public static final String STATE = "sso"; |
||||||
|
public static final String SSO_ACCESS_TOKEN = "ssoAccessToken"; |
||||||
|
private IcjbConfig config; |
||||||
|
|
||||||
|
/** |
||||||
|
* 过滤器名称 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public String filterName() { |
||||||
|
return "icjbFilter"; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 过滤规则 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public String[] urlPatterns() { |
||||||
|
return new String[]{"/decision", "/decision/view/form", "/decision/view/report", "/decision/v10/entry/access/*"}; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 过滤器初始化 |
||||||
|
* |
||||||
|
* @param filterConfig |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void init(FilterConfig filterConfig) { |
||||||
|
this.config = IcjbConfig.getInstance(); |
||||||
|
super.init(filterConfig); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 过滤器处理 |
||||||
|
* |
||||||
|
* @param request |
||||||
|
* @param response |
||||||
|
* @param filterChain |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) { |
||||||
|
try { |
||||||
|
if (operation(request, response)) { |
||||||
|
filterChain.doFilter(request, response); |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
LogKit.error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 用户验证登陆操作 |
||||||
|
* |
||||||
|
* @param req |
||||||
|
* @param res |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
private boolean operation(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||||
|
// 已登录
|
||||||
|
if (LoginService.getInstance().isLogged(req)) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
if (TerminalHandler.getTerminal(req, WebUtils.getDevice(req)) == TerminalHandler.APP |
||||||
|
|| TerminalHandler.getTerminal(req, WebUtils.getDevice(req)) == TerminalHandler.H5) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
String code = NetworkKit.getHTTPRequestParameter(req, CODE); |
||||||
|
String state = NetworkKit.getHTTPRequestParameter(req, "state"); |
||||||
|
LogKit.info("icjb-OAuthLogin-operation-code:{}, state:{}", code, state); |
||||||
|
if (StringKit.isBlank(code)) { |
||||||
|
res.sendRedirect(getLoginUrl()); |
||||||
|
return false; |
||||||
|
} |
||||||
|
JSONObject userInfo = getUsername(code); |
||||||
|
String accessToken = userInfo.getString("access_token"); |
||||||
|
String username = userInfo.getJSONObject("user_info").getString("username"); |
||||||
|
if (StringKit.isEmpty(username) || !UserKit.existUsername(username)) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
if (!PluginContexts.currentContext().isAvailable()) { |
||||||
|
LogKit.error(I18nKit.getLocText("Plugin-icjb_Licence_Expired")); |
||||||
|
return true; |
||||||
|
} |
||||||
|
String tokenFR = LoginKit.login(req, res, username); |
||||||
|
req.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME, tokenFR); |
||||||
|
LogKit.info("icjb-OAuthLogin-operation-accessToken:{}", accessToken); |
||||||
|
req.getSession().setAttribute(SSO_ACCESS_TOKEN, accessToken); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 通过凭证获得username |
||||||
|
* |
||||||
|
* @param token |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
private JSONObject getUsername(String token) throws Exception { |
||||||
|
LogKit.info("icjb-OAuthLogin-getUsername-token:{}", token); |
||||||
|
Map<String, String> params = new HashMap<>(); |
||||||
|
params.put("client_id", this.config.getClientId()); |
||||||
|
params.put("client_secret", this.config.getClientSecret()); |
||||||
|
params.put("code", token); |
||||||
|
params.put("redirect_uri", this.config.getFrUri()); |
||||||
|
LogKit.info("icjb-OAuthLogin-getUsername-params:{}", params); |
||||||
|
String userRes = HttpKit.get(this.config.getUriBase() + TOKEN_PATH, params); |
||||||
|
LogKit.info("icjb-OAuthLogin-getUsername-userRes:{}", userRes); |
||||||
|
JSONObject userJo = new JSONObject(userRes); |
||||||
|
if (userJo.has("data")) { |
||||||
|
return userJo.getJSONObject("data"); |
||||||
|
} |
||||||
|
return JSONObject.create(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取login_url |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
private String getLoginUrl() { |
||||||
|
String url = IcjbConfig.getInstance().getUriBase() + CODE_PATH; |
||||||
|
Map<String, String> params = new HashMap<>(); |
||||||
|
params.put("client_id", this.config.getClientId()); |
||||||
|
params.put("redirect_uri", this.config.getFrUri()); |
||||||
|
params.put("scope", "server"); |
||||||
|
params.put("response_type", "code"); |
||||||
|
params.put("state", STATE); |
||||||
|
String loginUrl = buildUrl(url, params); |
||||||
|
LogKit.info("icjb-OAuthLogin-getLoginUrl-loginUrl:{}", loginUrl); |
||||||
|
return loginUrl; |
||||||
|
} |
||||||
|
|
||||||
|
private String buildUrl(String url, Map<String, String> params) { |
||||||
|
if (params == null || params.isEmpty()) { |
||||||
|
return url; |
||||||
|
} |
||||||
|
try { |
||||||
|
URIBuilder builder = new URIBuilder(url); |
||||||
|
for (Map.Entry<String, String> entry : params.entrySet()) { |
||||||
|
builder.setParameter(entry.getKey(), entry.getValue()); |
||||||
|
} |
||||||
|
return builder.build().toString(); |
||||||
|
} catch (URISyntaxException e) { |
||||||
|
LogKit.error("Error to build url, please check the arguments."); |
||||||
|
return url; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,64 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: WechatTableDataPane |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2021/12/8 19:19 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb.ui; |
||||||
|
|
||||||
|
import com.fanruan.api.design.DesignKit; |
||||||
|
import com.fr.plugin.icjb.data.UsersTableData; |
||||||
|
import com.fr.script.Calculator; |
||||||
|
import com.fr.stable.ParameterProvider; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <UsersTableDataPane> |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class UsersTableDataPane extends WebBaseTableDataPane<UsersTableData> { |
||||||
|
protected WebQueryPane queryPane; |
||||||
|
|
||||||
|
public UsersTableDataPane() { |
||||||
|
super(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected JComponent createQueryPane() { |
||||||
|
if (queryPane == null) { |
||||||
|
queryPane = new WebQueryPane(); |
||||||
|
} |
||||||
|
return queryPane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(UsersTableData data) { |
||||||
|
if (data == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
Calculator c = Calculator.createCalculator(); |
||||||
|
this.editorPane.populate(data.getParameters(c)); |
||||||
|
this.queryPane.setSearchType(data.getSearchType()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public UsersTableData updateBean() { |
||||||
|
UsersTableData data = new UsersTableData(); |
||||||
|
List<ParameterProvider> parameterProviderList = this.editorPane.update(); |
||||||
|
ParameterProvider[] parameters = parameterProviderList.toArray(new ParameterProvider[0]); |
||||||
|
data.setParameters(parameters); |
||||||
|
data.setSearchType(queryPane.getSearchType()); |
||||||
|
return data; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return DesignKit.i18nText("Plugin-icjb_Query"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,139 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: WebBaseTableDatapane |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2021/12/10 8:49 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb.ui; |
||||||
|
|
||||||
|
import com.fanruan.api.design.DesignKit; |
||||||
|
import com.fanruan.api.design.ui.action.UpdateAction; |
||||||
|
import com.fanruan.api.design.ui.component.UIToolbar; |
||||||
|
import com.fanruan.api.design.ui.component.table.UITableEditorPane; |
||||||
|
import com.fanruan.api.design.ui.component.table.action.UITableEditAction; |
||||||
|
import com.fanruan.api.design.ui.component.table.model.ParameterTableModel; |
||||||
|
import com.fanruan.api.design.ui.component.table.model.UITableModelAdapter; |
||||||
|
import com.fanruan.api.design.ui.toolbar.ToolBarDef; |
||||||
|
import com.fanruan.api.design.work.BaseTableDataPane; |
||||||
|
import com.fanruan.api.log.LogKit; |
||||||
|
import com.fanruan.api.util.IOKit; |
||||||
|
import com.fr.base.TableData; |
||||||
|
import com.fr.stable.ParameterProvider; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.io.IOException; |
||||||
|
import java.net.URI; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <WebBaseTableDatapane> |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public abstract class WebBaseTableDataPane<T extends TableData> extends BaseTableDataPane<T> { |
||||||
|
public static final String ICON_HELP = "/com/fr/plugin/icjb/images/help.png"; |
||||||
|
public static final String ICON_PREVIEW = "/com/fr/design/images/m_file/preview.png"; |
||||||
|
public static final String ICON_REFRESH = "/com/fr/design/images/control/refresh.png"; |
||||||
|
public static final String HELP_URL = "https://help.finereport.com/index.php"; |
||||||
|
private static final String PREVIEW_BUTTON = DesignKit.i18nText("Plugin-icjb_Preview"); |
||||||
|
private static final String REFRESH_BUTTON = DesignKit.i18nText("Plugin-icjb_Refresh"); |
||||||
|
private static final String HELP_BUTTON = DesignKit.i18nText("Plugin-icjb_Help"); |
||||||
|
|
||||||
|
protected UITableEditorPane<ParameterProvider> editorPane; |
||||||
|
|
||||||
|
public WebBaseTableDataPane() { |
||||||
|
this.setLayout(new BorderLayout(4, 4)); |
||||||
|
Box box = new Box(BoxLayout.Y_AXIS); |
||||||
|
JPanel northPane = new JPanel(new BorderLayout(4, 4)); |
||||||
|
JToolBar editToolBar = createToolBar(); |
||||||
|
northPane.add(editToolBar, BorderLayout.CENTER); |
||||||
|
JToolBar editHelpBar = createHelpBar(); |
||||||
|
northPane.add(editHelpBar, BorderLayout.EAST); |
||||||
|
northPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 0)); |
||||||
|
|
||||||
|
UITableModelAdapter<ParameterProvider> model = new ParameterTableModel(); |
||||||
|
editorPane = new UITableEditorPane<ParameterProvider>(model); |
||||||
|
box.add(northPane); |
||||||
|
box.add(createQueryPane()); |
||||||
|
box.add(editorPane); |
||||||
|
JPanel sqlSplitPane = new JPanel(new BorderLayout(4, 4)); |
||||||
|
sqlSplitPane.add(box, BorderLayout.CENTER); |
||||||
|
this.add(sqlSplitPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private JToolBar createToolBar() { |
||||||
|
ToolBarDef toolBarDef = new ToolBarDef(); |
||||||
|
toolBarDef.addShortCut(new PreviewAction()); |
||||||
|
UIToolbar editToolBar = ToolBarDef.createJToolBar(); |
||||||
|
toolBarDef.updateToolBar(editToolBar); |
||||||
|
return editToolBar; |
||||||
|
} |
||||||
|
|
||||||
|
private JToolBar createHelpBar() { |
||||||
|
ToolBarDef helpBarDef = new ToolBarDef(); |
||||||
|
helpBarDef.addShortCut(new HelpAction()); |
||||||
|
UIToolbar editHelpBar = ToolBarDef.createJToolBar(); |
||||||
|
helpBarDef.updateToolBar(editHelpBar); |
||||||
|
return editHelpBar; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return DesignKit.i18nText("Plugin-icjb_Query"); |
||||||
|
} |
||||||
|
|
||||||
|
protected abstract JComponent createQueryPane(); |
||||||
|
|
||||||
|
private void refresh() { |
||||||
|
java.util.List<ParameterProvider> existParameterList = editorPane.update(); |
||||||
|
ParameterProvider[] ps = existParameterList == null ? new ParameterProvider[0] : existParameterList.toArray(new ParameterProvider[0]); |
||||||
|
editorPane.populate(ps); |
||||||
|
} |
||||||
|
|
||||||
|
private class PreviewAction extends UpdateAction { |
||||||
|
public PreviewAction() { |
||||||
|
this.setName(PREVIEW_BUTTON); |
||||||
|
this.setMnemonic('P'); |
||||||
|
this.setSmallIcon(IOKit.readIcon(ICON_PREVIEW)); |
||||||
|
} |
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
DesignKit.previewTableData(WebBaseTableDataPane.this.updateBean()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private class HelpAction extends UpdateAction { |
||||||
|
public HelpAction() { |
||||||
|
this.setName(HELP_BUTTON); |
||||||
|
this.setMnemonic('P'); |
||||||
|
this.setSmallIcon(IOKit.readIcon(ICON_HELP)); |
||||||
|
} |
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
try { |
||||||
|
Desktop.getDesktop().browse(URI.create(HELP_URL)); |
||||||
|
} catch (IOException e1) { |
||||||
|
LogKit.error(e1.getMessage(), e1); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected class RefreshAction extends UITableEditAction { |
||||||
|
public RefreshAction() { |
||||||
|
this.setName(REFRESH_BUTTON); |
||||||
|
this.setSmallIcon(IOKit.readIcon(ICON_REFRESH)); |
||||||
|
} |
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
refresh(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void checkEnabled() { |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2021 |
||||||
|
* Project: starter |
||||||
|
* FileName: WechatQueryPane |
||||||
|
* Author: fr.open |
||||||
|
* Date: 2021/12/14 15:32 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.icjb.ui; |
||||||
|
|
||||||
|
import com.fanruan.api.design.DesignKit; |
||||||
|
import com.fanruan.api.design.ui.component.UIButtonGroup; |
||||||
|
import com.fanruan.api.design.ui.component.UILabel; |
||||||
|
import com.fanruan.api.design.ui.container.BasicPane; |
||||||
|
import com.fanruan.api.design.ui.layout.TableLayoutKit; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <WebQueryPane> |
||||||
|
* |
||||||
|
* @author fr.open |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class WebQueryPane extends BasicPane { |
||||||
|
public static final String[] SEARCH_OPTIONS = new String[]{ |
||||||
|
DesignKit.i18nText("Plugin-icjb_Search_User"), |
||||||
|
DesignKit.i18nText("Plugin-icjb_Search_Department") |
||||||
|
}; |
||||||
|
private UIButtonGroup searchType; |
||||||
|
|
||||||
|
public WebQueryPane() { |
||||||
|
setLayout(new BorderLayout()); |
||||||
|
searchType = new UIButtonGroup<String[]>(SEARCH_OPTIONS); |
||||||
|
searchType.setSelectedIndex(0); |
||||||
|
Component[][] coms = new Component[][]{ |
||||||
|
{new UILabel(DesignKit.i18nText("Plugin-icjb_Search_Type") + ":"), searchType} |
||||||
|
}; |
||||||
|
|
||||||
|
double p = TableLayoutKit.PREFERRED; |
||||||
|
double f = TableLayoutKit.FILL; |
||||||
|
double[] rowSize = {p}; |
||||||
|
double[] columnSize = {p, f}; |
||||||
|
|
||||||
|
add(TableLayoutKit.createTableLayoutPane(coms, rowSize, columnSize)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return DesignKit.i18nText("Plugin-icjb_Query"); |
||||||
|
} |
||||||
|
|
||||||
|
public int getSearchType() { |
||||||
|
return searchType.getSelectedIndex(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setSearchType(int searchType) { |
||||||
|
this.searchType.setSelectedIndex(searchType); |
||||||
|
} |
||||||
|
} |
After Width: | Height: | Size: 817 B |
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,19 @@ |
|||||||
|
Plugin-icjb=Sso Plugin |
||||||
|
Plugin-icjb_Group=Sso Plugin |
||||||
|
Plugin-icjb_Config_UriBase=Uri Base |
||||||
|
Plugin-icjb_Config_UriBase_Description=Uri Base |
||||||
|
Plugin-icjb_Licence_Expired=Sso Plugin Licence Expired |
||||||
|
Plugin-icjb_Config_ClientId=Client Id |
||||||
|
Plugin-icjb_Config_ClientId_Description=Client Id |
||||||
|
Plugin-icjb_Config_ClientSecret=Client Secret |
||||||
|
Plugin-icjb_Config_ClientSecret_Description=Client Secret |
||||||
|
Plugin-icjb_Config_FrUri=FR Uri |
||||||
|
Plugin-icjb_Config_FrUri_Description=FR Uri |
||||||
|
Plugin-icjb_Users_Table_Data=Users Table Data |
||||||
|
Plugin-icjb_Query=Query |
||||||
|
Plugin-icjb_Help=Help |
||||||
|
Plugin-icjb_Preview=Preview |
||||||
|
Plugin-icjb_Refresh=Refresh |
||||||
|
Plugin-icjb_Search_Type=Search Type |
||||||
|
Plugin-icjb_Search_User=User |
||||||
|
Plugin-icjb_Search_Department=Department |
@ -0,0 +1,19 @@ |
|||||||
|
Plugin-icjb=\u5355\u70B9\u767B\u9646\u63D2\u4EF6 |
||||||
|
Plugin-icjb_Group=\u5355\u70B9\u767B\u9646\u63D2\u4EF6 |
||||||
|
Plugin-icjb_Config_UriBase=\u5355\u70B9\u63A5\u53E3\u5730\u5740 |
||||||
|
Plugin-icjb_Config_UriBase_Description=\u5355\u70B9\u63A5\u53E3\u5730\u5740 |
||||||
|
Plugin-icjb_Licence_Expired=\u5355\u70B9\u767B\u9646\u63D2\u4EF6\u8BB8\u53EF\u8FC7\u671F |
||||||
|
Plugin-icjb_Config_ClientId=\u5E94\u7528\u6CE8\u518CID |
||||||
|
Plugin-icjb_Config_ClientId_Description=\u5E94\u7528\u6CE8\u518CID |
||||||
|
Plugin-icjb_Config_ClientSecret=\u5E94\u7528\u6CE8\u518C\u5BC6\u7801 |
||||||
|
Plugin-icjb_Config_ClientSecret_Description=\u5E94\u7528\u6CE8\u518C\u5BC6\u7801 |
||||||
|
Plugin-icjb_Config_FrUri=\u5E06\u8F6F\u7CFB\u7EDFurl |
||||||
|
Plugin-icjb_Config_FrUri_Description=\u5E06\u8F6F\u7CFB\u7EDFurl |
||||||
|
Plugin-icjb_Users_Table_Data=\u7528\u6237\u6570\u636E\u96C6 |
||||||
|
Plugin-icjb_Query=\u67E5\u8BE2 |
||||||
|
Plugin-icjb_Help=\u5E2E\u52A9\u6587\u6863 |
||||||
|
Plugin-icjb_Preview=\u9884\u89C8 |
||||||
|
Plugin-icjb_Refresh=\u5237\u65B0 |
||||||
|
Plugin-icjb_Search_Type=\u64CD\u4F5C\u79CD\u7C7B |
||||||
|
Plugin-icjb_Search_User=\u7528\u6237 |
||||||
|
Plugin-icjb_Search_Department=\u90E8\u95E8 |
Loading…
Reference in new issue