@@ -12,17 +12,17 @@ export class ServiceProxy extends Proxy {
12
12
13
13
static get NAME ( ) { return "ServiceProxy" } ;
14
14
15
- constructor ( mySQL , user , role ) {
15
+ constructor ( mySQL , userData , roleData ) {
16
16
super ( ServiceProxy . NAME , null ) ;
17
17
this . mySQL = mySQL ;
18
- this . user = user ;
19
- this . role = role ;
18
+ this . userData = userData ;
19
+ this . roleData = roleData ;
20
20
}
21
21
22
22
async findAllUsers ( ) {
23
23
const connection = await this . mySQL . getConnection ( ) ;
24
24
try {
25
- return await this . user . findAllUsers ( connection ) ;
25
+ return await this . userData . findAllUsers ( connection ) ;
26
26
} catch ( error ) {
27
27
throw error ;
28
28
} finally {
@@ -33,7 +33,7 @@ export class ServiceProxy extends Proxy {
33
33
async findUserById ( id ) {
34
34
const connection = await this . mySQL . getConnection ( ) ;
35
35
try {
36
- return await this . user . findUserById ( connection , id ) ;
36
+ return await this . userData . findUserById ( connection , id ) ;
37
37
} catch ( error ) {
38
38
throw error ;
39
39
} finally {
@@ -45,9 +45,9 @@ export class ServiceProxy extends Proxy {
45
45
const connection = await this . mySQL . getConnection ( ) ;
46
46
try {
47
47
await this . mySQL . beginTransaction ( connection ) ;
48
- const result = await this . user . add ( connection , user ) ;
48
+ const result = await this . userData . add ( connection , user ) ;
49
49
if ( user . roles && user . roles . length > 0 )
50
- await this . role . updateRolesById ( connection , result . body . id , user . roles ) ;
50
+ await this . roleData . updateRolesById ( connection , result . body . id , user . roles ) ;
51
51
await this . mySQL . commit ( connection ) ;
52
52
return result ;
53
53
} catch ( error ) {
@@ -62,11 +62,11 @@ export class ServiceProxy extends Proxy {
62
62
const connection = await this . mySQL . getConnection ( ) ;
63
63
try {
64
64
await this . mySQL . beginTransaction ( connection ) ;
65
- const result = await this . user . update ( connection , user ) ;
65
+ const result = await this . userData . update ( connection , user ) ;
66
66
if ( user . roles ) {
67
- await this . role . deleteRolesById ( connection , user . id ) ;
67
+ await this . roleData . deleteRolesById ( connection , user . id ) ;
68
68
if ( user . roles . length > 0 )
69
- await this . role . updateRolesById ( connection , user . id , user . roles )
69
+ await this . roleData . updateRolesById ( connection , user . id , user . roles )
70
70
}
71
71
await this . mySQL . commit ( connection ) ;
72
72
result . body = user ;
@@ -82,7 +82,7 @@ export class ServiceProxy extends Proxy {
82
82
async deleteById ( id ) {
83
83
const connection = await this . mySQL . getConnection ( ) ;
84
84
try {
85
- return await this . user . deleteById ( connection , id ) ;
85
+ return await this . userData . deleteById ( connection , id ) ;
86
86
} catch ( error ) {
87
87
throw error ;
88
88
} finally {
@@ -93,7 +93,7 @@ export class ServiceProxy extends Proxy {
93
93
async findAllDepartments ( ) {
94
94
const connection = await this . mySQL . getConnection ( ) ;
95
95
try {
96
- return await this . user . findAllDepartments ( connection ) ;
96
+ return await this . userData . findAllDepartments ( connection ) ;
97
97
} catch ( error ) {
98
98
throw error ;
99
99
} finally {
@@ -104,7 +104,7 @@ export class ServiceProxy extends Proxy {
104
104
async findAllRoles ( ) {
105
105
const connection = await this . mySQL . getConnection ( ) ;
106
106
try {
107
- return await this . role . findAllRoles ( connection ) ;
107
+ return await this . roleData . findAllRoles ( connection ) ;
108
108
} catch ( error ) {
109
109
throw error ;
110
110
} finally {
@@ -115,7 +115,7 @@ export class ServiceProxy extends Proxy {
115
115
async findRolesById ( id ) {
116
116
const connection = await this . mySQL . getConnection ( ) ;
117
117
try {
118
- return await this . role . findRolesById ( connection , id ) ;
118
+ return await this . roleData . findRolesById ( connection , id ) ;
119
119
} catch ( error ) {
120
120
throw error ;
121
121
} finally {
@@ -127,8 +127,8 @@ export class ServiceProxy extends Proxy {
127
127
const connection = await this . mySQL . getConnection ( ) ;
128
128
try {
129
129
await this . mySQL . beginTransaction ( connection ) ;
130
- await this . role . deleteRolesById ( connection , id ) ;
131
- const payload = await this . role . updateRolesById ( connection , id , roles ) ;
130
+ await this . roleData . deleteRolesById ( connection , id ) ;
131
+ const payload = await this . roleData . updateRolesById ( connection , id , roles ) ;
132
132
await this . mySQL . commit ( connection ) ;
133
133
return payload ;
134
134
} catch ( error ) {
0 commit comments