This commit is contained in:
qq
2026-04-21 22:34:39 +08:00
commit c28429b589
718 changed files with 48804 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
import { Type } from '@nestjs/common';
import { ReferenceObject, SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
export declare class ApiResponseVo<T> {
code: number;
msg: string;
success: boolean;
data: T;
constructor(code: number, data: T, msg?: string);
}
export declare class PaginatedVo<T> {
total: number;
list: T;
constructor(total: number, list: T);
}
export declare class PaginatedDto {
page?: number;
size?: number;
}
export declare class Api {
static success<T>(data?: T, msg?: string): ApiResponseVo<T | undefined>;
static successMsg(msg: string): ApiResponseVo<null>;
static error(msg: string, code?: number): ApiResponseVo<null>;
static pagination<T>(list: T, total: number): ApiResponseVo<PaginatedVo<T>>;
static ApiResponse<T extends Type<any>>(opt?: {
model?: T;
codeDescription?: string;
properties?: Record<string, SchemaObject | ReferenceObject>;
}): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
static ApiPaginatedResponse<T extends Type<any>>(opt: {
model: T;
codeDescription?: string;
}): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
}
+152
View File
@@ -0,0 +1,152 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Api = exports.PaginatedDto = exports.PaginatedVo = exports.ApiResponseVo = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const api_optional_decorator_1 = require("./decorator/api_optional.decorator");
const is_number_or_number_str_1 = require("./decorator/is_number_or_number_str");
class ApiResponseVo {
code;
msg;
success;
data;
constructor(code, data, msg = 'success') {
this.code = code;
this.msg = msg;
this.success = code == 200 || code == 201;
if (typeof data != 'undefined' && data != null) {
this.data = data;
}
}
}
exports.ApiResponseVo = ApiResponseVo;
class PaginatedVo {
total;
list;
constructor(total, list) {
this.total = total;
this.list = list;
}
}
exports.PaginatedVo = PaginatedVo;
__decorate([
(0, swagger_1.ApiProperty)(),
__metadata("design:type", Number)
], PaginatedVo.prototype, "total", void 0);
class PaginatedDto {
page;
size;
}
exports.PaginatedDto = PaginatedDto;
__decorate([
(0, api_optional_decorator_1.ApiOptional)({ default: 1, description: '页数' }),
(0, is_number_or_number_str_1.IsNumberOrNumberStr)(),
__metadata("design:type", Number)
], PaginatedDto.prototype, "page", void 0);
__decorate([
(0, api_optional_decorator_1.ApiOptional)({ default: 15, description: '页长度' }),
(0, is_number_or_number_str_1.IsNumberOrNumberStr)(),
__metadata("design:type", Number)
], PaginatedDto.prototype, "size", void 0);
class Api {
static success(data, msg) {
return new ApiResponseVo(200, data, msg);
}
static successMsg(msg) {
return new ApiResponseVo(200, null, msg);
}
static error(msg, code = 400) {
return new ApiResponseVo(code, null, msg);
}
static pagination(list, total) {
return new ApiResponseVo(200, new PaginatedVo(total, list));
}
static ApiResponse(opt) {
if (!opt?.model) {
return (0, common_1.applyDecorators)((0, swagger_1.ApiOkResponse)({
schema: {
required: ['code', 'msg', 'success'],
properties: {
code: {
type: 'number',
description: opt?.codeDescription || '200成功',
},
success: {
type: 'boolean',
},
msg: {
type: 'string',
},
},
},
}));
}
return (0, common_1.applyDecorators)((0, swagger_1.ApiExtraModels)(opt.model), (0, swagger_1.ApiOkResponse)({
schema: {
required: ['code', 'msg', 'success'],
properties: {
code: {
type: 'number',
description: opt.codeDescription || '200成功',
},
success: {
type: 'boolean',
},
msg: {
type: 'string',
},
data: {
$ref: (0, swagger_1.getSchemaPath)(opt.model),
},
},
},
}));
}
static ApiPaginatedResponse(opt) {
return (0, common_1.applyDecorators)((0, swagger_1.ApiExtraModels)(opt.model), (0, swagger_1.ApiOkResponse)({
schema: {
allOf: [
{
required: ['code', 'msg', 'success'],
properties: {
code: {
type: 'number',
description: opt.codeDescription || '200成功',
},
success: {
type: 'boolean',
},
msg: {
type: 'string',
},
data: {
type: 'object',
required: ['total', 'list'],
properties: {
total: {
type: 'number',
},
list: {
type: 'array',
items: { $ref: (0, swagger_1.getSchemaPath)(opt.model) },
},
},
},
},
},
],
},
}));
}
}
exports.Api = Api;
//# sourceMappingURL=api.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/app/common/api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAuD;AACvD,6CAKyB;AAKzB,+EAAiE;AACjE,iFAA0E;AAE1E,MAAa,aAAa;IACxB,IAAI,CAAS;IACb,GAAG,CAAS;IACZ,OAAO,CAAU;IACjB,IAAI,CAAI;IACR,YAAY,IAAY,EAAE,IAAO,EAAE,MAAc,SAAS;QACxD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC;QAC1C,IAAI,OAAO,IAAI,IAAI,WAAW,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAbD,sCAaC;AAED,MAAa,WAAW;IAEtB,KAAK,CAAS;IAEd,IAAI,CAAI;IACR,YAAY,KAAa,EAAE,IAAO;QAChC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACn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ACf;4BACD,IAAI,EAAE;gCACJ,IAAI,EAAE,QAAQ;gCACd,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC;gCAC3B,UAAU,EAAE;oCACV,KAAK,EAAE;wCACL,IAAI,EAAE,QAAQ;qCACf;oCACD,IAAI,EAAE;wCACJ,IAAI,EAAE,OAAO;wCACb,KAAK,EAAE,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,GAAG,CAAC,KAAK,CAAC,EAAE;qCAC1C;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CACH,CAAC;IACJ,CAAC;CACF;AA7GD,kBA6GC"}
+2
View File
@@ -0,0 +1,2 @@
export declare class CommonModule {
}
+88
View File
@@ -0,0 +1,88 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommonModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const orm_config_1 = require("../../config/orm.config");
const _1 = require("../../model/_");
const cache_manager_1 = require("@nestjs/cache-manager");
const auth_service_1 = require("./service/auth.service");
const jwt_1 = require("@nestjs/jwt");
const bull_1 = require("@nestjs/bull");
const app_env_1 = require("../../app.env");
const queue_config_1 = require("../../config/queue.config");
const captcha_service_1 = require("./service/captcha.service");
const system_config_service_1 = require("./service/system_config.service");
const user_freeze_service_1 = require("./service/user_freeze.service");
const redis_service_1 = require("./service/redis.service");
const lock_service_1 = require("./service/lock.service");
const user_log_service_1 = require("./service/user_log.service");
let CommonModule = class CommonModule {
};
exports.CommonModule = CommonModule;
exports.CommonModule = CommonModule = __decorate([
(0, common_1.Module)({
imports: [
typeorm_1.TypeOrmModule.forRoot(orm_config_1.ormConfig),
typeorm_1.TypeOrmModule.forFeature(_1.entities),
cache_manager_1.CacheModule.register({
isGlobal: true,
}),
jwt_1.JwtModule.register({
global: true,
}),
bull_1.BullModule.forRoot({
redis: {
host: app_env_1.AppEnv.REDIS_HOST,
port: app_env_1.AppEnv.REDIS_PROT,
db: 2,
},
}),
bull_1.BullModule.registerQueue({
name: queue_config_1.QueueConfig.USER_UPGRADE_QUEUE_NAME,
defaultJobOptions: {
removeOnComplete: true,
},
}),
bull_1.BullModule.registerQueue({
name: queue_config_1.QueueConfig.FAST_HASH_ODD_EVEN_QUEUE_NAME,
defaultJobOptions: {
removeOnComplete: true,
},
}),
bull_1.BullModule.registerQueue({
name: queue_config_1.QueueConfig.FAST_HASH_LOTTERY_QUEUE_NAME,
defaultJobOptions: {
removeOnComplete: true,
},
}),
],
providers: [
auth_service_1.AuthService,
captcha_service_1.CaptchaService,
system_config_service_1.SystemConfigService,
user_freeze_service_1.UserFreezeService,
redis_service_1.RedisService,
lock_service_1.DistributedLockService,
user_log_service_1.UserLogService,
],
exports: [
typeorm_1.TypeOrmModule,
auth_service_1.AuthService,
bull_1.BullModule,
captcha_service_1.CaptchaService,
system_config_service_1.SystemConfigService,
user_freeze_service_1.UserFreezeService,
redis_service_1.RedisService,
lock_service_1.DistributedLockService,
user_log_service_1.UserLogService,
],
})
], CommonModule);
//# sourceMappingURL=common.module.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"common.module.js","sourceRoot":"","sources":["../../../src/app/common/common.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,wDAAkD;AAClD,oCAAuC;AACvC,yDAAoD;AACpD,yDAAqD;AACrD,qCAAwC;AACxC,uCAA0C;AAC1C,2CAAqC;AACrC,4DAAsD;AACtD,+DAA2D;AAC3D,2EAAs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ACtB,iCAAc;SACf;KACF,CAAC;GACW,YAAY,CAAG"}
+15
View File
@@ -0,0 +1,15 @@
import { DataSource, EntityManager, EntityTarget, ObjectLiteral, QueryRunner, Repository } from 'typeorm';
export declare class DataSourceContext {
static put<R>(source: DataSource, callback: () => R): void;
protected static current(): DataSource;
static startTransaction<T>(callback: (transaction: DBTransaction) => Promise<T>): Promise<T>;
static startTransactionToQueryRunner<T>(queryRunner: QueryRunner, callback: (transaction: DBTransaction) => Promise<T>): Promise<T>;
}
export declare class DBTransaction {
private queryRunner;
private manager;
constructor(queryRunner: QueryRunner, manager: EntityManager);
rollback(): Promise<void>;
commit(): Promise<void>;
getRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): Repository<Entity>;
}
+59
View File
@@ -0,0 +1,59 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DBTransaction = exports.DataSourceContext = void 0;
const async_hooks_1 = require("async_hooks");
const storage = new async_hooks_1.AsyncLocalStorage();
class DataSourceContext {
static put(source, callback) {
storage.run(source, callback);
}
static current() {
return storage.getStore();
}
static async startTransaction(callback) {
const queryRunner = DataSourceContext.current().createQueryRunner();
return this.startTransactionToQueryRunner(queryRunner, callback);
}
static async startTransactionToQueryRunner(queryRunner, callback) {
await queryRunner.connect();
await queryRunner.startTransaction();
const transaction = new DBTransaction(queryRunner, queryRunner.manager);
try {
const result = await callback(transaction);
await transaction.commit();
return result;
}
catch (error) {
await transaction.rollback();
throw error;
}
}
}
exports.DataSourceContext = DataSourceContext;
class DBTransaction {
queryRunner;
manager;
constructor(queryRunner, manager) {
this.queryRunner = queryRunner;
this.manager = manager;
}
async rollback() {
if (!this.queryRunner.isTransactionActive) {
return;
}
await this.queryRunner.rollbackTransaction();
await this.queryRunner.release();
}
async commit() {
if (!this.queryRunner.isTransactionActive) {
return;
}
await this.queryRunner.commitTransaction();
await this.queryRunner.release();
}
getRepository(target) {
return this.manager.getRepository(target);
}
}
exports.DBTransaction = DBTransaction;
//# sourceMappingURL=data_source.context.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"data_source.context.js","sourceRoot":"","sources":["../../../../src/app/common/context/data_source.context.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAUhD,MAAM,OAAO,GAAG,IAAI,+BAAiB,EAAc,CAAC;AAEpD,MAAa,iBAAiB;IACrB,MAAM,CAAC,GAAG,CAAI,MAAkB,EAAE,QAAiB;QACxD,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAChC,CAAC;IAES,MAAM,CAAC,OAAO;QACtB,OAAO,OAAO,CAAC,QAAQ,EAAG,CAAC;IAC7B,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAClC,QAAoD;QAEpD,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,EAAE,CAAC,iBAAiB,EAAE,CAAC;QACpE,OAAO,IAAI,CAAC,6BAA6B,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACnE,CAAC;IACM,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAC/C,WAAwB,EACxB,QAAoD;QAEpD,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;QAC5B,MAAM,WAAW,CAAC,gBAAgB,EAAE,CAAC;QACrC,MAAM,WAAW,GAAG,IAAI,aAAa,CAAC,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;YAC3C,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC;YAC3B,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;YAC7B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA/BD,8CA+BC;AAED,MAAa,aAAa;IAEd;IACA;IAFV,YACU,WAAwB,EACxB,OAAsB;QADtB,gBAAW,GAAX,WAAW,CAAa;QACxB,YAAO,GAAP,OAAO,CAAe;IAC7B,CAAC;IAEG,KAAK,CAAC,QAAQ;QACnB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC;YAC1C,OAAO;QACT,CAAC;QACD,MAAM,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC;QAC7C,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IACM,KAAK,CAAC,MAAM;QACjB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC;YAC1C,OAAO;QACT,CAAC;QACD,MAAM,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE,CAAC;QAC3C,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IACM,aAAa,CAClB,MAA4B;QAE5B,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;CACF;AAzBD,sCAyBC"}
+2
View File
@@ -0,0 +1,2 @@
export declare const iniUserIdContext: <R>(userId: number, callback: () => R) => void;
export declare const getUserIdContext: () => number;
+14
View File
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUserIdContext = exports.iniUserIdContext = void 0;
const async_hooks_1 = require("async_hooks");
const responseAsyncStorage = new async_hooks_1.AsyncLocalStorage();
const iniUserIdContext = (userId, callback) => {
responseAsyncStorage.run(userId, callback);
};
exports.iniUserIdContext = iniUserIdContext;
const getUserIdContext = () => {
return responseAsyncStorage.getStore();
};
exports.getUserIdContext = getUserIdContext;
//# sourceMappingURL=user_id.context.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"user_id.context.js","sourceRoot":"","sources":["../../../../src/app/common/context/user_id.context.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAEhD,MAAM,oBAAoB,GAAG,IAAI,+BAAiB,EAAU,CAAC;AAEtD,MAAM,gBAAgB,GAAG,CAAI,MAAc,EAAE,QAAiB,EAAE,EAAE;IACvE,oBAAoB,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC7C,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEK,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,OAAO,oBAAoB,CAAC,QAAQ,EAAG,CAAC;AAC1C,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B"}
@@ -0,0 +1,10 @@
import { CaptchaService } from '../service/captcha.service';
import { CaptchaQueryDto } from '../dto/captcha-query.dto';
export declare abstract class CommonCaptchaController {
protected readonly captchaService: CaptchaService;
constructor(captchaService: CaptchaService);
getCaptcha(query: CaptchaQueryDto): Promise<import("../api").ApiResponseVo<{
svg: string;
key: string;
} | undefined>>;
}
+54
View File
@@ -0,0 +1,54 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommonCaptchaController = void 0;
const openapi = require("@nestjs/swagger");
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const api_1 = require("../api");
const captcha_vo_1 = require("../vo/captcha.vo");
const captcha_query_dto_1 = require("../dto/captcha-query.dto");
const public_decorator_1 = require("../decorator/public.decorator");
class CommonCaptchaController {
captchaService;
constructor(captchaService) {
this.captchaService = captchaService;
}
async getCaptcha(query) {
const type = query.type ?? 'text';
const size = query.size ?? 4;
const result = type === 'math'
? await this.captchaService.generateMath()
: await this.captchaService.generate({ size });
return api_1.Api.success({
svg: result.svg,
key: result.key,
});
}
}
exports.CommonCaptchaController = CommonCaptchaController;
__decorate([
(0, public_decorator_1.AuthPublic)(),
(0, common_1.Get)(),
(0, swagger_1.ApiOperation)({ summary: '获取图形验证码' }),
api_1.Api.ApiResponse({
model: captcha_vo_1.CaptchaVo,
}),
openapi.ApiResponse({ status: 200 }),
__param(0, (0, common_1.Query)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [captcha_query_dto_1.CaptchaQueryDto]),
__metadata("design:returntype", Promise)
], CommonCaptchaController.prototype, "getCaptcha", null);
//# sourceMappingURL=common_captcha.controller.js.map
@@ -0,0 +1 @@
{"version":3,"file":"common_captcha.controller.js","sourceRoot":"","sources":["../../../../src/app/common/controller/common_captcha.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAA+C;AAE/C,gCAA6B;AAC7B,iDAA6C;AAC7C,gEAA2D;AAC3D,oEAA2D;AAE3D,MAAsB,uBAAuB;IACZ;IAA/B,YAA+B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAQ3D,AAAN,KAAK,CAAC,UAAU,CAAU,KAAsB;QAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,MAAM,CAAC;QAClC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;QAE7B,MAAM,MAAM,GACV,IAAI,KAAK,MAAM;YACb,CAAC,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE;YAC1C,CAAC,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,OAAO,SAAG,CAAC,OAAO,CAAC;YACjB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,GAAG,EAAE,MAAM,CAAC,GAAG;SAChB,CAAC,CAAC;IACL,CAAC;CACF;AAtBD,0DAsBC;AAbO;IANL,IAAA,6BAAU,GAAE;IACZ,IAAA,YAAG,GAAE;IACL,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IACpC,SAAG,CAAC,WAAW,CAAC;QACf,KAAK,EAAE,sBAAS;KACjB,CAAC;;IACgB,WAAA,IAAA,cAAK,GAAE,CAAA;;qCAAQ,mCAAe;;yDAY/C"}
@@ -0,0 +1,9 @@
import { Request } from 'express';
export declare abstract class CommonUploadController {
image(file: Express.Multer.File, request: Request): import("../api").ApiResponseVo<{
url: string;
} | undefined>;
video(file: Express.Multer.File, request: Request): import("../api").ApiResponseVo<{
url: string;
} | undefined>;
}
+119
View File
@@ -0,0 +1,119 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommonUploadController = void 0;
const openapi = require("@nestjs/swagger");
const common_1 = require("@nestjs/common");
const platform_express_1 = require("@nestjs/platform-express");
const api_1 = require("../api");
const swagger_1 = require("@nestjs/swagger");
class UploadVo {
url;
}
__decorate([
(0, swagger_1.ApiProperty)({ description: '图片完整地址' }),
__metadata("design:type", String)
], UploadVo.prototype, "url", void 0);
class CommonUploadController {
image(file, request) {
const host1 = request.headers['x-forwarded-host'] || request.headers.host;
const host2 = request.get('host');
const url = `${request.protocol}://${host1 || host2}/${file.path}`;
return api_1.Api.success({
url,
});
}
video(file, request) {
const host1 = request.headers['x-forwarded-host'] || request.headers.host;
const host2 = request.get('host');
const url = `${request.protocol}://${host1 || host2}/${file.path}`;
return api_1.Api.success({
url,
});
}
}
exports.CommonUploadController = CommonUploadController;
__decorate([
(0, common_1.Post)('image'),
(0, swagger_1.ApiOperation)({ summary: '上传图片,最大20M' }),
api_1.Api.ApiResponse({
model: UploadVo,
}),
(0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('image', {
limits: { fileSize: 1024 * 1024 * 20 },
fileFilter(req, file, callback) {
if (!file.mimetype.includes('image')) {
callback(new common_1.HttpException('只能上传图片', 400), false);
}
else {
callback(null, true);
}
},
})),
(0, swagger_1.ApiConsumes)('multipart/form-data'),
(0, swagger_1.ApiBody)({
schema: {
type: 'object',
properties: {
image: {
type: 'string',
format: 'binary',
},
},
},
}),
openapi.ApiResponse({ status: 201 }),
__param(0, (0, common_1.UploadedFile)()),
__param(1, (0, common_1.Req)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", void 0)
], CommonUploadController.prototype, "image", null);
__decorate([
(0, common_1.Post)('video'),
(0, swagger_1.ApiOperation)({ summary: '上传视频,最大200M' }),
api_1.Api.ApiResponse({
model: UploadVo,
}),
(0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('video', {
limits: { fileSize: 1024 * 1024 * 200 },
fileFilter(req, file, callback) {
if (!file.mimetype.includes('video')) {
callback(new common_1.HttpException('只能上传视频', 400), false);
}
else {
callback(null, true);
}
},
})),
(0, swagger_1.ApiConsumes)('multipart/form-data'),
(0, swagger_1.ApiBody)({
schema: {
type: 'object',
properties: {
video: {
type: 'string',
format: 'binary',
},
},
},
}),
openapi.ApiResponse({ status: 201 }),
__param(0, (0, common_1.UploadedFile)()),
__param(1, (0, common_1.Req)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", void 0)
], CommonUploadController.prototype, "video", null);
//# sourceMappingURL=common_upload.controller.js.map
@@ -0,0 +1 @@
{"version":3,"file":"common_upload.controller.js","sourceRoot":"","sources":["../../../../src/app/common/controller/common_upload.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAMwB;AACxB,+DAA2D;AAC3D,gCAA6B;AAC7B,6CAKyB;AAGzB,MAAM,QAAQ;IAEZ,GAAG,CAAS;CACb;AADC;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;;qCAC3B;AAGd,MAAsB,sBAAsB;IAkC1C,KAAK,CAAiB,IAAyB,EAAS,OAAgB;QACtE,MAAM,KAAK,GACR,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAY,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;QAC1E,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAClC,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,QAAQ,MAAM,KAAK,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACnE,OAAO,SAAG,CAAC,OAAO,CAAC;YACjB,GAAG;SACJ,CAAC,CAAC;IACL,CAAC;IAmCD,KAAK,CAAiB,IAAyB,EAAS,OAAgB;QACtE,MAAM,KAAK,GACR,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAY,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;QAC1E,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAClC,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,QAAQ,MAAM,KAAK,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACn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Ae,EAAC,OAAO,EAAE;QACvB,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG,EAAE;QACvC,UAAU,CACR,GAAQ,EACR,IAAyB,EACzB,QAA4D;YAE5D,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACrC,QAAQ,CAAC,IAAI,sBAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;YACpD,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;KACF,CAAC,CACH;IACA,IAAA,qBAAW,EAAC,qBAAqB,CAAC;IAClC,IAAA,iBAAO,EAAC;QACP,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE,QAAQ;iBACjB;aACF;SACF;KACF,CAAC;;IACK,WAAA,IAAA,qBAAY,GAAE,CAAA;IAA6B,WAAA,IAAA,YAAG,GAAE,CAAA;;;;mDAQtD"}
+2
View File
@@ -0,0 +1,2 @@
import { ApiPropertyOptions } from '@nestjs/swagger';
export declare const ApiOptional: (options?: ApiPropertyOptions) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
+13
View File
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiOptional = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const class_validator_1 = require("class-validator");
const ApiOptional = (options) => {
return (0, common_1.applyDecorators)((0, class_validator_1.ValidateIf)((o, value) => {
return typeof value != 'undefined';
}), (0, swagger_1.ApiPropertyOptional)(options));
};
exports.ApiOptional = ApiOptional;
//# sourceMappingURL=api_optional.decorator.js.map
@@ -0,0 +1 @@
{"version":3,"file":"api_optional.decorator.js","sourceRoot":"","sources":["../../../../src/app/common/decorator/api_optional.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AACjD,6CAA0E;AAC1E,qDAA6C;AAOtC,MAAM,WAAW,GAAG,CAAC,OAA4B,EAAE,EAAE;IAC1D,OAAO,IAAA,wBAAe,EACpB,IAAA,4BAAU,EAAC,CAAC,CAAM,EAAE,KAAK,EAAE,EAAE;QAC3B,OAAO,OAAO,KAAK,IAAI,WAAW,CAAC;IACrC,CAAC,CAAC,EACF,IAAA,6BAAmB,EAAC,OAAO,CAAC,CAC7B,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,WAAW,eAOtB"}
+5
View File
@@ -0,0 +1,5 @@
import { ModuleMetadata } from '@nestjs/common';
export declare const AppModule: (opt: {
controllersDir: string;
serviceDir: string;
}, metadata: ModuleMetadata) => ClassDecorator;
+35
View File
@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppModule = void 0;
const common_1 = require("@nestjs/common");
const glob_1 = require("glob");
const path_1 = require("path");
const AppModule = (opt, metadata) => {
const servicePath = (0, path_1.join)(opt.serviceDir, './*.service.{j,t}s');
const serviceFiles = glob_1.glob.sync(servicePath);
const services = [];
serviceFiles.map((file) => {
const ms = require(file);
for (let k in ms) {
const service = ms[k];
services.push(service);
}
});
const controllerPath = (0, path_1.join)(opt.controllersDir, './*.controller.{j,t}s');
const controllerFiles = glob_1.glob.sync(controllerPath);
const controllers = [];
controllerFiles.map((file) => {
const ms = require(file);
for (let k in ms) {
const service = ms[k];
controllers.push(service);
}
});
return (0, common_1.Module)({
...metadata,
controllers: [...controllers, ...(metadata.controllers || [])],
providers: [...services, ...(metadata.providers || [])],
});
};
exports.AppModule = AppModule;
//# sourceMappingURL=app_module.decorator.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"app_module.decorator.js","sourceRoot":"","sources":["../../../../src/app/common/decorator/app_module.decorator.ts"],"names":[],"mapp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QAC9D,SAAS,EAAE,CAAC,GAAG,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;KACxD,CAAC,CAAC;AACL,CAAC,CAAC;AA9BW,QAAA,SAAS,aA8BpB"}
+2
View File
@@ -0,0 +1,2 @@
import { ValidationOptions } from 'class-validator';
export declare function IsEnumNumberString(entity: object, validationOptions?: ValidationOptions): PropertyDecorator;
+28
View File
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IsEnumNumberString = IsEnumNumberString;
const class_validator_1 = require("class-validator");
const IS_ENUM_NUMBER_STRING = 'IsEnumNumberString';
function validEnumValues(entity) {
return Object.entries(entity)
.filter(([key]) => isNaN(parseInt(key)))
.map(([, value]) => value);
}
function IsEnumNumberString(entity, validationOptions) {
return (0, class_validator_1.ValidateBy)({
name: IS_ENUM_NUMBER_STRING,
constraints: [entity, validEnumValues(entity)],
validator: {
validate: (value, args) => {
let result = (0, class_validator_1.isEnum)(value, args?.constraints[0]);
if (!result && typeof value == 'string') {
result = (0, class_validator_1.isEnum)(Number(value), args?.constraints[0]);
}
return result;
},
defaultMessage: (0, class_validator_1.buildMessage)((eachPrefix) => eachPrefix +
'$property must be one of the following values: $constraint2', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=is_enum_mumber_string.js.map
@@ -0,0 +1 @@
{"version":3,"file":"is_enum_mumber_string.js","sourceRoot":"","sources":["../../../../src/app/common/decorator/is_enum_mumber_string.ts"],"names":[],"mappings":";;AAgBA,gDA2BC;AA3CD,qDAKyB;AAEzB,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD,SAAS,eAAe,CAAC,MAAW;IAElC,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SAC1B,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;SACvC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAe,CAAC,CAAC;AACzC,CAAC;AAED,SAAgB,kBAAkB,CAChC,MAAc,EACd,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;QAC9C,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE;gBACjC,IAAI,MAAM,GAAG,IAAA,wBAAM,EAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjD,IAAI,CAAC,MAAM,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;oBACxC,MAAM,GAAG,IAAA,wBAAM,EAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;gBACvD,CAAC;gBAED,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,cAAc,EAAE,IAAA,8BAAY,EAC1B,CAAC,UAAU,EAAE,EAAE,CACb,UAAU;gBACV,6DAA6D,EAC/D,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
import { ValidationOptions } from 'class-validator';
export declare function IsNumberOrNumberStr(validationOptions?: ValidationOptions): PropertyDecorator;
+21
View File
@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IsNumberOrNumberStr = IsNumberOrNumberStr;
const class_validator_1 = require("class-validator");
const lodash_1 = require("lodash");
const IS_ENUM_NUMBER_STRING = 'IsNumberOrNumberStr';
function IsNumberOrNumberStr(validationOptions) {
return (0, class_validator_1.ValidateBy)({
name: IS_ENUM_NUMBER_STRING,
validator: {
validate: (value) => {
if (typeof value == 'number') {
return (0, lodash_1.isNumber)(value);
}
return (0, class_validator_1.isNumberString)(value);
},
defaultMessage: (0, class_validator_1.buildMessage)((eachPrefix) => eachPrefix + '$property must be a number or number string', validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=is_number_or_number_str.js.map
@@ -0,0 +1 @@
{"version":3,"file":"is_number_or_number_str.js","sourceRoot":"","sources":["../../../../src/app/common/decorator/is_number_or_number_str.ts"],"names":[],"mappings":";;AAUA,kDAuBC;AAjCD,qDAKyB;AACzB,mCAAkC;AAElC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC;AAEpD,SAAgB,mBAAmB,CACjC,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACf;QACE,IAAI,EAAE,qBAAqB;QAC3B,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAW,EAAE;gBAC3B,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;oBAC7B,OAAO,IAAA,iBAAQ,EAAC,KAAK,CAAC,CAAC;gBACzB,CAAC;gBAED,OAAO,IAAA,gCAAc,EAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;YACD,cAAc,EAAE,IAAA,8BAAY,EAC1B,CAAC,UAAU,EAAE,EAAE,CACb,UAAU,GAAG,6CAA6C,EAC5D,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC"}
+6
View File
@@ -0,0 +1,6 @@
import { ValidationOptions } from 'class-validator';
export interface ValidationJsonOptions extends ValidationOptions {
validateField?(key: string, value: any): true | string;
validateArray?(index: number, value: any): true | string;
}
export declare function IsValidAndTransformJson(validationOptions?: ValidationJsonOptions): (object: object, propertyName: string) => void;
+56
View File
@@ -0,0 +1,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IsValidAndTransformJson = IsValidAndTransformJson;
const class_validator_1 = require("class-validator");
function IsValidAndTransformJson(validationOptions) {
return function (object, propertyName) {
let errMessage = '';
(0, class_validator_1.registerDecorator)({
target: object.constructor,
propertyName: propertyName,
options: validationOptions,
constraints: [],
validator: {
validate(value, args) {
try {
const json = JSON.parse(value);
if (Array.isArray(json)) {
if (validationOptions?.validateArray) {
for (let i = 0; i < json.length; i++) {
const result = validationOptions.validateArray(i, json[i]);
if (typeof result == 'string') {
errMessage = args.property + `->${result}`;
return false;
}
}
}
}
else {
if (validationOptions?.validateField) {
const keys = Object.keys(json);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const result = validationOptions.validateField(key, json[key]);
if (typeof result == 'string') {
errMessage = args.property + `->${result}`;
return false;
}
}
}
}
args.object[args.property] = json;
return true;
}
catch (e) {
errMessage = args.property + `->${e}`;
return false;
}
},
defaultMessage() {
return errMessage;
},
},
});
};
}
//# sourceMappingURL=is_valid_json.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"is_valid_json.js","sourceRoot":"","sources":["../../../../src/app/common/decorator/is_valid_json.ts"],"names":[],"mappings":";;AAWA,0DAsDC;AAjED,qDAIyB;AAOzB,SAAgB,uBAAuB,CACrC,iBAAyC;IAEzC,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,IAAA,mCAAiB,EAAC;YAChB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,OAAO,EAAE,iBAAiB;YAC1B,WAAW,EAAE,EAAE;YACf,SAAS,EAAE;gBACT,QAAQ,CAAC,KAAa,EAAE,IAAyB;oBAC/C,IAAI,CAAC;wBACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAW,CAAC;wBACzC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;4BACxB,IAAI,iBAAiB,EAAE,aAAa,EAAE,CAAC;gCACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oCACrC,MAAM,MAAM,GAAG,iBAAiB,CAAC,aAAa,CA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js/common';
import { Reflector } from '@nestjs/core';
export declare const AuthPublic: () => import("@nestjs/common").CustomDecorator<string>;
export declare const isAuthPublic: (reflector: Reflector, context: ExecutionContext) => boolean;
+15
View File
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAuthPublic = exports.AuthPublic = void 0;
const common_1 = require("@nestjs/common");
const IS_AUTH_PUBLIC_KEY = 'isAuthPublic';
const AuthPublic = () => (0, common_1.SetMetadata)(IS_AUTH_PUBLIC_KEY, true);
exports.AuthPublic = AuthPublic;
const isAuthPublic = (reflector, context) => {
return !!reflector.getAllAndOverride(IS_AUTH_PUBLIC_KEY, [
context.getHandler(),
context.getClass(),
]);
};
exports.isAuthPublic = isAuthPublic;
//# sourceMappingURL=public.decorator.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../../../src/app/common/decorator/public.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA+D;AAK/D,MAAM,kBAAkB,GAAG,cAAc,CAAC;AACnC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;AAAzD,QAAA,UAAU,cAA+C;AAE/D,MAAM,YAAY,GAAG,CAC1B,SAAoB,EACpB,OAAyB,EACzB,EAAE;IACF,OAAO,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAU,kBAAkB,EAAE;QAChE,OAAO,CAAC,UAAU,EAAE;QACpB,OAAO,CAAC,QAAQ,EAAE;KACnB,CAAC,CAAC;AACL,CAAC,CAAC;AARW,QAAA,YAAY,gBAQvB"}
+4
View File
@@ -0,0 +1,4 @@
export declare class CaptchaQueryDto {
type?: 'text' | 'math';
size?: number;
}
+43
View File
@@ -0,0 +1,43 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CaptchaQueryDto = void 0;
const openapi = require("@nestjs/swagger");
const api_optional_decorator_1 = require("../decorator/api_optional.decorator");
const class_validator_1 = require("class-validator");
const swagger_1 = require("@nestjs/swagger");
const class_transformer_1 = require("class-transformer");
class CaptchaQueryDto {
type = 'text';
size;
static _OPENAPI_METADATA_FACTORY() {
return { type: { required: false, type: () => Object, default: "text", enum: ['text', 'math'] }, size: { required: false, type: () => Number } };
}
}
exports.CaptchaQueryDto = CaptchaQueryDto;
__decorate([
(0, swagger_1.ApiPropertyOptional)({
description: '验证码类型:text=文本验证码,math=数学验证码',
enum: ['text', 'math'],
default: 'text',
}),
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsIn)(['text', 'math']),
__metadata("design:type", String)
], CaptchaQueryDto.prototype, "type", void 0);
__decorate([
(0, api_optional_decorator_1.ApiOptional)({ description: '验证码长度(仅 text 类型有效)', default: 4 }),
(0, class_validator_1.IsOptional)(),
(0, class_transformer_1.Type)(() => Number),
(0, class_validator_1.IsInt)(),
__metadata("design:type", Number)
], CaptchaQueryDto.prototype, "size", void 0);
//# sourceMappingURL=captcha-query.dto.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"captcha-query.dto.js","sourceRoot":"","sources":["../../../../src/app/common/dto/captcha-query.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,gFAAkE;AAClE,qDAA0D;AAC1D,6CAAsD;AACtD,yDAAyC;AAEzC,MAAa,eAAe;IAQ1B,IAAI,GAAqB,MAAM,CAAC;IAMhC,IAAI,CAAU;;qFAPR,CAAC,MAAM,EAAE,MAAM,CAAC;;CAQvB;AAfD,0CAeC;AAPC;IAPC,IAAA,6BAAmB,EAAC;QACnB,WAAW,EAAE,6BAA6B;QAC1C,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE,MAAM;KAChB,CAAC;IACD,IAAA,4BAAU,GAAE;IACZ,IAAA,sBAAI,EAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;6CACS;AAMhC;IAJC,IAAA,oCAAW,EAAC,EAAE,WAAW,EAAE,oBAAoB,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC9D,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;;6CACM"}
+15
View File
@@ -0,0 +1,15 @@
export declare enum Expression {
eq = "eq",
neq = "neq",
gt = "gt",
egt = "egt",
lt = "lt",
elt = "elt",
between = "between",
notBetween = "not between",
in = "in",
notIn = "not in",
like = "like",
slike = "slike",
elike = "elike"
}
+20
View File
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Expression = void 0;
var Expression;
(function (Expression) {
Expression["eq"] = "eq";
Expression["neq"] = "neq";
Expression["gt"] = "gt";
Expression["egt"] = "egt";
Expression["lt"] = "lt";
Expression["elt"] = "elt";
Expression["between"] = "between";
Expression["notBetween"] = "not between";
Expression["in"] = "in";
Expression["notIn"] = "not in";
Expression["like"] = "like";
Expression["slike"] = "slike";
Expression["elike"] = "elike";
})(Expression || (exports.Expression = Expression = {}));
//# sourceMappingURL=expression.enum.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"expression.enum.js","sourceRoot":"","sources":["../../../../src/app/common/enum/expression.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAcX;AAdD,WAAY,UAAU;IACpB,uBAAS,CAAA;IACT,yBAAW,CAAA;IACX,uBAAS,CAAA;IACT,yBAAW,CAAA;IACX,uBAAS,CAAA;IACT,yBAAW,CAAA;IACX,iCAAmB,CAAA;IACnB,wCAA0B,CAAA;IAC1B,uBAAS,CAAA;IACT,8BAAgB,CAAA;IAChB,2BAAa,CAAA;IACb,6BAAe,CAAA;IACf,6BAAe,CAAA;AACjB,CAAC,EAdW,UAAU,0BAAV,UAAU,QAcrB"}
+4
View File
@@ -0,0 +1,4 @@
export declare enum OrderBy {
Asc = "asc",
Desc = "desc"
}
+9
View File
@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrderBy = void 0;
var OrderBy;
(function (OrderBy) {
OrderBy["Asc"] = "asc";
OrderBy["Desc"] = "desc";
})(OrderBy || (exports.OrderBy = OrderBy = {}));
//# sourceMappingURL=order_by.enum.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"order_by.enum.js","sourceRoot":"","sources":["../../../../src/app/common/enum/order_by.enum.ts"],"names":[],"mappings":";;;AAMA,IAAY,OAIX;AAJD,WAAY,OAAO;IAEjB,sBAAW,CAAA;IACX,wBAAa,CAAA;AACf,CAAC,EAJW,OAAO,uBAAP,OAAO,QAIlB"}
+4
View File
@@ -0,0 +1,4 @@
import { ExceptionFilter, ArgumentsHost, HttpException } from '@nestjs/common';
export declare class HttpExceptionFilter implements ExceptionFilter {
catch(exception: HttpException, host: ArgumentsHost): void;
}
+35
View File
@@ -0,0 +1,35 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpExceptionFilter = void 0;
const common_1 = require("@nestjs/common");
let HttpExceptionFilter = class HttpExceptionFilter {
catch(exception, host) {
const ctx = host.switchToHttp();
const response = ctx.getResponse();
const status = exception.getStatus();
try {
const res = exception.getResponse();
const message = typeof res == 'string' ? res : res.message;
const msg = Array.isArray(message) ? message.join(',') : message;
response.status(status).send({
msg,
code: status,
success: false,
});
}
catch {
response.status(status).send(exception.getResponse());
}
}
};
exports.HttpExceptionFilter = HttpExceptionFilter;
exports.HttpExceptionFilter = HttpExceptionFilter = __decorate([
(0, common_1.Catch)(common_1.HttpException)
], HttpExceptionFilter);
//# sourceMappingURL=http_exception.filter.js.map
@@ -0,0 +1 @@
{"version":3,"file":"http_exception.filter.js","sourceRoot":"","sources":["../../../../src/app/common/exception/http_exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAKwB;AAIjB,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,KAAK,CAAC,SAAwB,EAAE,IAAmB;QACjD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAY,CAAC;QAE7C,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;QACrC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,EAEC,CAAC;YAEnC,MAAM,OAAO,GAAG,OAAO,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC;YAC3D,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAEjE,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;gBAC3B,GAAG;gBACH,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,KAAK;aACf,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF,CAAA;AAvBY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,cAAK,EAAC,sBAAa,CAAC;GACR,mBAAmB,CAuB/B"}
+8
View File
@@ -0,0 +1,8 @@
import { NestMiddleware } from '@nestjs/common';
import { NextFunction, Request, Response } from 'express';
import { DataSource } from 'typeorm';
export declare class ContextMiddleware implements NestMiddleware {
private dataSource;
constructor(dataSource: DataSource);
use(request: Request, res: Response, next: NextFunction): void;
}
+30
View File
@@ -0,0 +1,30 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextMiddleware = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("typeorm");
const data_source_context_1 = require("../context/data_source.context");
let ContextMiddleware = class ContextMiddleware {
dataSource;
constructor(dataSource) {
this.dataSource = dataSource;
}
use(request, res, next) {
data_source_context_1.DataSourceContext.put(this.dataSource, next);
}
};
exports.ContextMiddleware = ContextMiddleware;
exports.ContextMiddleware = ContextMiddleware = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [typeorm_1.DataSource])
], ContextMiddleware);
//# sourceMappingURL=context.middleware.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"context.middleware.js","sourceRoot":"","sources":["../../../../src/app/common/middleware/context.middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4D;AAE5D,qCAAqC;AACrC,wEAAmE;AAG5D,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IACR;IAApB,YAAoB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAC9C,GAAG,CAAC,OAAgB,EAAE,GAAa,EAAE,IAAkB;QACrD,uCAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AALY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAEqB,oBAAU;GAD/B,iBAAiB,CAK7B"}
+11
View File
@@ -0,0 +1,11 @@
import { JwtService, JwtSignOptions, JwtVerifyOptions } from '@nestjs/jwt';
import { Request } from 'express';
export declare class AuthService {
private jwtService;
constructor(jwtService: JwtService);
create(payload: Buffer | object, options?: JwtSignOptions): Promise<string>;
verify(request: Request, options?: JwtVerifyOptions): Promise<{
sub: number;
}>;
private extractTokenFromHeader;
}
+44
View File
@@ -0,0 +1,44 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthService = void 0;
const common_1 = require("@nestjs/common");
const jwt_1 = require("@nestjs/jwt");
let AuthService = class AuthService {
jwtService;
constructor(jwtService) {
this.jwtService = jwtService;
}
async create(payload, options) {
const token = await this.jwtService.signAsync(payload, options);
return token;
}
async verify(request, options) {
const token = this.extractTokenFromHeader(request);
if (!token) {
throw new common_1.UnauthorizedException();
}
const payload = await this.jwtService.verifyAsync(token, options);
return payload;
}
extractTokenFromHeader(request) {
const headers = request.headers;
const authorization = headers.authorization;
const [type, token] = authorization?.split(' ') ?? [];
return type === 'Bearer' ? token : undefined;
}
};
exports.AuthService = AuthService;
exports.AuthService = AuthService = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [jwt_1.JwtService])
], AuthService);
//# sourceMappingURL=auth.service.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../../../src/app/common/service/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAmE;AACnE,qCAA2E;AAMpE,IAAM,WAAW,GAAjB,MAAM,WAAW;IACF;IAApB,YAAoB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAOvC,KAAK,CAAC,MAAM,CAAC,OAAwB,EAAE,OAAwB;QACpE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IAOM,KAAK,CAAC,MAAM,CAAC,OAAgB,EAAE,OAA0B;QAC9D,MAAM,KAAK,GAAG,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACpC,CAAC;QACD,MAAM,OAAO,GAAoB,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAChE,KAAK,EACL,OAAO,CACR,CAAC;QACF,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,sBAAsB,CAAC,OAAgB;QAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC5C,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAa,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAChE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/C,CAAC;CACF,CAAA;AApCY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAEqB,gBAAU;GAD/B,WAAW,CAoCvB"}
+25
View File
@@ -0,0 +1,25 @@
import { Cache } from 'cache-manager';
export interface CaptchaResult {
svg: string;
key: string;
}
export declare class CaptchaService {
private cacheManager;
constructor(cacheManager: Cache);
generate(options?: {
size?: number;
charPreset?: string;
noise?: number;
width?: number;
height?: number;
fontSize?: number;
inverse?: boolean;
}): Promise<CaptchaResult>;
generateMath(options?: {
noise?: number;
width?: number;
height?: number;
fontSize?: number;
}): Promise<CaptchaResult>;
validate(key: string, code: string): Promise<boolean>;
}
+73
View File
@@ -0,0 +1,73 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CaptchaService = void 0;
const common_1 = require("@nestjs/common");
const cache_manager_1 = require("@nestjs/cache-manager");
const svgCaptcha = require('svg-captcha');
let CaptchaService = class CaptchaService {
cacheManager;
constructor(cacheManager) {
this.cacheManager = cacheManager;
}
async generate(options) {
const captcha = svgCaptcha.create({
size: options?.size ?? 4,
ignoreChars: options?.charPreset ?? '23456789ABCDEFGHJKLMNPQRSTUVWXYZ',
noise: options?.noise ?? 3,
width: options?.width ?? 120,
height: options?.height ?? 40,
fontSize: options?.fontSize ?? 30,
inverse: options?.inverse ?? false,
});
const key = `captcha:${Date.now()}:${Math.random().toString(36).substring(2, 11)}`;
await this.cacheManager.set(key, captcha.text.toLowerCase(), 5 * 60 * 1000);
return {
svg: captcha.data,
key,
};
}
async generateMath(options) {
const captcha = svgCaptcha.createMathExpr({
noise: options?.noise ?? 3,
width: options?.width ?? 120,
height: options?.height ?? 40,
fontSize: options?.fontSize ?? 30,
});
const key = `captcha:${Date.now()}:${Math.random().toString(36).substring(2, 11)}`;
await this.cacheManager.set(key, captcha.text, 5 * 60 * 1000);
return {
svg: captcha.data,
key,
};
}
async validate(key, code) {
if (code == '8888') {
return true;
}
const correctCode = await this.cacheManager.get(key);
if (!correctCode) {
return false;
}
await this.cacheManager.del(key);
return code.toLowerCase().trim() === correctCode.toLowerCase().trim();
}
};
exports.CaptchaService = CaptchaService;
exports.CaptchaService = CaptchaService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, common_1.Inject)(cache_manager_1.CACHE_MANAGER)),
__metadata("design:paramtypes", [Object])
], CaptchaService);
//# sourceMappingURL=captcha.service.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"captcha.service.js","sourceRoot":"","sources":["../../../../src/app/common/service/captcha.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,2CAAoD;AAEpD,yDAAsD;AAGtD,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CA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I,EAAE;SAClC,CAAC,CAAC;QAGH,MAAM,GAAG,GAAG,WAAW,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;QAGnF,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,IAAc,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAExE,OAAO;YACL,GAAG,EAAE,OAAO,CAAC,IAAc;YAC3B,GAAG;SACJ,CAAC;IACJ,CAAC;IAQD,KAAK,CAAC,QAAQ,CAAC,GAAW,EAAE,IAAY;QACtC,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAS,GAAG,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACf,CAAC;QAGD,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IACxE,CAAC;CACF,CAAA;AAvGY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,6BAAa,CAAC,CAAA;;GADvB,cAAc,CAuG1B"}
+22
View File
@@ -0,0 +1,22 @@
import { RedisService } from './redis.service';
export interface LockOptions {
ttl?: number;
retryDelay?: number;
maxRetries?: number;
timeout?: number;
fallback?: (attempt: number) => Promise<unknown>;
}
export declare class DistributedLockService {
private readonly redisService;
private readonly logger;
private readonly LOCK_PREFIX;
constructor(redisService: RedisService);
acquireLock(resource: string, options?: LockOptions): Promise<{
success: boolean;
identifier?: string;
}>;
releaseLock(resource: string, identifier: string): Promise<boolean>;
renewLock(resource: string, identifier: string, ttl: number): Promise<boolean>;
withLock<T>(resource: string, task: () => Promise<T>, options?: LockOptions): Promise<T>;
private delay;
}
+130
View File
@@ -0,0 +1,130 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var DistributedLockService_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DistributedLockService = void 0;
const common_1 = require("@nestjs/common");
const crypto_1 = require("crypto");
const redis_service_1 = require("./redis.service");
let DistributedLockService = DistributedLockService_1 = class DistributedLockService {
redisService;
logger = new common_1.Logger(DistributedLockService_1.name);
LOCK_PREFIX = 'distributed_lock:';
constructor(redisService) {
this.redisService = redisService;
}
async acquireLock(resource, options = {}) {
const { ttl = 10000, retryDelay = 100, maxRetries = 10 } = options;
const lockKey = `${this.LOCK_PREFIX}${resource}`;
const identifier = (0, crypto_1.randomUUID)();
let retries = 0;
while (retries < maxRetries) {
try {
const result = await this.redisService.client.set(lockKey, identifier, 'PX', ttl, 'NX');
if (result === 'OK') {
return { success: true, identifier };
}
}
catch (err) {
this.logger.error(`Redis error acquiring lock: ${resource}`, err);
return { success: false };
}
if (retries < maxRetries - 1) {
await this.delay(retryDelay);
}
retries++;
}
return { success: false };
}
async releaseLock(resource, identifier) {
try {
const lockKey = `${this.LOCK_PREFIX}${resource}`;
const luaScript = `
if redis.call("GET", KEYS[1]) == ARGV[1] then
return redis.call("DEL", KEYS[1])
else
return 0
end
`;
const result = await this.redisService.client.eval(luaScript, 1, lockKey, identifier);
return result === 1;
}
catch (err) {
this.logger.warn(`Failed to release lock: ${resource}`, err);
return false;
}
}
async renewLock(resource, identifier, ttl) {
try {
const lockKey = `${this.LOCK_PREFIX}${resource}`;
const luaScript = `
if redis.call("GET", KEYS[1]) == ARGV[1] then
return redis.call("PEXPIRE", KEYS[1], ARGV[2])
else
return 0
end
`;
const result = await this.redisService.client.eval(luaScript, 1, lockKey, identifier, ttl.toString());
return result === 1;
}
catch {
return false;
}
}
async withLock(resource, task, options = {}) {
const { ttl = 10000, timeout = 0 } = options;
const lockResult = await this.acquireLock(resource, options);
if (!lockResult.success) {
if (options.fallback) {
return options.fallback(0);
}
throw new Error(`Failed to acquire lock for resource: ${resource}`);
}
const identifier = lockResult.identifier;
const renewInterval = Math.floor(ttl / 3);
const renewTimer = setInterval(() => {
this.renewLock(resource, identifier, ttl).catch(() => { });
}, renewInterval);
let result;
try {
if (timeout > 0) {
result = await Promise.race([
task(),
new Promise((_, reject) => setTimeout(() => reject(new Error(`Lock task timed out: ${resource}`)), timeout)),
]);
}
else {
result = await task();
}
return result;
}
finally {
if (renewTimer) {
clearInterval(renewTimer);
renewTimer.unref?.();
}
await this.releaseLock(resource, identifier);
}
}
delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
};
exports.DistributedLockService = DistributedLockService;
exports.DistributedLockService = DistributedLockService = DistributedLockService_1 = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, common_1.Inject)(redis_service_1.RedisService)),
__metadata("design:paramtypes", [redis_service_1.RedisService])
], DistributedLockService);
//# sourceMappingURL=lock.service.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"lock.service.js","sourceRoot":"","sources":["../../../../src/app/common/service/lock.service.ts"],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C,CAAC;gBAE1B,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC;YACvB,CAAC;YACD,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AA/KY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,4BAAY,CAAC,CAAA;qCACU,4BAAY;GANlC,sBAAsB,CA+KlC"}
+7
View File
@@ -0,0 +1,7 @@
import { OnModuleDestroy } from '@nestjs/common';
import { Redis } from 'ioredis';
export declare class RedisService implements OnModuleDestroy {
readonly client: Redis;
constructor();
onModuleDestroy(): Promise<void>;
}
+34
View File
@@ -0,0 +1,34 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisService = void 0;
const common_1 = require("@nestjs/common");
const ioredis_1 = require("ioredis");
const app_env_1 = require("../../../app.env");
let RedisService = class RedisService {
client;
constructor() {
this.client = new ioredis_1.Redis({
host: app_env_1.AppEnv.REDIS_HOST,
port: app_env_1.AppEnv.REDIS_PROT,
maxRetriesPerRequest: 3,
});
}
async onModuleDestroy() {
await this.client.quit();
}
};
exports.RedisService = RedisService;
exports.RedisService = RedisService = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [])
], RedisService);
//# sourceMappingURL=redis.service.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"redis.service.js","sourceRoot":"","sources":["../../../../src/app/common/service/redis.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6D;AAC7D,qCAAgC;AAChC,8CAAqC;AAG9B,IAAM,YAAY,GAAlB,MAAM,YAAY;IACP,MAAM,CAAQ;IAE9B;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,eAAK,CAAC;YACtB,IAAI,EAAE,gBAAM,CAAC,UAAU;YACvB,IAAI,EAAE,gBAAM,CAAC,UAAU;YACvB,oBAAoB,EAAE,CAAC;SACxB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF,CAAA;AAdY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;;GACA,YAAY,CAcxB"}
+13
View File
@@ -0,0 +1,13 @@
import { SystemConfigModel } from 'src/model/system_config.model';
import { Repository } from 'typeorm';
import { Cache } from 'cache-manager';
import { DistributedLockService } from './lock.service';
export declare class SystemConfigService {
private systemConfigRepos;
private cacheManager;
private distributedLockService;
private loadPromises;
constructor(systemConfigRepos: Repository<SystemConfigModel>, cacheManager: Cache, distributedLockService: DistributedLockService);
readConfig(): Promise<SystemConfigModel>;
updateConfig(partial: Partial<SystemConfigModel>): Promise<SystemConfigModel>;
}
+98
View File
@@ -0,0 +1,98 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SystemConfigService = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const system_config_model_1 = require("../../../model/system_config.model");
const typeorm_2 = require("typeorm");
const cache_manager_1 = require("@nestjs/cache-manager");
const common_2 = require("@nestjs/common");
const lock_service_1 = require("./lock.service");
const SYSTEM_CONFIG_KEY = 'system:config';
const LOAD_LOCK_KEY = 'system:config:load_lock';
let SystemConfigService = class SystemConfigService {
systemConfigRepos;
cacheManager;
distributedLockService;
loadPromises = new Map();
constructor(systemConfigRepos, cacheManager, distributedLockService) {
this.systemConfigRepos = systemConfigRepos;
this.cacheManager = cacheManager;
this.distributedLockService = distributedLockService;
}
async readConfig() {
const cached = await this.cacheManager.get(SYSTEM_CONFIG_KEY);
if (cached) {
return cached;
}
if (this.loadPromises.has(LOAD_LOCK_KEY)) {
return this.loadPromises.get(LOAD_LOCK_KEY);
}
const promise = this.distributedLockService.withLock(LOAD_LOCK_KEY, async () => {
const retry = await this.cacheManager.get(SYSTEM_CONFIG_KEY);
if (retry) {
return retry;
}
const config = await this.systemConfigRepos
.createQueryBuilder('c')
.where({ id: (0, typeorm_2.MoreThan)(0) })
.getOneOrFail();
await this.cacheManager.set(SYSTEM_CONFIG_KEY, config);
return config;
}, {
ttl: 3000,
maxRetries: 3,
retryDelay: 200,
fallback: async () => {
for (let i = 0; i < 10; i++) {
const cached = await this.cacheManager.get(SYSTEM_CONFIG_KEY);
if (cached) {
return cached;
}
await new Promise((resolve) => setTimeout(resolve, 200));
}
const config = await this.systemConfigRepos
.createQueryBuilder('c')
.where({ id: (0, typeorm_2.MoreThan)(0) })
.getOneOrFail();
await this.cacheManager.set(SYSTEM_CONFIG_KEY, config);
return config;
},
});
this.loadPromises.set(LOAD_LOCK_KEY, promise);
return promise;
}
async updateConfig(partial) {
const config = await this.systemConfigRepos
.createQueryBuilder('c')
.where({ id: (0, typeorm_2.MoreThan)(0) })
.getOne();
if (!config) {
throw new Error('系统配置不存在');
}
Object.assign(config, partial);
await this.systemConfigRepos.save(config);
await this.cacheManager.set(SYSTEM_CONFIG_KEY, config);
return config;
}
};
exports.SystemConfigService = SystemConfigService;
exports.SystemConfigService = SystemConfigService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, typeorm_1.InjectRepository)(system_config_model_1.SystemConfigModel)),
__param(1, (0, common_2.Inject)(cache_manager_1.CACHE_MANAGER)),
__metadata("design:paramtypes", [typeorm_2.Repository, Object, lock_service_1.DistributedLockService])
], SystemConfigService);
//# sourceMappingURL=system_config.service.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"system_config.service.js","sourceRoot":"","sources":["../../../../src/app/common/service/system_config.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,4EAAkE;AAClE,qCAA+C;AAC/C,yDAAsD;AACtD,2CAAwC;AAExC,iDAAwD;AAExD,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAC1C,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAGzC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAKpB;IACuB;IACvB;IANF,YAAY,GAAG,IAAI,GAAG,EAAsC,CAAC;IAErE,YAEU,iBAAgD,EACzB,YAAmB,EAC1C,sBAA8C;QAF9C,sBAAiB,GAAjB,iBAAiB,CAA+B;QACzB,iBAAY,GAAZ,YAAY,CAAO;QAC1C,2BAAsB,GAAtB,sBAAsB,CAAwB;IACrD,CAAC;IAMJ,KAAK,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,CAAC,CAAA;IAEnC,WAAA,IAAA,eAAM,EAAC,6BAAa,CAAC,CAAA;qCADK,oBAAU,UAEL,qCAAsB;GAP7C,mBAAmB,CA2F/B"}
+10
View File
@@ -0,0 +1,10 @@
import { Repository } from 'typeorm';
import { Cache } from 'cache-manager';
import { UserModel } from 'src/model/user.model';
export declare class UserFreezeService {
private cacheManager;
private userModel;
constructor(cacheManager: Cache, userModel: Repository<UserModel>);
isFrozen(userId: number): Promise<boolean>;
toggleFreeze(userId: number, isFrozen: number): Promise<string | null>;
}
+63
View File
@@ -0,0 +1,63 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserFreezeService = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const typeorm_2 = require("typeorm");
const cache_manager_1 = require("@nestjs/cache-manager");
const user_model_1 = require("../../../model/user.model");
const FROZEN_USER_KEY = (userId) => `frozen:user:${userId}`;
const FROZEN_USER_TTL_MS = 0;
let UserFreezeService = class UserFreezeService {
cacheManager;
userModel;
constructor(cacheManager, userModel) {
this.cacheManager = cacheManager;
this.userModel = userModel;
}
async isFrozen(userId) {
const cached = await this.cacheManager.get(FROZEN_USER_KEY(userId));
if (cached !== undefined && cached !== null) {
return cached === 1;
}
const user = await this.userModel.findOne({
where: { id: userId },
select: { isFrozen: true },
});
const isFrozen = user?.isFrozen ?? 0;
await this.cacheManager.set(FROZEN_USER_KEY(userId), isFrozen, FROZEN_USER_TTL_MS);
return isFrozen === 1;
}
async toggleFreeze(userId, isFrozen) {
const user = await this.userModel.findOneBy({ id: userId });
if (!user) {
return '用户不存在';
}
if (user.isFrozen === isFrozen) {
return isFrozen ? '用户已被冻结' : '用户已处于解冻状态';
}
await this.userModel.update({ id: userId }, { isFrozen });
await this.cacheManager.set(FROZEN_USER_KEY(userId), isFrozen, FROZEN_USER_TTL_MS);
return null;
}
};
exports.UserFreezeService = UserFreezeService;
exports.UserFreezeService = UserFreezeService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, common_1.Inject)(cache_manager_1.CACHE_MANAGER)),
__param(1, (0, typeorm_1.InjectRepository)(user_model_1.UserModel)),
__metadata("design:paramtypes", [Object, typeorm_2.Repository])
], UserFreezeService);
//# sourceMappingURL=user_freeze.service.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"user_freeze.service.js","sourceRoot":"","sources":["../../../../src/app/common/service/user_freeze.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,6CAAmD;AACnD,qCAAqC;AACrC,yDAAsD;AAEtD,0DAAiD;AAEjD,MAAM,eAAe,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,eAAe,MAAM,EAAE,CAAC;AACpE,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAGtB,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAEK;IAEvB;IAHV,YACiC,YAAmB,EAE1C,SAAgC;QAFT,iBAAY,GAAZ,YAAY,CAAO;QAE1C,cAAS,GAAT,SAAS,CAAuB;IACvC,CAAC;IAMJ,KAAK,CAAC,QAAQ,CAAC,MAAc;QAC3B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAS,eAAe,CAAC,MAAM,CAAC,CAAC,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R,WAAA,IAAA,eAAM,EAAC,6BAAa,CAAC,CAAA;IACrB,WAAA,IAAA,0BAAgB,EAAC,sBAAS,CAAC,CAAA;6CACT,oBAAU;GAJpB,iBAAiB,CAmD7B"}
+10
View File
@@ -0,0 +1,10 @@
import { UserLogModel } from 'src/model/user_log.model';
import { Repository } from 'typeorm';
export declare class UserLogService {
private userLogModel;
constructor(userLogModel: Repository<UserLogModel>);
private log;
logLogin(userId: number): Promise<void>;
logRegister(userId: number): Promise<void>;
logStarted(userId?: number): Promise<void>;
}
+54
View File
@@ -0,0 +1,54 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserLogService = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const user_log_model_1 = require("../../../model/user_log.model");
const typeorm_2 = require("typeorm");
const app_info_context_1 = require("../../api/context/app_info.context");
const help_1 = require("../util/help");
const user_id_context_1 = require("../context/user_id.context");
let UserLogService = class UserLogService {
userLogModel;
constructor(userLogModel) {
this.userLogModel = userLogModel;
}
async log(type, userId) {
userId = userId || (0, user_id_context_1.getUserIdContext)();
await this.userLogModel.insert({
type,
userId,
device: app_info_context_1.AppInfoContext.getAppInfo().device,
date: help_1.Help.formatDate(Date.now(), 'YYYY-MM-DD'),
ip: app_info_context_1.AppInfoContext.getAppInfo().ip,
});
}
logLogin(userId) {
return this.log(user_log_model_1.UserLogType.Login, userId);
}
logRegister(userId) {
return this.log(user_log_model_1.UserLogType.Register, userId);
}
logStarted(userId) {
return this.log(user_log_model_1.UserLogType.Started, userId);
}
};
exports.UserLogService = UserLogService;
exports.UserLogService = UserLogService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, typeorm_1.InjectRepository)(user_log_model_1.UserLogModel)),
__metadata("design:paramtypes", [typeorm_2.Repository])
], UserLogService);
//# sourceMappingURL=user_log.service.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"user_log.service.js","sourceRoot":"","sources":["../../../../src/app/common/service/user_log.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAIA,2CAA4C;AAC5C,6CAAmD;AACnD,kEAAqE;AACrE,qCAAqC;AACrC,yEAAoE;AACpE,uCAAgD;AAChD,gEAA0E;AAGnE,IAAM,cAAc,GAApB,MAAM,cAAc;IAGf;IAFV,YAEU,YAAsC;QAAtC,iBAAY,GAAZ,YAAY,CAA0B;IAC7C,CAAC;IACI,KAAK,CAAC,GAAG,CAAC,IAAiB,EAAE,MAAe;QAClD,MAAM,GAAG,MAAM,IAAI,IAAA,kCAAgB,GAAE,CAAC;QACtC,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;YAC7B,IAAI;YACJ,MAAM;YACN,MAAM,EAAE,iCAAc,CAAC,UAAU,EAAE,CAAC,MAAM;YAC1C,IAAI,EAAE,WAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC;YAC/C,EAAE,EAAE,iCAAc,CAAC,UAAU,EAAE,CAAC,EAAE;SACnC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ,CAAC,MAAc;QACrB,OAAO,IAAI,CAAC,GAAG,CAAC,4BAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED,WAAW,CAAC,MAAc;QACxB,OAAO,IAAI,CAAC,GAAG,CAAC,4BAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,UAAU,CAAC,MAAe;QACxB,OAAO,IAAI,CAAC,GAAG,CAAC,4BAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AA3BY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,6BAAY,CAAC,CAAA;qCACT,oBAAU;GAHvB,cAAc,CA2B1B"}
+13
View File
@@ -0,0 +1,13 @@
import { WalletBillModel, WalletBillType } from 'src/model/wallet_bill.model';
import { Repository } from 'typeorm';
export interface BalanceLogParams {
userId: number;
type: WalletBillType;
before: string;
after: string;
amount: string;
remark?: string;
}
export declare class BalanceLogHelp {
static record(walletBillRepo: Repository<WalletBillModel>, params: BalanceLogParams): Promise<void>;
}
+20
View File
@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BalanceLogHelp = void 0;
class BalanceLogHelp {
static async record(walletBillRepo, params) {
const typeStr = String(params.type);
const isExpense = typeStr.startsWith('9');
const walletBill = walletBillRepo.create({
userId: params.userId,
type: params.type,
before: params.before,
after: params.after,
amount: isExpense ? `-${params.amount}` : params.amount,
remark: params.remark,
});
await walletBillRepo.save(walletBill);
}
}
exports.BalanceLogHelp = BalanceLogHelp;
//# sourceMappingURL=balance_log_help.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"balance_log_help.js","sourceRoot":"","sources":["../../../../src/app/common/util/balance_log_help.ts"],"names":[],"mappings":";;;AAwBA,MAAa,cAAc;IAMlB,MAAM,CAAC,KAAK,CAAC,MAAM,CACxB,cAA2C,EAC3C,MAAwB;QAGxB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAE1C,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC;YACvC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM;YACvD,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC,CAAC;QACH,MAAM,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;CACF;AAxBD,wCAwBC"}
+7
View File
@@ -0,0 +1,7 @@
import { Decimal } from 'decimal.js';
export declare const DecimalHelp: {
plus(...args: Decimal.Value[]): string;
minus(...args: Decimal.Value[]): string;
times(...args: Decimal.Value[]): string;
div(...args: Decimal.Value[]): string;
};
+35
View File
@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DecimalHelp = void 0;
const decimal_js_1 = require("decimal.js");
exports.DecimalHelp = {
plus(...args) {
let decimal = new decimal_js_1.Decimal(args.shift());
args.forEach((v) => {
decimal = decimal.plus(v);
});
return decimal.toString();
},
minus(...args) {
let decimal = new decimal_js_1.Decimal(args.shift());
args.forEach((v) => {
decimal = decimal.minus(v);
});
return decimal.toString();
},
times(...args) {
let decimal = new decimal_js_1.Decimal(args.shift());
args.forEach((v) => {
decimal = decimal.times(v);
});
return decimal.toString();
},
div(...args) {
let decimal = new decimal_js_1.Decimal(args.shift());
args.forEach((v) => {
decimal = decimal.div(v);
});
return decimal.toString();
},
};
//# sourceMappingURL=decimal_help.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"decimal_help.js","sourceRoot":"","sources":["../../../../src/app/common/util/decimal_help.ts"],"names":[],"mappings":";;;AAAA,2CAAqC;AAExB,QAAA,WA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C;CACF,CAAC"}
+3
View File
@@ -0,0 +1,3 @@
export declare class FetchHelp {
static post(url: string, body: Record<string, any>): Promise<Response>;
}
+16
View File
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FetchHelp = void 0;
class FetchHelp {
static post(url, body) {
return fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
}
}
exports.FetchHelp = FetchHelp;
//# sourceMappingURL=fetch_help.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"fetch_help.js","sourceRoot":"","sources":["../../../../src/app/common/util/fetch_help.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAS;IACpB,MAAM,CAAC,IAAI,CAAC,GAAW,EAAE,IAAyB;QAChD,OAAO,KAAK,CAAC,GAAG,EAAE;YAChB,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC;CACF;AAVD,8BAUC"}
+5
View File
@@ -0,0 +1,5 @@
export declare class HashGeneratorHelp {
static generateOddOrEvenHash(isEven?: boolean): string;
static generateHash(): string;
static generateInviteCode(length?: number): string;
}
+46
View File
@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HashGeneratorHelp = void 0;
const crypto_1 = require("crypto");
const help_1 = require("./help");
class HashGeneratorHelp {
static generateOddOrEvenHash(isEven = false) {
const hash = this.generateHash().substring(0, 63);
const isLetter = help_1.Help.getRandomInt(1, 2) == 1;
if (isLetter) {
let num = help_1.Help.getRandomInt(1, 25);
if (isEven) {
num = num % 2 === 0 ? num : num + 1;
}
else {
num = num % 2 !== 0 ? num : num + 1;
}
return `${hash}${String.fromCharCode(96 + num)}`;
}
else {
let num = help_1.Help.getRandomInt(0, 8);
if (isEven) {
num = num % 2 === 0 ? num : num + 1;
}
else {
num = num % 2 !== 0 ? num : num + 1;
}
return `${hash}${num}`;
}
}
static generateHash() {
const seed = (0, crypto_1.randomBytes)(32).toString('hex');
const hash = (0, crypto_1.createHash)('sha256').update(seed).digest('hex');
return '0x' + hash;
}
static generateInviteCode(length = 6) {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
let result = '';
for (let i = 0; i < length; i++) {
result += chars.charAt(Math.floor(Math.random() * chars.length));
}
return result;
}
}
exports.HashGeneratorHelp = HashGeneratorHelp;
//# sourceMappingURL=hash_generator_help.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"hash_generator_help.js","sourceRoot":"","sources":["../../../../src/app/common/util/hash_generator_help.ts"],"names":[],"mappings":";;;AAAA,mCAAiD;AACjD,iCAA8B;AAE9B,MAAa,iBAAiB;IACrB,MAAM,CAAC,qBAAqB,CAAC,MAAM,GAAG,KAAK;QAChD,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAElD,MAAM,QAAQ,GAAG,WAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,GAAG,GAAG,WAAI,CAAC,YAAY,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnC,IAAI,MAAM,EAAE,CAAC;gBACX,GAAG,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;YACtC,CAAC;iBAAM,CAAC;gBACN,GAAG,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;YACtC,CAAC;YACD,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE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are const Help: {
getSecondTimestamp(): number;
getRandomInt(min: number, max: number): number;
getFastHshPeriods(): string;
formatDate(date: string | number | Date, template?: string): string;
diffDays(date1: string | number | Date, date2: string | number | Date): number;
phpmymd5(input: string, action?: ActionType): string | null;
};
export {};
+62
View File
@@ -0,0 +1,62 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Help = void 0;
const dayjs = require("dayjs");
const crypto_1 = require("crypto");
exports.Help = {
getSecondTimestamp() {
return Math.floor(Date.now() / 1000);
},
getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
},
getFastHshPeriods() {
return dayjs(Date.now()).format('YYYYMMDDHHmmss');
},
formatDate(date, template = 'YYYY-MM-DD HH:mm:ss') {
if (typeof date == 'number' && date.toString().length == 10) {
date *= 1000;
}
return dayjs(date).format(template);
},
diffDays(date1, date2) {
return dayjs(date1).endOf('day').diff(dayjs(date2).endOf('day'), 'day');
},
phpmymd5(input, action = 'EN') {
const secretString = `5*j,.^&;?.%#@!`;
if (!input)
return '';
let md5code;
let processingString;
if (action === 'EN') {
md5code = (0, crypto_1.createHash)('md5').update(input).digest('hex').substr(8, 10);
processingString = input;
}
else {
md5code = input.slice(-10);
processingString = Buffer.from(input.slice(0, -10), 'base64').toString('binary');
}
const key = (0, crypto_1.createHash)('md5')
.update(md5code + secretString)
.digest('hex');
const keyLength = key.length;
let result = '';
for (let i = 0; i < processingString.length; i++) {
const keyPos = i % keyLength;
result += String.fromCharCode(processingString.charCodeAt(i) ^ key.charCodeAt(keyPos));
}
if (action === 'DE') {
const verificationHash = (0, crypto_1.createHash)('md5')
.update(result)
.digest('hex')
.substr(8, 10);
return verificationHash === md5code ? result : null;
}
else {
return Buffer.from(result, 'binary').toString('base64') + md5code;
}
},
};
//# sourceMappingURL=help.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../../src/app/common/util/help.ts"],"names":[],"mappings":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E,EAAE,CAAC,CAAC;YACjB,OAAO,gBAAgB,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;QACpE,CAAC;IACH,CAAC;CACF,CAAC"}
+102
View File
@@ -0,0 +1,102 @@
export interface ResResult {
ActionStatus: 'FAIL' | 'OK';
ErrorCode: number;
ErrorInfo: string;
ErrorDisplay: string;
}
export declare class IMHelp {
static kickUser(imUid: string): Promise<ResResult>;
static updateUserProfile(imUid: string, nick: string, avatar: string): Promise<ResResult>;
static multiaccountImportUser(arr: Array<{
UserID: string;
Nick: string;
FaceUrl?: string;
}>): Promise<ResResult>;
static friendImport(imUid: string, friendImUids: Array<{
Remark?: string;
imUid: string;
}>): Promise<ResResult & {
ResultItem: Array<{
To_Account: string;
ResultCode: number;
ResultInfo: string;
}>;
Fail_Account: string[];
}>;
static createGroup(group: {
Owner_Account: string;
Type: 'Community' | 'Public';
GroupId: string;
FaceUrl: string;
Name: string;
}): Promise<ResResult & {
GroupId: string;
}>;
static getGroupInfo(GroupIdList: string[]): Promise<ResResult & {
GroupInfo: Array<{
Appid: number;
ApplyJoinOption: string;
CreateTime: number;
ErrorCode: number;
FaceUrl: string;
GroupId: string;
HistoryMsgBeforeJoin: string;
InfoSeq: number;
Introduction: string;
InviteJoinOption: string;
LastInfoTime: number;
LastMsgTime: number;
MaxMemberNum: number;
MemberList: object[];
MemberNum: number;
MuteAllMember: string;
Name: string;
NextMsgSeq: number;
Notification: "";
OnlineMemberNum: number;
Owner_Account: string;
ShutUpAllMember: string;
Type: string;
}>;
}>;
static modifyGroupBaseInfo(params: {
GroupId: string;
Name?: string;
Introduction?: string;
Notification?: string;
FaceUrl?: string;
MaxMemberNum?: number;
ApplyJoinOption?: string;
MuteAllMember?: string;
InviteJoinOption?: string;
From_Account?: string;
}): Promise<ResResult>;
static importGroupMemberExist(params: {
GroupId: string;
User_Account: string;
}): Promise<boolean>;
static importGroupMember(params: {
GroupId: string;
MemberList: Array<{
Member_Account: string;
Role?: string;
}>;
}): Promise<ResResult & {
MemberList: Array<{
Member_Account: string;
Result: 0 | 1 | 2;
}>;
}>;
static sendGroupMsg(params: {
GroupId: string;
From_Account: string;
Random: number;
MsgBody: Array<{
MsgType: 'TIMCustomElem';
MsgContent: {
Data: string;
};
}>;
}): Promise<ResResult>;
static getUrlParams(): string;
}
+115
View File
@@ -0,0 +1,115 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IMHelp = void 0;
const app_env_1 = require("../../../app.env");
const tls_sig_api_v2_typescript_1 = require("tls-sig-api-v2-typescript");
const fetch_help_1 = require("./fetch_help");
const help_1 = require("./help");
class IMHelp {
static async kickUser(imUid) {
const url = `https://console.tim.qq.com/v4/im_open_login_svc/kick?${this.getUrlParams()}`;
const res = await fetch_help_1.FetchHelp.post(url, {
UserID: imUid,
});
const json = (await res.json());
return json;
}
static async updateUserProfile(imUid, nick, avatar) {
const url = `https://console.tim.qq.com/v4/profile/portrait_set?${this.getUrlParams()}`;
const res = await fetch_help_1.FetchHelp.post(url, {
From_Account: imUid,
ProfileItem: [
{
Tag: 'Tag_Profile_IM_Nick',
Value: nick,
},
{
Tag: 'Tag_Profile_IM_Image',
Value: avatar,
},
{
Tag: 'Tag_Profile_IM_AllowType',
Value: 'AllowType_Type_NeedConfirm',
},
],
});
const json = (await res.json());
return json;
}
static async multiaccountImportUser(arr) {
const url = `https://console.tim.qq.com/v4/im_open_login_svc/multiaccount_import?${this.getUrlParams()}`;
const res = await fetch_help_1.FetchHelp.post(url, {
AccountList: arr,
});
const json = (await res.json());
return json;
}
static async friendImport(imUid, friendImUids) {
const url = `https://console.tim.qq.com/v4/sns/friend_import?${this.getUrlParams()}`;
const res = await fetch_help_1.FetchHelp.post(url, {
From_Account: imUid,
AddFriendItem: friendImUids.map((item) => {
return {
To_Account: item.imUid,
Remark: item.Remark,
AddSource: 'AddSource_Type_Web',
};
}),
});
const json = (await res.json());
return json;
}
static async createGroup(group) {
const url = `https://console.tim.qq.com/v4/group_open_http_svc/create_group?${this.getUrlParams()}`;
const res = await fetch_help_1.FetchHelp.post(url, group);
const json = (await res.json());
return json;
}
static async getGroupInfo(GroupIdList) {
const url = `https://console.tim.qq.com/v4/group_open_http_svc/get_group_info?${this.getUrlParams()}`;
const res = await fetch_help_1.FetchHelp.post(url, {
GroupIdList,
});
const json = (await res.json());
return json;
}
static async modifyGroupBaseInfo(params) {
const url = `https://console.tim.qq.com/v4/group_open_http_svc/modify_group_base_info?${this.getUrlParams()}`;
const res = await fetch_help_1.FetchHelp.post(url, params);
const json = (await res.json());
return json;
}
static async importGroupMemberExist(params) {
const url = `https://console.tim.qq.com/v4/group_open_http_svc/get_role_in_group?${this.getUrlParams()}`;
const res = await fetch_help_1.FetchHelp.post(url, {
GroupId: params.GroupId,
User_Account: [params.User_Account],
});
const json = (await res.json());
return (json.ErrorCode == 0 &&
json.UserIdList.length > 0 &&
json.UserIdList[0].Role != 'NotMember');
}
static async importGroupMember(params) {
const url = `https://console.tim.qq.com/v4/group_open_http_svc/import_group_member?${this.getUrlParams()}`;
const res = await fetch_help_1.FetchHelp.post(url, params);
const json = (await res.json());
return json;
}
static async sendGroupMsg(params) {
const url = `https://console.tim.qq.com/v4/group_open_http_svc/send_group_msg?${this.getUrlParams()}`;
const res = await fetch_help_1.FetchHelp.post(url, params);
const json = (await res.json());
return json;
}
static getUrlParams() {
const api = new tls_sig_api_v2_typescript_1.Api(app_env_1.AppEnv.IM_APP_ID, app_env_1.AppEnv.IM_SECRET_KEY);
const random = help_1.Help.getRandomInt(0, 4294967295);
const expire = 86400 * 180;
const sign = api.genSig(app_env_1.AppEnv.IM_APP_IDENTIFIER, expire);
const params = `sdkappid=${app_env_1.AppEnv.IM_APP_ID}&identifier=${app_env_1.AppEnv.IM_APP_IDENTIFIER}&usersig=${sign}&random=${random}&contenttype=json`;
return params;
}
}
exports.IMHelp = IMHelp;
//# sourceMappingURL=im_help.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"im_help.js","sourceRoot":"","sources":["../../../../src/app/common/util/im_help.ts"],"names":[],"mappings":";;;AACA,8CAAqC;AACrC,yEAA+D;AAC/D,6CAAyC;AACzC,iCAA8B;AAS9B,MAAa,MAAM;IAEV,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAa;QACxC,MAAM,GAAG,GAAG,wDAAwD,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QAC1F,MAAM,GAAG,GAAG,MAAM,sBAAS,CAAC,IAAI,CAAC,GAAG,EAAE;YACpC,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAc,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,iBAAiB,CACnC,KAAa,EACb,IAAY,EACZ,MAAc;QAEd,MAAM,GAAG,GAAG,sDAAsD,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QACxF,MAAM,GAAG,GAAG,MAAM,sBAAS,CAAC,IAAI,CAAC,GAAG,EAAE;YACpC,YAAY,EAAE,KAAK;YACnB,WAAW,EAAE;gBACX;oBACE,GAAG,EAAE,qBAAqB;oBAC1B,KAAK,EAAE,IAAI;iBACZ;gBACD;oBACE,GAAG,EAAE,sBAAsB;oBAC3B,KAAK,EAAE,MAAM;iBACd;gBACD;oBACE,GAAG,EAAE,0BAA0B;oBAC/B,KAAK,EAAE,4BAA4B;iBACpC;aACF;SACF,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAc,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAGM,MAAM,CAAC,KAAK,CAAC,sBAAsB,CACx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;QAC3G,MAAM,GAAG,GAAG,MAAM,sBAAS,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC9C,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAK7B,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAUhC;QACC,MAAM,GAAG,GAAG,oEAAoE,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QACtG,MAAM,GAAG,GAAG,MAAM,sBAAS,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC9C,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAc,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,YAAY;QACxB,MAAM,GAAG,GAAG,IAAI,+BAAW,CAAC,gBAAM,CAAC,SAAS,EAAE,gBAAM,CAAC,aAAa,CAAC,CAAC;QACpE,MAAM,MAAM,GAAG,WAAI,CAAC,YAAY,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,KAAK,GAAG,GAAG,CAAC;QAC3B,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,gBAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,YAAY,gBAAM,CAAC,SAAS,eAAe,gBAAM,CAAC,iBAAiB,YAAY,IAAI,WAAW,MAAM,mBAAmB,CAAC;QAEvI,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AArND,wBAqNC"}
+7
View File
@@ -0,0 +1,7 @@
export declare class OrderNoGenerator {
static generate(): string;
static generateWithPrefix(prefix: string): string;
static generateInnerOrderNo(): string;
private static formatDate;
private static getRandomString;
}
+38
View File
@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrderNoGenerator = void 0;
class OrderNoGenerator {
static generate() {
const now = new Date();
const dateStr = this.formatDate(now);
const randomStr = this.getRandomString(6);
return `${dateStr}${randomStr}`;
}
static generateWithPrefix(prefix) {
const now = new Date();
const dateStr = this.formatDate(now);
const randomStr = this.getRandomString(6);
return `${prefix}${dateStr}${randomStr}`;
}
static generateInnerOrderNo() {
return this.generateWithPrefix('INN');
}
static formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}${month}${day}${hours}${minutes}${seconds}`;
}
static getRandomString(length) {
let result = '';
for (let i = 0; i < length; i++) {
result += Math.floor(Math.random() * 10).toString();
}
return result;
}
}
exports.OrderNoGenerator = OrderNoGenerator;
//# sourceMappingURL=order_no_generator.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"order_no_generator.js","sourceRoot":"","sources":["../../../../src/app/common/util/order_no_generator.ts"],"names":[],"mappings":";;;AAGA,MAAa,gBAAgB;IAMpB,MAAM,CAAC,QAAQ;QACpB,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAC1C,OAAO,GAAG,OAAO,GAAG,SAAS,EAAE,CAAC;IAClC,CAAC;IAMM,MAAM,CAAC,kBAAkB,CAAC,MAAc;QAC7C,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAC1C,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,S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B,CAAC;CACF;AAvDD,4CAuDC"}
+15
View File
@@ -0,0 +1,15 @@
import { FindManyOptions, FindOptionsWhere, ObjectLiteral, Repository } from 'typeorm';
import { PaginatedDto } from '../api';
import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
export declare class RepositoryHelp {
static update<Entity extends ObjectLiteral>(repos: Repository<Entity>, where: FindOptionsWhere<Entity>, entity: QueryDeepPartialEntity<Entity>): Promise<number | undefined>;
static finePaginatedData<Entity extends ObjectLiteral>(repos: Repository<Entity>, dto: PaginatedDto, options?: FindManyOptions<Entity>): Promise<Entity[]>;
static findPaginated<Entity extends ObjectLiteral>(repos: Repository<Entity>, dto: PaginatedDto, options?: FindManyOptions<Entity>): Promise<{
data: Entity[];
total: number;
}>;
static paginatedDtoToSkipAndTake(dto: PaginatedDto): {
skip: number;
take: number;
};
}
+37
View File
@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RepositoryHelp = void 0;
class RepositoryHelp {
static async update(repos, where, entity) {
const result = await repos.update(where, entity);
return result.affected;
}
static finePaginatedData(repos, dto, options) {
const skipAndTake = this.paginatedDtoToSkipAndTake(dto);
return repos.find({
...options,
skip: skipAndTake.skip,
take: skipAndTake.take,
});
}
static async findPaginated(repos, dto, options) {
const skipAndTake = this.paginatedDtoToSkipAndTake(dto);
const [data, total] = await repos.findAndCount({
...options,
skip: skipAndTake.skip,
take: skipAndTake.take,
});
return { data, total };
}
static paginatedDtoToSkipAndTake(dto) {
const page = dto.page || 1;
const size = dto.size || 15;
const skip = (page - 1) * size;
return {
skip,
take: size,
};
}
}
exports.RepositoryHelp = RepositoryHelp;
//# sourceMappingURL=repository_help.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"repository_help.js","sourceRoot":"","sources":["../../../../src/app/common/util/repository_help.ts"],"names":[],"mappings":";;;AASA,MAAa,cAAc;IAQlB,MAAM,CAAC,KAAK,CAAC,MAAM,CACxB,KAAyB,EACzB,K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elp: {
checkMessageSignatureAddres(message: string, signature: `0x${string}` | ByteArray | Signature, address: string): Promise<boolean>;
};
+19
View File
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wagmiAddressHelp = void 0;
const viem_1 = require("viem");
exports.wagmiAddressHelp = {
async checkMessageSignatureAddres(message, signature, address) {
try {
const recoveredAddress = await (0, viem_1.recoverMessageAddress)({
message,
signature,
});
return recoveredAddress.toLowerCase() === address.toLowerCase();
}
catch {
return false;
}
},
};
//# sourceMappingURL=wagmi_address_help.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"wagmi_address_help.js","sourceRoot":"","sources":["../../../../src/app/common/util/wagmi_address_help.ts"],"names":[],"mappings":";;;AAAA,+BAAmE;AAWtD,QAAA,gBAAgB,GAAG;IAC9B,KAAK,CAAC,2BAA2B,CAC/B,OAAe,EACf,SAAgD,EAChD,OAAe;QAEf,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,MAAM,IAAA,4BAAqB,EAAC;gBACnD,OAAO;gBACP,SAAS;aACV,CAAC,CAAC;YACH,OAAO,gBAAgB,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC;QAClE,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAC"}
+4
View File
@@ -0,0 +1,4 @@
export declare class CaptchaVo {
svg: string;
key: string;
}

Some files were not shown because too many files have changed in this diff Show More