commit
f6f93e3173
14 changed files with 555 additions and 0 deletions
@ -0,0 +1,7 @@ |
|||||||
|
|
||||||
|
# open-JSD-9934 |
||||||
|
|
||||||
|
JSD-9934 一句话简介该插件的功能和场景\ |
||||||
|
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||||
|
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||||
|
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。 |
@ -0,0 +1,168 @@ |
|||||||
|
apply plugin: 'java' |
||||||
|
|
||||||
|
buildscript { |
||||||
|
repositories { |
||||||
|
maven { |
||||||
|
url = uri('https://mvn.fanruan.com/repository/maven-public/') |
||||||
|
} |
||||||
|
dependencies { |
||||||
|
classpath localGroovy() |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ext { |
||||||
|
/** |
||||||
|
* 项目中依赖的jar的路径 |
||||||
|
* 1.如果依赖的jar需要打包到zip中,放置在lib根目录下 |
||||||
|
* 2.如果依赖的jar仅仅是编译时需要,防止在lib下子目录下即可 |
||||||
|
*/ |
||||||
|
libPath = "$projectDir/../webroot/WEB-INF/lib" |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否对插件的class进行加密保护,防止反编译 |
||||||
|
*/ |
||||||
|
guard = true |
||||||
|
|
||||||
|
def pluginInfo = getPluginInfo() |
||||||
|
pluginPre = "fine-plugin" |
||||||
|
pluginName = pluginInfo.id |
||||||
|
pluginVersion = pluginInfo.version |
||||||
|
|
||||||
|
outputPath = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/classes" |
||||||
|
XMLPath = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0" |
||||||
|
pluginLibPath = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/lib" |
||||||
|
} |
||||||
|
|
||||||
|
group = 'com.fr.plugin' |
||||||
|
version = '10.0' |
||||||
|
|
||||||
|
compileJava { |
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8 |
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8 |
||||||
|
} |
||||||
|
|
||||||
|
sourceSets { |
||||||
|
main { |
||||||
|
java { |
||||||
|
destinationDirectory.set(file(outputPath)) |
||||||
|
} |
||||||
|
output.resourcesDir = file(outputPath) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
ant.importBuild("encrypt.xml") |
||||||
|
//定义ant变量 |
||||||
|
ant.projectDir = projectDir |
||||||
|
ant.references["compile.classpath"] = ant.path { |
||||||
|
fileset(dir: libPath, includes: '**/*.jar') |
||||||
|
fileset(dir: ".", includes: "**/*.jar") |
||||||
|
} |
||||||
|
|
||||||
|
clean.doFirst { |
||||||
|
delete file(outputPath) |
||||||
|
delete file("$projectDir/classes") |
||||||
|
delete file("$projectDir/transform-classes") |
||||||
|
} |
||||||
|
|
||||||
|
classes.dependsOn('clean') |
||||||
|
|
||||||
|
tasks.withType(JavaCompile) { |
||||||
|
options.encoding = "UTF-8" |
||||||
|
} |
||||||
|
|
||||||
|
task copyFiles(type: Copy, dependsOn: 'classes') { |
||||||
|
from outputPath |
||||||
|
into "$projectDir/classes" |
||||||
|
} |
||||||
|
|
||||||
|
task copy_plugin_config(type: Copy, dependsOn: 'copy_plugin_lib') { |
||||||
|
from "$projectDir/plugin.xml" |
||||||
|
into XMLPath |
||||||
|
} |
||||||
|
|
||||||
|
task copy_plugin_lib(type: Copy) { |
||||||
|
from("$projectDir/lib") { |
||||||
|
include "*.jar" |
||||||
|
} |
||||||
|
into file(pluginLibPath) |
||||||
|
} |
||||||
|
|
||||||
|
task copy_dependencies(type: Copy) { |
||||||
|
from configurations.runtimeClasspath |
||||||
|
into file("$projectDir/lib") |
||||||
|
exclude "fine-third*", "fine-activator*", "fine-core*", "fine-webui*", "fine-datasource*", "fine-decision*", "fine-schedule*", "fine-swift*", "fine-accumulator*", "fine-report*", "fineio*" |
||||||
|
} |
||||||
|
|
||||||
|
task preJar(type: Copy, dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas') { |
||||||
|
from "$projectDir/classes" |
||||||
|
into "$projectDir/transform-classes" |
||||||
|
include "**/*.*" |
||||||
|
} |
||||||
|
jar.dependsOn("preJar") |
||||||
|
|
||||||
|
task makeJar(type: Jar, dependsOn: preJar) { |
||||||
|
from fileTree(dir: "$projectDir/transform-classes") |
||||||
|
archiveBaseName.set(pluginPre) |
||||||
|
archiveAppendix.set(pluginName) |
||||||
|
archiveVersion.set(pluginVersion) |
||||||
|
destinationDirectory = file("$buildDir/libs") |
||||||
|
|
||||||
|
doLast() { |
||||||
|
delete file("$projectDir/classes") |
||||||
|
delete file("$projectDir/transform-classes") |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
task copyFile(type: Copy, dependsOn: ["makeJar"]) { |
||||||
|
from "$buildDir/libs" |
||||||
|
from("$projectDir/lib") { |
||||||
|
include "*.jar" |
||||||
|
} |
||||||
|
from "$projectDir/plugin.xml" |
||||||
|
into file("$buildDir/temp/plugin") |
||||||
|
} |
||||||
|
|
||||||
|
task zip(type: Zip, dependsOn: ["copyFile"]) { |
||||||
|
from "$buildDir/temp/plugin" |
||||||
|
destinationDirectory = file("$buildDir/install") |
||||||
|
archiveBaseName.set(pluginPre) |
||||||
|
archiveAppendix.set(pluginName) |
||||||
|
archiveVersion.set(pluginVersion) |
||||||
|
} |
||||||
|
|
||||||
|
//控制build时包含哪些文件,排除哪些文件 |
||||||
|
processResources { |
||||||
|
// exclude everything |
||||||
|
// 用*.css没效果 |
||||||
|
// exclude '**/*.css' |
||||||
|
// except this file |
||||||
|
// include 'xx.xml' |
||||||
|
} |
||||||
|
|
||||||
|
/*读取plugin.xml中的version*/ |
||||||
|
|
||||||
|
def getPluginInfo() { |
||||||
|
def xmlFile = file("plugin.xml") |
||||||
|
if (!xmlFile.exists()) { |
||||||
|
return ["id": "none", "version": "1.0.0"] |
||||||
|
} |
||||||
|
def plugin = new groovy.xml.XmlParser().parse(xmlFile) |
||||||
|
def version = plugin.version.text() |
||||||
|
def id = plugin.id.text() |
||||||
|
return ["id": id, "version": version] |
||||||
|
} |
||||||
|
|
||||||
|
repositories { |
||||||
|
// mavenLocal() |
||||||
|
maven { |
||||||
|
url = uri('https://mvn.fanruan.com/repository/maven-public/') |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//使用本地jar |
||||||
|
implementation fileTree(dir: 'lib', include: ['**/*.jar']) |
||||||
|
// 指定依赖引用 |
||||||
|
// implementation files("../finekit/build/libs/finekit-10.0.jar") |
||||||
|
} |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,153 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<WorkBook xmlVersion="20211223" releaseVersion="10.0.0"> |
||||||
|
<TableDataMap> |
||||||
|
<TableData name="getToken" class="com.tptj.plugin.hg.tabledata.factory.core.FactoryTableData" pluginID="com.tptj.plugin.hg.tabledata.factory.v10" plugin-version="2.4.7"> |
||||||
|
<Parameters> |
||||||
|
<Parameter> |
||||||
|
<Attributes name="credential"/> |
||||||
|
<O> |
||||||
|
<![CDATA[bbb]]></O> |
||||||
|
</Parameter> |
||||||
|
<Parameter> |
||||||
|
<Attributes name="appId"/> |
||||||
|
<O> |
||||||
|
<![CDATA[aaa]]></O> |
||||||
|
</Parameter> |
||||||
|
</Parameters> |
||||||
|
<Attributes> |
||||||
|
<![CDATA[Koj,G__;LR?Nik<41,_Aest+j'7u(+>GTCeAgq7^Q$At$lFZ(1.Om(Gin2iV422$Z4<.0gZ$ |
||||||
|
"*8k8.p\']AQ+*!J5KMeD:Ea(u+3&@s^kuMaG@3O=*`<I8&!7"j`:Z_7q`^W2TUta"]AWSKOm_ |
||||||
|
XQ7cii2C+HdWijLRAEs$V]A%eMfi>oTE`Inh=1:Pq"50UUl6;0p4G]A))jeSOdhbXi<-G7Nj64 |
||||||
|
!QD6mlVB./(,"=HKr:cs0iik&>q7@A`J8'(q.'\ZFkCi1>2/BJ=`6p5@==jaQ#i`K=7/n,NN |
||||||
|
mF\pW"=21>Q~ |
||||||
|
]]></Attributes> |
||||||
|
</TableData> |
||||||
|
<TableData name="getData" class="com.tptj.plugin.hg.tabledata.factory.core.FactoryTableData" pluginID="com.tptj.plugin.hg.tabledata.factory.v10" plugin-version="2.4.7"> |
||||||
|
<Parameters> |
||||||
|
<Parameter> |
||||||
|
<Attributes name="token"/> |
||||||
|
<O t="XMLable" class="com.fr.base.Formula"> |
||||||
|
<Attributes> |
||||||
|
<![CDATA[=getToken.value(1,1)]]></Attributes> |
||||||
|
</O> |
||||||
|
</Parameter> |
||||||
|
</Parameters> |
||||||
|
<Attributes> |
||||||
|
<![CDATA[4c_l:_CuCPs,%MONY_9FH<!@$<)@Lc;S'B<[2iO8aRHs6DK@+ck+f-KV.Is<(GNs+mTnXs[a |
||||||
|
>:Hr2@"mXj2H3+*7fd>s:-E/Rlt:/.RgX34Csk%tpGZr^Nh<r.N?W3a".0cR%a,)!u-Q:bG0 |
||||||
|
hpnK;0I(nMR?ns1`XOeRTO=5N:11PHC!"!!cRqt**$Rq;[gcBS&JsXrplee:4UIp)mFEBCo= |
||||||
|
@gUh.K7dZD'QbZ~ |
||||||
|
]]></Attributes> |
||||||
|
</TableData> |
||||||
|
</TableDataMap> |
||||||
|
<ElementCaseMobileAttr> |
||||||
|
<ElementCaseMobileAttrProvider horizontal="1" vertical="1" zoom="true" refresh="false" isUseHTML="false" isMobileCanvasSize="false" appearRefresh="false" allowFullScreen="false" allowDoubleClickOrZoom="true" functionalWhenUnactivated="false"/> |
||||||
|
</ElementCaseMobileAttr> |
||||||
|
<Report class="com.fr.report.worksheet.WorkSheet" name="sheet1"> |
||||||
|
<ReportPageAttr> |
||||||
|
<HR/> |
||||||
|
<FR/> |
||||||
|
<HC/> |
||||||
|
<FC/> |
||||||
|
</ReportPageAttr> |
||||||
|
<ColumnPrivilegeControl/> |
||||||
|
<RowPrivilegeControl/> |
||||||
|
<RowHeight defaultValue="723900"> |
||||||
|
<![CDATA[723900,723900,723900,723900,723900,723900,723900,723900,723900,723900]]></RowHeight> |
||||||
|
<ColumnWidth defaultValue="2743200"> |
||||||
|
<![CDATA[5334000,4968240,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200]]></ColumnWidth> |
||||||
|
<CellElementList> |
||||||
|
<C c="0" r="0"> |
||||||
|
<O> |
||||||
|
<![CDATA[token值:]]></O> |
||||||
|
<PrivilegeControl/> |
||||||
|
<Expand/> |
||||||
|
</C> |
||||||
|
<C c="1" r="0"> |
||||||
|
<O t="XMLable" class="com.fr.base.Formula"> |
||||||
|
<Attributes> |
||||||
|
<![CDATA[=getToken.value(1, 1)]]></Attributes> |
||||||
|
</O> |
||||||
|
<PrivilegeControl/> |
||||||
|
<Expand/> |
||||||
|
</C> |
||||||
|
<C c="0" r="1"> |
||||||
|
<O> |
||||||
|
<![CDATA[STORE_CODE]]></O> |
||||||
|
<PrivilegeControl/> |
||||||
|
<Expand/> |
||||||
|
</C> |
||||||
|
<C c="1" r="1"> |
||||||
|
<O> |
||||||
|
<![CDATA[MSS_RTL_PROFILE_CI]]></O> |
||||||
|
<PrivilegeControl/> |
||||||
|
<Expand/> |
||||||
|
</C> |
||||||
|
<C c="0" r="2"> |
||||||
|
<O t="DSColumn"> |
||||||
|
<Attributes dsName="getData" columnName="STORE_CODE"/> |
||||||
|
<Condition class="com.fr.data.condition.ListCondition"/> |
||||||
|
<Complex/> |
||||||
|
<RG class="com.fr.report.cell.cellattr.core.group.FunctionGrouper"/> |
||||||
|
<Result> |
||||||
|
<![CDATA[$$$]]></Result> |
||||||
|
<Parameters/> |
||||||
|
</O> |
||||||
|
<PrivilegeControl/> |
||||||
|
<Expand dir="0"/> |
||||||
|
</C> |
||||||
|
<C c="1" r="2" s="0"> |
||||||
|
<O t="DSColumn"> |
||||||
|
<Attributes dsName="getData" columnName="MSS_RTL_PROFILE_CI"/> |
||||||
|
<Condition class="com.fr.data.condition.ListCondition"/> |
||||||
|
<Complex/> |
||||||
|
<RG class="com.fr.report.cell.cellattr.core.group.FunctionGrouper"/> |
||||||
|
<Result> |
||||||
|
<![CDATA[$$$]]></Result> |
||||||
|
<Parameters/> |
||||||
|
</O> |
||||||
|
<PrivilegeControl/> |
||||||
|
<Expand dir="0"/> |
||||||
|
</C> |
||||||
|
</CellElementList> |
||||||
|
<ReportAttrSet> |
||||||
|
<ReportSettings headerHeight="0" footerHeight="0"> |
||||||
|
<PaperSetting/> |
||||||
|
<Background name="ColorBackground" color="-1"/> |
||||||
|
</ReportSettings> |
||||||
|
<Header reportPageType="0"> |
||||||
|
<Background name="NullBackground"/> |
||||||
|
<LeftList/> |
||||||
|
<CenterList/> |
||||||
|
<RightList/> |
||||||
|
</Header> |
||||||
|
<Footer reportPageType="0"> |
||||||
|
<Background name="NullBackground"/> |
||||||
|
<LeftList/> |
||||||
|
<CenterList/> |
||||||
|
<RightList/> |
||||||
|
</Footer> |
||||||
|
</ReportAttrSet> |
||||||
|
<PrivilegeControl/> |
||||||
|
</Report> |
||||||
|
<ReportParameterAttr> |
||||||
|
<Attributes showWindow="true" delayPlaying="true" windowPosition="1" align="0" useParamsTemplate="true" currentIndex="0"/> |
||||||
|
<PWTitle> |
||||||
|
<![CDATA[参数]]></PWTitle> |
||||||
|
</ReportParameterAttr> |
||||||
|
<StyleList> |
||||||
|
<Style horizontal_alignment="2" imageLayout="1"> |
||||||
|
<FRFont name="SimSun" style="0" size="72"/> |
||||||
|
<Background name="NullBackground"/> |
||||||
|
<Border/> |
||||||
|
</Style> |
||||||
|
</StyleList> |
||||||
|
<DesignerVersion DesignerVersion="KAA"/> |
||||||
|
<PreviewType PreviewType="0"/> |
||||||
|
<TemplateCloudInfoAttrMark class="com.fr.plugin.cloud.analytics.attr.TemplateInfoAttrMark" pluginID="com.fr.plugin.cloud.analytics.v10" plugin-version="2.6.0.20220316"> |
||||||
|
<TemplateCloudInfoAttrMark createTime="1649174183712"/> |
||||||
|
</TemplateCloudInfoAttrMark> |
||||||
|
<TemplateIdAttMark class="com.fr.base.iofile.attr.TemplateIdAttrMark"> |
||||||
|
<TemplateIdAttMark TemplateId="41aabcb9-c5f9-4691-b955-e158e5c268bd"/> |
||||||
|
</TemplateIdAttMark> |
||||||
|
</WorkBook> |
@ -0,0 +1,13 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||||
|
<project> |
||||||
|
<target name="compile_encrypt_javas" depends="copyFiles"> |
||||||
|
<echo message="加密文件"/> |
||||||
|
<echo message="${projectDir}"/> |
||||||
|
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask"> |
||||||
|
<classpath refid="compile.classpath"/> |
||||||
|
</taskdef> |
||||||
|
<pretreatment baseDir="${projectDir}"/> |
||||||
|
</target> |
||||||
|
<target name="compile_plain_javas" depends="copyFiles"> |
||||||
|
</target> |
||||||
|
</project> |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,24 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<plugin> |
||||||
|
<id>com.fr.plugin.iscd.http</id> |
||||||
|
<name><![CDATA[数据工厂接口数据扩展]]></name> |
||||||
|
<active>yes</active> |
||||||
|
<version>1.1</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.iscd</main-package> |
||||||
|
<prefer-packages> |
||||||
|
<prefer-package>com.fanruan.api</prefer-package> |
||||||
|
</prefer-packages> |
||||||
|
<dependence> |
||||||
|
<Item key="com.tptj.plugin.hg.tabledata.factory.v10" type="plugin"/> |
||||||
|
</dependence> |
||||||
|
<extra-core> |
||||||
|
<LocaleFinder class="com.fr.plugin.iscd.LocaleFinder"/> |
||||||
|
<TableDataResolver class="com.fr.plugin.iscd.resolver.JSONResolver"/> |
||||||
|
</extra-core> |
||||||
|
<function-recorder class="com.fr.plugin.iscd.LocaleFinder"/> |
||||||
|
</plugin> |
@ -0,0 +1,38 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2020 |
||||||
|
* Project: starter |
||||||
|
* FileName: LocaleFinder |
||||||
|
* Author: xxx |
||||||
|
* Date: 2020/8/31 22:19 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.iscd; |
||||||
|
|
||||||
|
import com.fr.intelli.record.Focus; |
||||||
|
import com.fr.intelli.record.Original; |
||||||
|
import com.fr.record.analyzer.EnableMetrics; |
||||||
|
import com.fr.stable.fun.Authorize; |
||||||
|
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <LocaleFinder> |
||||||
|
* |
||||||
|
* @author xxx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
@Authorize(callSignKey = LocaleFinder.PLUGIN_ID) |
||||||
|
@EnableMetrics |
||||||
|
public class LocaleFinder extends AbstractLocaleFinder { |
||||||
|
public static final String PLUGIN_ID = "com.fr.plugin.iscd.http"; |
||||||
|
|
||||||
|
@Override |
||||||
|
@Focus(id = PLUGIN_ID, text = "Plugin-iscd", source = Original.PLUGIN) |
||||||
|
public String find() { |
||||||
|
return "com/fr/plugin/iscd/locale/lang"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2022 |
||||||
|
* Project: starter |
||||||
|
* FileName: HttpLoader |
||||||
|
* Author: xxx |
||||||
|
* Date: 2022/4/5 22:53 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.iscd.loader; |
||||||
|
|
||||||
|
import com.fr.plugin.context.PluginContexts; |
||||||
|
import com.fr.plugin.iscd.LocaleFinder; |
||||||
|
import com.fr.script.Calculator; |
||||||
|
import com.fr.stable.ParameterProvider; |
||||||
|
import com.fr.stable.fun.Authorize; |
||||||
|
import com.tptj.plugin.hg.impl.AbstractLoader; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <HttpLoader> |
||||||
|
* |
||||||
|
* @author xxx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
@Authorize(callSignKey = LocaleFinder.PLUGIN_ID) |
||||||
|
public class HttpLoader extends AbstractLoader { |
||||||
|
/** |
||||||
|
* 装载数据 |
||||||
|
* |
||||||
|
* @param cal 当前算子 |
||||||
|
* @param params 需要用到的参数 |
||||||
|
* @param others 其他你可能用到的但是又不希望通过参数控制的配置项 |
||||||
|
* @return 保存数据的对象 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public Object load(Calculator cal, ParameterProvider[] params, String others) { |
||||||
|
if (!PluginContexts.currentContext().isAvailable()) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 装载器的名字【显示在数据工厂配置界面的下拉列表里面的】,唯一,支持国际化的key |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public String getName() { |
||||||
|
return "HttpAPI"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @return 默认显示的配置【显示在数据工厂配置界面装载器配置文本域里面的,配置项自定义,其实就是放一些,不想写死在代码里,又不希望被参数篡改的部分】 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public String getDefaultConfig() { |
||||||
|
return "{url:\"www.114.com\",type:\"GET\",charset:\"UTF-8\",header:{aa:${bb}}}"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,88 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C), 2018-2022 |
||||||
|
* Project: starter |
||||||
|
* FileName: JSONResolver |
||||||
|
* Author: xxx |
||||||
|
* Date: 2022/4/5 22:53 |
||||||
|
*/ |
||||||
|
package com.fr.plugin.iscd.resolver; |
||||||
|
|
||||||
|
import com.fanruan.api.i18n.I18nKit; |
||||||
|
import com.fanruan.api.log.LogKit; |
||||||
|
import com.fr.json.JSONArray; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.plugin.context.PluginContexts; |
||||||
|
import com.tptj.plugin.hg.impl.AbstractResolver; |
||||||
|
import com.tptj.plugin.hg.stable.SimpleDataModel; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* <Function Description><br> |
||||||
|
* <JSONResolver> |
||||||
|
* |
||||||
|
* @author xxx |
||||||
|
* @since 1.0.0 |
||||||
|
*/ |
||||||
|
public class JSONResolver extends AbstractResolver { |
||||||
|
/** |
||||||
|
* 解析数据 |
||||||
|
* |
||||||
|
* @param data 从装载器得到的原始数据 |
||||||
|
* @param others 解析时会使用,但是不希望是参数的配置 |
||||||
|
* @return 解析出来的二维数据模型 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public SimpleDataModel parse(Object data, String others) { |
||||||
|
if (!PluginContexts.currentContext().isAvailable()) { |
||||||
|
LogKit.error(I18nKit.getLocText("Plugin-iscd_Licence_Expired")); |
||||||
|
return null; |
||||||
|
} |
||||||
|
LogKit.info("iscd-JSONResolver-parse-data:{}", data); |
||||||
|
JSONObject json = (new JSONObject(data.toString())).getJSONObject("data"); |
||||||
|
List<String> columns = getColumns(json); |
||||||
|
List<Object[]> datas = getDatas(json); |
||||||
|
return new SimpleDataModel(columns, datas); |
||||||
|
} |
||||||
|
|
||||||
|
private List<String> getColumns(JSONObject data) { |
||||||
|
JSONArray cellMetas = data.getJSONArray("cellMetas").getJSONArray(0); |
||||||
|
List<String> columns = new ArrayList<>(); |
||||||
|
for (Object cell : cellMetas) { |
||||||
|
JSONObject cellMeta = (JSONObject) cell; |
||||||
|
columns.add(cellMeta.getString("displayName")); |
||||||
|
} |
||||||
|
LogKit.info("iscd-JSONResolver-getColumns:{}", columns); |
||||||
|
return columns; |
||||||
|
} |
||||||
|
|
||||||
|
private List<Object[]> getDatas(JSONObject data) { |
||||||
|
JSONArray cellData = data.getJSONArray("cellData"); |
||||||
|
List<Object[]> datas = new ArrayList<>(); |
||||||
|
for (Object row : cellData) { |
||||||
|
JSONArray rowData = (JSONArray) row; |
||||||
|
datas.add(rowData.getList().toArray()); |
||||||
|
} |
||||||
|
LogKit.info("iscd-JSONResolver-getDatas:{}", datas.toString()); |
||||||
|
return datas; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 解析器的名字【显示在数据工厂配置界面的下拉列表里面的】,唯一,支持国际化的key |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public String getName() { |
||||||
|
return "CellJSON"; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return 默认显示的配置【显示在数据工厂配置界面解析器配置文本域里面的,配置项自定义,其实就是放一些,不想写死在代码里,又不希望被参数篡改的部分】 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public String getDefaultConfig() { |
||||||
|
return ""; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,2 @@ |
|||||||
|
Plugin-iscd=http Plugin |
||||||
|
Plugin-iscd_Licence_Expired=http Plugin Licence Expired |
@ -0,0 +1,2 @@ |
|||||||
|
Plugin-iscd=\u6570\u636E\u5DE5\u5382\u63A5\u53E3\u6570\u636E\u6269\u5C55\u63D2\u4EF6 |
||||||
|
Plugin-iscd_Licence_Expired=\u6570\u636E\u5DE5\u5382\u63A5\u53E3\u6570\u636E\u6269\u5C55\u63D2\u4EF6\u8BB8\u53EF\u8FC7\u671F |
Loading…
Reference in new issue