packageorg.thingsboard.server.controller;importio.swagger.annotations.ApiOperation;importio.swagger.annotations.ApiParam;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.security.access.prepost.PreAuthorize;importorg.springframework.stereotype.Service;importorg.springframework.web.bind.annotation.*;importorg.thingsboard.server.common.data.exception.ThingsboardException;importorg.thingsboard.server.common.data.id.ProjectId;importorg.thingsboard.server.common.data.id.TenantId;importorg.thingsboard.server.common.data.project.Project;importorg.thingsboard.server.dao.project.ProjectService;importjava.util.UUID;importstaticorg.thingsboard.server.controller.ControllerConstants.SYSTEM_AUTHORITY_PARAGRAPH;importstaticorg.thingsboard.server.controller.ControllerConstants.TENANT_AUTHORITY_PARAGRAPH;@RestController@RequestMapping("/api")@ServicepublicclassProjectControllerextendsBaseController{@AutowiredprivateProjectService projectService;@ApiOperation(value ="Get Tenant Customer by Customer title (getTenantCustomer)",
notes ="Get the Customer using Customer Title. "+ TENANT_AUTHORITY_PARAGRAPH)@RequestMapping(value ="/project", params ={"projectIdStr"}, method =RequestMethod.GET)@ResponseBodypublicProjectfindById(@ApiParam(value ="A string value representing the Project title.")@RequestParamString projectIdStr)throwsThingsboardException{try{ProjectId projectId =newProjectId(UUID.fromString(projectIdStr));return projectService.findProjectsById(TenantId.SYS_TENANT_ID, projectId);}catch(Exception e){System.out.println(e.getMessage());System.out.println("dddddddddddddd");throwhandleException(e);}}@ApiOperation(value ="Get the Administration Settings object using key (getAdminSettings)",
notes ="Creates or Updates the Administration Settings. Platform generates random Administration Settings Id during settings creation. "+"The Administration Settings Id will be present in the response. Specify the Administration Settings Id when you would like to update the Administration Settings. "+"Referencing non-existing Administration Settings Id will cause an error."+ SYSTEM_AUTHORITY_PARAGRAPH)@PreAuthorize("hasAuthority('TENANT_ADMIN')")@RequestMapping(value ="/project", method =RequestMethod.POST)@ResponseBodypublicProjectsaveProject(@ApiParam(value ="A JSON value representing the Administration Settings.")@RequestBodyProject project)throwsThingsboardException{try{
project.setTenantId(getTenantId());
project =checkNotNull(projectService.saveProject(TenantId.SYS_TENANT_ID, project));return project;}catch(Exception e){throwhandleException(e);}}@ApiOperation(value ="Get Tenant Customer by Customer title (getTenantCustomer)",
notes ="Get the Customer using Customer Title. "+ TENANT_AUTHORITY_PARAGRAPH)@RequestMapping(value ="/projects", params ={"projectIdStr"}, method =RequestMethod.GET)@ResponseBodypublicProjectgetProject(@ApiParam(value ="A string value representing the Customer title.")@RequestParamString projectIdStr)throwsThingsboardException{try{ProjectId projectId =newProjectId(UUID.fromString(projectIdStr));returncheckNotNull(projectService.findProjectById(projectId),"Customer with id ["+ projectIdStr +"] is not found");}catch(Exception e){System.out.println(e.getMessage());System.out.println("dddddddddddddd");throwhandleException(e);}}}