package cn.autoform.web.controller.formapi; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import cn.autoform.db.entity.FieldPropertyEntity; import cn.autoform.fw.exception.RestResult; import cn.autoform.fw.utility.RestResultGenerator; import cn.autoform.web.service.datasource.DatasourceService; import cn.autoform.web.service.formapi.FormApiService; @RestController public class FormApiController { @Autowired private FormApiService formApiService = null; @Autowired private DatasourceService datasourceService = null; /** * 获取表单api * @param tenantID * @param formID * @return */ @RequestMapping(value = "${requset.formapi01}", method = RequestMethod.GET) public RestResult>> getFormApiListService(String tenantID, String formID) { List> rsList = new ArrayList>(); // 设定API的字段取得 List listFieldProper = formApiService.getColumnNum(tenantID, formID); for(FieldPropertyEntity fieldProperty : listFieldProper){ Map mpApi = new HashMap(); int columnOrderNum = fieldProperty.getColumnOrderNum(); // 别名取得 String fieldKey = datasourceService.getFieldkeyList(tenantID, formID, columnOrderNum).get(0).getFieldKey(); // API详细 String restapi = datasourceService.getFieldPropertyList(tenantID, formID, columnOrderNum, "apiUrl").get(0).getValue(); mpApi.put(fieldKey, restapi); rsList.add(mpApi); } return RestResultGenerator.genSuccessResult(rsList); } }