@things-factory/organization 7.0.68 → 7.0.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/pages/employee/employee-list-page.ts +3 -3
- package/dist-client/pages/employee/employee-list-page.js +3 -3
- package/dist-client/pages/employee/employee-list-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/register-employee-as-system-user.d.ts +1 -0
- package/dist-server/controllers/register-employee-as-system-user.js +54 -0
- package/dist-server/controllers/register-employee-as-system-user.js.map +1 -0
- package/dist-server/migrations/1723861013111-seed-organization-codes.d.ts +5 -0
- package/dist-server/migrations/1723861013111-seed-organization-codes.js +120 -0
- package/dist-server/migrations/1723861013111-seed-organization-codes.js.map +1 -0
- package/dist-server/migrations/index.d.ts +1 -0
- package/dist-server/migrations/index.js +12 -0
- package/dist-server/migrations/index.js.map +1 -0
- package/dist-server/service/employee/employee-mutation.d.ts +1 -0
- package/dist-server/service/employee/employee-mutation.js +39 -0
- package/dist-server/service/employee/employee-mutation.js.map +1 -1
- package/dist-server/service/index.d.ts +3 -3
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/server/controllers/register-employee-as-system-user.ts +62 -0
- package/server/migrations/1723861013111-seed-organization-codes.ts +127 -0
- package/server/migrations/index.ts +9 -0
- package/server/service/employee/employee-mutation.ts +40 -0
- package/translations/en.json +2 -0
- package/translations/ja.json +2 -0
- package/translations/ko.json +2 -0
- package/translations/ms.json +2 -0
- package/translations/zh.json +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/organization",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.69",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "dist-client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"@operato/p13n": "^7.0.0",
|
|
35
35
|
"@operato/shell": "^7.0.0",
|
|
36
36
|
"@things-factory/auth-base": "^7.0.68",
|
|
37
|
-
"@things-factory/code-ui": "^7.0.
|
|
38
|
-
"@things-factory/contact": "^7.0.
|
|
37
|
+
"@things-factory/code-ui": "^7.0.69",
|
|
38
|
+
"@things-factory/contact": "^7.0.69",
|
|
39
39
|
"@things-factory/shell": "^7.0.68"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "7768bbf12490e519b058e651cc4ae05d9780906f"
|
|
42
42
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Role, User } from '@things-factory/auth-base'
|
|
2
|
+
import { Contact } from '@things-factory/contact'
|
|
3
|
+
import { getRepository } from '@things-factory/shell'
|
|
4
|
+
import { Employee } from 'service'
|
|
5
|
+
|
|
6
|
+
export async function registerEmployeeAsSystemUser(employeeId: string, context: ResolverContext) {
|
|
7
|
+
/*
|
|
8
|
+
process
|
|
9
|
+
|
|
10
|
+
0. 이미 연결된 사용자가 없어야 한다.
|
|
11
|
+
1. contact 정보가 있어야 한다.
|
|
12
|
+
2. contact 정보에 대표 email 정보가 있어야 한다.
|
|
13
|
+
3. employee 의 직책 정보가 있어야 한다. => role 과 연결된다.
|
|
14
|
+
4. 사용자 중에서 동일한 이메일을 가진 사용자가 있는가 확인한다.
|
|
15
|
+
5. 그 사용자가 이 도메인에 연결되어 있는 지 확인한다. 없다면 실패.
|
|
16
|
+
6. 직책에 해당하는 역할이 있는 지 확인한다.
|
|
17
|
+
7. 시스템에 사용자를 등록한다.
|
|
18
|
+
8. 역할을 추가한다.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const { domain, user } = context.state
|
|
22
|
+
|
|
23
|
+
const employeeRepository = getRepository(Employee)
|
|
24
|
+
|
|
25
|
+
const employee = await employeeRepository.findOne({
|
|
26
|
+
where: {
|
|
27
|
+
id: employeeId,
|
|
28
|
+
domain: { id: domain.id }
|
|
29
|
+
},
|
|
30
|
+
relations: ['contact']
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const { email } = employee.contact
|
|
34
|
+
const { jobResponsibility } = employee
|
|
35
|
+
|
|
36
|
+
const userRepository = getRepository(User)
|
|
37
|
+
const existingUser = await userRepository.findOne({
|
|
38
|
+
where: {
|
|
39
|
+
email
|
|
40
|
+
},
|
|
41
|
+
relations: ['domains']
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const newUser = await userRepository.save({
|
|
45
|
+
name: employee.contact.name,
|
|
46
|
+
email
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// permission for this domain
|
|
50
|
+
|
|
51
|
+
const roleRepository = getRepository(Role)
|
|
52
|
+
const existingRole = await roleRepository.findOne({
|
|
53
|
+
where: {
|
|
54
|
+
name: jobResponsibility,
|
|
55
|
+
domain: { id: domain.id }
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
// permission for this role
|
|
60
|
+
|
|
61
|
+
return true
|
|
62
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { logger } from '@things-factory/env'
|
|
4
|
+
import { Domain, getRepository } from '@things-factory/shell'
|
|
5
|
+
import { User } from '@things-factory/auth-base'
|
|
6
|
+
import { CommonCode, CommonCodeDetail } from '@things-factory/code-base'
|
|
7
|
+
|
|
8
|
+
const SEED_COMMON_CODES = [
|
|
9
|
+
{
|
|
10
|
+
name: 'EMPLOYEE_TYPE',
|
|
11
|
+
description: '직원 유형',
|
|
12
|
+
details: [
|
|
13
|
+
{
|
|
14
|
+
name: 'FULLTIME',
|
|
15
|
+
description: '풀타임 정규직',
|
|
16
|
+
labels: null,
|
|
17
|
+
rank: 1
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'PARTTIME',
|
|
21
|
+
description: '파트타임 정규직',
|
|
22
|
+
labels: null,
|
|
23
|
+
rank: 2
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'TEMPORARY',
|
|
27
|
+
description: '임시직',
|
|
28
|
+
labels: null,
|
|
29
|
+
rank: 3
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'JOB_POSITION',
|
|
35
|
+
description: '직급',
|
|
36
|
+
details: [
|
|
37
|
+
// {
|
|
38
|
+
// name: '임원',
|
|
39
|
+
// description: '임원',
|
|
40
|
+
// labels: null,
|
|
41
|
+
// rank: 1
|
|
42
|
+
// },
|
|
43
|
+
// {
|
|
44
|
+
// name: '직원',
|
|
45
|
+
// description: '직원',
|
|
46
|
+
// labels: null,
|
|
47
|
+
// rank: 2
|
|
48
|
+
// }
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'JOB_RESPONSIBILITY',
|
|
53
|
+
description: '직책',
|
|
54
|
+
details: [
|
|
55
|
+
// {
|
|
56
|
+
// name: '상담사',
|
|
57
|
+
// description: '상담사',
|
|
58
|
+
// labels: null,
|
|
59
|
+
// rank: 1
|
|
60
|
+
// },
|
|
61
|
+
// {
|
|
62
|
+
// name: '매니저',
|
|
63
|
+
// description: '매니저',
|
|
64
|
+
// labels: null,
|
|
65
|
+
// rank: 2
|
|
66
|
+
// }
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
export class SeedOrganizationCodes1723861013111 implements MigrationInterface {
|
|
72
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
73
|
+
const commonCodeRepository = getRepository(CommonCode)
|
|
74
|
+
const commonCodeDetailRepository = getRepository(CommonCodeDetail)
|
|
75
|
+
const domainRepository = getRepository(Domain)
|
|
76
|
+
const userRepository = getRepository(User)
|
|
77
|
+
|
|
78
|
+
const domain: Domain = await domainRepository.findOne({
|
|
79
|
+
where: { name: 'SYSTEM' }
|
|
80
|
+
})
|
|
81
|
+
const user = await userRepository.findOne({ where: { id: domain.owner } })
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
for (let i = 0; i < SEED_COMMON_CODES.length; i++) {
|
|
85
|
+
const { name, description, details } = SEED_COMMON_CODES[i]
|
|
86
|
+
|
|
87
|
+
const commonCode = await commonCodeRepository.save({
|
|
88
|
+
domain,
|
|
89
|
+
name,
|
|
90
|
+
description,
|
|
91
|
+
creator: user,
|
|
92
|
+
updater: user
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
for (const commonCodeDetail of details) {
|
|
96
|
+
const { name, description, labels, rank } = commonCodeDetail
|
|
97
|
+
|
|
98
|
+
await commonCodeDetailRepository.save({
|
|
99
|
+
domain,
|
|
100
|
+
commonCode,
|
|
101
|
+
name,
|
|
102
|
+
description,
|
|
103
|
+
labels,
|
|
104
|
+
rank
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} catch (e) {
|
|
109
|
+
logger.error(e)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
114
|
+
const domainRepository = getRepository(Domain)
|
|
115
|
+
|
|
116
|
+
const domain: Domain = await domainRepository.findOne({
|
|
117
|
+
where: { name: 'SYSTEM' }
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
const repository = getRepository(CommonCode)
|
|
121
|
+
|
|
122
|
+
SEED_COMMON_CODES.reverse().forEach(async commonCode => {
|
|
123
|
+
let record = await repository.findOne({ where: { name: commonCode.name, domain: { id: domain.id } } })
|
|
124
|
+
record && (await repository.remove(record))
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const glob = require('glob')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
|
|
4
|
+
export var migrations = []
|
|
5
|
+
|
|
6
|
+
glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {
|
|
7
|
+
if (file.indexOf('index.js') !== -1) return
|
|
8
|
+
migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])
|
|
9
|
+
})
|
|
@@ -323,4 +323,44 @@ export class EmployeeMutation {
|
|
|
323
323
|
|
|
324
324
|
return result
|
|
325
325
|
}
|
|
326
|
+
|
|
327
|
+
// @Directive('@privilege')
|
|
328
|
+
@Directive('@transaction')
|
|
329
|
+
@Mutation(returns => Boolean, { description: 'To register employee as a system user' })
|
|
330
|
+
async registerEmployeeAsSystemUser(
|
|
331
|
+
@Arg('id', { description: 'Employee Id' }) id: string,
|
|
332
|
+
@Ctx() context: ResolverContext
|
|
333
|
+
): Promise<boolean> {
|
|
334
|
+
const { domain, user, tx } = context.state
|
|
335
|
+
|
|
336
|
+
const employeeRepository = tx.getRepository(Employee)
|
|
337
|
+
const employee = await employeeRepository.findOne({
|
|
338
|
+
where: { domain: { id: domain.id }, id },
|
|
339
|
+
relations: ['contact', 'user']
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
return true
|
|
343
|
+
|
|
344
|
+
/*
|
|
345
|
+
process
|
|
346
|
+
|
|
347
|
+
0. 이미 연결된 사용자가 없어야 한다.
|
|
348
|
+
1. contact 정보가 있어야 한다.
|
|
349
|
+
2. contact 정보에 대표 email 정보가 있어야 한다.
|
|
350
|
+
3. employee 의 직책 정보가 있어야 한다. => role 과 연결된다.
|
|
351
|
+
4. 사용자 중에서 동일한 이메일을 가진 사용자가 있는가 확인한다.
|
|
352
|
+
5. 그 사용자가 이 도메인에 연결되어 있는 지 확인한다. 없다면 실패.
|
|
353
|
+
6. 직책에 해당하는 역할이 있는 지 확인한다.
|
|
354
|
+
7. 시스템에 사용자를 등록한다.
|
|
355
|
+
8. 역할을 추가한다.
|
|
356
|
+
*/
|
|
357
|
+
// const result = await employeeRepository.save({
|
|
358
|
+
// ...employee,
|
|
359
|
+
// name: contact.name,
|
|
360
|
+
// contact: { id: contactId },
|
|
361
|
+
// updater: user
|
|
362
|
+
// })
|
|
363
|
+
|
|
364
|
+
// return result
|
|
365
|
+
}
|
|
326
366
|
}
|
package/translations/en.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"field.note": "note",
|
|
12
12
|
"field.owner-type": "owner type",
|
|
13
13
|
"field.supervisor": "supervisor",
|
|
14
|
+
"field.system-user": "system user",
|
|
14
15
|
"label.control-no": "control No.",
|
|
15
16
|
"label.hired-on": "hired on",
|
|
16
17
|
"label.Department": "department",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"title.assignee list": "assignee list",
|
|
37
38
|
"title.assignees editor": "assignee editor",
|
|
38
39
|
"title.common-approval-line template list": "common approval line template list",
|
|
40
|
+
"title.lookup system-user": "lookup system user",
|
|
39
41
|
"title.my-approval-line template list": "my approval line template list",
|
|
40
42
|
"title.employee list": "employee list",
|
|
41
43
|
"title.department list": "department list",
|
package/translations/ja.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"field.note": "コメント",
|
|
12
12
|
"field.owner-type": "所有者タイプ",
|
|
13
13
|
"field.supervisor": "監督者",
|
|
14
|
+
"field.system-user": "システムユーザー",
|
|
14
15
|
"label.control-no": "管理番号",
|
|
15
16
|
"label.hired-on": "入社日",
|
|
16
17
|
"label.Department": "部署",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"title.assignee list": "譲渡人リスト",
|
|
37
38
|
"title.assignees editor": "譲渡人リスト編集",
|
|
38
39
|
"title.common-approval-line template list": "共通決裁ライン テンプレート リスト",
|
|
40
|
+
"title.lookup system-user": "システムユーザーを検索",
|
|
39
41
|
"title.my-approval-line template list": "マイ決裁ライン テンプレート リスト",
|
|
40
42
|
"title.employee list": "職員リスト",
|
|
41
43
|
"title.department list": "部署リスト",
|
package/translations/ko.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"field.note": "코멘트",
|
|
12
12
|
"field.owner-type": "소유자 종류",
|
|
13
13
|
"field.supervisor": "감독자",
|
|
14
|
+
"field.system-user": "시스템 사용자",
|
|
14
15
|
"label.Department": "부서",
|
|
15
16
|
"label.Employee": "직원",
|
|
16
17
|
"label.Role": "역할",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"title.assignee list": "할당자 목록",
|
|
37
38
|
"title.assignees editor": "할당자 목록 편집",
|
|
38
39
|
"title.common-approval-line template list": "공통 결재라인 템플릿 목록",
|
|
40
|
+
"title.lookup system-user": "시스템 사용자 검색",
|
|
39
41
|
"title.my-approval-line template list": "나의 결재라인 템플릿 목록",
|
|
40
42
|
"title.employee list": "직원 목록",
|
|
41
43
|
"title.department list": "부서 목록",
|
package/translations/ms.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"field.note": "catatan",
|
|
12
12
|
"field.owner-type": "jenis pemilik",
|
|
13
13
|
"field.supervisor": "penyelia",
|
|
14
|
+
"field.system-user": "pengguna sistem",
|
|
14
15
|
"label.Department": "jabatan",
|
|
15
16
|
"label.Employee": "pekerja",
|
|
16
17
|
"label.Role": "peranan",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"title.assignee list": "senarai penerima tugasan",
|
|
37
38
|
"title.assignees editor": "editor penerima tugasan",
|
|
38
39
|
"title.common-approval-line template list": "senarai templat garis kelulusan biasa",
|
|
40
|
+
"title.lookup system-user": "cari pengguna sistem",
|
|
39
41
|
"title.my-approval-line template list": "senarai templat garis kelulusan saya",
|
|
40
42
|
"title.employee list": "senarai pekerja",
|
|
41
43
|
"title.department list": "senarai jabatan",
|
package/translations/zh.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"field.note": "备注",
|
|
12
12
|
"field.owner-type": "所有者类型",
|
|
13
13
|
"field.supervisor": "主管",
|
|
14
|
+
"field.system-user": "系统用户",
|
|
14
15
|
"label.Department": "部门",
|
|
15
16
|
"label.Employee": "员工",
|
|
16
17
|
"label.Role": "角色",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"title.assignee list": "受托人列表",
|
|
37
38
|
"title.assignees editor": "受托人编辑器",
|
|
38
39
|
"title.common-approval-line template list": "常用审批线模板列表",
|
|
40
|
+
"title.lookup system-user": "查找系统用户",
|
|
39
41
|
"title.my-approval-line template list": "我的审批线模板列表",
|
|
40
42
|
"title.employee list": "员工列表",
|
|
41
43
|
"title.department list": "部门列表",
|