rez_core 2.1.28 → 2.1.30
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/meta/controller/entity.controller.d.ts +7 -4
- package/dist/module/meta/controller/entity.controller.js +33 -80
- package/dist/module/meta/controller/entity.controller.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/meta/controller/entity.controller.ts +56 -96
package/package.json
CHANGED
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
UseGuards,
|
|
14
14
|
Inject,
|
|
15
15
|
Request,
|
|
16
|
+
InternalServerErrorException,
|
|
17
|
+
NotFoundException,
|
|
16
18
|
} from '@nestjs/common';
|
|
17
19
|
import { EntityServiceImpl } from '../service/entity-service-impl.service';
|
|
18
20
|
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
@@ -60,128 +62,86 @@ export class EntityController {
|
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
@Post('create')
|
|
65
|
+
@HttpCode(200)
|
|
63
66
|
async create(
|
|
64
67
|
@Body() entityData: BaseEntity,
|
|
65
68
|
@Query('entity_type') entityType: string,
|
|
66
|
-
@Res() res: Response,
|
|
67
69
|
@Req() req: Request & { user: any },
|
|
68
70
|
) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
let appcode = req.user.userData.appcode;
|
|
72
|
-
if (!entityType) {
|
|
73
|
-
return res.status(HttpStatus.BAD_REQUEST).json({
|
|
74
|
-
success: false,
|
|
75
|
-
error: 'Query parameter "entity_type" is required',
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
const entityMaster =
|
|
79
|
-
await this.entityMasterService.getEntityData(entityType);
|
|
71
|
+
let loggedInUser = req.user.userData;
|
|
72
|
+
let appcode = req.user.userData.appcode;
|
|
80
73
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
if (!entityService) {
|
|
87
|
-
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
88
|
-
success: false,
|
|
89
|
-
error: `No service found for Entity Type ${entityType}`,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
const createdEntity = await entityService.createEntity(
|
|
93
|
-
entityData,
|
|
94
|
-
loggedInUser as UserData,
|
|
95
|
-
null,
|
|
96
|
-
appcode,
|
|
74
|
+
if (!entityType) {
|
|
75
|
+
throw new BadRequestException(
|
|
76
|
+
`Query parameter "entity_type" is required`,
|
|
97
77
|
);
|
|
78
|
+
}
|
|
98
79
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
80
|
+
const entityMaster =
|
|
81
|
+
await this.entityMasterService.getEntityData(entityType);
|
|
82
|
+
const entityService =
|
|
83
|
+
await this.reflectionHelper.getBean<EntityServiceImpl>(
|
|
84
|
+
entityMaster.entity_service,
|
|
85
|
+
);
|
|
105
86
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
} catch (error) {
|
|
111
|
-
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
112
|
-
success: false,
|
|
113
|
-
error: error.message || 'Internal server error',
|
|
114
|
-
});
|
|
87
|
+
if (!entityService) {
|
|
88
|
+
throw new InternalServerErrorException(
|
|
89
|
+
`No service found for Entity Type ${entityType}`,
|
|
90
|
+
);
|
|
115
91
|
}
|
|
92
|
+
|
|
93
|
+
return entityService.createEntity(
|
|
94
|
+
entityData,
|
|
95
|
+
loggedInUser as UserData,
|
|
96
|
+
null,
|
|
97
|
+
appcode,
|
|
98
|
+
);
|
|
116
99
|
}
|
|
117
100
|
|
|
118
101
|
@Post('update/:id')
|
|
102
|
+
@HttpCode(200)
|
|
119
103
|
async update(
|
|
120
104
|
@Param('id') id: number,
|
|
121
105
|
@Body() entityData: BaseEntity,
|
|
122
106
|
@Query('entity_type') entityType: string,
|
|
123
|
-
@Res() response: Response,
|
|
124
107
|
@Req() req: Request & { user: any },
|
|
125
108
|
) {
|
|
126
|
-
|
|
127
|
-
let loggedInUser = req.user.userData;
|
|
128
|
-
// let loggedInUser = await this.entityService.getEntityData(
|
|
129
|
-
// ENTITYTYPE_USER,
|
|
130
|
-
// requestedUser.userId,
|
|
131
|
-
// );
|
|
132
|
-
if (!entityType) {
|
|
133
|
-
return response.status(HttpStatus.BAD_REQUEST).json({
|
|
134
|
-
success: false,
|
|
135
|
-
error: 'Query parameter "entity_type" is required',
|
|
136
|
-
});
|
|
137
|
-
}
|
|
109
|
+
const loggedInUser = req.user.userData;
|
|
138
110
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
entityMaster.entity_service,
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
if (!entityService) {
|
|
148
|
-
return response.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
149
|
-
success: false,
|
|
150
|
-
error: `No service found for entity_type "${entityType}"`,
|
|
151
|
-
});
|
|
152
|
-
}
|
|
111
|
+
if (!entityType) {
|
|
112
|
+
throw new BadRequestException(
|
|
113
|
+
'Query parameter "entity_type" is required',
|
|
114
|
+
);
|
|
115
|
+
}
|
|
153
116
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return response.status(HttpStatus.NOT_FOUND).json({
|
|
157
|
-
success: false,
|
|
158
|
-
error: `No entity found for id "${id}"`,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
// let mergeEntity = JsonUtil.merge(existingEntity, entityData);
|
|
117
|
+
const entityMaster =
|
|
118
|
+
await this.entityMasterService.getEntityData(entityType);
|
|
162
119
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
120
|
+
const entityService =
|
|
121
|
+
await this.reflectionHelper.getBean<EntityServiceImpl>(
|
|
122
|
+
entityMaster.entity_service,
|
|
166
123
|
);
|
|
167
124
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
125
|
+
if (!entityService) {
|
|
126
|
+
throw new InternalServerErrorException(
|
|
127
|
+
`No service found for entity_type "${entityType}"`,
|
|
128
|
+
);
|
|
129
|
+
}
|
|
174
130
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
});
|
|
179
|
-
} catch (error) {
|
|
180
|
-
return response.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
181
|
-
success: false,
|
|
182
|
-
error: error.message || 'Internal server error',
|
|
183
|
-
});
|
|
131
|
+
const existingEntity = await entityService.getEntityData(entityType, id);
|
|
132
|
+
if (!existingEntity) {
|
|
133
|
+
throw new NotFoundException(`No entity found for id "${id}"`);
|
|
184
134
|
}
|
|
135
|
+
|
|
136
|
+
const updatedEntity = await entityService.updateEntity(
|
|
137
|
+
entityData,
|
|
138
|
+
loggedInUser as UserData,
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
success: true,
|
|
143
|
+
data: updatedEntity.data,
|
|
144
|
+
};
|
|
185
145
|
}
|
|
186
146
|
|
|
187
147
|
@Post('getFilteredDataWithTabs/:entity_type')
|