mirror of https://github.com/doccano/doccano.git
Hironsan
1 year ago
11 changed files with 28 additions and 103 deletions
Split View
Diff Options
-
6frontend/components/member/FormCreate.vue
-
13frontend/domain/models/member/memberRepository.ts
-
3frontend/layouts/project.vue
-
3frontend/layouts/workspace.vue
-
4frontend/middleware/check-admin.js
-
3frontend/pages/projects/_id/dataset/index.vue
-
24frontend/pages/projects/_id/members/index.vue
-
3frontend/plugins/services.ts
-
10frontend/repositories/member/apiMemberRepository.ts
-
45frontend/services/application/member/memberApplicationService.ts
-
17frontend/services/application/member/memberData.ts
@ -1,13 +0,0 @@ |
|||
import { MemberItem } from '~/domain/models/member/member' |
|||
|
|||
export interface MemberRepository { |
|||
list(projectId: string): Promise<MemberItem[]> |
|||
|
|||
create(projectId: string, item: MemberItem): Promise<MemberItem> |
|||
|
|||
update(projectId: string, item: MemberItem): Promise<MemberItem> |
|||
|
|||
bulkDelete(projectId: string, memberIds: number[]): Promise<void> |
|||
|
|||
fetchMyRole(projectId: string): Promise<MemberItem> |
|||
} |
@ -1,45 +0,0 @@ |
|||
import { plainToInstance } from 'class-transformer' |
|||
import { MemberDTO } from './memberData' |
|||
import { MemberRepository } from '~/domain/models/member/memberRepository' |
|||
import { MemberItem } from '~/domain/models/member/member' |
|||
|
|||
export class MemberApplicationService { |
|||
constructor(private readonly repository: MemberRepository) {} |
|||
|
|||
public async list(id: string): Promise<MemberDTO[]> { |
|||
try { |
|||
const items = await this.repository.list(id) |
|||
return items.map((item) => new MemberDTO(item)) |
|||
} catch (e: any) { |
|||
throw new Error(e.response.data.detail) |
|||
} |
|||
} |
|||
|
|||
public async create(projectId: string, item: MemberDTO): Promise<void> { |
|||
try { |
|||
const member = plainToInstance(MemberItem, item) |
|||
await this.repository.create(projectId, member) |
|||
} catch (e: any) { |
|||
throw new Error(e.response.data.detail) |
|||
} |
|||
} |
|||
|
|||
public async update(projectId: string, item: MemberDTO): Promise<void> { |
|||
try { |
|||
const member = plainToInstance(MemberItem, item) |
|||
await this.repository.update(projectId, member) |
|||
} catch (e: any) { |
|||
throw new Error(e.response.data.detail) |
|||
} |
|||
} |
|||
|
|||
public bulkDelete(projectId: string, items: MemberDTO[]): Promise<void> { |
|||
const ids = items.map((item) => item.id) |
|||
return this.repository.bulkDelete(projectId, ids) |
|||
} |
|||
|
|||
public async isProjectAdmin(projectId: string): Promise<boolean> { |
|||
const item = await this.repository.fetchMyRole(projectId) |
|||
return item.isProjectAdmin |
|||
} |
|||
} |
@ -1,17 +0,0 @@ |
|||
import { MemberItem } from '~/domain/models/member/member' |
|||
import { RoleName } from '~/domain/models/role/role' |
|||
export class MemberDTO { |
|||
id: number |
|||
user: number |
|||
role: number |
|||
username: string |
|||
rolename: RoleName |
|||
|
|||
constructor(item: MemberItem) { |
|||
this.id = item.id |
|||
this.user = item.user |
|||
this.role = item.role |
|||
this.username = item.username |
|||
this.rolename = item.rolename |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save