Skip to content

Commit 7337d4e

Browse files
committed
fix: typo service user
1 parent db33a36 commit 7337d4e

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/controllers/User/controller.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-await-in-loop */
12
import { NextFunction, Request, Response } from 'express'
23
import routes from 'routes/public'
34
import asyncHandler from 'helpers/asyncHandler'
@@ -123,8 +124,7 @@ routes.put(
123124
RoleId,
124125
}
125126

126-
// eslint-disable-next-line no-await-in-loop
127-
await UserRoleService.findOrCreate(formRole, txn)
127+
await UserRoleService.findOrCreate(formRole)
128128
}
129129
await txn.commit()
130130
const buildResponse = BuildResponse.updated({ data })

src/controllers/User/service.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class UserService {
4646
/**
4747
*
4848
* @param id
49+
* @param paranoid
4950
*/
5051
public static async getOne(id: string, paranoid?: boolean) {
5152
const data = await User.findByPk(id, {
@@ -65,6 +66,7 @@ class UserService {
6566
/**
6667
*
6768
* @param id
69+
* @param paranoid
6870
*/
6971
public static async getUserWithSession(id: string, paranoid?: boolean) {
7072
const data = await User.findByPk(id, {
@@ -84,6 +86,7 @@ class UserService {
8486
/**
8587
*
8688
* @param id
89+
* @param paranoid
8790
* note: find by id only find data not include relation
8891
*/
8992
public static async findById(id: string, paranoid?: boolean) {
@@ -188,7 +191,11 @@ class UserService {
188191
throw new ResponseError.BadRequest('ids cannot be empty')
189192
}
190193

191-
await Role.destroy({
194+
if (isForce) {
195+
await UserRoleService.deleteByUserIds(ids)
196+
}
197+
198+
await User.destroy({
192199
where: {
193200
id: {
194201
[Op.in]: ids,
@@ -204,7 +211,7 @@ class UserService {
204211
* @example ids = ["id_1", "id_2"]
205212
*/
206213
public static async multipleRestore(ids: Array<string>) {
207-
await Role.restore({
214+
await User.restore({
208215
where: {
209216
id: {
210217
[Op.in]: ids,

0 commit comments

Comments
 (0)