use of com.plumdo.form.entity.FormDefinition in project plumdo-work by wengwh.
the class FormDefinitionJsonResource method getEditorJson.
@ApiOperation(value = "获取表单定义设计内容", notes = "根据表单定义的id来获取表单定义设计内容")
@ApiImplicitParam(name = "id", value = "表单定义ID", required = true, dataType = "Long", paramType = "path")
@RequestMapping(value = "/form-definitions/{id}/json", method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
public String getEditorJson(@PathVariable Long id) throws UnsupportedEncodingException {
FormDefinition formDefinition = getFormDefinitionFromRequest(id);
String editorJson = null;
if (formDefinition.getEditorSourceBytes() == null) {
editorJson = objectMapper.createArrayNode().toString();
} else {
editorJson = new String(formDefinition.getEditorSourceBytes(), "utf-8");
}
return editorJson;
}
use of com.plumdo.form.entity.FormDefinition in project plumdo-work by wengwh.
the class FormDefinitionResource method deleteFormDefinition.
@ApiOperation(value = "删除表单定义", notes = "根据表单定义的id来删除指定对象")
@ApiImplicitParam(name = "id", value = "表单定义ID", required = true, dataType = "Long", paramType = "path")
@RequestMapping(value = "/form-definitions/{id}", method = RequestMethod.DELETE)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteFormDefinition(@PathVariable Long id) {
FormDefinition formDefinition = getFormDefinitionFromRequest(id);
formDefinitionRepository.delete(formDefinition);
}
use of com.plumdo.form.entity.FormDefinition in project plumdo-work by wengwh.
the class FormModelDeployResource method deploy.
@ApiOperation(value = "部署表单模型", notes = "根据表单模型的id来部署表单模型")
@ApiImplicitParam(name = "id", value = "表单模型ID", required = true, dataType = "Long", paramType = "path")
@RequestMapping(value = "/form-models/{id}/deploy", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.CREATED)
public FormDefinitionResponse deploy(@PathVariable Long id) {
FormModel formModel = getFormModelFromRequest(id);
FormDefinition formDefinition = new FormDefinition();
formDefinition.setKey(formModel.getKey());
formDefinition.setCategory(formModel.getCategory());
formDefinition.setName(formModel.getName());
formDefinition.setTenantId(formModel.getTenantId());
formDefinition.setEditorSourceBytes(formModel.getEditorSourceBytes());
FormDefinition latestFormDefinition = null;
if (StringUtils.isNotBlank(formModel.getTenantId())) {
latestFormDefinition = formDefinitionRepository.findLatestFormDefinitionByKeyAndTenantId(formModel.getKey(), formModel.getTenantId());
} else {
latestFormDefinition = formDefinitionRepository.findLatestFormDefinitionByKey(formModel.getKey());
}
if (latestFormDefinition == null) {
formDefinition.setVersion(1);
} else {
formDefinition.setVersion(latestFormDefinition.getVersion() + 1);
}
formDefinitionRepository.save(formDefinition);
return responseFactory.createFormDefinitionResponse(formDefinition);
}
Aggregations