Search in sources :

Example 56 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project plumdo-work by wengwh.

the class FormInstanceCollectionResource method createFormInstance.

@ApiOperation(value = "创建表单模型", notes = "根据传过来的modelRequest信息来创建表单模型")
@ApiImplicitParam(name = "modelRequest", value = "表单模型请求实体modelRequest", required = true, dataType = "FormInstanceRequest")
@RequestMapping(value = "/form-instances", method = RequestMethod.POST, produces = "application/json")
@ResponseStatus(value = HttpStatus.CREATED)
@Transactional(propagation = Propagation.REQUIRED)
public FormInstanceResponse createFormInstance(@RequestBody FormInstanceRequest formInstanceRequest) {
    FormInstance formInstance = new FormInstance();
    if (formInstanceRequest.getBusinessKey() != null) {
        formInstance.setBusinessKey(formInstanceRequest.getBusinessKey());
    }
    if (formInstanceRequest.getTenantId() != null) {
        formInstance.setTenantId(formInstanceRequest.getTenantId());
    }
    if (formInstanceRequest.getFormDatas() != null) {
        for (FormInstanceData formInstanceData : formInstanceRequest.getFormDatas()) {
            FormData formData = new FormData();
            formData.setFormInstance(formInstance);
            formData.setKey(formInstanceData.getKey());
            formData.setValue(formInstanceData.getValue());
            formInstance.addFormData(formData);
        }
    }
    formInstanceRepository.save(formInstance);
    return responseFactory.createFormInstanceResponse(formInstance);
}
Also used : FormData(com.plumdo.form.entity.FormData) FormInstance(com.plumdo.form.entity.FormInstance) FormInstanceData(com.plumdo.form.rest.instance.FormInstanceData) 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 57 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus 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 58 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project plumdo-work by wengwh.

the class FormInstanceResource method updateFormInstance.

@ApiOperation(value = "创建表单模型", notes = "根据传过来的modelRequest信息来创建表单模型")
@ApiImplicitParam(name = "modelRequest", value = "表单模型请求实体modelRequest", required = true, dataType = "FormInstanceRequest")
@RequestMapping(value = "/form-instances/{id}", method = RequestMethod.PUT, produces = "application/json")
@ResponseStatus(value = HttpStatus.CREATED)
@Transactional(propagation = Propagation.REQUIRED)
public FormInstanceResponse updateFormInstance(@PathVariable Long id, @RequestBody FormInstanceRequest formInstanceRequest) {
    FormInstance formInstance = getFormInstanceFromRequest(id);
    if (formInstanceRequest.getBusinessKey() != null) {
        formInstance.setBusinessKey(formInstanceRequest.getBusinessKey());
    }
    if (formInstanceRequest.getTenantId() != null) {
        formInstance.setTenantId(formInstanceRequest.getTenantId());
    }
    if (formInstanceRequest.getFormDatas() != null) {
        for (FormInstanceData formInstanceData : formInstanceRequest.getFormDatas()) {
            Criteria<FormData> criteria = new Criteria<FormData>();
            criteria.add(Restrictions.eq("key", formInstanceData.getKey(), false));
            criteria.add(Restrictions.eq("formInstance.id", id, false));
            FormData oldFormData = formDataRepository.findOne(criteria);
            if (oldFormData == null) {
                FormData formData = new FormData();
                formData.setFormInstance(formInstance);
                formData.setKey(formInstanceData.getKey());
                formData.setValue(formInstanceData.getValue());
                formInstance.addFormData(formData);
            } else {
                oldFormData.setValue(formInstanceData.getValue());
                formInstance.addFormData(oldFormData);
            }
        }
    }
    formInstanceRepository.save(formInstance);
    return responseFactory.createFormInstanceResponse(formInstance);
}
Also used : FormData(com.plumdo.form.entity.FormData) Criteria(com.plumdo.form.jpa.Criteria) FormInstance(com.plumdo.form.entity.FormInstance) FormInstanceData(com.plumdo.form.rest.instance.FormInstanceData) 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 59 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project plumdo-work by wengwh.

the class RoleResource method deleteRole.

@DeleteMapping(value = "/roles/{id}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@Transactional
public void deleteRole(@PathVariable Integer id) {
    Role role = getRoleFromRequest(id);
    roleRepository.delete(role);
    roleMenuRepository.deleteByRoleId(role.getId());
}
Also used : Role(com.plumdo.identity.domain.Role) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) Transactional(org.springframework.transaction.annotation.Transactional)

Example 60 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project plumdo-work by wengwh.

the class MenuResource method deleteMenu.

@DeleteMapping(value = "/menus/{id}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteMenu(@PathVariable Integer id) {
    Menu menu = getMenuFromRequest(id);
    menuRepository.delete(menu);
}
Also used : Menu(com.plumdo.identity.domain.Menu) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Aggregations

ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)149 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)118 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)36 ApiOperation (io.swagger.annotations.ApiOperation)31 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)26 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)19 GetMapping (org.springframework.web.bind.annotation.GetMapping)18 ApiResponses (io.swagger.annotations.ApiResponses)14 User (org.hisp.dhis.user.User)14 Transactional (org.springframework.transaction.annotation.Transactional)14 Date (java.util.Date)13 Configuration (org.hisp.dhis.configuration.Configuration)12 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)12 Period (org.hisp.dhis.period.Period)11 ArrayList (java.util.ArrayList)10 QualifiedName (com.netflix.metacat.common.QualifiedName)9 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)9 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)9 Calendar (java.util.Calendar)9 Task (org.flowable.engine.task.Task)8