rez_core 2.1.63 → 2.1.65
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/dist/module/layout_preference/entity/layout_preference.entity.d.ts +1 -0
- package/dist/module/layout_preference/entity/layout_preference.entity.js +4 -0
- package/dist/module/layout_preference/entity/layout_preference.entity.js.map +1 -1
- package/dist/module/listmaster/repository/list-master.repository.js +1 -0
- package/dist/module/listmaster/repository/list-master.repository.js.map +1 -1
- package/dist/module/listmaster/service/list-master-item.service.js +3 -2
- package/dist/module/listmaster/service/list-master-item.service.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.js +18 -5
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/user/service/user-session.service.js +7 -1
- package/dist/module/user/service/user-session.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/layout_preference/entity/layout_preference.entity.ts +3 -0
- package/src/module/listmaster/repository/list-master.repository.ts +3 -0
- package/src/module/listmaster/service/list-master-item.service.ts +4 -1
- package/src/module/listmaster/service/list-master.service.ts +29 -6
- package/src/module/user/service/user-session.service.ts +15 -1
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BadRequestException,
|
|
2
3
|
forwardRef,
|
|
3
4
|
Inject,
|
|
4
5
|
Injectable,
|
|
@@ -64,7 +65,9 @@ export class ListMasterItemService {
|
|
|
64
65
|
const name = item.name?.trim();
|
|
65
66
|
const code = item.code?.trim();
|
|
66
67
|
|
|
67
|
-
if (!name)
|
|
68
|
+
if (!name) {
|
|
69
|
+
throw new BadRequestException('Name is required and cannot be empty');
|
|
70
|
+
}
|
|
68
71
|
|
|
69
72
|
let existingItem;
|
|
70
73
|
|
|
@@ -238,6 +238,18 @@ export class ListMasterService {
|
|
|
238
238
|
|
|
239
239
|
// createEntity method
|
|
240
240
|
async createEntity(entityData: any, loggedInUser: UserData): Promise<any> {
|
|
241
|
+
// Trim and validate name and code
|
|
242
|
+
const name = entityData.name?.trim();
|
|
243
|
+
const code = entityData.code?.trim();
|
|
244
|
+
|
|
245
|
+
if (!name || !code) {
|
|
246
|
+
throw new BadRequestException(
|
|
247
|
+
'Name and Code are required and cannot be empty',
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
entityData.name = name;
|
|
252
|
+
entityData.code = code;
|
|
241
253
|
entityData.is_factory = entityData.is_factory || 0;
|
|
242
254
|
entityData.source = entityData.source || 'master';
|
|
243
255
|
entityData.status = entityData.status || 'ACTIVE';
|
|
@@ -245,16 +257,27 @@ export class ListMasterService {
|
|
|
245
257
|
entityData.sort_by = entityData.sort_by || 'asc';
|
|
246
258
|
entityData.organization_id = loggedInUser.organization_id;
|
|
247
259
|
|
|
248
|
-
//
|
|
249
|
-
const
|
|
250
|
-
name
|
|
251
|
-
|
|
260
|
+
// Check for duplicate name
|
|
261
|
+
const nameExists = await this.listMasterRepo.findOneByCondition({
|
|
262
|
+
name,
|
|
263
|
+
organization_id: loggedInUser.organization_id,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
if (nameExists) {
|
|
267
|
+
throw new BadRequestException(
|
|
268
|
+
'A List Master with the same name already exists',
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Check for duplicate code
|
|
273
|
+
const codeExists = await this.listMasterRepo.findOneByCondition({
|
|
274
|
+
code,
|
|
252
275
|
organization_id: loggedInUser.organization_id,
|
|
253
276
|
});
|
|
254
277
|
|
|
255
|
-
if (
|
|
278
|
+
if (codeExists) {
|
|
256
279
|
throw new BadRequestException(
|
|
257
|
-
'List
|
|
280
|
+
'A List Master with the same code already exists',
|
|
258
281
|
);
|
|
259
282
|
}
|
|
260
283
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { get } from 'http';
|
|
1
2
|
import { UserSession } from '../entity/user-session.entity';
|
|
2
3
|
import { ClockIDGenService } from '../../../utils/service/clockIDGenUtil.service';
|
|
3
4
|
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
@@ -7,6 +8,7 @@ import { ConfigService } from '@nestjs/config';
|
|
|
7
8
|
import { UserRoleMappingService } from './user-role-mapping.service';
|
|
8
9
|
import { DataSource } from 'typeorm';
|
|
9
10
|
import { UserRoleMapping } from '../entity/user-role-mapping.entity';
|
|
11
|
+
import { UserData } from '../entity/user.entity';
|
|
10
12
|
|
|
11
13
|
@Injectable()
|
|
12
14
|
export class UserSessionService {
|
|
@@ -84,7 +86,19 @@ export class UserSessionService {
|
|
|
84
86
|
appcode: data.appcode,
|
|
85
87
|
};
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
let getUserDetails;
|
|
90
|
+
|
|
91
|
+
if (currentUser) {
|
|
92
|
+
// Check if user has any role mappings for the given appcode
|
|
93
|
+
getUserDetails = await this.dataSource.query(
|
|
94
|
+
`
|
|
95
|
+
SELECT * from cr_user where id = ?
|
|
96
|
+
`,
|
|
97
|
+
[currentUser.id],
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (getUserDetails.organization_id === 1 && payload.level_type === 'ORG') {
|
|
88
102
|
payload.organization_id = payload.level_id;
|
|
89
103
|
}
|
|
90
104
|
|