package com.changhong.epc.rely.api.epc.autoForm;
|
|
import com.alibaba.fastjson.TypeReference;
|
import com.changhong.epc.bean.form.FormBaseEntity;
|
import com.changhong.epc.bean.form.FormFieldEntity;
|
import com.changhong.epc.constter.base.Context;
|
import com.changhong.epc.constter.system.prop.ChangHongProperties;
|
import com.changhong.epc.rely.api.epc.BaseApi;
|
import com.iemsoft.framework.cloud.core.base.ResMsg;
|
import com.iemsoft.framework.cloud.core.thread.ThreadData;
|
import com.iemsoft.framework.cloud.core.tools.http.Http;
|
import lombok.Setter;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Collections;
|
import java.util.List;
|
|
import static com.changhong.epc.constter.base.BaseConst.TENANT_ID;
|
|
@Service
|
public class FormApi extends BaseApi {
|
|
@Resource
|
@Setter
|
private ChangHongProperties changHongProperties;
|
|
/**
|
* 获取表单信息
|
* @param formId
|
* @return
|
*/
|
public FormBaseEntity getFormBaseEntity(String formId){
|
return (FormBaseEntity) Http.get(
|
String.format("http://%s:%s/autoForm/formbase/getFormInfoService", changHongProperties.getFormServiceUrl(), changHongProperties.getFormServicePost())
|
, ResMsg.class)
|
.addUrlParam("formID", formId)
|
.addUrlParam("tenantID", Context.getTenantId())
|
.addValidate(BaseApi::assertSuccess)
|
.execute(new TypeReference<ResMsg<FormBaseEntity>>(){}.getType())
|
.map(res->((ResMsg) res).getData())
|
.orElse(null);
|
}
|
|
/**
|
* 获取表单控件信息
|
* @param formId
|
* @return
|
*/
|
public List<FormFieldEntity> getFormFields(String formId){
|
return (List<FormFieldEntity>) Http.get(
|
String.format("http://%s:%s/autoForm/datamanagement/getFormFieldListService", changHongProperties.getFormServiceUrl(), changHongProperties.getFormServicePost())
|
, ResMsg.class)
|
.addUrlParam("formID", formId)
|
.addUrlParam("tenantID", Context.getTenantId())
|
.addValidate(BaseApi::assertSuccess)
|
.execute(new TypeReference<ResMsg<List<FormFieldEntity>>>(){}.getType())
|
.map(res->((ResMsg) res).getData())
|
.orElse(Collections.EMPTY_LIST);
|
}
|
|
public static void main(String... args){
|
FormApi formApi = new FormApi();
|
ChangHongProperties c = new ChangHongProperties();
|
c.setFormServiceUrl("epcf.chfcloud.com");
|
c.setFormServicePost("8081");
|
formApi.setChangHongProperties(c);
|
ThreadData.set(TENANT_ID, "100000001");
|
System.out.println(
|
// formApi.getFormBaseEntity("4cf2b58ef36f14d200fbdc308f64b319")
|
);
|
System.out.println(
|
formApi.getFormFields("4cf2b58ef36f14d200fbdc308f64b319")
|
);
|
}
|
}
|