login, client modified

This commit is contained in:
Kallesh B S 2025-06-09 16:46:22 +05:30
parent 19e12bcf62
commit 5305f10e18
6 changed files with 172 additions and 12 deletions

View File

@ -4,9 +4,9 @@ import { IsString } from 'class-validator';
export class AuthLoginDTO { export class AuthLoginDTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString() @IsString()
p_emailaddr: string; P_EMAILADDR: string;
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString() @IsString()
p_password: string; P_PASSWORD: string;
} }

View File

@ -18,15 +18,15 @@ export class AuthService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USERLOGIN_PKG.ValidateUser(:p_emailaddr,:p_password,:p_login_cursor); USERLOGIN_PKG.ValidateUser(:P_EMAILADDR,:P_PASSWORD,:p_login_cursor);
END;`, END;`,
{ {
p_emailaddr: { P_EMAILADDR: {
val: body.p_emailaddr, val: body.P_EMAILADDR,
type: oracledb.DB_TYPE_NVARCHAR, type: oracledb.DB_TYPE_NVARCHAR,
}, },
p_password: { P_PASSWORD: {
val: body.p_password, val: body.P_PASSWORD,
type: oracledb.DB_TYPE_NVARCHAR, type: oracledb.DB_TYPE_NVARCHAR,
}, },
p_login_cursor: { p_login_cursor: {

View File

@ -119,3 +119,9 @@ export class GetClientDTO extends IntersectionType(
SPID_DTO, SPID_DTO,
CLIENTID_DTO CLIENTID_DTO
) { } ) { }
export class ClientContactControlsDTO extends IntersectionType(
GetClientDTO,
USERID_DTO
) { }

View File

@ -1,8 +1,9 @@
import { Body, Controller, Get, Param, Post, Put, Query } from '@nestjs/common'; import { Body, Controller, Get, Param, Patch, Post, Put, Query } from '@nestjs/common';
import { ManageClientsService } from './manage-clients.service'; import { ManageClientsService } from './manage-clients.service';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { import {
ClientContactControlsDTO,
CreateClientContactsDTO, CreateClientDataDTO, CreateClientContactsDTO, CreateClientDataDTO,
CreateClientLocationsDTO, CreateClientLocationsDTO,
GetClientDTO, GetClientDTO,
@ -43,6 +44,24 @@ export class ManageClientsController {
return this.manageClientsService.CreateClientContact(body); return this.manageClientsService.CreateClientContact(body);
} }
@ApiTags('Manage Clients - Oracle')
@Patch('SetDefaultClientContacts/:P_SPID/:P_CLIENTID/:P_USERID')
SetDefaultClientContacts(@Param() param: ClientContactControlsDTO) {
return this.manageClientsService.SetDefaultClientContacts(param);
}
@ApiTags('Manage Clients - Oracle')
@Patch('InactivateClientContacts/:P_SPID/:P_CLIENTID/:P_USERID')
InactivateClientContacts(@Param() param: ClientContactControlsDTO) {
return this.manageClientsService.InactivateClientContacts(param);
}
@ApiTags('Manage Clients - Oracle')
@Patch('ReactivateClientContacts/:P_SPID/:P_CLIENTID/:P_USERID')
ReactivateClientContacts(@Param() param: ClientContactControlsDTO) {
return this.manageClientsService.ReactivateClientContacts(param);
}
@ApiTags('Manage Clients - Oracle') @ApiTags('Manage Clients - Oracle')
@Post('CreateClientLocations') @Post('CreateClientLocations')
CreateClientLocation(@Body() body: CreateClientLocationsDTO) { CreateClientLocation(@Body() body: CreateClientLocationsDTO) {

View File

@ -7,6 +7,7 @@ import { InternalServerException } from 'src/exceptions/internalServerError.exce
import { closeOracleDbConnection, fetchCursor, handleError, setEmptyStringsToNull } from 'src/utils/helper'; import { closeOracleDbConnection, fetchCursor, handleError, setEmptyStringsToNull } from 'src/utils/helper';
import { import {
ClientContactControlsDTO,
CreateClientContactsDTO, CreateClientDataDTO, CreateClientContactsDTO, CreateClientDataDTO,
CreateClientLocationsDTO, CreateClientLocationsDTO,
GetClientDTO, GetClientDTO,
@ -388,6 +389,139 @@ export class ManageClientsService {
} }
} }
SetDefaultClientContacts = async (body: ClientContactControlsDTO) => {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEPREPARER_PKG.CreateClientContact(
:P_SPID, :P_CLIENTID, :P_USERID, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CLIENTID: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ManageClientsService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Default contact added successfully", ...fres[0] };
} catch (error) {
handleError(error, ManageClientsService.name)
} finally {
await closeOracleDbConnection(connection, ManageClientsService.name)
}
}
InactivateClientContacts = async (body: ClientContactControlsDTO) => {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEPREPARER_PKG.CreateClientContact(
:P_SPID, :P_CLIENTID, :P_USERID, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CLIENTID: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ManageClientsService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Contact inactivated successfully", ...fres[0] };
} catch (error) {
handleError(error, ManageClientsService.name)
} finally {
await closeOracleDbConnection(connection, ManageClientsService.name)
}
}
ReactivateClientContacts = async (body: ClientContactControlsDTO) => {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEPREPARER_PKG.CreateClientContact(
:P_SPID, :P_CLIENTID, :P_USERID, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CLIENTID: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ManageClientsService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Contact reactivated successfully", ...fres[0] };
} catch (error) {
handleError(error, ManageClientsService.name)
} finally {
await closeOracleDbConnection(connection, ManageClientsService.name)
}
}
CreateClientLocation = async (body: CreateClientLocationsDTO) => { CreateClientLocation = async (body: CreateClientLocationsDTO) => {
const newBody = { const newBody = {
P_SPID: null, P_SPID: null,

View File

@ -2,7 +2,8 @@ import { SpContactsService } from './sp-contacts.service';
import { Body, Controller, Get, Param, Patch, Post, Put, Query } from '@nestjs/common'; import { Body, Controller, Get, Param, Patch, Post, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { SPID_DTO, import {
SPID_DTO,
SP_CONTACTID_DTO, SP_CONTACTID_DTO,
InsertSPContactsDTO, UpdateSPContactsDTO InsertSPContactsDTO, UpdateSPContactsDTO
} from 'src/dto/property.dto'; } from 'src/dto/property.dto';
@ -28,7 +29,7 @@ export class SpContactsController {
return this.spContactsService.updateSPContacts(body); return this.spContactsService.updateSPContacts(body);
} }
@Patch('/InactivateSPContact/:P_SPID') @Patch('/InactivateSPContact/:P_SPCONTACTID')
inactivateSPContact(@Param() param: SP_CONTACTID_DTO) { inactivateSPContact(@Param() param: SP_CONTACTID_DTO) {
return this.spContactsService.inactivateSPContact(param); return this.spContactsService.inactivateSPContact(param);
} }