mirror of
https://github.com/vastxie/99AI.git
synced 2025-11-12 11:43:42 +08:00
v-4.0.0 开源可二开源码
This commit is contained in:
@@ -13,13 +13,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GlobalConfigController = void 0;
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const setConfig_dto_1 = require("./dto/setConfig.dto");
|
||||
const globalConfig_service_1 = require("./globalConfig.service");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const queryConfig_dto_1 = require("./dto/queryConfig.dto");
|
||||
const adminAuth_guard_1 = require("../../common/auth/adminAuth.guard");
|
||||
const superAuth_guard_1 = require("../../common/auth/superAuth.guard");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const queryConfig_dto_1 = require("./dto/queryConfig.dto");
|
||||
const setConfig_dto_1 = require("./dto/setConfig.dto");
|
||||
const globalConfig_service_1 = require("./globalConfig.service");
|
||||
let GlobalConfigController = class GlobalConfigController {
|
||||
constructor(globalConfigService) {
|
||||
this.globalConfigService = globalConfigService;
|
||||
@@ -30,12 +30,6 @@ let GlobalConfigController = class GlobalConfigController {
|
||||
queryFrontConfig(query, req) {
|
||||
return this.globalConfigService.queryFrontConfig(query, req);
|
||||
}
|
||||
queryGptKeys(req) {
|
||||
return this.globalConfigService.queryGptKeys(req);
|
||||
}
|
||||
setGptKeys(body) {
|
||||
return this.globalConfigService.setGptKeys(body);
|
||||
}
|
||||
queryConfig(body, req) {
|
||||
return this.globalConfigService.queryConfig(body, req);
|
||||
}
|
||||
@@ -45,9 +39,6 @@ let GlobalConfigController = class GlobalConfigController {
|
||||
queryNotice() {
|
||||
return this.globalConfigService.queryNotice();
|
||||
}
|
||||
getCopyright() {
|
||||
return this.globalConfigService.getCopyright();
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, swagger_1.ApiOperation)({ summary: '查询所有配置' }),
|
||||
@@ -68,26 +59,6 @@ __decorate([
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], GlobalConfigController.prototype, "queryFrontConfig", null);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiOperation)({ summary: '查询所有gpt的key' }),
|
||||
(0, common_1.Get)('queryGptKeys'),
|
||||
(0, common_1.UseGuards)(adminAuth_guard_1.AdminAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], GlobalConfigController.prototype, "queryGptKeys", null);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiOperation)({ summary: '设置gpt的key' }),
|
||||
(0, common_1.Post)('setGptKeys'),
|
||||
(0, common_1.UseGuards)(superAuth_guard_1.SuperAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], GlobalConfigController.prototype, "setGptKeys", null);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiOperation)({ summary: '查询所有配置' }),
|
||||
(0, common_1.Post)('query'),
|
||||
@@ -116,13 +87,6 @@ __decorate([
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], GlobalConfigController.prototype, "queryNotice", null);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiOperation)({ summary: '管理端查询版权信息' }),
|
||||
(0, common_1.Get)('copyright'),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], GlobalConfigController.prototype, "getCopyright", null);
|
||||
GlobalConfigController = __decorate([
|
||||
(0, swagger_1.ApiTags)('config'),
|
||||
(0, common_1.Controller)('config'),
|
||||
|
||||
@@ -130,7 +130,6 @@ let GlobalConfigService = class GlobalConfigService {
|
||||
}
|
||||
async queryFrontConfig(query, req) {
|
||||
const allowKeys = [
|
||||
'vxNumber',
|
||||
'registerSendStatus',
|
||||
'registerSendModel3Count',
|
||||
'registerSendModel4Count',
|
||||
@@ -140,13 +139,6 @@ let GlobalConfigService = class GlobalConfigService {
|
||||
'firstRregisterSendModel3Count',
|
||||
'firstRregisterSendModel4Count',
|
||||
'firstRregisterSendDrawMjCount',
|
||||
'inviteSendStatus',
|
||||
'inviteGiveSendModel3Count',
|
||||
'inviteGiveSendModel4Count',
|
||||
'inviteGiveSendDrawMjCount',
|
||||
'invitedGuestSendModel3Count',
|
||||
'invitedGuestSendModel4Count',
|
||||
'invitedGuestSendDrawMjCount',
|
||||
'clientHomePath',
|
||||
'clientLogoPath',
|
||||
'clientFavoIconPath',
|
||||
@@ -187,7 +179,6 @@ let GlobalConfigService = class GlobalConfigService {
|
||||
'mjHideNotBlock',
|
||||
'mjHideWorkIn',
|
||||
'isVerifyEmail',
|
||||
'isHideSidebar',
|
||||
'showWatermark',
|
||||
'isHideTts',
|
||||
'isHideDefaultPreset',
|
||||
@@ -202,6 +193,9 @@ let GlobalConfigService = class GlobalConfigService {
|
||||
'noVerifyRegister',
|
||||
'noticeInfo',
|
||||
'homeHtml',
|
||||
'isAutoOpenAgreement',
|
||||
'agreementInfo',
|
||||
'agreementTitle',
|
||||
];
|
||||
const data = await this.configEntity.find({
|
||||
where: { configKey: (0, typeorm_2.In)(allowKeys) },
|
||||
@@ -224,42 +218,6 @@ let GlobalConfigService = class GlobalConfigService {
|
||||
const isUseWxLogin = !!(wechatOfficialAppId && wechatOfficialAppSecret);
|
||||
return Object.assign(Object.assign({}, publicConfig), { isUseWxLogin });
|
||||
}
|
||||
async queryGptKeys(req) {
|
||||
const { role } = req.user;
|
||||
const data = await this.configEntity.find({
|
||||
where: { configKey: (0, typeorm_2.Like)(`%${'chatGptKey'}%`) },
|
||||
});
|
||||
if (role === 'super')
|
||||
return data;
|
||||
return data.map((t) => {
|
||||
t.configVal = (0, utils_1.hideString)(t.configVal);
|
||||
return t;
|
||||
});
|
||||
}
|
||||
async setGptKeys(body) {
|
||||
const effectiveConfig = body.configs.filter((t) => t.configVal);
|
||||
const keys = effectiveConfig.map((t) => t.configKey);
|
||||
for (const [index, value] of effectiveConfig.entries()) {
|
||||
const { configKey, configVal, status } = value;
|
||||
await this.createOrUpdate({
|
||||
configKey: `chatGptKey:${index + 1}`,
|
||||
configVal,
|
||||
status,
|
||||
});
|
||||
}
|
||||
const likeChatGptKeys = await this.configEntity.find({
|
||||
where: { configKey: (0, typeorm_2.Like)(`%${'chatGptKey'}%`) },
|
||||
});
|
||||
const allKey = likeChatGptKeys.map((t) => t.configKey);
|
||||
if (allKey.length > keys.length) {
|
||||
const diffKey = (0, utils_1.getDiffArray)(allKey.length, keys.length, 'chatGptKey:');
|
||||
for (const key of diffKey) {
|
||||
await this.configEntity.delete({ configKey: key });
|
||||
}
|
||||
}
|
||||
await this.initGetAllConfig();
|
||||
return '操作完成!';
|
||||
}
|
||||
async queryConfig(body, req) {
|
||||
const { role } = req.user;
|
||||
const { keys } = body;
|
||||
@@ -346,9 +304,6 @@ let GlobalConfigService = class GlobalConfigService {
|
||||
async queryNotice() {
|
||||
return await this.getConfigs(['noticeInfo', 'noticeTitle']);
|
||||
}
|
||||
async getCopyright() {
|
||||
return await this.getConfigs(['copyrightUrl', 'copyrightTitle']);
|
||||
}
|
||||
async queryPayType() {
|
||||
const { payHupiStatus = 0, payEpayStatus = 0, payWechatStatus = 0, payMpayStatus = 0, payLtzfStatus = 0, } = await this.getConfigs([
|
||||
'payHupiStatus',
|
||||
@@ -383,14 +338,12 @@ let GlobalConfigService = class GlobalConfigService {
|
||||
}
|
||||
}
|
||||
async getAuthInfo() {
|
||||
const { siteName, qqNumber, vxNumber, registerBaseUrl, domain } = await this.getConfigs([
|
||||
const { siteName, registerBaseUrl, domain } = await this.getConfigs([
|
||||
'siteName',
|
||||
'qqNumber',
|
||||
'vxNumber',
|
||||
'registerBaseUrl',
|
||||
'domain',
|
||||
]);
|
||||
return { siteName, qqNumber, vxNumber, registerBaseUrl, domain };
|
||||
return { siteName, registerBaseUrl, domain };
|
||||
}
|
||||
async getPhoneVerifyConfig() {
|
||||
const { phoneLoginStatus, aliPhoneAccessKeyId, aliPhoneAccessKeySecret, aliPhoneSignName, aliPhoneTemplateCode, } = await this.getConfigs([
|
||||
|
||||
Reference in New Issue
Block a user