Search in sources :

Example 1 with FormModel

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);
}
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)

Example 2 with FormModel

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

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

Example 5 with 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;
}
Also used : FormModel(com.plumdo.form.entity.FormModel) 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

FormModel (com.plumdo.form.entity.FormModel)6 ApiOperation (io.swagger.annotations.ApiOperation)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)6 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)4 ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)2 FormDefinition (com.plumdo.form.entity.FormDefinition)1 Transactional (org.springframework.transaction.annotation.Transactional)1