zs 1 ano atrás
pai
commit
9e59310219

+ 8 - 0
src/controller/system/user.controller.ts

@@ -40,6 +40,14 @@ export class UserController extends BaseController {
     return result;
   }
 
+
+  @Get('/detail/:id')
+  @ApiResponse({ type: FVO_user })
+  async detail(@Param('id') id: string) {
+    const data = await this.service.detail(id);
+    return data;
+  }
+
   @Post('/:id')
   @Validate()
   @ApiResponse({ type: UVAO_user })

+ 7 - 0
src/service/system/user.service.ts

@@ -8,4 +8,11 @@ type modelType = ReturnModelType<typeof User>;
 export class UserService extends BaseService<modelType> {
   @InjectEntityModel(User)
   model: modelType;
+
+  async detail(id) {
+    const arr = await this.model.findById(id).lean();
+    let role_type;
+    if (arr && arr.role && arr.role.length > 1) role_type = arr.role[1];
+    return { ...arr, role_type };
+  }
 }