Search in sources :

Example 1 with FormDefinition

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;
}
Also used : FormDefinition(com.plumdo.form.entity.FormDefinition) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(io.swagger.annotations.ApiOperation) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with FormDefinition

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);
}
Also used : FormDefinition(com.plumdo.form.entity.FormDefinition) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(io.swagger.annotations.ApiOperation) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with 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);
}
Also used : FormModel(com.plumdo.form.entity.FormModel) FormDefinition(com.plumdo.form.entity.FormDefinition) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(io.swagger.annotations.ApiOperation) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

FormDefinition (com.plumdo.form.entity.FormDefinition)3 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)3 ApiOperation (io.swagger.annotations.ApiOperation)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3 FormModel (com.plumdo.form.entity.FormModel)1