File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change
1
+ /* eslint-disable no-await-in-loop */
1
2
import { NextFunction , Request , Response } from 'express'
2
3
import routes from 'routes/public'
3
4
import asyncHandler from 'helpers/asyncHandler'
@@ -123,8 +124,7 @@ routes.put(
123
124
RoleId,
124
125
}
125
126
126
- // eslint-disable-next-line no-await-in-loop
127
- await UserRoleService . findOrCreate ( formRole , txn )
127
+ await UserRoleService . findOrCreate ( formRole )
128
128
}
129
129
await txn . commit ( )
130
130
const buildResponse = BuildResponse . updated ( { data } )
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ class UserService {
46
46
/**
47
47
*
48
48
* @param id
49
+ * @param paranoid
49
50
*/
50
51
public static async getOne ( id : string , paranoid ?: boolean ) {
51
52
const data = await User . findByPk ( id , {
@@ -65,6 +66,7 @@ class UserService {
65
66
/**
66
67
*
67
68
* @param id
69
+ * @param paranoid
68
70
*/
69
71
public static async getUserWithSession ( id : string , paranoid ?: boolean ) {
70
72
const data = await User . findByPk ( id , {
@@ -84,6 +86,7 @@ class UserService {
84
86
/**
85
87
*
86
88
* @param id
89
+ * @param paranoid
87
90
* note: find by id only find data not include relation
88
91
*/
89
92
public static async findById ( id : string , paranoid ?: boolean ) {
@@ -188,7 +191,11 @@ class UserService {
188
191
throw new ResponseError . BadRequest ( 'ids cannot be empty' )
189
192
}
190
193
191
- await Role . destroy ( {
194
+ if ( isForce ) {
195
+ await UserRoleService . deleteByUserIds ( ids )
196
+ }
197
+
198
+ await User . destroy ( {
192
199
where : {
193
200
id : {
194
201
[ Op . in ] : ids ,
@@ -204,7 +211,7 @@ class UserService {
204
211
* @example ids = ["id_1", "id_2"]
205
212
*/
206
213
public static async multipleRestore ( ids : Array < string > ) {
207
- await Role . restore ( {
214
+ await User . restore ( {
208
215
where : {
209
216
id : {
210
217
[ Op . in ] : ids ,
You can’t perform that action at this time.
0 commit comments