@saihu/common 1.1.25 → 1.1.27
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/dto/base-response.dto.d.ts +14 -0
- package/dist/dto/base-response.dto.js +27 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +1 -0
- package/dist/util/number.d.ts +2 -0
- package/dist/util/number.d.ts.map +1 -0
- package/dist/util/number.js +6 -0
- package/dist/util/times.d.ts +2 -0
- package/dist/util/times.d.ts.map +1 -1
- package/dist/util/times.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class BaseResponseDto<T> {
|
|
2
|
+
code: number;
|
|
3
|
+
msg: string;
|
|
4
|
+
data: T | null;
|
|
5
|
+
constructor(code: number, msg: string, data?: T | null);
|
|
6
|
+
static success<T>(data: T): BaseResponseDto<T>;
|
|
7
|
+
static successWithMessage<T>(msg: string, data: T): BaseResponseDto<T>;
|
|
8
|
+
static error<T>(code: number, msg: string): BaseResponseDto<T>;
|
|
9
|
+
static readonly CODE_NOT_FOUND = 404;
|
|
10
|
+
static readonly CODE_UNAUTHORIZED = 401;
|
|
11
|
+
static readonly CODE_FORBIDDEN = 403;
|
|
12
|
+
static readonly CODE_BAD_REQUEST = 400;
|
|
13
|
+
static readonly CODE_SERVER_ERROR = 500;
|
|
14
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseResponseDto = void 0;
|
|
4
|
+
// src/dto/base-response.dto.ts
|
|
5
|
+
class BaseResponseDto {
|
|
6
|
+
constructor(code, msg, data = null) {
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.msg = msg;
|
|
9
|
+
this.data = data;
|
|
10
|
+
}
|
|
11
|
+
static success(data) {
|
|
12
|
+
return new BaseResponseDto(0, 'success', data);
|
|
13
|
+
}
|
|
14
|
+
static successWithMessage(msg, data) {
|
|
15
|
+
return new BaseResponseDto(0, msg, data);
|
|
16
|
+
}
|
|
17
|
+
static error(code, msg) {
|
|
18
|
+
return new BaseResponseDto(code, msg, null);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.BaseResponseDto = BaseResponseDto;
|
|
22
|
+
// Common error codes
|
|
23
|
+
BaseResponseDto.CODE_NOT_FOUND = 404;
|
|
24
|
+
BaseResponseDto.CODE_UNAUTHORIZED = 401;
|
|
25
|
+
BaseResponseDto.CODE_FORBIDDEN = 403;
|
|
26
|
+
BaseResponseDto.CODE_BAD_REQUEST = 400;
|
|
27
|
+
BaseResponseDto.CODE_SERVER_ERROR = 500;
|
package/dist/util/index.d.ts
CHANGED
package/dist/util/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/dist/util/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/util/number.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAExC"}
|
package/dist/util/times.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare function getDayStart(date: string): Date;
|
|
2
|
+
export declare function getDayEnd(date: string): Date;
|
|
1
3
|
export declare function getCurrentDate(): string;
|
|
2
4
|
export declare function getTomorrowDate(): string;
|
|
3
5
|
export declare function getCurrentChinaTime(): Date;
|
package/dist/util/times.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"times.d.ts","sourceRoot":"","sources":["../../src/util/times.ts"],"names":[],"mappings":"AAQA,wBAAgB,cAAc,WAE7B;AAED,wBAAgB,eAAe,WAE9B;AAED,wBAAgB,mBAAmB,SAMlC;AAED,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,MAAM,EACrB,MAAM,GAAE,MAA8B,GACrC,MAAM,CAER;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CASjD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAS/C;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7D;
|
|
1
|
+
{"version":3,"file":"times.d.ts","sourceRoot":"","sources":["../../src/util/times.ts"],"names":[],"mappings":"AAQA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,QAEvC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,QAErC;AAED,wBAAgB,cAAc,WAE7B;AAED,wBAAgB,eAAe,WAE9B;AAED,wBAAgB,mBAAmB,SAMlC;AAED,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,MAAM,EACrB,MAAM,GAAE,MAA8B,GACrC,MAAM,CAER;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CASjD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAS/C;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,eAAO,MAAM,cAAc,QAAO,MAOjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAO,MAOpC,CAAC"}
|
package/dist/util/times.js
CHANGED
|
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getCurrentVersion = exports.getNextVersion = void 0;
|
|
7
|
+
exports.getDayStart = getDayStart;
|
|
8
|
+
exports.getDayEnd = getDayEnd;
|
|
7
9
|
exports.getCurrentDate = getCurrentDate;
|
|
8
10
|
exports.getTomorrowDate = getTomorrowDate;
|
|
9
11
|
exports.getCurrentChinaTime = getCurrentChinaTime;
|
|
@@ -19,6 +21,12 @@ const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
|
19
21
|
// Enable timezone support
|
|
20
22
|
dayjs_1.default.extend(utc_1.default);
|
|
21
23
|
dayjs_1.default.extend(timezone_1.default);
|
|
24
|
+
function getDayStart(date) {
|
|
25
|
+
return dayjs_1.default.utc(date).startOf('day').toDate();
|
|
26
|
+
}
|
|
27
|
+
function getDayEnd(date) {
|
|
28
|
+
return dayjs_1.default.utc(date).endOf('day').toDate();
|
|
29
|
+
}
|
|
22
30
|
function getCurrentDate() {
|
|
23
31
|
return (0, dayjs_1.default)().tz('Asia/Shanghai').format('YYYY-MM-DD');
|
|
24
32
|
}
|