From f16833d7decbb3624530d16aae4007c225b420ed Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 24 Feb 2023 16:26:27 +0900 Subject: [PATCH] Remove role application service --- frontend/components/member/FormCreate.vue | 22 +++++++++---------- frontend/domain/models/role/roleRepository.ts | 5 ----- frontend/plugins/services.ts | 3 --- .../repositories/role/apiRoleRepository.ts | 5 ++--- .../services/application/member/memberData.ts | 4 ++-- .../role/roleApplicationService.ts | 11 ---------- .../services/application/role/roleData.ts | 11 ---------- 7 files changed, 15 insertions(+), 46 deletions(-) delete mode 100644 frontend/domain/models/role/roleRepository.ts delete mode 100644 frontend/services/application/role/roleApplicationService.ts delete mode 100644 frontend/services/application/role/roleData.ts diff --git a/frontend/components/member/FormCreate.vue b/frontend/components/member/FormCreate.vue index 119f5dc0..218173e5 100644 --- a/frontend/components/member/FormCreate.vue +++ b/frontend/components/member/FormCreate.vue @@ -25,7 +25,7 @@ @@ -56,9 +56,9 @@ import { mdiAccount, mdiCreditCardOutline } from '@mdi/js' import type { PropType } from 'vue' import Vue from 'vue' import BaseCard from '@/components/utils/BaseCard.vue' +import { RoleItem } from '~/domain/models/role/role' import { UserItem } from '~/domain/models/user/user' import { MemberDTO } from '~/services/application/member/memberData' -import { RoleDTO } from '~/services/application/role/roleData' export default Vue.extend({ components: { @@ -81,11 +81,11 @@ export default Vue.extend({ isLoading: false, valid: false, users: [] as UserItem[], - roles: [] as RoleDTO[], + roles: [] as RoleItem[], username: '', rules: { userRequired: (v: UserItem) => (!!v && !!v.username) || 'Required', - roleRequired: (v: RoleDTO) => (!!v && !!v.rolename) || 'Required' + roleRequired: (v: RoleItem) => (!!v && !!v.name) || 'Required' }, mdiAccount, mdiCreditCardOutline @@ -115,14 +115,14 @@ export default Vue.extend({ } }, role: { - get(): RoleDTO { + get(): RoleItem { return { id: this.value.role, - rolename: this.value.rolename + name: this.value.rolename } }, - set(val: MemberDTO) { - const role = { role: val.id, rolename: val.rolename } + set(val: RoleItem) { + const role = { role: val.id, rolename: val.name } this.$emit('input', { ...this.value, ...role }) } } @@ -141,7 +141,7 @@ export default Vue.extend({ }, async created() { - this.roles = await this.$services.role.list() + this.roles = await this.$repositories.role.list() } }) diff --git a/frontend/domain/models/role/roleRepository.ts b/frontend/domain/models/role/roleRepository.ts deleted file mode 100644 index 17750a44..00000000 --- a/frontend/domain/models/role/roleRepository.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { RoleItem } from '~/domain/models/role/role' - -export interface RoleRepository { - list(): Promise -} diff --git a/frontend/plugins/services.ts b/frontend/plugins/services.ts index 051d9394..73d69b6c 100644 --- a/frontend/plugins/services.ts +++ b/frontend/plugins/services.ts @@ -12,7 +12,6 @@ import { MemberApplicationService } from '@/services/application/member/memberAp import { MetricsApplicationService } from '@/services/application/metrics/metricsApplicationService' import { OptionApplicationService } from '@/services/application/option/optionApplicationService' import { ProjectApplicationService } from '@/services/application/project/projectApplicationService' -import { RoleApplicationService } from '@/services/application/role/roleApplicationService' import { TagApplicationService } from '@/services/application/tag/tagApplicationService' import { BoundingBoxApplicationService } from '@/services/application/tasks/boundingBox/boundingBoxApplicationService' import { SegmentationApplicationService } from '@/services/application/tasks/segmentation/segmentationApplicationService' @@ -27,7 +26,6 @@ export interface Services { spanType: LabelApplicationService relationType: LabelApplicationService member: MemberApplicationService - role: RoleApplicationService project: ProjectApplicationService comment: CommentApplicationService metrics: MetricsApplicationService @@ -60,7 +58,6 @@ const plugin: Plugin = (_, inject) => { spanType: new LabelApplicationService(repositories.spanType), relationType: new LabelApplicationService(repositories.relationType), member: new MemberApplicationService(repositories.member), - role: new RoleApplicationService(repositories.role), project: new ProjectApplicationService(repositories.project), comment: new CommentApplicationService(repositories.comment), metrics: new MetricsApplicationService(repositories.metrics), diff --git a/frontend/repositories/role/apiRoleRepository.ts b/frontend/repositories/role/apiRoleRepository.ts index 1de6961e..cc6961d5 100644 --- a/frontend/repositories/role/apiRoleRepository.ts +++ b/frontend/repositories/role/apiRoleRepository.ts @@ -1,12 +1,11 @@ -import ApiService from '@/services/api.service' -import { RoleRepository } from '@/domain/models/role/roleRepository' import { RoleItem } from '@/domain/models/role/role' +import ApiService from '@/services/api.service' function toModel(item: { [key: string]: any }): RoleItem { return new RoleItem(item.id, item.name) } -export class APIRoleRepository implements RoleRepository { +export class APIRoleRepository { constructor(private readonly request = ApiService) {} async list(): Promise { diff --git a/frontend/services/application/member/memberData.ts b/frontend/services/application/member/memberData.ts index 74cf2c94..70dbb826 100644 --- a/frontend/services/application/member/memberData.ts +++ b/frontend/services/application/member/memberData.ts @@ -1,11 +1,11 @@ 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: string + rolename: RoleName constructor(item: MemberItem) { this.id = item.id diff --git a/frontend/services/application/role/roleApplicationService.ts b/frontend/services/application/role/roleApplicationService.ts deleted file mode 100644 index 0f132bf6..00000000 --- a/frontend/services/application/role/roleApplicationService.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { RoleDTO } from './roleData' -import { RoleRepository } from '~/domain/models/role/roleRepository' - -export class RoleApplicationService { - constructor(private readonly repository: RoleRepository) {} - - public async list(): Promise { - const items = await this.repository.list() - return items.map((item) => new RoleDTO(item)) - } -} diff --git a/frontend/services/application/role/roleData.ts b/frontend/services/application/role/roleData.ts deleted file mode 100644 index c9c33e09..00000000 --- a/frontend/services/application/role/roleData.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { RoleItem } from '~/domain/models/role/role' - -export class RoleDTO { - id: number - rolename: string - - constructor(item: RoleItem) { - this.id = item.id - this.rolename = item.name - } -}