@xrystal/core 3.23.5 → 3.23.6
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
|
@@ -154,28 +154,35 @@ export default class Controller extends BaseController {
|
|
|
154
154
|
let successCode = this.currentStore?.metadata?._code || 200;
|
|
155
155
|
const source = resResult !== undefined ? resResult : logicResult;
|
|
156
156
|
if (source !== null && typeof source === 'object') {
|
|
157
|
-
if (source.payload) {
|
|
158
|
-
finalData = source.payload.data;
|
|
157
|
+
if (source.payload && typeof source.payload === 'object') {
|
|
158
|
+
finalData = source.payload.data !== undefined ? source.payload.data : source.payload;
|
|
159
159
|
finalExtraData = source.payload.extraData;
|
|
160
160
|
}
|
|
161
161
|
else if (source.data !== undefined || source.extraData !== undefined) {
|
|
162
162
|
finalData = source.data;
|
|
163
163
|
finalExtraData = source.extraData;
|
|
164
164
|
}
|
|
165
|
-
else
|
|
166
|
-
|
|
165
|
+
else {
|
|
166
|
+
const hasMetadata = source.status !== undefined || source.message !== undefined || source.code !== undefined;
|
|
167
|
+
if (!hasMetadata && Object.keys(source).length > 0) {
|
|
168
|
+
finalData = source;
|
|
169
|
+
}
|
|
167
170
|
}
|
|
168
171
|
if (source.message)
|
|
169
172
|
messageSource = source.message;
|
|
170
|
-
if (source.code)
|
|
173
|
+
if (source.code !== undefined)
|
|
171
174
|
successCode = source.code;
|
|
172
175
|
}
|
|
173
176
|
else if (source !== undefined) {
|
|
174
177
|
messageSource = source;
|
|
175
178
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
let payload = undefined;
|
|
180
|
+
if (finalData !== undefined || finalExtraData !== undefined) {
|
|
181
|
+
payload = {
|
|
182
|
+
data: finalData ?? {},
|
|
183
|
+
extraData: finalExtraData ?? {}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
179
186
|
return currentRes.status(successCode).send(new ResponseSchema({
|
|
180
187
|
status: true,
|
|
181
188
|
message: this.parseMessage(messageSource, currentReq.t, false),
|