use of com.plumdo.form.entity.FormModel 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);
}
use of com.plumdo.form.entity.FormModel in project plumdo-work by wengwh.
the class FormModelResource method deleteFormModel.
@ApiOperation(value = "删除表单模型", notes = "根据表单模型的id来删除指定对象")
@ApiImplicitParam(name = "id", value = "表单模型ID", required = true, dataType = "Long", paramType = "path")
@RequestMapping(value = "/form-models/{id}", method = RequestMethod.DELETE)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteFormModel(@PathVariable Long id) {
FormModel formModel = getFormModelFromRequest(id);
formModelRepository.delete(formModel);
}
use of com.plumdo.form.entity.FormModel in project plumdo-work by wengwh.
the class FormModelResource method updateFormModel.
@ApiOperation(value = "更新表单模型", notes = "根据表单模型的id来指定更新对象,并根据传过来的modelRequest信息来更新表单模型")
@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "表单模型ID", required = true, dataType = "Long", paramType = "path"), @ApiImplicitParam(name = "modelRequest", value = "表单模型请求实体modelRequest", required = true, dataType = "FormModelRequest") })
@RequestMapping(value = "/form-models/{id}", method = RequestMethod.PUT, produces = "application/json")
@ResponseStatus(value = HttpStatus.OK)
public FormModelResponse updateFormModel(@PathVariable Long id, @RequestBody FormModelRequest modelRequest) {
FormModel formModel = getFormModelFromRequest(id);
if (modelRequest.getName() != null) {
formModel.setName(modelRequest.getName());
}
if (modelRequest.getKey() != null) {
formModel.setKey(modelRequest.getKey());
}
if (modelRequest.getCategory() != null) {
formModel.setCategory(modelRequest.getCategory());
}
if (modelRequest.getTenantId() != null) {
formModel.setTenantId(modelRequest.getTenantId());
}
formModelRepository.save(formModel);
return responseFactory.createFormModelResponse(formModel);
}
use of com.plumdo.form.entity.FormModel in project plumdo-work by wengwh.
the class FormModelCollectionResource method createFormModel.
@ApiOperation(value = "创建表单模型", notes = "根据传过来的modelRequest信息来创建表单模型")
@ApiImplicitParam(name = "modelRequest", value = "表单模型请求实体modelRequest", required = true, dataType = "FormModelRequest")
@RequestMapping(value = "/form-models", method = RequestMethod.POST, produces = "application/json")
@ResponseStatus(value = HttpStatus.CREATED)
@Transactional(propagation = Propagation.REQUIRED)
public FormModelResponse createFormModel(@RequestBody FormModelRequest modelRequest) {
FormModel formModel = new FormModel();
if (modelRequest.getName() != null) {
formModel.setName(modelRequest.getName());
}
if (modelRequest.getKey() != null) {
formModel.setKey(modelRequest.getKey());
}
if (modelRequest.getCategory() != null) {
formModel.setCategory(modelRequest.getCategory());
}
if (modelRequest.getTenantId() != null) {
formModel.setTenantId(modelRequest.getTenantId());
}
formModelRepository.save(formModel);
return responseFactory.createFormModelResponse(formModel);
}
use of com.plumdo.form.entity.FormModel in project plumdo-work by wengwh.
the class FormModelEditorResource method getEditorJson.
@ApiOperation(value = "获取表单模型设计内容", notes = "根据表单模型的id来获取表单模型设计内容")
@ApiImplicitParam(name = "id", value = "表单模型ID", required = true, dataType = "Long", paramType = "path")
@RequestMapping(value = "/form-models/{id}/json", method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
public String getEditorJson(@PathVariable Long id) throws UnsupportedEncodingException {
FormModel formModel = getFormModelFromRequest(id);
String editorJson = null;
if (formModel.getEditorSourceBytes() == null) {
editorJson = objectMapper.createArrayNode().toString();
} else {
editorJson = new String(formModel.getEditorSourceBytes(), "utf-8");
}
return editorJson;
}
Aggregations