rez_core 5.0.280 → 5.0.283

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "5.0.280",
3
+ "version": "5.0.283",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -1,4 +1,4 @@
1
- import { Injectable } from '@nestjs/common';
1
+ import { Inject, Injectable,BadRequestException } from '@nestjs/common';
2
2
  import { InjectRepository } from '@nestjs/typeorm';
3
3
  import { ClockIDGenService } from 'src/utils/service/clockIDGenUtil.service';
4
4
  import { EntityManager, IsNull, Repository } from 'typeorm';
@@ -111,19 +111,53 @@ export class OrganizationService {
111
111
  return await this.organizationRepository.find({ where: { id } });
112
112
  }
113
113
 
114
- async update(
115
- id: number,
116
- organizationDto: Partial<OrganizationData>,
117
- manager?: EntityManager,
118
- ): Promise<OrganizationData | null> {
119
- const repo = manager
120
- ? manager.getRepository(OrganizationData)
121
- : this.organizationRepository;
114
+ // async update(
115
+ // id: number,
116
+ // organizationDto: Partial<OrganizationData>,
117
+ // // manager?: EntityManager,
118
+ // ): Promise<OrganizationData | null> {
119
+ // // const repo = manager
120
+ // // ? manager.getRepository(OrganizationData)
121
+ // // : this.organizationRepository;
122
+
123
+ // const repo = this.organizationRepository;
124
+
125
+ // await repo.update(id, organizationDto);
126
+ // return await repo.findOne({ where: { id } });
127
+ // }
128
+
129
+ async update(
130
+ organizationDto: Partial<OrganizationData>,
131
+ userData: any,
132
+ ): Promise<OrganizationData | null> {
133
+
134
+ const orgId =
135
+ typeof organizationDto.id === 'number'
136
+ ? organizationDto.id
137
+ : parseInt(String(organizationDto.id).trim(), 10);
138
+
139
+ if (!Number.isInteger(orgId)) {
140
+ throw new BadRequestException('Invalid organization id');
141
+ }
122
142
 
123
- await repo.update(id, organizationDto);
124
- return await repo.findOne({ where: { id } });
143
+ const {
144
+ id: _ignoreId,
145
+ sessionToken,
146
+ appcode,
147
+ email_id,
148
+ level_id,
149
+ level_type,
150
+ ...dbData
151
+ } = organizationDto as any;
152
+
153
+ if (!dbData || Object.keys(dbData).length === 0) {
154
+ throw new BadRequestException('No valid fields to update');
125
155
  }
126
156
 
157
+ await this.organizationRepository.update(orgId, dbData);
158
+ return this.organizationRepository.findOne({ where: { id: orgId } });
159
+ }
160
+
127
161
  async remove(id: number, manager?: EntityManager): Promise<void> {
128
162
  const repo = manager
129
163
  ? manager.getRepository(OrganizationData)
@@ -87,9 +87,14 @@ export class FilterService {
87
87
  if (Array.isArray(val)) {
88
88
  // Create ($1,$2,$3)
89
89
  const placeholders = val.map(() => `$${paramIndex++}`).join(', ');
90
+ // parsedQuery = parsedQuery
91
+ // .replace(new RegExp(`:...${key}`, 'g'), `${placeholders}`)
92
+ // .replace(new RegExp(`:${key}`, 'g'), `${placeholders}`);
93
+
90
94
  parsedQuery = parsedQuery
91
- .replace(new RegExp(`:...${key}`, 'g'), `${placeholders}`)
92
- .replace(new RegExp(`:${key}`, 'g'), `${placeholders}`);
95
+ .replace(new RegExp(`:...${key}`, 'g'), placeholders)
96
+ .replace(new RegExp(`:${key}`, 'g'), placeholders);
97
+
93
98
  values.push(...val.map((v) => String(v)));
94
99
  } else {
95
100
  // Create $1