feat: added fineOne API for workspace & project for update purposes
This commit is contained in:
@@ -20,6 +20,15 @@ import { ITokenPayload } from "../../auth/interfaces/IToken-payload";
|
||||
export class ProjectController {
|
||||
constructor(private readonly projectService: ProjectService) {}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({summary: 'Get one project by ID'})
|
||||
@ApiResponse({status: 200, description: 'received the project successfully!'})
|
||||
@ApiResponse({status: 404, description: 'Project Not Found!'})
|
||||
@ApiResponse({status: 400, description: 'Bad Request!'})
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.projectService.findOneOrFail(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@PermissionsDec(PermissionEnum.PROJECT)
|
||||
@ApiOperation({ summary: "Create a new project" })
|
||||
@@ -63,7 +72,7 @@ export class ProjectController {
|
||||
return this.projectService.findUserProjectsByWorkspace(user.id, user.permissions, paramDto.id, pagination);
|
||||
}
|
||||
|
||||
@Get("project/:id")
|
||||
@Get("detail/:id")
|
||||
@ApiOperation({ summary: "Get project detail" })
|
||||
@ApiResponse({ status: 200, description: "Got Project Detail Successfully!" })
|
||||
@ApiResponse({ status: 400, description: "Bad request!" })
|
||||
|
||||
@@ -18,6 +18,16 @@ import { ITokenPayload } from '../../auth/interfaces/IToken-payload';
|
||||
export class WorkspaceController {
|
||||
constructor(private readonly workspaceService: WorkspaceService) {}
|
||||
|
||||
@Get(':id')
|
||||
@PermissionsDec(PermissionEnum.WORKSPACE)
|
||||
@ApiOperation({summary: "Get one workspace by ID"})
|
||||
@ApiResponse({status: 200, description: 'Received workspace', type: TMWorkspace})
|
||||
@ApiResponse({status: 404, description: 'Workspace Not Found!'})
|
||||
@ApiResponse({status: 400, description: 'Bad Request!'})
|
||||
findOne(@Param('id') id: string): Promise<TMWorkspace> {
|
||||
return this.workspaceService.findOneOrFail(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@PermissionsDec(PermissionEnum.WORKSPACE)
|
||||
@ApiOperation({ summary: 'Create a new workspace' })
|
||||
|
||||
@@ -17,10 +17,6 @@ export class WorkspaceService {
|
||||
private readonly userRepository: Repository<User>,
|
||||
) {}
|
||||
|
||||
findAll(): Promise<TMWorkspace[]> {
|
||||
return this.workspaceRepository.find({});
|
||||
}
|
||||
|
||||
async findOneOrFail(id: string): Promise<TMWorkspace> {
|
||||
const workspace = await this.workspaceRepository.findOneWorkSpace(id);
|
||||
if (!workspace) throw new NotFoundException(WorkSpaceMessage.WORKSPACE_NOT_FOUND);
|
||||
|
||||
@@ -25,7 +25,7 @@ export enum PermissionEnum {
|
||||
DPAGE = "dpage",
|
||||
DMAIL = 'dmail',
|
||||
RESELLER="reseller",
|
||||
WORKSPACE="workspace", // create, update, remove
|
||||
WORKSPACE="workspace", // create, update, remove, read-one(for update purposes)
|
||||
VIEW_ALL_WORKSPACES="view_all_workspaces",
|
||||
PROJECT="project", // create, update, remove
|
||||
VIEW_ALL_PROJECTS="view_all_projects",
|
||||
|
||||
Reference in New Issue
Block a user