diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index 28a68842..b2536033 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -52,6 +52,11 @@ export class AppController { return this.appService.inicioSesion(pEmail,pPassword); } + @Get('user/findAdminSistema') + allUsersAdminSistema() { + return this.appService.allUsersAdminSistema(); + } + @Get('user/find/:dni') findUser( @Param('dni') paramUserDNI: string diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 4e59d974..bb8385a5 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -60,6 +60,16 @@ export class AppService { ); } + allUsersAdminSistema() { + const pattern = { cmd: 'findAdminSistema' }; + const payload = {}; + return this.clientUserApp + .send(pattern, payload) + .pipe( + map((message: string) => ({ message })), + ); + } + //GET parameter from API findUser(paramUserDNI: string) { const pattern = { cmd: 'findUserDNI' }; diff --git a/servicio-usuarios/src/users/users.controller.ts b/servicio-usuarios/src/users/users.controller.ts index 24ca5c01..43e23dd7 100644 --- a/servicio-usuarios/src/users/users.controller.ts +++ b/servicio-usuarios/src/users/users.controller.ts @@ -46,4 +46,10 @@ export class UsersController { let ppassword= body['password']; return this.userService.findLogin(pemail,ppassword); } + + //buscar solo admins del sistema + @MessagePattern({ cmd: 'findAdminSistema' }) + allUsersAdminSistema() { + return this.userService.allUsersAdminSistema(); + } } diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index aae09cd1..dabd96f7 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -22,7 +22,6 @@ export class UsersService { .setOptions({ sanitizeFilter: true }) .exec(); } - async findOne(id: string): Promise { return this.userModel.findOne({ _id: id }).exec(); } @@ -65,4 +64,9 @@ export class UsersService { return userReturn; } + + //find admin del sistema + async allUsersAdminSistema(): Promise { + return this.userModel.find({ user_type: 1 }).exec(); + } } diff --git a/web-ui/web-react/src/components/FormAdminSistema.js b/web-ui/web-react/src/components/FormAdminSistema.js index 3a3efdb0..8e71860f 100644 --- a/web-ui/web-react/src/components/FormAdminSistema.js +++ b/web-ui/web-react/src/components/FormAdminSistema.js @@ -7,7 +7,7 @@ import { Column } from 'primereact/column'; const FormAdminSistema = () => { const [pokemones,setPokemones]=useState([]); - const [urlFetch,setUrlFetch]=useState('http://localhost:4000/user/allUsers'); + const [urlFetch,setUrlFetch]=useState('http://localhost:4000/user/findAdminSistema/'); async function fetchP(){ let nombres=await fetch(urlFetch, {method:'GET'}); let pokemonesRes= await nombres.json();