Listar de guardas de seguridad
This commit is contained in:
parent
bb83aa1482
commit
537997bc40
|
@ -12,6 +12,7 @@
|
||||||
"@nestjs/core": "^8.0.0",
|
"@nestjs/core": "^8.0.0",
|
||||||
"@nestjs/microservices": "^8.4.7",
|
"@nestjs/microservices": "^8.4.7",
|
||||||
"@nestjs/platform-express": "^8.0.0",
|
"@nestjs/platform-express": "^8.0.0",
|
||||||
|
"@types/cors": "^2.8.12",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
|
@ -1883,6 +1884,11 @@
|
||||||
"integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==",
|
"integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/cors": {
|
||||||
|
"version": "2.8.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz",
|
||||||
|
"integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw=="
|
||||||
|
},
|
||||||
"node_modules/@types/eslint": {
|
"node_modules/@types/eslint": {
|
||||||
"version": "8.4.3",
|
"version": "8.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.3.tgz",
|
||||||
|
@ -10109,6 +10115,11 @@
|
||||||
"integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==",
|
"integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/cors": {
|
||||||
|
"version": "2.8.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz",
|
||||||
|
"integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw=="
|
||||||
|
},
|
||||||
"@types/eslint": {
|
"@types/eslint": {
|
||||||
"version": "8.4.3",
|
"version": "8.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.3.tgz",
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
"@nestjs/core": "^8.0.0",
|
"@nestjs/core": "^8.0.0",
|
||||||
"@nestjs/microservices": "^8.4.7",
|
"@nestjs/microservices": "^8.4.7",
|
||||||
"@nestjs/platform-express": "^8.0.0",
|
"@nestjs/platform-express": "^8.0.0",
|
||||||
|
"@types/cors": "^2.8.12",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import { Controller, Get, Post, Body, Param } from '@nestjs/common';
|
import { Controller, Get, Post, Body, Param } from '@nestjs/common';
|
||||||
import { AppService } from "./app.service";
|
import { AppService } from "./app.service";
|
||||||
|
|
||||||
@Controller()
|
@Controller()
|
||||||
export class AppController {
|
export class AppController {
|
||||||
constructor(private readonly appService: AppService) { }
|
constructor(private readonly appService: AppService) { }
|
||||||
|
|
||||||
// #==== API Users
|
// #==== API Users
|
||||||
@Post('user/createAdminSystem')
|
@Post('user/createAdminSystem')
|
||||||
createAdminSystem(
|
createAdminSystem(
|
||||||
|
@ -79,6 +77,12 @@ export class AppController {
|
||||||
allUsersAdminComunidad() {
|
allUsersAdminComunidad() {
|
||||||
return this.appService.allUsersAdminComunidad();
|
return this.appService.allUsersAdminComunidad();
|
||||||
}
|
}
|
||||||
|
@Get('user/findGuards/:community')
|
||||||
|
findGuardsCommunity(
|
||||||
|
@Param('community_id') community_id: string
|
||||||
|
) {
|
||||||
|
return this.appService.findGuardsCommunity(community_id);
|
||||||
|
}
|
||||||
|
|
||||||
@Get('user/find/:dni')
|
@Get('user/find/:dni')
|
||||||
findUser(
|
findUser(
|
||||||
|
|
|
@ -105,6 +105,16 @@ export class AppService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findGuardsCommunity(community_id: string) {
|
||||||
|
const pattern = { cmd: 'findGuardsCommunity' };
|
||||||
|
const payload = { community_id: community_id };
|
||||||
|
return this.clientUserApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
inicioSesion(pEmail: string, pPassword: string) {
|
inicioSesion(pEmail: string, pPassword: string) {
|
||||||
const pattern = { cmd: 'loginUser' };
|
const pattern = { cmd: 'loginUser' };
|
||||||
const payload = { email: pEmail, password: pPassword};
|
const payload = { email: pEmail, password: pPassword};
|
||||||
|
|
|
@ -3,7 +3,13 @@ import { AppModule } from './app.module';
|
||||||
const cors= require('cors');
|
const cors= require('cors');
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule);
|
||||||
|
|
||||||
|
app.enableCors({
|
||||||
|
origin: 'http://localhost:3000',
|
||||||
|
methods: 'GET, PUT, POST, DELETE',
|
||||||
|
allowedHeaders: 'Content-Type, Authorization',
|
||||||
|
});
|
||||||
await app.listen(4000);
|
await app.listen(4000);
|
||||||
app.use(cors())
|
//app.use(cors(enableCors))
|
||||||
}
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "servicio-comunidad-viviendas",
|
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
"@nestjs/platform-express": "^8.0.0",
|
"@nestjs/platform-express": "^8.0.0",
|
||||||
"@nestjs/swagger": "^5.2.1",
|
"@nestjs/swagger": "^5.2.1",
|
||||||
"buffer": "^5.7.1",
|
"buffer": "^5.7.1",
|
||||||
|
"cors": "^2.8.5",
|
||||||
"crypto-browserify": "^3.12.0",
|
"crypto-browserify": "^3.12.0",
|
||||||
"md5-typescript": "^1.0.5",
|
"md5-typescript": "^1.0.5",
|
||||||
"mongoose": "^6.4.1",
|
"mongoose": "^6.4.1",
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"@nestjs/platform-express": "^8.0.0",
|
"@nestjs/platform-express": "^8.0.0",
|
||||||
"@nestjs/swagger": "^5.2.1",
|
"@nestjs/swagger": "^5.2.1",
|
||||||
"buffer": "^5.7.1",
|
"buffer": "^5.7.1",
|
||||||
|
"cors": "^2.8.5",
|
||||||
"crypto-browserify": "^3.12.0",
|
"crypto-browserify": "^3.12.0",
|
||||||
"md5-typescript": "^1.0.5",
|
"md5-typescript": "^1.0.5",
|
||||||
"mongoose": "^6.4.1",
|
"mongoose": "^6.4.1",
|
||||||
|
|
|
@ -33,6 +33,12 @@ export class UsersController {
|
||||||
return this.userService.findOneByDNI(dni);
|
return this.userService.findOneByDNI(dni);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'findGuardsCommunity' })
|
||||||
|
findGuardsCommunity(@Payload() community_id: string) {
|
||||||
|
let pcommunity_id = community_id['community_id'];
|
||||||
|
return this.userService.findGuardsCommunity(pcommunity_id);
|
||||||
|
}
|
||||||
|
|
||||||
@MessagePattern({ cmd: 'updateUser' })
|
@MessagePattern({ cmd: 'updateUser' })
|
||||||
update(@Payload() user: UserDocument) {
|
update(@Payload() user: UserDocument) {
|
||||||
return this.userService.update(user.id, user);
|
return this.userService.update(user.id, user);
|
||||||
|
|
|
@ -70,6 +70,10 @@ export class UsersService {
|
||||||
return this.userModel.find({ user_type: 1 }).exec();
|
return this.userModel.find({ user_type: 1 }).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//find admin del sistema
|
||||||
|
async findGuardsCommunity(pcommunity_id: string): Promise<User[]> {
|
||||||
|
return this.userModel.find({ user_type: 4 }).exec();
|
||||||
|
}
|
||||||
//find admin de comunidad
|
//find admin de comunidad
|
||||||
async allUsersAdminComunidad(): Promise<User[]> {
|
async allUsersAdminComunidad(): Promise<User[]> {
|
||||||
return this.userModel.find({ user_type: 2 }).exec();
|
return this.userModel.find({ user_type: 2 }).exec();
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { Column } from 'primereact/column';
|
||||||
const GuardasSeguridad = () => {
|
const GuardasSeguridad = () => {
|
||||||
|
|
||||||
const [pokemones,setPokemones]=useState([]);
|
const [pokemones,setPokemones]=useState([]);
|
||||||
const [urlFetch,setUrlFetch]=useState('http://localhost:4000/user/findAdminSistema/');
|
const [urlFetch,setUrlFetch]=useState('http://localhost:4000/user/findGuards/62be68215692582bbfd77134');
|
||||||
async function fetchP(){
|
async function fetchP(){
|
||||||
let nombres=await fetch(urlFetch, {method:'GET'});
|
let nombres=await fetch(urlFetch, {method:'GET'});
|
||||||
let pokemonesRes= await nombres.json();
|
let pokemonesRes= await nombres.json();
|
||||||
|
@ -46,6 +46,7 @@ const GuardasSeguridad = () => {
|
||||||
fetch('http://localhost:4000/user/createGuard', {
|
fetch('http://localhost:4000/user/createGuard', {
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
mode:'cors',
|
||||||
body: JSON.stringify(data2),
|
body: JSON.stringify(data2),
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
|
|
Loading…
Reference in New Issue