mirror of
https://github.com/vastxie/99AI.git
synced 2025-10-20 08:33:43 +08:00
v-4.0.0 开源可二开源码
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ logs
|
||||
pnpm-lock.yaml
|
||||
.env
|
||||
/public/file
|
||||
.DS_Store
|
195
README.md
195
README.md
@@ -1,6 +1,8 @@
|
||||
# 99 AI 稳定版
|
||||
|
||||
可商业化的 AI Web 应用,旨在提供一个易部署、低门槛的集成化人工智能服务站点。已编译为整合包,支持多种方式快速部署。
|
||||
可商业化的 AI Web 应用,旨在提供一个易部署、低门槛的集成化人工智能服务站点,支持多种部署方式。
|
||||
|
||||
源码可商用,支持二开及分发,但不要仅改名后割韭菜,尽量保留[出处](https://github.com/vastxie/99AI),有兴趣的小伙伴可共同维护。
|
||||
|
||||
## 项目介绍
|
||||
|
||||
@@ -14,9 +16,15 @@
|
||||
|
||||
<img width="1443" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/e1f1ed62-97e5-4412-9b72-5916d2337fdc">
|
||||
|
||||
- [x] **应用广场**
|
||||
- [x] **全模型文件分析**
|
||||
|
||||

|
||||
<img width="1444" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/eedfd9fd-f3f3-4a37-8a82-b73e135e8dfe">
|
||||
|
||||
- [x] **代码预览**: `HTML` 代码的预览与编辑。
|
||||
|
||||
<img width="1444" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/d7860dbf-0897-4f26-9d70-d304a270c05a">
|
||||
|
||||
<img width="1444" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/13e558fa-62a8-4fff-9e2b-c4820acefbc4">
|
||||
|
||||
- [x] **联网搜索**:对接[插件系统](https://github.com/vastxie/99AIPlugin),拓展 AI 功能边界。
|
||||
|
||||
@@ -38,11 +46,13 @@
|
||||
|
||||
<img width="1445" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/a2e42201-fad7-4498-9fb0-c107fcc2f683">
|
||||
|
||||
<img width="1446" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/62e466d0-7866-4efb-b28e-03f6b088d043">
|
||||
|
||||
- [x] **AI 视频**:对接 `luma-video` 文生视频。
|
||||
|
||||
<img width="1446" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/365cc93e-6fc0-4107-ac4c-6b25f31f0f12">
|
||||
|
||||
### 开发版支持
|
||||
<img width="1443" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/734013e1-273b-4655-b18e-a8f138165130">
|
||||
|
||||
- [x] **知识库预设**
|
||||
|
||||
@@ -52,183 +62,20 @@
|
||||
|
||||
<img width="1443" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/a341dc07-cd83-4594-bff7-c5b784f41eb1">
|
||||
|
||||
- [x] **AI 音乐弹窗**:支持调整歌词,选择音乐类型及风格。
|
||||
|
||||
<img width="1446" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/62e466d0-7866-4efb-b28e-03f6b088d043">
|
||||
|
||||
- [x] **更丰富的 AI 视频选项**:支持图生视频,视频尺寸的选择。
|
||||
|
||||
<img width="1443" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/734013e1-273b-4655-b18e-a8f138165130">
|
||||
|
||||
- [x] **代码预览**: `HTML` 代码的预览与编辑。
|
||||
|
||||
<img width="1444" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/d7860dbf-0897-4f26-9d70-d304a270c05a">
|
||||
|
||||
<img width="1444" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/13e558fa-62a8-4fff-9e2b-c4820acefbc4">
|
||||
|
||||
- [x] **全模型文件分析**
|
||||
|
||||
<img width="1444" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/eedfd9fd-f3f3-4a37-8a82-b73e135e8dfe">
|
||||
|
||||
- 本地化存储。
|
||||
- UI 调整与美化。
|
||||
- 更多功能持续开发中 ··· ···
|
||||
|
||||
<details>
|
||||
|
||||
<summary>不再维护的页面</summary>
|
||||
|
||||
**专业绘图**
|
||||
|
||||

|
||||
|
||||
**绘画广场**
|
||||
|
||||

|
||||
|
||||
**分销邀请**
|
||||
|
||||

|
||||
</details>
|
||||
- [x] 更多功能持续开发中 ··· ···
|
||||
|
||||
## 版本说明
|
||||
|
||||
| 特性 | 稳定版 | 开发版 |
|
||||
| :--------- | :--------------------------- | :--------------------------- |
|
||||
| 项目功能 | 详见项目介绍 | 有一定的保留功能 |
|
||||
| 更新频率 | 月更 | 周更 |
|
||||
| 商用许可 | 可直接商用 | 可直接商用 |
|
||||
| 部署方式 | Node.js / Docker-compose | Node.js / Docker-compose |
|
||||
| 编译状态 | 前端混淆编译,后端非混淆编译 | 前端混淆编译,后端非混淆编译 |
|
||||
| 未编译源码 | 暂不开源 | 暂不开源 |
|
||||
| 授权要求 | 无需授权 | 无需授权 |
|
||||
| 获取方式 | 本项目即为稳定版 | 赞助获取 |
|
||||
|
||||
## 更新日志
|
||||
|
||||
### 稳定版 v3.7.0
|
||||
|
||||
- 新增代码预览~~及编辑~~弹窗(HTML 格式)。
|
||||
- 新增问题编辑及重新生成功能。
|
||||
- 新增全模型文件分析功能 (模型设置-文件上传类型),选择后对于非图片的文本格式,将读取文件内容,作为 system 传给 AI,图片按 4o 格式传图。(建议搭配 token 关联计费及 `gpt-4o-mini` 使用)
|
||||
- 新增 Luma 视频图生视频,视频尺寸选择。
|
||||
- 取消注册验证码,改为获取 邮箱/手机 验证码时滑动验证。
|
||||
- 优化新建对话、对话中断、切换对话的逻辑。取消旧的初始新建对话页,可直接提问,或使用预设。AI回复中,禁止切换对话和开启新对话。
|
||||
- 对话页应用广场改为弹窗方式。
|
||||
- 调整暗色模式 UI 显示,整体显示更美观。
|
||||
- 调整购买套餐弹窗样式。
|
||||
- 后台显示设置新增 `显示全局水印` 选项,开启后将在对话页显示基于用户ID的水印。
|
||||
- 后台插件显示-基础显示,新增 `隐藏插件` 选项,开启后,用户端将隐藏插件功能。
|
||||
- 环境变量新增自定义后台路径设置,后台地址可自行使用 `/admin` 之外的的路径。
|
||||
- 新增自定义欢迎页,跳转样式参考:
|
||||
```html
|
||||
<button class="button" onclick="goToChat()">开始对话</button>
|
||||
<script>
|
||||
function goToChat() {
|
||||
window.parent.postMessage('goToChat', '*');
|
||||
}
|
||||
</script>
|
||||
```
|
||||
- ~~后台新增本地存储(开启后将优先使用本地存储方式保存数据,有些场景需开启跨域访问,可能需额外自行解决读写权限问题。文件存储目录为 `/public/file`,更新迁移时请做好数据维护及备份。)~~
|
||||
- ~~开启本地存储后,生成的视频及音乐将默认保存到本地。~~
|
||||
- ~~新增知识库问答【数据管理】-【内容预设】。通过检测提问关键词,将匹配到的内容附加到 `system` 参数中。~~
|
||||
- ~~Midjourney 绘图适配 `describe` ,支持以图生文。~~
|
||||
- ~~Suno 音乐新增调整歌词,选择音乐类型及风格。~~
|
||||
|
||||
注:划线部分为开发版保留功能。
|
||||
|
||||
<details>
|
||||
|
||||
<summary>历史日志</summary>
|
||||
|
||||
### 稳定版 v3.5.0
|
||||
|
||||
主要更新内容:
|
||||
|
||||
- 对话 UI 参考 ChatGPT 官网调整为左右布局。
|
||||
- 全新的[插件系统](https://github.com/vastxie/99AIPlugin)
|
||||
- 普通插件:联网搜索、思维导图。
|
||||
- 内置插件:Midjourney 绘图、Dalle 绘图、Stable-Diffusion 绘图、Suno 音乐、Luma 视频。
|
||||
- 统一后台 UI 样式,增加更详细的设置说明。
|
||||
- 优化调整多处 UI 界面显示。
|
||||
- 新增模型自定义图标及介绍。
|
||||
- 提问输入框支持通过剪切板粘贴图片,文件。
|
||||
- 对话显示公式渲染适配 `/[ /]`、`/( /)` 格式。
|
||||
- 新增对话中使用 `@` 调用应用功能。
|
||||
- 优化首页“九宫格”显示(使用内置对话预设、不再依赖后端配置)
|
||||
- Midjourney 绘图支持 `图生图`、`人脸一致性`、`风格一致性`、`MJ版本`自定义参数等自定义选择。
|
||||
|
||||
### 稳定版 v3.3.0
|
||||
|
||||
- 重构流式回复逻辑,加入错误反馈并优化用户端等待动画。
|
||||
- 调整文档显示 UI,提升视觉体验。
|
||||
- 新增 AI 回复 TTS 播报功能【后台模型管理-模型设置-添加特殊模型 `tts-1` 】。
|
||||
- 对话页新增 Dalle 绘图风格选择与连续对话绘画选项,配置入口:后台模型管理-绘画设置-Dalle 绘图配置。
|
||||
- 新增对话页 Midjourney 图片尺寸及风格选择功能。
|
||||
- 重构应用广场 UI,注意:**本次升级可能会导致应用广场图片丢失,请务必提前备份**。
|
||||
- 优化侧边栏显示,现支持应用收藏,允许同一应用开启多个对话窗口。
|
||||
- 新增 `GPTs` 适配及应用固定模型功能,需先在后台添加 `GPTs` 模型后进行设置。
|
||||
- 创意模型 【后台模型管理-模型设置-添加创意模型】现已针对以下模型特别优化:
|
||||
- 【dalle-e-3】(OpenAI 格式)
|
||||
- 【midjourney】(Mj-Plus 格式)
|
||||
- 【stable-diffusion】([LightAI API](https://api.lightai.io) 中转格式)
|
||||
- 【suno】([LightAI API](https://api.lightai.io) 中转格式)
|
||||
- 邮箱 SMTP 配置已迁移至后台【用户管理-邮件登录配置】,同时【基础配置】新增网页链接选项,增强发信显示效果。
|
||||
- 重构应用逻辑,翻译及导图特殊模型不再需配置,已整合至【模型管理-系统应用】。
|
||||
- 新增模型配置选项,允许设置模型调用频率限制,确保用户体验。
|
||||
|
||||
### v3.0.0
|
||||
|
||||
**前端改进**
|
||||
|
||||
- 对话页 UI 重构,参考 ChatGPT 风格,增加美观度。
|
||||
- 新增对话页 Midjourney 绘图功能,包括绘画进度反馈及点按操作。
|
||||
- Dalle 绘图支持模型绘画比例选择(方形/宽屏/垂直)。
|
||||
- 绘图页面新增区域重绘功能。
|
||||
- 全局字体优先使用系统默认,优化阅读体验。
|
||||
- 适配 ALL 模型及 GPTs 返回图片,修正显示过大的问题。
|
||||
- 对话页根据模型自动展示 AI 头像,可手动替换文件。
|
||||
|
||||
**后台配置调整**
|
||||
|
||||
- 模型配置迁移到模型管理,分普通对话/绘画/特殊模型。
|
||||
- 后台支持模型文件上传模块开关,区分 ALL/4V 格式。
|
||||
- 后台新增 Midjourney 提示词优化开关及优化词配置。
|
||||
|
||||
**注意**
|
||||
|
||||
- 重要:旧版 Midjourney 配置不再生效,需在模型配置绘画模型中重新配置。
|
||||
- 模型配置支持扣除积分类型选择。
|
||||
- 后台管理菜单重新排版,精简非必要配置。
|
||||
|
||||
### v2.6.0
|
||||
|
||||
1. **新增 mj-proxy-plus 支持**:支持[第三方](https://api.lightai.io)中转,添加容错和重试机制。(可联系作者获得 mj-proxy-plus 支持)。
|
||||
2. **简化模型配置流程**:精简了 Midjourney 模型的配置要求,现在用户仅需填写地址和 key 即可完成后台配置,简化了操作步骤。
|
||||
3. **新增模型排序**:引入了新的模型排序功能,优化了模型排序逻辑,以提升用户的操作体验。
|
||||
4. **DALL-E 绘图功能整合**:DALL-E 绘图功能现在可以在 Chat 组件内直接使用,DALL-E-3 模型可以在后台进行单独配置。
|
||||
5. **注意事项**:本次升级 Midjourney 对历史数据不兼容,在升级前请做好数据备份,以防数据丢失。
|
||||
|
||||
### v2.5.0
|
||||
|
||||
1. **GPT-4V(gpt-4-1106-vision-preview)模型识图功能**:添加了 GPT-4V 的图像识别功能,增强了模型的多媒体处理能力。
|
||||
2. **文件上传预览及显示美化**:对文件上传预览及显示进行了美化,目前仅支持 4V 和 ALL 模型。
|
||||
3. **简化模型切换逻辑**:简化了模型切换逻辑,支持更多国内模型。该功能需搭配类 OneAPI 的中转管理使用。
|
||||
4. **Chat 页面 UI 精简和美化**:对 Chat 页面进行了精简和美化。请注意,其他页面尚未进行同步优化,因此在多界面切换时可能会有一定的割裂感。后续将继续对其他页面进行优化。
|
||||
|
||||
### v2.4.5
|
||||
|
||||
1. 部分页面 UI 精简。
|
||||
2. 管理端地址改为 `/admin`,默认密码均设为 `123456`。
|
||||
3. 支持使用 GPT-4-All(第三方逆向)解析上传的文件、图片。
|
||||
4. 增加模型关联 Token 计费(可选)。
|
||||
5. MJ 版本默认调整为 v6.0。
|
||||
|
||||
</details>
|
||||
| :----------- | :--------------------------------------------- | :--------------------------------------------------------- |
|
||||
| **商用许可** | 支持商用 | 支持商用 |
|
||||
| **源码状态** | 未编译,支持自由修改 | 已编译,代码不可二次开发 |
|
||||
| **获取方式** | 公开项目 | 私有库,需赞助后获取 |
|
||||
| **页面特性** | 单对话页面 | 包含更多功能页面(如独立的绘画页面、思维导图页面、分销页面等) |
|
||||
|
||||
## 安装部署
|
||||
|
||||
安装文档可能不是非常详细,但绝对够用。如果在安装或配置中遇到任何问题,可以询问 AI、通过 [issue](https://github.com/vastxie/99AI/issues) 反馈或交流群内提问题,以获得更多帮助和支持。
|
||||
安装文档可能不是非常详细,但绝对够用。如果在安装或配置中遇到任何问题,可询问 AI、通过 [issue](https://github.com/vastxie/99AI/issues) 反馈或交流群内提问题。
|
||||
|
||||
### Node.js 部署
|
||||
|
||||
|
10
dist/app.module.js
vendored
10
dist/app.module.js
vendored
@@ -17,22 +17,19 @@ const path_1 = require("path");
|
||||
const app_module_1 = require("./modules/app/app.module");
|
||||
const auth_module_1 = require("./modules/auth/auth.module");
|
||||
const autoreply_module_1 = require("./modules/autoreply/autoreply.module");
|
||||
const badwords_module_1 = require("./modules/badwords/badwords.module");
|
||||
const badWords_module_1 = require("./modules/badWords/badWords.module");
|
||||
const chat_module_1 = require("./modules/chat/chat.module");
|
||||
const chatGroup_module_1 = require("./modules/chatGroup/chatGroup.module");
|
||||
const chatLog_module_1 = require("./modules/chatLog/chatLog.module");
|
||||
const crami_module_1 = require("./modules/crami/crami.module");
|
||||
const database_module_1 = require("./modules/database/database.module");
|
||||
const globalConfig_module_1 = require("./modules/globalConfig/globalConfig.module");
|
||||
const menu_module_1 = require("./modules/menu/menu.module");
|
||||
const midjourney_module_1 = require("./modules/midjourney/midjourney.module");
|
||||
const models_module_1 = require("./modules/models/models.module");
|
||||
const official_module_1 = require("./modules/official/official.module");
|
||||
const order_module_1 = require("./modules/order/order.module");
|
||||
const pay_module_1 = require("./modules/pay/pay.module");
|
||||
const plugin_module_1 = require("./modules/plugin/plugin.module");
|
||||
const redisCache_module_1 = require("./modules/redisCache/redisCache.module");
|
||||
const sales_module_1 = require("./modules/sales/sales.module");
|
||||
const signin_module_1 = require("./modules/signin/signin.module");
|
||||
const statistic_module_1 = require("./modules/statistic/statistic.module");
|
||||
const task_module_1 = require("./modules/task/task.module");
|
||||
@@ -75,18 +72,15 @@ AppModule = __decorate([
|
||||
redisCache_module_1.RedisCacheModule,
|
||||
globalConfig_module_1.GlobalConfigModule,
|
||||
statistic_module_1.StatisticModule,
|
||||
badwords_module_1.BadwordsModule,
|
||||
badWords_module_1.BadWordsModule,
|
||||
autoreply_module_1.AutoreplyModule,
|
||||
app_module_1.AppModule,
|
||||
pay_module_1.PayModule,
|
||||
order_module_1.OrderModule,
|
||||
official_module_1.OfficialModule,
|
||||
task_module_1.TaskModule,
|
||||
midjourney_module_1.MidjourneyModule,
|
||||
chatGroup_module_1.ChatGroupModule,
|
||||
sales_module_1.SalesModule,
|
||||
signin_module_1.SigninModule,
|
||||
menu_module_1.MenuModule,
|
||||
models_module_1.ModelsModule,
|
||||
],
|
||||
providers: [
|
||||
|
25
dist/common/filters/allExceptions.filter.js
vendored
25
dist/common/filters/allExceptions.filter.js
vendored
@@ -14,21 +14,32 @@ let AllExceptionsFilter = class AllExceptionsFilter {
|
||||
const ctx = host.switchToHttp();
|
||||
const response = ctx.getResponse();
|
||||
const request = ctx.getRequest();
|
||||
const exceptionRes = exception.getResponse() || 'Internal server error';
|
||||
const message = (exceptionRes === null || exceptionRes === void 0 ? void 0 : exceptionRes.message)
|
||||
? Array.isArray(exceptionRes)
|
||||
? exceptionRes['message'][0]
|
||||
: exceptionRes['message']
|
||||
: exceptionRes;
|
||||
const status = exception instanceof common_1.HttpException
|
||||
? exception.getStatus()
|
||||
: common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
let message = 'Internal server error';
|
||||
if (exception instanceof common_1.HttpException) {
|
||||
const exceptionRes = exception.getResponse();
|
||||
message = (exceptionRes === null || exceptionRes === void 0 ? void 0 : exceptionRes.message)
|
||||
? Array.isArray(exceptionRes.message)
|
||||
? exceptionRes.message[0]
|
||||
: exceptionRes.message
|
||||
: exceptionRes;
|
||||
}
|
||||
else if (typeof exception.getResponse === 'function') {
|
||||
const exceptionRes = exception.getResponse();
|
||||
message = (exceptionRes === null || exceptionRes === void 0 ? void 0 : exceptionRes.message)
|
||||
? Array.isArray(exceptionRes.message)
|
||||
? exceptionRes.message[0]
|
||||
: exceptionRes.message
|
||||
: exceptionRes;
|
||||
}
|
||||
if (status === common_1.HttpStatus.NOT_FOUND) {
|
||||
response.redirect('/');
|
||||
}
|
||||
else {
|
||||
const statusCode = status || 400;
|
||||
response.status(status);
|
||||
response.status(statusCode);
|
||||
response.header('Content-Type', 'application/json; charset=utf-8');
|
||||
response.send(result_1.Result.fail(statusCode, Array.isArray(message) ? message[0] : message));
|
||||
}
|
||||
|
@@ -8,25 +8,37 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var AzureTtsService_1;
|
||||
var AiPptService_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AzureTtsService = void 0;
|
||||
exports.AiPptService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const chatLog_service_1 = require("../chatLog/chatLog.service");
|
||||
const globalConfig_service_1 = require("../globalConfig/globalConfig.service");
|
||||
const models_service_1 = require("../models/models.service");
|
||||
const upload_service_1 = require("../upload/upload.service");
|
||||
let AzureTtsService = AzureTtsService_1 = class AzureTtsService {
|
||||
constructor(uploadService, globalConfigService, chatLogService) {
|
||||
const openaiChat_service_1 = require("./openaiChat.service");
|
||||
let AiPptService = AiPptService_1 = class AiPptService {
|
||||
constructor(uploadService, globalConfigService, chatLogService, openAIChatService, modelsService) {
|
||||
this.uploadService = uploadService;
|
||||
this.globalConfigService = globalConfigService;
|
||||
this.chatLogService = chatLogService;
|
||||
this.logger = new common_1.Logger(AzureTtsService_1.name);
|
||||
this.openAIChatService = openAIChatService;
|
||||
this.modelsService = modelsService;
|
||||
this.logger = new common_1.Logger(AiPptService_1.name);
|
||||
}
|
||||
async aiPPT(inputs) {
|
||||
return;
|
||||
}
|
||||
async pptCover(inputs) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
AzureTtsService = AzureTtsService_1 = __decorate([
|
||||
AiPptService = AiPptService_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [upload_service_1.UploadService,
|
||||
globalConfig_service_1.GlobalConfigService,
|
||||
chatLog_service_1.ChatLogService])
|
||||
], AzureTtsService);
|
||||
exports.AzureTtsService = AzureTtsService;
|
||||
chatLog_service_1.ChatLogService,
|
||||
openaiChat_service_1.OpenAIChatService,
|
||||
models_service_1.ModelsService])
|
||||
], AiPptService);
|
||||
exports.AiPptService = AiPptService;
|
214
dist/modules/ai/cogVideo.service.js
vendored
Normal file
214
dist/modules/ai/cogVideo.service.js
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
"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.CogVideoService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const axios_1 = require("axios");
|
||||
const chatLog_service_1 = require("../chatLog/chatLog.service");
|
||||
const globalConfig_service_1 = require("../globalConfig/globalConfig.service");
|
||||
const upload_service_1 = require("../upload/upload.service");
|
||||
let CogVideoService = class CogVideoService {
|
||||
constructor(chatLogService, globalConfigService, uploadService) {
|
||||
this.chatLogService = chatLogService;
|
||||
this.globalConfigService = globalConfigService;
|
||||
this.uploadService = uploadService;
|
||||
}
|
||||
async cogVideo(inputs) {
|
||||
var _a, _b, _c;
|
||||
const { apiKey, proxyUrl, fileInfo, prompt, timeout, assistantLogId } = inputs;
|
||||
let result = {
|
||||
text: '',
|
||||
fileInfo: '',
|
||||
taskId: '',
|
||||
taskData: '',
|
||||
status: 2,
|
||||
};
|
||||
let response = null;
|
||||
let url = '';
|
||||
let payloadJson = {};
|
||||
const headers = { Authorization: `Bearer ${apiKey}` };
|
||||
url = `${proxyUrl}/cogvideox/v4/videos/generations`;
|
||||
payloadJson = {
|
||||
model: 'cogvideox',
|
||||
prompt: prompt,
|
||||
};
|
||||
if (fileInfo) {
|
||||
payloadJson['image_url'] = fileInfo;
|
||||
}
|
||||
common_1.Logger.log(`正在准备发送请求到 ${url},payload: ${JSON.stringify(payloadJson)}, headers: ${JSON.stringify(headers)}`, 'CogService');
|
||||
try {
|
||||
response = await axios_1.default.post(url, payloadJson, { headers });
|
||||
common_1.Logger.debug(`任务提交结果,状态码: ${response.status}, 状态消息: ${response.statusText}, 数据: ${JSON.stringify(response.data)}`);
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error(`任务提交失败: ${error.message}`, 'CogService');
|
||||
throw new Error('任务提交失败');
|
||||
}
|
||||
if ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.id) {
|
||||
result.taskId = (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.id;
|
||||
common_1.Logger.log(`任务提交成功, 任务ID: ${(_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.id}`, 'CogService');
|
||||
}
|
||||
else {
|
||||
throw new Error('未能获取结果数据, 即将重试');
|
||||
}
|
||||
try {
|
||||
await this.pollCogVideoResult({
|
||||
proxyUrl,
|
||||
apiKey,
|
||||
taskId: response.data.id,
|
||||
timeout,
|
||||
prompt,
|
||||
onSuccess: async (data) => {
|
||||
try {
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
videoUrl: data === null || data === void 0 ? void 0 : data.videoUrl,
|
||||
audioUrl: data === null || data === void 0 ? void 0 : data.audioUrl,
|
||||
fileInfo: data === null || data === void 0 ? void 0 : data.fileInfo,
|
||||
answer: (data === null || data === void 0 ? void 0 : data.answer) || prompt,
|
||||
progress: '100%',
|
||||
status: 3,
|
||||
taskId: data === null || data === void 0 ? void 0 : data.taskId,
|
||||
taskData: data === null || data === void 0 ? void 0 : data.taskData,
|
||||
});
|
||||
common_1.Logger.log('视频任务已完成', 'CogService');
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error(`更新日志失败: ${error.message}`, 'CogService');
|
||||
}
|
||||
},
|
||||
onGenerating: async (data) => {
|
||||
try {
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
videoUrl: data === null || data === void 0 ? void 0 : data.videoUrl,
|
||||
audioUrl: data === null || data === void 0 ? void 0 : data.audioUrl,
|
||||
fileInfo: data === null || data === void 0 ? void 0 : data.fileInfo,
|
||||
answer: (data === null || data === void 0 ? void 0 : data.answer) || '视频生成中...',
|
||||
progress: data === null || data === void 0 ? void 0 : data.progress,
|
||||
status: data.status,
|
||||
});
|
||||
common_1.Logger.log('视频生成中...', 'CogService');
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error(`更新日志失败: ${error.message}`, 'CogService');
|
||||
}
|
||||
},
|
||||
onFailure: async (data) => {
|
||||
try {
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
answer: '视频生成失败',
|
||||
status: data.status,
|
||||
});
|
||||
common_1.Logger.log('生成失败', 'Lum aService');
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error(`更新日志失败: ${error.message}`, 'CogService');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error('查询生成结果时发生错误:', error.message, 'CogService');
|
||||
throw new Error('查询生成结果时发生错误');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
async pollCogVideoResult(inputs) {
|
||||
const { proxyUrl, apiKey, taskId, timeout, onSuccess, onFailure, onGenerating, prompt, action, } = inputs;
|
||||
let result = {
|
||||
videoUrl: '',
|
||||
audioUrl: '',
|
||||
fileInfo: '',
|
||||
drawId: '',
|
||||
taskData: '',
|
||||
status: 2,
|
||||
progress: 0,
|
||||
answer: '',
|
||||
};
|
||||
const headers = { Authorization: `Bearer ${apiKey}` };
|
||||
const url = `${proxyUrl}/cogvideox/v4/async-result/${taskId}`;
|
||||
const startTime = Date.now();
|
||||
const totalDuration = 300000;
|
||||
const POLL_INTERVAL = 5000;
|
||||
let retryCount = 0;
|
||||
try {
|
||||
while (Date.now() - startTime < timeout) {
|
||||
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL));
|
||||
try {
|
||||
const res = await axios_1.default.get(url, { headers });
|
||||
const interval = setInterval(() => {
|
||||
const elapsed = Date.now() - startTime;
|
||||
let percentage = Math.floor((elapsed / totalDuration) * 100);
|
||||
if (percentage >= 99)
|
||||
percentage = 99;
|
||||
result.answer = `视频生成中 (${percentage}%)`;
|
||||
}, 1000);
|
||||
const responses = res.data;
|
||||
common_1.Logger.debug(`轮询结果: ${JSON.stringify(responses)}`, 'CogService');
|
||||
if (responses.task_status === 'SUCCESS') {
|
||||
result.taskId = responses.request_id;
|
||||
result.taskData = JSON.stringify(responses);
|
||||
common_1.Logger.log('视频生成成功', 'CogService');
|
||||
result.fileInfo = responses.video_result[0].url;
|
||||
common_1.Logger.log(result.fileInfo, 'CogService');
|
||||
try {
|
||||
const localStorageStatus = await this.globalConfigService.getConfigs([
|
||||
'localStorageStatus',
|
||||
]);
|
||||
if (Number(localStorageStatus)) {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(now.getDate()).padStart(2, '0');
|
||||
const currentDate = `${year}${month}/${day}`;
|
||||
result.fileInfo = await this.uploadService.uploadFileFromUrl({
|
||||
url: responses.video_result[0].url,
|
||||
dir: `video/cog/${currentDate}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error(`上传文件失败: ${error.message}`, 'CogService');
|
||||
}
|
||||
result.answer = `提示词: "${prompt}"`;
|
||||
onSuccess(result);
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
onGenerating(result);
|
||||
}
|
||||
if (result.progress) {
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
retryCount++;
|
||||
common_1.Logger.error(`轮询失败,重试次数: ${retryCount}`, 'CogService');
|
||||
}
|
||||
}
|
||||
common_1.Logger.error('轮询超时,请稍后再试!', 'CogService');
|
||||
result.status = 4;
|
||||
onFailure(result);
|
||||
throw new Error('查询超时,请稍后再试!');
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error(`轮询过程中发生错误: ${error}`, 'CogService');
|
||||
result.status = 5;
|
||||
onFailure(result);
|
||||
}
|
||||
}
|
||||
};
|
||||
CogVideoService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [chatLog_service_1.ChatLogService,
|
||||
globalConfig_service_1.GlobalConfigService,
|
||||
upload_service_1.UploadService])
|
||||
], CogVideoService);
|
||||
exports.CogVideoService = CogVideoService;
|
148
dist/modules/ai/fluxDraw.service.js
vendored
Normal file
148
dist/modules/ai/fluxDraw.service.js
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
"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 FluxDrawService_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FluxDrawService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const axios_1 = require("axios");
|
||||
const chatLog_service_1 = require("../chatLog/chatLog.service");
|
||||
const globalConfig_service_1 = require("../globalConfig/globalConfig.service");
|
||||
const upload_service_1 = require("../upload/upload.service");
|
||||
const openaiChat_service_1 = require("./openaiChat.service");
|
||||
let FluxDrawService = FluxDrawService_1 = class FluxDrawService {
|
||||
constructor(uploadService, globalConfigService, chatLogService, openAIChatService) {
|
||||
this.uploadService = uploadService;
|
||||
this.globalConfigService = globalConfigService;
|
||||
this.chatLogService = chatLogService;
|
||||
this.openAIChatService = openAIChatService;
|
||||
this.logger = new common_1.Logger(FluxDrawService_1.name);
|
||||
}
|
||||
async fluxDraw(inputs, buildMessageFromParentMessageId) {
|
||||
var _a, _b, _c, _d;
|
||||
common_1.Logger.log('开始提交 Flux 绘图任务 ', 'DrawService');
|
||||
const { apiKey, model, proxyUrl, prompt, extraParam, timeout, onSuccess, onFailure, groupId, } = inputs;
|
||||
const isDalleChat = await this.globalConfigService.getConfigs([
|
||||
'isDalleChat',
|
||||
]);
|
||||
let drawPrompt;
|
||||
if (isDalleChat === '1') {
|
||||
try {
|
||||
common_1.Logger.log('已开启连续绘画模式', 'FluxDraw');
|
||||
const { messagesHistory } = await buildMessageFromParentMessageId(`参考上文,结合我的需求,给出绘画描述。我的需求是:${prompt}`, {
|
||||
groupId,
|
||||
systemMessage: '你是一个绘画提示词生成工具,请根据用户的要求,结合上下文,用一段文字,描述用户需要的绘画需求,不用包含任何礼貌性的寒暄,只需要场景的描述,可以适当联想',
|
||||
maxModelTokens: 8000,
|
||||
maxRounds: 5,
|
||||
fileInfo: '',
|
||||
}, this.chatLogService);
|
||||
drawPrompt = await this.openAIChatService.chatFree(prompt, undefined, messagesHistory);
|
||||
}
|
||||
catch (error) {
|
||||
console.error('调用chatFree失败:', error);
|
||||
drawPrompt = prompt;
|
||||
}
|
||||
}
|
||||
else {
|
||||
drawPrompt = prompt;
|
||||
}
|
||||
const size = (extraParam === null || extraParam === void 0 ? void 0 : extraParam.size) || '1024x1024';
|
||||
let result = { answer: '', fileInfo: '', status: 2 };
|
||||
try {
|
||||
const options = {
|
||||
method: 'POST',
|
||||
url: `${proxyUrl}/v1/images/generations`,
|
||||
timeout: timeout,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
},
|
||||
data: {
|
||||
model: model,
|
||||
prompt: drawPrompt,
|
||||
size,
|
||||
},
|
||||
};
|
||||
common_1.Logger.log(`正在准备发送请求到 ${options.url},payload: ${JSON.stringify(options.data)}, headers: ${JSON.stringify(options.headers)}`, 'FluxDrawService');
|
||||
const response = await (0, axios_1.default)(options);
|
||||
common_1.Logger.debug(`请求成功${JSON.stringify(response.data.data[0])}`);
|
||||
common_1.Logger.debug(`请求状态${JSON.stringify(response.status)}`);
|
||||
const url = response.data.data[0].url;
|
||||
try {
|
||||
common_1.Logger.log(`------> 开始上传图片!!!`, 'DrawService');
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(now.getDate()).padStart(2, '0');
|
||||
const currentDate = `${year}${month}/${day}`;
|
||||
result.fileInfo = await this.uploadService.uploadFileFromUrl({
|
||||
url: url,
|
||||
dir: `images/dalle/${currentDate}`,
|
||||
});
|
||||
common_1.Logger.log(`图片上传成功,URL: ${result.fileInfo}`, 'DrawService');
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error(`上传图片过程中出现错误: ${error}`, 'DrawService');
|
||||
}
|
||||
let revised_prompt_cn;
|
||||
try {
|
||||
revised_prompt_cn = await this.openAIChatService.chatFree(`根据提示词{${drawPrompt}}, 模拟AI绘画机器人的语气,用中文回复,告诉用户已经画好了`);
|
||||
}
|
||||
catch (error) {
|
||||
revised_prompt_cn = `${prompt} 绘制成功`;
|
||||
common_1.Logger.error('翻译失败: ', error);
|
||||
}
|
||||
result.answer = revised_prompt_cn;
|
||||
result.status = 3;
|
||||
onSuccess(result);
|
||||
return;
|
||||
}
|
||||
catch (error) {
|
||||
result.status = 5;
|
||||
onFailure(result);
|
||||
const status = ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) || 500;
|
||||
console.log('draw error: ', JSON.stringify(error), status);
|
||||
const message = (_d = (_c = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.message;
|
||||
if (status === 429) {
|
||||
result.text = '当前请求已过载、请稍等会儿再试试吧!';
|
||||
return result;
|
||||
}
|
||||
if (status === 400 &&
|
||||
message.includes('This request has been blocked by our content filters')) {
|
||||
result.text = '您的请求已被系统拒绝。您的提示可能存在一些非法的文本。';
|
||||
return result;
|
||||
}
|
||||
if (status === 400 &&
|
||||
message.includes('Billing hard limit has been reached')) {
|
||||
result.text =
|
||||
'当前模型key已被封禁、已冻结当前调用Key、尝试重新对话试试吧!';
|
||||
return result;
|
||||
}
|
||||
if (status === 500) {
|
||||
result.text = '绘制图片失败,请检查你的提示词是否有非法描述!';
|
||||
return result;
|
||||
}
|
||||
if (status === 401) {
|
||||
result.text = '绘制图片失败,此次绘画被拒绝了!';
|
||||
return result;
|
||||
}
|
||||
result.text = '绘制图片失败,请稍后试试吧!';
|
||||
return result;
|
||||
}
|
||||
}
|
||||
};
|
||||
FluxDrawService = FluxDrawService_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [upload_service_1.UploadService,
|
||||
globalConfig_service_1.GlobalConfigService,
|
||||
chatLog_service_1.ChatLogService,
|
||||
openaiChat_service_1.OpenAIChatService])
|
||||
], FluxDrawService);
|
||||
exports.FluxDrawService = FluxDrawService;
|
39
dist/modules/ai/openaiChat.service.js
vendored
39
dist/modules/ai/openaiChat.service.js
vendored
@@ -29,6 +29,9 @@ let OpenAIChatService = class OpenAIChatService {
|
||||
errMsg: '',
|
||||
modelAvatar: modelAvatar,
|
||||
};
|
||||
const data = Object.assign({ model, messages: messagesHistory }, (isFileUpload === 2 && { max_tokens: 2048 }));
|
||||
data.stream = true;
|
||||
data.temperature = temperature;
|
||||
const options = {
|
||||
method: 'POST',
|
||||
url: `${proxyUrl}/v1/chat/completions`,
|
||||
@@ -38,9 +41,11 @@ let OpenAIChatService = class OpenAIChatService {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
},
|
||||
data: Object.assign({ stream: true, model, temperature: temperature, messages: messagesHistory }, (isFileUpload === 2 && { max_tokens: 2048 })),
|
||||
data: data,
|
||||
};
|
||||
console.log('请求配置:', JSON.stringify(options, null, 2), 'ChatService');
|
||||
const sanitizedOptions = await this.sanitizeOptionsForLogging(options);
|
||||
console.log('请求配置:', JSON.stringify(sanitizedOptions, null, 2), 'ChatService');
|
||||
console.log('请求配置:', JSON.stringify(sanitizedOptions, null, 2), 'ChatService');
|
||||
try {
|
||||
const response = await (0, axios_1.default)(options);
|
||||
const stream = response.data;
|
||||
@@ -92,6 +97,36 @@ let OpenAIChatService = class OpenAIChatService {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
async sanitizeOptionsForLogging(options) {
|
||||
const sanitizedOptions = JSON.parse(JSON.stringify(options));
|
||||
if (sanitizedOptions.headers && sanitizedOptions.headers.Authorization) {
|
||||
const authHeader = sanitizedOptions.headers.Authorization;
|
||||
if (authHeader.startsWith('Bearer ')) {
|
||||
const token = authHeader.slice(7);
|
||||
if (token.length > 10) {
|
||||
sanitizedOptions.headers.Authorization = `Bearer ${token.slice(0, 5)}****${token.slice(-4)}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sanitizedOptions.data &&
|
||||
sanitizedOptions.data.messages &&
|
||||
Array.isArray(sanitizedOptions.data.messages)) {
|
||||
sanitizedOptions.data.messages = sanitizedOptions.data.messages.map((message) => {
|
||||
if (message.content && Array.isArray(message.content)) {
|
||||
message.content = message.content.map((content) => {
|
||||
if (content.type === 'image_url' &&
|
||||
content.image_url &&
|
||||
content.image_url.url) {
|
||||
content.image_url.url = 'data:image/***;base64 ... ...';
|
||||
}
|
||||
return content;
|
||||
});
|
||||
}
|
||||
return message;
|
||||
});
|
||||
}
|
||||
return sanitizedOptions;
|
||||
}
|
||||
async chatFree(prompt, systemMessage, messagesHistory) {
|
||||
const { openaiBaseUrl = '', openaiBaseKey = '', openaiBaseModel, } = await this.globalConfigService.getConfigs([
|
||||
'openaiBaseKey',
|
||||
|
9
dist/modules/ai/stableDiffusion.service.js
vendored
9
dist/modules/ai/stableDiffusion.service.js
vendored
@@ -13,17 +13,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.StableDiffusionService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const axios_1 = require("axios");
|
||||
const chatLog_service_1 = require("../chatLog/chatLog.service");
|
||||
const globalConfig_service_1 = require("../globalConfig/globalConfig.service");
|
||||
const upload_service_1 = require("../upload/upload.service");
|
||||
let StableDiffusionService = StableDiffusionService_1 = class StableDiffusionService {
|
||||
constructor(uploadService, globalConfigService, chatLogService) {
|
||||
constructor(uploadService, globalConfigService) {
|
||||
this.uploadService = uploadService;
|
||||
this.globalConfigService = globalConfigService;
|
||||
this.chatLogService = chatLogService;
|
||||
this.logger = new common_1.Logger(StableDiffusionService_1.name);
|
||||
}
|
||||
async sdxl(messagesHistory, inputs) {
|
||||
async sdxl(inputs) {
|
||||
const { onSuccess, onFailure, apiKey, model, proxyUrl, modelName, timeout, chatId, prompt, } = inputs;
|
||||
let result = {
|
||||
answer: '',
|
||||
@@ -101,7 +99,6 @@ let StableDiffusionService = StableDiffusionService_1 = class StableDiffusionSer
|
||||
StableDiffusionService = StableDiffusionService_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [upload_service_1.UploadService,
|
||||
globalConfig_service_1.GlobalConfigService,
|
||||
chatLog_service_1.ChatLogService])
|
||||
globalConfig_service_1.GlobalConfigService])
|
||||
], StableDiffusionService);
|
||||
exports.StableDiffusionService = StableDiffusionService;
|
||||
|
2
dist/modules/ai/suno.service.js
vendored
2
dist/modules/ai/suno.service.js
vendored
@@ -24,6 +24,7 @@ let SunoService = class SunoService {
|
||||
async suno(inputs) {
|
||||
var _a, _b, _c;
|
||||
const { apiKey, proxyUrl, action, prompt, timeout, assistantLogId, taskData, extraParam, } = inputs;
|
||||
common_1.Logger.debug(`SunoService: ${JSON.stringify(inputs)}`, 'SunoService');
|
||||
let result = {
|
||||
text: '',
|
||||
fileInfo: '',
|
||||
@@ -53,6 +54,7 @@ let SunoService = class SunoService {
|
||||
common_1.Logger.log(`正在准备发送请求到 ${url},payload: ${JSON.stringify(payloadJson)}, headers: ${JSON.stringify(headers)}`, 'SunoService');
|
||||
try {
|
||||
response = await axios_1.default.post(url, payloadJson, { headers });
|
||||
common_1.Logger.debug(`任务提交结果,状态码: ${response.status}, 状态消息: ${response.statusText}, 数据: ${JSON.stringify(response.data)}`);
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error(`任务提交失败: ${error.message}`, 'SunoService');
|
||||
|
80
dist/modules/app/app.controller.js
vendored
80
dist/modules/app/app.controller.js
vendored
@@ -22,7 +22,6 @@ const app_service_1 = require("./app.service");
|
||||
const collectApp_dto_1 = require("./dto/collectApp.dto");
|
||||
const createApp_dto_1 = require("./dto/createApp.dto");
|
||||
const createCats_dto_1 = require("./dto/createCats.dto");
|
||||
const custonApp_dto_1 = require("./dto/custonApp.dto");
|
||||
const deleteApp_dto_1 = require("./dto/deleteApp.dto");
|
||||
const deleteCats_dto_1 = require("./dto/deleteCats.dto");
|
||||
const queryApp_dto_1 = require("./dto/queryApp.dto");
|
||||
@@ -55,9 +54,6 @@ let AppController = class AppController {
|
||||
appList(req, query) {
|
||||
return this.appService.appList(req, query);
|
||||
}
|
||||
appSystemList() {
|
||||
return this.appService.appSystemList();
|
||||
}
|
||||
list(req, query) {
|
||||
return this.appService.frontAppList(req, query);
|
||||
}
|
||||
@@ -67,27 +63,12 @@ let AppController = class AppController {
|
||||
createApp(body) {
|
||||
return this.appService.createApp(body);
|
||||
}
|
||||
customApp(body, req) {
|
||||
return this.appService.customApp(body, req);
|
||||
}
|
||||
updateApp(body) {
|
||||
return this.appService.updateApp(body);
|
||||
}
|
||||
updateSystemApp(body) {
|
||||
return this.appService.updateSystemApp(body);
|
||||
}
|
||||
delApp(body) {
|
||||
return this.appService.delApp(body);
|
||||
}
|
||||
auditPass(body) {
|
||||
return this.appService.auditPass(body);
|
||||
}
|
||||
auditFail(body) {
|
||||
return this.appService.auditFail(body);
|
||||
}
|
||||
delMineApp(body, req) {
|
||||
return this.appService.delMineApp(body, req);
|
||||
}
|
||||
collect(body, req) {
|
||||
return this.appService.collect(body, req);
|
||||
}
|
||||
@@ -161,15 +142,6 @@ __decorate([
|
||||
__metadata("design:paramtypes", [Object, queryApp_dto_1.QuerAppDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "appList", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('querySystemApp'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '获取系统App列表' }),
|
||||
(0, common_1.UseGuards)(adminAuth_guard_1.AdminAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "appSystemList", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('list'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '客户端获取App' }),
|
||||
@@ -197,17 +169,6 @@ __decorate([
|
||||
__metadata("design:paramtypes", [createApp_dto_1.CreateAppDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "createApp", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('customApp'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '添加自定义App' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [custonApp_dto_1.CustomAppDto, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "customApp", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('updateApp'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '修改App' }),
|
||||
@@ -218,16 +179,6 @@ __decorate([
|
||||
__metadata("design:paramtypes", [updateApp_dto_1.UpdateAppDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "updateApp", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('updateSystemApp'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '修改系统App' }),
|
||||
(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)
|
||||
], AppController.prototype, "updateSystemApp", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('delApp'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '删除App' }),
|
||||
@@ -238,37 +189,6 @@ __decorate([
|
||||
__metadata("design:paramtypes", [deleteApp_dto_1.OperateAppDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "delApp", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('auditPass'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '审核通过App' }),
|
||||
(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", [deleteApp_dto_1.OperateAppDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "auditPass", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('auditFail'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '审核拒绝App' }),
|
||||
(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", [deleteApp_dto_1.OperateAppDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "auditFail", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('delMineApp'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '删除个人App' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [deleteApp_dto_1.OperateAppDto, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "delMineApp", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('collect'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '收藏/取消收藏App' }),
|
||||
|
97
dist/modules/app/app.service.js
vendored
97
dist/modules/app/app.service.js
vendored
@@ -130,14 +130,6 @@ let AppService = class AppService {
|
||||
}
|
||||
return { rows, count };
|
||||
}
|
||||
async appSystemList() {
|
||||
const where = { isSystemReserved: 1 };
|
||||
const [rows, count] = await this.appEntity.findAndCount({
|
||||
where,
|
||||
order: { id: 'DESC' },
|
||||
});
|
||||
return { rows, count };
|
||||
}
|
||||
async frontAppList(req, query, orderKey = 'id') {
|
||||
var _a;
|
||||
const { page = 1, size = 1000, name, catId, role } = query;
|
||||
@@ -218,67 +210,6 @@ let AppService = class AppService {
|
||||
}
|
||||
return await this.appEntity.save(body);
|
||||
}
|
||||
async customApp(body, req) {
|
||||
const { id } = req.user;
|
||||
const { name, catId, des, preset, coverImg, demoData, public: isPublic, appId, } = body;
|
||||
if (appId) {
|
||||
const a = await this.appEntity.findOne({
|
||||
where: { id: appId, userId: id },
|
||||
});
|
||||
if (!a) {
|
||||
throw new common_1.HttpException('您正在编辑一个不存在的应用!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const data = {
|
||||
name,
|
||||
catId,
|
||||
des,
|
||||
preset,
|
||||
coverImg,
|
||||
demoData,
|
||||
public: isPublic,
|
||||
status: isPublic ? 3 : 1,
|
||||
};
|
||||
const res = await this.appEntity.update({ id: appId, userId: id }, data);
|
||||
if (res.affected) {
|
||||
return '修改成功';
|
||||
}
|
||||
else {
|
||||
throw new common_1.HttpException('修改失败!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
if (!appId) {
|
||||
const c = await this.appCatsEntity.findOne({ where: { id: catId } });
|
||||
if (!c) {
|
||||
throw new common_1.HttpException('该分类不存在!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const a = await this.appEntity.findOne({ where: { name } });
|
||||
if (a) {
|
||||
throw new common_1.HttpException('该应用名称已存在!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const data = {
|
||||
name,
|
||||
catId,
|
||||
des,
|
||||
preset,
|
||||
coverImg,
|
||||
status: isPublic ? 3 : 1,
|
||||
demoData,
|
||||
public: isPublic,
|
||||
role: 'user',
|
||||
userId: id,
|
||||
};
|
||||
const res = await this.appEntity.save(data);
|
||||
const params = {
|
||||
appId: res.id,
|
||||
userId: id,
|
||||
appType: 'user',
|
||||
public: isPublic,
|
||||
status: isPublic ? 3 : 1,
|
||||
catId,
|
||||
};
|
||||
return this.userAppsEntity.save(params);
|
||||
}
|
||||
}
|
||||
async updateApp(body) {
|
||||
const { id, name, catId, status } = body;
|
||||
const a = await this.appEntity.findOne({ where: { name, id: (0, typeorm_2.Not)(id) } });
|
||||
@@ -298,22 +229,6 @@ let AppService = class AppService {
|
||||
return '修改App信息成功';
|
||||
throw new common_1.HttpException('修改App信息失败!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
async updateSystemApp(body) {
|
||||
const { id, name } = body;
|
||||
const existingApp = await this.appEntity.findOne({
|
||||
where: { name, id: (0, typeorm_2.Not)(id) },
|
||||
});
|
||||
if (existingApp) {
|
||||
common_1.Logger.warn(`应用名称已存在:${name}`);
|
||||
throw new common_1.HttpException('该应用名称已存在!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const res = await this.appEntity.update({ id }, body);
|
||||
if (res.affected > 0) {
|
||||
return '修改系统应用信息成功';
|
||||
}
|
||||
common_1.Logger.error(`修改系统应用信息失败:${name}`);
|
||||
throw new common_1.HttpException('修改系统应用信息失败!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
async delApp(body) {
|
||||
const { id } = body;
|
||||
const a = await this.appEntity.findOne({ where: { id } });
|
||||
@@ -346,18 +261,6 @@ let AppService = class AppService {
|
||||
await this.userAppsEntity.update({ appId: id }, { status: 5 });
|
||||
return '应用审核拒绝完成';
|
||||
}
|
||||
async delMineApp(body, req) {
|
||||
const { id } = body;
|
||||
const a = await this.appEntity.findOne({
|
||||
where: { id, userId: req.user.id },
|
||||
});
|
||||
if (!a) {
|
||||
throw new common_1.HttpException('您正在操作一个不存在的资源!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
await this.appEntity.delete(id);
|
||||
await this.userAppsEntity.delete({ appId: id, userId: req.user.id });
|
||||
return '删除应用成功!';
|
||||
}
|
||||
async collect(body, req) {
|
||||
const { appId } = body;
|
||||
const { id: userId } = req.user;
|
||||
|
39
dist/modules/auth/auth.controller.js
vendored
39
dist/modules/auth/auth.controller.js
vendored
@@ -46,6 +46,15 @@ let AuthController = class AuthController {
|
||||
async sendCode(parmas) {
|
||||
return this.authService.sendCode(parmas);
|
||||
}
|
||||
async sendPhoneCode(parmas) {
|
||||
return this.authService.sendPhoneCode(parmas);
|
||||
}
|
||||
async verifyIdentity(req, body) {
|
||||
return this.authService.verifyIdentity(req, body);
|
||||
}
|
||||
async verifyPhoneIdentity(req, body) {
|
||||
return this.authService.verifyPhoneIdentity(req, body);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Post)('register'),
|
||||
@@ -114,6 +123,36 @@ __decorate([
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "sendCode", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('sendPhoneCode'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '发送手机验证码' }),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "sendPhoneCode", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('verifyIdentity'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '验证身份' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "verifyIdentity", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('verifyPhoneIdentity'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '验证手机号' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthController.prototype, "verifyPhoneIdentity", null);
|
||||
AuthController = __decorate([
|
||||
(0, swagger_1.ApiTags)('auth'),
|
||||
(0, common_1.Controller)('auth'),
|
||||
|
4
dist/modules/auth/auth.module.js
vendored
4
dist/modules/auth/auth.module.js
vendored
@@ -18,10 +18,8 @@ const chatLog_entity_1 = require("../chatLog/chatLog.entity");
|
||||
const cramiPackage_entity_1 = require("../crami/cramiPackage.entity");
|
||||
const config_entity_1 = require("../globalConfig/config.entity");
|
||||
const mailer_service_1 = require("../mailer/mailer.service");
|
||||
const midjourney_entity_1 = require("../midjourney/midjourney.entity");
|
||||
const redisCache_module_1 = require("../redisCache/redisCache.module");
|
||||
const redisCache_service_1 = require("../redisCache/redisCache.service");
|
||||
const salesUsers_entity_1 = require("../sales/salesUsers.entity");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const user_module_1 = require("../user/user.module");
|
||||
const accountLog_entity_1 = require("../userBalance/accountLog.entity");
|
||||
@@ -56,12 +54,10 @@ AuthModule = __decorate([
|
||||
config_entity_1.ConfigEntity,
|
||||
cramiPackage_entity_1.CramiPackageEntity,
|
||||
userBalance_entity_1.UserBalanceEntity,
|
||||
salesUsers_entity_1.SalesUsersEntity,
|
||||
user_entity_1.UserEntity,
|
||||
fingerprint_entity_1.FingerprintLogEntity,
|
||||
chatLog_entity_1.ChatLogEntity,
|
||||
chatGroup_entity_1.ChatGroupEntity,
|
||||
midjourney_entity_1.MidjourneyEntity,
|
||||
]),
|
||||
],
|
||||
controllers: [auth_controller_1.AuthController],
|
||||
|
91
dist/modules/auth/auth.service.js
vendored
91
dist/modules/auth/auth.service.js
vendored
@@ -43,7 +43,7 @@ let AuthService = class AuthService {
|
||||
this.getIp();
|
||||
}
|
||||
async register(body, req) {
|
||||
const { password, contact, code, invitedBy } = body;
|
||||
const { password, contact, code } = body;
|
||||
let email = '', phone = '';
|
||||
const isEmail = /\S+@\S+\.\S+/.test(contact);
|
||||
const isPhone = /^\d{10,}$/.test(contact);
|
||||
@@ -111,7 +111,6 @@ let AuthService = class AuthService {
|
||||
username,
|
||||
password,
|
||||
email: contact,
|
||||
invitedBy,
|
||||
status: user_constant_1.UserStatusEnum.ACTIVE,
|
||||
};
|
||||
}
|
||||
@@ -122,7 +121,6 @@ let AuthService = class AuthService {
|
||||
password,
|
||||
email,
|
||||
phone: contact,
|
||||
invitedBy,
|
||||
status: user_constant_1.UserStatusEnum.ACTIVE,
|
||||
};
|
||||
}
|
||||
@@ -138,12 +136,7 @@ let AuthService = class AuthService {
|
||||
common_1.Logger.debug('保存新用户到数据库...');
|
||||
const u = await this.userService.createUser(newUser);
|
||||
common_1.Logger.debug(`用户创建成功,用户ID: ${u.id}`);
|
||||
let inviteUser;
|
||||
if (invitedBy) {
|
||||
inviteUser = await this.userService.qureyUserInfoByInviteCode(invitedBy);
|
||||
common_1.Logger.debug(`邀请人信息: ${inviteUser}`);
|
||||
}
|
||||
await this.userBalanceService.addBalanceToNewUser(u.id, inviteUser === null || inviteUser === void 0 ? void 0 : inviteUser.id);
|
||||
await this.userBalanceService.addBalanceToNewUser(u.id);
|
||||
common_1.Logger.debug('完成新用户余额处理');
|
||||
return { success: true, message: '注册成功' };
|
||||
}
|
||||
@@ -360,6 +353,34 @@ let AuthService = class AuthService {
|
||||
return `验证码发送成功、请填写验证码完成注册!`;
|
||||
}
|
||||
}
|
||||
async sendPhoneCode(body) {
|
||||
const { phone, isLogin } = body;
|
||||
const code = (0, utils_1.createRandomCode)();
|
||||
const isPhone = /^\d{10,}$/.test(phone);
|
||||
if (!isPhone) {
|
||||
throw new common_1.HttpException('请提供有效的邮箱地址或手机号码。', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (isLogin) {
|
||||
if (isPhone) {
|
||||
const isAvailable = await this.userService.verifyUserRegister({
|
||||
phone,
|
||||
});
|
||||
if (!isAvailable) {
|
||||
throw new common_1.HttpException('当前手机号已注册,请勿重复注册!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
const nameSpace = await this.globalConfigService.getNamespace();
|
||||
const key = `${nameSpace}:CODE:${phone}`;
|
||||
const ttl = await this.redisCacheService.ttl(key);
|
||||
if (ttl && ttl > 0 && isPhone) {
|
||||
throw new common_1.HttpException(`${ttl}秒内不得重复发送验证码!`, common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const messageInfo = { phone, code };
|
||||
await this.redisCacheService.set({ key, val: code }, 10 * 60);
|
||||
await this.verificationService.sendPhoneCode(messageInfo);
|
||||
return `验证码发送成功、请填写验证码完成认证!`;
|
||||
}
|
||||
createTokenFromFingerprint(fingerprint) {
|
||||
const token = this.jwtService.sign({
|
||||
username: `游客${fingerprint}`,
|
||||
@@ -371,6 +392,58 @@ let AuthService = class AuthService {
|
||||
});
|
||||
return token;
|
||||
}
|
||||
async verifyIdentity(req, body) {
|
||||
common_1.Logger.debug('开始实名认证流程');
|
||||
const { name, idCard } = body;
|
||||
const { id } = req.user;
|
||||
try {
|
||||
const result = await this.verificationService.verifyIdentity(body);
|
||||
common_1.Logger.debug(`实名认证结果: ${result}`);
|
||||
if (!result) {
|
||||
throw new common_1.HttpException('身份验证错误,请检查实名信息', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
await this.userService.saveRealNameInfo(id, name, idCard);
|
||||
return '认证成功';
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error('验证过程出现错误', error);
|
||||
throw new common_1.HttpException('认证失败,请检查相关信息', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async verifyPhoneIdentity(req, body) {
|
||||
common_1.Logger.debug('开始手机号认证流程');
|
||||
const { phone, username, password, code } = body;
|
||||
const { id } = req.user;
|
||||
const nameSpace = this.globalConfigService.getNamespace();
|
||||
const key = `${nameSpace}:CODE:${phone}`;
|
||||
const redisCode = await this.redisCacheService.get({ key });
|
||||
common_1.Logger.debug(`Retrieved redisCode for ${phone}: ${redisCode}`);
|
||||
if (code === '') {
|
||||
throw new common_1.HttpException('请输入验证码', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (!redisCode) {
|
||||
common_1.Logger.log(`验证码过期: ${phone}`, 'authService');
|
||||
throw new common_1.HttpException('验证码已过期,请重新发送!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (code !== redisCode) {
|
||||
common_1.Logger.log(`验证码错误: ${phone} 输入的验证码: ${code}, 期望的验证码: ${redisCode}`, 'authService');
|
||||
throw new common_1.HttpException('验证码填写错误,请重新输入!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (username) {
|
||||
const usernameTaken = await this.userService.isUsernameTaken(body.username, id);
|
||||
if (usernameTaken) {
|
||||
throw new common_1.HttpException('用户名已存在!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
try {
|
||||
await this.userService.updateUserPhone(id, phone, username, password);
|
||||
return '认证成功';
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error('验证过程出现错误', error);
|
||||
throw new common_1.HttpException('身份验证错误,请检查相关信息', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
};
|
||||
AuthService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
|
9
dist/modules/auth/dto/authRegister.dto.js
vendored
9
dist/modules/auth/dto/authRegister.dto.js
vendored
@@ -29,15 +29,6 @@ __decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'ai@aiweb.com', description: '用户邮箱' }),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterDto.prototype, "email", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: 'FRJDLJHFNV',
|
||||
description: '用户填写的别人邀请码',
|
||||
required: false,
|
||||
}),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterDto.prototype, "invitedBy", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: '',
|
||||
|
@@ -39,9 +39,4 @@ __decorate([
|
||||
(0, class_validator_1.IsNotEmpty)({ message: '手机验证码不能为空!' }),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterByPhoneDto.prototype, "phoneCode", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'SNINE', description: '用户邀请码', required: true }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], UserRegisterByPhoneDto.prototype, "invitedBy", void 0);
|
||||
exports.UserRegisterByPhoneDto = UserRegisterByPhoneDto;
|
||||
|
48
dist/modules/badwords/badwords.controller.js
vendored
48
dist/modules/badwords/badwords.controller.js
vendored
@@ -12,35 +12,35 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BadwordsController = void 0;
|
||||
const badwords_service_1 = require("./badwords.service");
|
||||
exports.BadWordsController = void 0;
|
||||
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 badWords_service_1 = require("./badWords.service");
|
||||
const addBadWords_dto_1 = require("./dto/addBadWords.dto");
|
||||
const delBadWords_dto_1 = require("./dto/delBadWords.dto");
|
||||
const queryBadWords_dto_1 = require("./dto/queryBadWords.dto");
|
||||
const queryViolation_dto_1 = require("./dto/queryViolation.dto");
|
||||
const updateBadWords_dto_1 = require("./dto/updateBadWords.dto");
|
||||
const delBadWords_dto_1 = require("./dto/delBadWords.dto");
|
||||
const addBadWords_dto_1 = require("./dto/addBadWords.dto");
|
||||
const superAuth_guard_1 = require("../../common/auth/superAuth.guard");
|
||||
const adminAuth_guard_1 = require("../../common/auth/adminAuth.guard");
|
||||
let BadwordsController = class BadwordsController {
|
||||
constructor(badwordsService) {
|
||||
this.badwordsService = badwordsService;
|
||||
let BadWordsController = class BadWordsController {
|
||||
constructor(badWordsService) {
|
||||
this.badWordsService = badWordsService;
|
||||
}
|
||||
queryBadWords(query) {
|
||||
return this.badwordsService.queryBadWords(query);
|
||||
return this.badWordsService.queryBadWords(query);
|
||||
}
|
||||
delBadWords(body) {
|
||||
return this.badwordsService.delBadWords(body);
|
||||
return this.badWordsService.delBadWords(body);
|
||||
}
|
||||
updateBadWords(body) {
|
||||
return this.badwordsService.updateBadWords(body);
|
||||
return this.badWordsService.updateBadWords(body);
|
||||
}
|
||||
addBadWord(body) {
|
||||
return this.badwordsService.addBadWord(body);
|
||||
return this.badWordsService.addBadWord(body);
|
||||
}
|
||||
violation(req, query) {
|
||||
return this.badwordsService.violation(req, query);
|
||||
return this.badWordsService.violation(req, query);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
@@ -50,7 +50,7 @@ __decorate([
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [queryBadWords_dto_1.QueryBadWordsDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], BadwordsController.prototype, "queryBadWords", null);
|
||||
], BadWordsController.prototype, "queryBadWords", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('del'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '删除敏感词' }),
|
||||
@@ -60,7 +60,7 @@ __decorate([
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [delBadWords_dto_1.DelBadWordsDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], BadwordsController.prototype, "delBadWords", null);
|
||||
], BadWordsController.prototype, "delBadWords", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('update'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '更新敏感词' }),
|
||||
@@ -70,7 +70,7 @@ __decorate([
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [updateBadWords_dto_1.UpdateBadWordsDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], BadwordsController.prototype, "updateBadWords", null);
|
||||
], BadWordsController.prototype, "updateBadWords", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('add'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '新增敏感词' }),
|
||||
@@ -80,7 +80,7 @@ __decorate([
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [addBadWords_dto_1.AddBadWordDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], BadwordsController.prototype, "addBadWord", null);
|
||||
], BadWordsController.prototype, "addBadWord", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('violation'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '查询违规记录' }),
|
||||
@@ -91,10 +91,10 @@ __decorate([
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, queryViolation_dto_1.QueryViolationDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], BadwordsController.prototype, "violation", null);
|
||||
BadwordsController = __decorate([
|
||||
], BadWordsController.prototype, "violation", null);
|
||||
BadWordsController = __decorate([
|
||||
(0, swagger_1.ApiTags)('badWords'),
|
||||
(0, common_1.Controller)('badwords'),
|
||||
__metadata("design:paramtypes", [badwords_service_1.BadwordsService])
|
||||
], BadwordsController);
|
||||
exports.BadwordsController = BadwordsController;
|
||||
(0, common_1.Controller)('badWords'),
|
||||
__metadata("design:paramtypes", [badWords_service_1.BadWordsService])
|
||||
], BadWordsController);
|
||||
exports.BadWordsController = BadWordsController;
|
||||
|
2
dist/modules/badwords/badwords.entity.js
vendored
2
dist/modules/badwords/badwords.entity.js
vendored
@@ -10,8 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BadWordsEntity = void 0;
|
||||
const typeorm_1 = require("typeorm");
|
||||
const baseEntity_1 = require("../../common/entity/baseEntity");
|
||||
const typeorm_1 = require("typeorm");
|
||||
let BadWordsEntity = class BadWordsEntity extends baseEntity_1.BaseEntity {
|
||||
};
|
||||
__decorate([
|
||||
|
28
dist/modules/badwords/badwords.module.js
vendored
28
dist/modules/badwords/badwords.module.js
vendored
@@ -6,23 +6,25 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BadwordsModule = void 0;
|
||||
exports.BadWordsModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const badwords_service_1 = require("./badwords.service");
|
||||
const badwords_controller_1 = require("./badwords.controller");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const badwords_entity_1 = require("./badwords.entity");
|
||||
const violationLog_entity_1 = require("./violationLog.entity");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
let BadwordsModule = class BadwordsModule {
|
||||
const badWords_controller_1 = require("./badWords.controller");
|
||||
const badWords_entity_1 = require("./badWords.entity");
|
||||
const badWords_service_1 = require("./badWords.service");
|
||||
const violationLog_entity_1 = require("./violationLog.entity");
|
||||
let BadWordsModule = class BadWordsModule {
|
||||
};
|
||||
BadwordsModule = __decorate([
|
||||
BadWordsModule = __decorate([
|
||||
(0, common_1.Global)(),
|
||||
(0, common_1.Module)({
|
||||
imports: [typeorm_1.TypeOrmModule.forFeature([badwords_entity_1.BadWordsEntity, violationLog_entity_1.ViolationLogEntity, user_entity_1.UserEntity])],
|
||||
providers: [badwords_service_1.BadwordsService],
|
||||
controllers: [badwords_controller_1.BadwordsController],
|
||||
exports: [badwords_service_1.BadwordsService],
|
||||
imports: [
|
||||
typeorm_1.TypeOrmModule.forFeature([badWords_entity_1.BadWordsEntity, violationLog_entity_1.ViolationLogEntity, user_entity_1.UserEntity]),
|
||||
],
|
||||
providers: [badWords_service_1.BadWordsService],
|
||||
controllers: [badWords_controller_1.BadWordsController],
|
||||
exports: [badWords_service_1.BadWordsService],
|
||||
})
|
||||
], BadwordsModule);
|
||||
exports.BadwordsModule = BadwordsModule;
|
||||
], BadWordsModule);
|
||||
exports.BadWordsModule = BadWordsModule;
|
||||
|
23
dist/modules/badwords/badwords.service.js
vendored
23
dist/modules/badwords/badwords.service.js
vendored
@@ -12,17 +12,17 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BadwordsService = void 0;
|
||||
exports.BadWordsService = void 0;
|
||||
const utils_1 = require("../../common/utils");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const axios_1 = require("axios");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const globalConfig_service_1 = require("../globalConfig/globalConfig.service");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const globalConfig_service_1 = require("./../globalConfig/globalConfig.service");
|
||||
const badwords_entity_1 = require("./badwords.entity");
|
||||
const badWords_entity_1 = require("./badWords.entity");
|
||||
const violationLog_entity_1 = require("./violationLog.entity");
|
||||
let BadwordsService = class BadwordsService {
|
||||
let BadWordsService = class BadWordsService {
|
||||
constructor(badWordsEntity, violationLogEntity, userEntity, globalConfigService) {
|
||||
this.badWordsEntity = badWordsEntity;
|
||||
this.violationLogEntity = violationLogEntity;
|
||||
@@ -43,16 +43,15 @@ let BadwordsService = class BadwordsService {
|
||||
}
|
||||
if (triggeredWords.length) {
|
||||
await this.recordUserBadWords(userId, content, triggeredWords, ['自定义'], '自定义检测');
|
||||
const tips = `您提交的信息中包含违规的内容、我们已对您的账户进行标记、请合规使用!`;
|
||||
throw new common_1.HttpException(tips, common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
return triggeredWords;
|
||||
}
|
||||
async checkBadWords(content, userId) {
|
||||
const config = await this.globalConfigService.getSensitiveConfig();
|
||||
if (config) {
|
||||
await this.checkBadWordsByConfig(content, config, userId);
|
||||
}
|
||||
await this.customSensitiveWords(content, userId);
|
||||
return await this.customSensitiveWords(content, userId);
|
||||
}
|
||||
async checkBadWordsByConfig(content, config, userId) {
|
||||
const { useType } = config;
|
||||
@@ -189,21 +188,21 @@ let BadwordsService = class BadwordsService {
|
||||
select: ['id', 'avatar', 'username', 'email', 'violationCount', 'status'],
|
||||
});
|
||||
rows.forEach((t) => {
|
||||
const user = usersInfo.find((u) => u.id === t.userId);
|
||||
const user = usersInfo.find((u) => u.id === t.userId) || {};
|
||||
role !== 'super' && (user.email = (0, utils_1.hideString)(user.email));
|
||||
t.userInfo = user;
|
||||
});
|
||||
return { rows, count };
|
||||
}
|
||||
};
|
||||
BadwordsService = __decorate([
|
||||
BadWordsService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(0, (0, typeorm_1.InjectRepository)(badwords_entity_1.BadWordsEntity)),
|
||||
__param(0, (0, typeorm_1.InjectRepository)(badWords_entity_1.BadWordsEntity)),
|
||||
__param(1, (0, typeorm_1.InjectRepository)(violationLog_entity_1.ViolationLogEntity)),
|
||||
__param(2, (0, typeorm_1.InjectRepository)(user_entity_1.UserEntity)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
globalConfig_service_1.GlobalConfigService])
|
||||
], BadwordsService);
|
||||
exports.BadwordsService = BadwordsService;
|
||||
], BadWordsService);
|
||||
exports.BadWordsService = BadWordsService;
|
||||
|
20
dist/modules/chat/chat.controller.js
vendored
20
dist/modules/chat/chat.controller.js
vendored
@@ -18,11 +18,13 @@ const jwtAuth_guard_1 = require("../../common/auth/jwtAuth.guard");
|
||||
const chat_service_1 = require("./chat.service");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const chatProcess_dto_1 = require("./dto/chatProcess.dto");
|
||||
const aiPPT_1 = require("../ai/aiPPT");
|
||||
const globalConfig_service_1 = require("../globalConfig/globalConfig.service");
|
||||
let ChatController = class ChatController {
|
||||
constructor(chatService, globalConfigService) {
|
||||
constructor(chatService, globalConfigService, aiPptService) {
|
||||
this.chatService = chatService;
|
||||
this.globalConfigService = globalConfigService;
|
||||
this.aiPptService = aiPptService;
|
||||
}
|
||||
chatProcess(body, req, res) {
|
||||
return this.chatService.chatProcess(body, req, res);
|
||||
@@ -39,6 +41,9 @@ let ChatController = class ChatController {
|
||||
ttsProcess(body, req, res) {
|
||||
return this.chatService.ttsProcess(body, req, res);
|
||||
}
|
||||
pptCover(body) {
|
||||
return this.aiPptService.pptCover(body);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Post)('chat-process'),
|
||||
@@ -98,10 +103,21 @@ __decorate([
|
||||
__metadata("design:paramtypes", [Object, Object, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], ChatController.prototype, "ttsProcess", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('ppt-cover'),
|
||||
(0, swagger_1.ApiOperation)({ summary: 'ppt封面获取' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], ChatController.prototype, "pptCover", null);
|
||||
ChatController = __decorate([
|
||||
(0, swagger_1.ApiTags)('chatgpt'),
|
||||
(0, common_1.Controller)('chatgpt'),
|
||||
__metadata("design:paramtypes", [chat_service_1.ChatService,
|
||||
globalConfig_service_1.GlobalConfigService])
|
||||
globalConfig_service_1.GlobalConfigService,
|
||||
aiPPT_1.AiPptService])
|
||||
], ChatController);
|
||||
exports.ChatController = ChatController;
|
||||
|
10
dist/modules/chat/chat.module.js
vendored
10
dist/modules/chat/chat.module.js
vendored
@@ -9,6 +9,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ChatModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const aiPPT_1 = require("../ai/aiPPT");
|
||||
const cogVideo_service_1 = require("../ai/cogVideo.service");
|
||||
const fluxDraw_service_1 = require("../ai/fluxDraw.service");
|
||||
const lumaVideo_service_1 = require("../ai/lumaVideo.service");
|
||||
const midjourneyDraw_service_1 = require("../ai/midjourneyDraw.service");
|
||||
const openaiChat_service_1 = require("../ai/openaiChat.service");
|
||||
@@ -22,10 +25,8 @@ const chatLog_service_1 = require("../chatLog/chatLog.service");
|
||||
const cramiPackage_entity_1 = require("../crami/cramiPackage.entity");
|
||||
const config_entity_1 = require("../globalConfig/config.entity");
|
||||
const mailer_service_1 = require("../mailer/mailer.service");
|
||||
const midjourney_entity_1 = require("../midjourney/midjourney.entity");
|
||||
const plugin_entity_1 = require("../plugin/plugin.entity");
|
||||
const redisCache_service_1 = require("../redisCache/redisCache.service");
|
||||
const salesUsers_entity_1 = require("../sales/salesUsers.entity");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const user_service_1 = require("../user/user.service");
|
||||
const accountLog_entity_1 = require("../userBalance/accountLog.entity");
|
||||
@@ -56,9 +57,7 @@ ChatModule = __decorate([
|
||||
chatGroup_entity_1.ChatGroupEntity,
|
||||
app_entity_1.AppEntity,
|
||||
userBalance_entity_1.UserBalanceEntity,
|
||||
salesUsers_entity_1.SalesUsersEntity,
|
||||
fingerprint_entity_1.FingerprintLogEntity,
|
||||
midjourney_entity_1.MidjourneyEntity,
|
||||
]),
|
||||
],
|
||||
controllers: [chat_controller_1.ChatController],
|
||||
@@ -76,6 +75,9 @@ ChatModule = __decorate([
|
||||
midjourneyDraw_service_1.MidjourneyService,
|
||||
openaiDraw_service_1.OpenAIDrawService,
|
||||
lumaVideo_service_1.LumaVideoService,
|
||||
cogVideo_service_1.CogVideoService,
|
||||
fluxDraw_service_1.FluxDrawService,
|
||||
aiPPT_1.AiPptService,
|
||||
],
|
||||
exports: [chat_service_1.ChatService],
|
||||
})
|
||||
|
242
dist/modules/chat/chat.service.js
vendored
242
dist/modules/chat/chat.service.js
vendored
@@ -18,6 +18,9 @@ const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const axios_1 = require("axios");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const aiPPT_1 = require("../ai/aiPPT");
|
||||
const cogVideo_service_1 = require("../ai/cogVideo.service");
|
||||
const fluxDraw_service_1 = require("../ai/fluxDraw.service");
|
||||
const lumaVideo_service_1 = require("../ai/lumaVideo.service");
|
||||
const midjourneyDraw_service_1 = require("../ai/midjourneyDraw.service");
|
||||
const openaiChat_service_1 = require("../ai/openaiChat.service");
|
||||
@@ -26,7 +29,7 @@ const stableDiffusion_service_1 = require("../ai/stableDiffusion.service");
|
||||
const suno_service_1 = require("../ai/suno.service");
|
||||
const app_entity_1 = require("../app/app.entity");
|
||||
const autoreply_service_1 = require("../autoreply/autoreply.service");
|
||||
const badwords_service_1 = require("../badwords/badwords.service");
|
||||
const badWords_service_1 = require("../badWords/badWords.service");
|
||||
const chatGroup_service_1 = require("../chatGroup/chatGroup.service");
|
||||
const chatLog_service_1 = require("../chatLog/chatLog.service");
|
||||
const config_entity_1 = require("../globalConfig/config.entity");
|
||||
@@ -37,7 +40,7 @@ const upload_service_1 = require("../upload/upload.service");
|
||||
const user_service_1 = require("../user/user.service");
|
||||
const userBalance_service_1 = require("../userBalance/userBalance.service");
|
||||
let ChatService = class ChatService {
|
||||
constructor(configEntity, appEntity, pluginEntity, sunoService, openAIChatService, chatLogService, midjourneyService, stableDiffusionService, userBalanceService, userService, uploadService, badwordsService, autoreplyService, globalConfigService, chatGroupService, modelsService, openAIDrawService, lumaVideoService) {
|
||||
constructor(configEntity, appEntity, pluginEntity, sunoService, openAIChatService, chatLogService, midjourneyService, stableDiffusionService, userBalanceService, userService, uploadService, badWordsService, autoreplyService, globalConfigService, chatGroupService, modelsService, openAIDrawService, lumaVideoService, cogVideoService, fluxDrawService, aiPptService) {
|
||||
this.configEntity = configEntity;
|
||||
this.appEntity = appEntity;
|
||||
this.pluginEntity = pluginEntity;
|
||||
@@ -49,16 +52,20 @@ let ChatService = class ChatService {
|
||||
this.userBalanceService = userBalanceService;
|
||||
this.userService = userService;
|
||||
this.uploadService = uploadService;
|
||||
this.badwordsService = badwordsService;
|
||||
this.badWordsService = badWordsService;
|
||||
this.autoreplyService = autoreplyService;
|
||||
this.globalConfigService = globalConfigService;
|
||||
this.chatGroupService = chatGroupService;
|
||||
this.modelsService = modelsService;
|
||||
this.openAIDrawService = openAIDrawService;
|
||||
this.lumaVideoService = lumaVideoService;
|
||||
this.cogVideoService = cogVideoService;
|
||||
this.fluxDrawService = fluxDrawService;
|
||||
this.aiPptService = aiPptService;
|
||||
}
|
||||
async chatProcess(body, req, res) {
|
||||
const { options = {}, usingPluginId, appId = null, specialModel, prompt, fileInfo, modelType, extraParam, model, drawId, customId, action, modelName, modelAvatar, } = body;
|
||||
await this.userBalanceService.checkUserCertification(req.user.id);
|
||||
const { options = {}, usingPluginId, appId = null, specialModel, prompt, fileInfo, extraParam, model, drawId, customId, action, modelName, modelAvatar, } = body;
|
||||
let appInfo;
|
||||
if (specialModel) {
|
||||
appInfo = await this.appEntity.findOne({
|
||||
@@ -74,7 +81,7 @@ let ChatService = class ChatService {
|
||||
}
|
||||
}
|
||||
const { groupId, fileParsing } = options;
|
||||
const { openaiTimeout, openaiBaseUrl, openaiBaseKey, systemPreMessage, isMjTranslate, mjTranslatePrompt, openaiTemperature, openaiBaseModel, } = await this.globalConfigService.getConfigs([
|
||||
const { openaiTimeout, openaiBaseUrl, openaiBaseKey, systemPreMessage, isMjTranslate, mjTranslatePrompt, openaiTemperature, openaiBaseModel, isGeneratePromptReference, isConvertToBase64, isSensitiveWordFilter, } = await this.globalConfigService.getConfigs([
|
||||
'openaiTimeout',
|
||||
'openaiBaseUrl',
|
||||
'openaiBaseKey',
|
||||
@@ -83,11 +90,21 @@ let ChatService = class ChatService {
|
||||
'mjTranslatePrompt',
|
||||
'openaiTemperature',
|
||||
'openaiBaseModel',
|
||||
'isGeneratePromptReference',
|
||||
'isConvertToBase64',
|
||||
'isSensitiveWordFilter',
|
||||
]);
|
||||
await this.userService.checkUserStatus(req.user);
|
||||
res &&
|
||||
res.setHeader('Content-type', 'application/octet-stream; charset=utf-8');
|
||||
await this.badwordsService.checkBadWords(prompt, req.user.id);
|
||||
if (isSensitiveWordFilter === '1') {
|
||||
const triggeredWords = await this.badWordsService.checkBadWords(prompt, req.user.id);
|
||||
if (triggeredWords.length > 0) {
|
||||
const tips = `您提交的信息中包含违规的内容,我们已对您的账户进行标记,请合规使用!`;
|
||||
throw new common_1.HttpException(tips, common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
const autoReplyRes = await this.autoreplyService.checkAutoReply(prompt);
|
||||
let currentRequestModelKey = null;
|
||||
let appName = '';
|
||||
let setSystemMessage = '';
|
||||
@@ -132,6 +149,7 @@ let ChatService = class ChatService {
|
||||
}
|
||||
}
|
||||
else {
|
||||
const groupInfo = await this.chatGroupService.getGroupInfoFromId(groupId);
|
||||
if (usingPlugin && usingPlugin.isSystemPlugin === 0) {
|
||||
let pluginPrompt = '';
|
||||
try {
|
||||
@@ -183,13 +201,13 @@ let ChatService = class ChatService {
|
||||
title: groupInfo.title,
|
||||
isSticky: false,
|
||||
config: updatedConfig,
|
||||
fileUrl: '',
|
||||
}, req);
|
||||
}
|
||||
const { deduct, isTokenBased, tokenFeeRatio, deductType, key, id: keyId, maxRounds, proxyUrl, maxModelTokens, timeout, model: useModel, isFileUpload, } = currentRequestModelKey;
|
||||
const { deduct, isTokenBased, tokenFeeRatio, deductType, key, id: keyId, maxRounds, proxyUrl, maxModelTokens, timeout, model: useModel, isFileUpload, keyType: modelType, } = currentRequestModelKey;
|
||||
if (await this.chatLogService.checkModelLimits(req.user, useModel)) {
|
||||
throw new common_1.HttpException('1 小时内对话次数过多,请切换模型或稍后再试!', common_1.HttpStatus.TOO_MANY_REQUESTS);
|
||||
}
|
||||
common_1.Logger.debug(`原始用户提问: ${prompt}, 是否翻译: ${isMjTranslate}, 翻译提示: ${mjTranslatePrompt}, 模型: ${model}, 是否文件上传: ${isFileUpload}, 文件信息: ${fileInfo}`);
|
||||
if (isMjTranslate === '1' &&
|
||||
action === 'IMAGINE' &&
|
||||
model === 'midjourney') {
|
||||
@@ -265,11 +283,35 @@ let ChatService = class ChatService {
|
||||
});
|
||||
const userLogId = userSaveLog.id;
|
||||
const assistantLogId = assistantSaveLog.id;
|
||||
if (autoReplyRes.answer && res) {
|
||||
if (autoReplyRes.isAIReplyEnabled === 0) {
|
||||
const chars = autoReplyRes.answer.split('');
|
||||
const sendCharByChar = (index) => {
|
||||
if (index < chars.length) {
|
||||
const msg = { text: chars[index] };
|
||||
res.write(`${JSON.stringify(msg)}\n`);
|
||||
setTimeout(() => sendCharByChar(index + 1), 10);
|
||||
}
|
||||
else {
|
||||
res.end();
|
||||
}
|
||||
};
|
||||
sendCharByChar(0);
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
answer: autoReplyRes.answer,
|
||||
});
|
||||
return;
|
||||
}
|
||||
else {
|
||||
setSystemMessage = setSystemMessage + autoReplyRes.answer;
|
||||
}
|
||||
}
|
||||
const { messagesHistory } = await this.buildMessageFromParentMessageId(prompt, {
|
||||
groupId,
|
||||
systemMessage: setSystemMessage,
|
||||
maxModelTokens,
|
||||
maxRounds: maxRounds,
|
||||
isConvertToBase64: isConvertToBase64,
|
||||
fileInfo: fileInfo,
|
||||
model: useModel,
|
||||
isFileUpload,
|
||||
@@ -284,11 +326,15 @@ let ChatService = class ChatService {
|
||||
let response;
|
||||
let firstChunk = true;
|
||||
try {
|
||||
if (useModel === 'dall-e-3' ||
|
||||
if ((useModel === 'dall-e-3' ||
|
||||
useModel === 'midjourney' ||
|
||||
useModel.includes('suno') ||
|
||||
useModel === 'ai-ppt' ||
|
||||
useModel === 'suno-music' ||
|
||||
useModel === 'luma-video' ||
|
||||
useModel.includes('stable-diffusion')) {
|
||||
useModel.includes('stable-diffusion') ||
|
||||
useModel.includes('cog-video') ||
|
||||
useModel.includes('flux')) &&
|
||||
modelType === 2) {
|
||||
if (useModel === 'dall-e-3') {
|
||||
response = this.openAIDrawService.dalleDraw({
|
||||
prompt: prompt,
|
||||
@@ -318,7 +364,57 @@ let ChatService = class ChatService {
|
||||
answer: '绘制中',
|
||||
});
|
||||
}
|
||||
else if (useModel.includes('suno')) {
|
||||
else if (useModel === 'ai-ppt') {
|
||||
common_1.Logger.log('开始生成PPT', 'DrawService');
|
||||
response = this.aiPptService.aiPPT({
|
||||
usePrompt: usePrompt,
|
||||
prompt: prompt,
|
||||
apiKey: modelKey,
|
||||
proxyUrl: proxyResUrl,
|
||||
model: useModel,
|
||||
modelName: useModeName,
|
||||
drawId,
|
||||
customId,
|
||||
action,
|
||||
timeout: modelTimeout,
|
||||
assistantLogId,
|
||||
extraParam,
|
||||
fileInfo,
|
||||
});
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
answer: '生成中',
|
||||
});
|
||||
}
|
||||
else if (useModel.includes('flux')) {
|
||||
response = this.fluxDrawService.fluxDraw({
|
||||
prompt: prompt,
|
||||
extraParam: extraParam,
|
||||
apiKey: modelKey,
|
||||
proxyUrl: proxyResUrl,
|
||||
model: useModel,
|
||||
timeout: modelTimeout,
|
||||
modelName: useModeName,
|
||||
groupId: groupId,
|
||||
onSuccess: async (data) => {
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
fileInfo: data === null || data === void 0 ? void 0 : data.fileInfo,
|
||||
answer: (data === null || data === void 0 ? void 0 : data.answer) || prompt,
|
||||
progress: '100%',
|
||||
status: data.status,
|
||||
});
|
||||
},
|
||||
onFailure: async (data) => {
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
answer: '绘图失败',
|
||||
status: data.status,
|
||||
});
|
||||
},
|
||||
}, this.buildMessageFromParentMessageId);
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
answer: '绘制中',
|
||||
});
|
||||
}
|
||||
else if (useModel.includes('suno-music')) {
|
||||
response = this.sunoService.suno({
|
||||
assistantLogId,
|
||||
apiKey: modelKey,
|
||||
@@ -370,8 +466,46 @@ let ChatService = class ChatService {
|
||||
answer: '提交成功,视频生成中',
|
||||
});
|
||||
}
|
||||
else if (useModel.includes('cog-video')) {
|
||||
response = this.cogVideoService.cogVideo({
|
||||
fileInfo,
|
||||
extraParam,
|
||||
assistantLogId,
|
||||
apiKey: modelKey,
|
||||
action,
|
||||
prompt,
|
||||
model: useModel,
|
||||
timeout: modelTimeout,
|
||||
proxyUrl: proxyResUrl,
|
||||
taskData: customId,
|
||||
onGenerate: async (data) => {
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
fileInfo: data === null || data === void 0 ? void 0 : data.fileInfo,
|
||||
answer: (data === null || data === void 0 ? void 0 : data.answer) || prompt,
|
||||
status: 2,
|
||||
});
|
||||
},
|
||||
onSuccess: async (data) => {
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
fileInfo: data === null || data === void 0 ? void 0 : data.fileInfo,
|
||||
answer: (data === null || data === void 0 ? void 0 : data.answer) || prompt,
|
||||
progress: '100%',
|
||||
status: 3,
|
||||
});
|
||||
},
|
||||
onFailure: async (data) => {
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
answer: data.errMsg,
|
||||
status: 4,
|
||||
});
|
||||
},
|
||||
});
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
answer: '提交成功,视频生成中',
|
||||
});
|
||||
}
|
||||
else if (useModel.includes('stable-diffusion')) {
|
||||
response = this.stableDiffusionService.sdxl(messagesHistory, {
|
||||
response = this.stableDiffusionService.sdxl({
|
||||
chatId: assistantLogId,
|
||||
maxModelTokens,
|
||||
apiKey: modelKey,
|
||||
@@ -481,14 +615,33 @@ let ChatService = class ChatService {
|
||||
completionTokens: completionTokens,
|
||||
totalTokens: promptTokens + completionTokens,
|
||||
});
|
||||
let sanitizedAnswer = response.answer;
|
||||
if (isSensitiveWordFilter === '1') {
|
||||
const triggeredWords = await this.badWordsService.checkBadWords(response.answer, req.user.id);
|
||||
if (triggeredWords.length > 0) {
|
||||
const regex = new RegExp(triggeredWords.join('|'), 'gi');
|
||||
sanitizedAnswer = sanitizedAnswer.replace(regex, (matched) => '*'.repeat(matched.length));
|
||||
}
|
||||
}
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
fileInfo: response === null || response === void 0 ? void 0 : response.fileInfo,
|
||||
answer: response.answer,
|
||||
answer: sanitizedAnswer,
|
||||
promptTokens: promptTokens,
|
||||
completionTokens: completionTokens,
|
||||
totalTokens: promptTokens + completionTokens,
|
||||
status: 3,
|
||||
});
|
||||
try {
|
||||
if (isGeneratePromptReference === '1') {
|
||||
const promptReference = await this.openAIChatService.chatFree(`根据用户提问{${prompt}}以及 AI 的回答{${response.answer}},生成三个更进入一步的提问,用{}包裹每个问题,不需要分行,不需要其他任何内容,单个提问不超过30个字`);
|
||||
await this.chatLogService.updateChatLog(assistantLogId, {
|
||||
promptReference: promptReference,
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error(`调用 chatFree 出错: ${error}`);
|
||||
}
|
||||
if (isTokenBased === true) {
|
||||
charge =
|
||||
deduct *
|
||||
@@ -594,13 +747,14 @@ let ChatService = class ChatService {
|
||||
title: chatTitle,
|
||||
isSticky: false,
|
||||
config: '',
|
||||
fileUrl: '',
|
||||
}, req)
|
||||
.then(() => common_1.Logger.log(`更新标题名称为: ${chatTitle}`, 'ChatService'))
|
||||
.catch((error) => common_1.Logger.error(`更新对话组标题失败: ${error}`));
|
||||
}
|
||||
}
|
||||
async buildMessageFromParentMessageId(text, options, chatLogService) {
|
||||
let { systemMessage = '', fileInfo, groupId, maxRounds = 5, maxModelTokens = 8000, isFileUpload = 0, } = options;
|
||||
let { systemMessage = '', fileInfo, groupId, maxRounds = 5, maxModelTokens = 8000, isFileUpload = 0, isConvertToBase64, } = options;
|
||||
if (systemMessage.length > maxModelTokens) {
|
||||
common_1.Logger.log('系统消息超过最大长度,将被截断', 'ChatService');
|
||||
systemMessage = systemMessage.slice(0, maxModelTokens);
|
||||
@@ -612,16 +766,21 @@ let ChatService = class ChatService {
|
||||
if (groupId) {
|
||||
const history = await chatLogService.chatHistory(groupId, maxRounds);
|
||||
let tempUserMessage = null;
|
||||
history.forEach((record) => {
|
||||
for (const record of history) {
|
||||
try {
|
||||
let content;
|
||||
if ((isFileUpload === 2 || isFileUpload === 3) &&
|
||||
record.fileInfo &&
|
||||
record.role === 'user') {
|
||||
content = [
|
||||
{ type: 'text', text: record.text },
|
||||
{ type: 'image_url', image_url: { url: record.fileInfo } },
|
||||
];
|
||||
const imageUrls = await Promise.all(record.fileInfo.split(',').map(async (url) => ({
|
||||
type: 'image_url',
|
||||
image_url: {
|
||||
url: isConvertToBase64 === '1'
|
||||
? await this.convertUrlToBase64(url.trim())
|
||||
: url.trim(),
|
||||
},
|
||||
})));
|
||||
content = [{ type: 'text', text: record.text }, ...imageUrls];
|
||||
}
|
||||
else if (isFileUpload === 1 &&
|
||||
record.fileInfo &&
|
||||
@@ -648,14 +807,19 @@ let ChatService = class ChatService {
|
||||
catch (error) {
|
||||
common_1.Logger.error('处理历史记录时出错:', error, '记录:', JSON.stringify(record, null, 2));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
let currentMessageContent;
|
||||
if ((isFileUpload === 2 || isFileUpload === 3) && fileInfo) {
|
||||
currentMessageContent = [
|
||||
{ type: 'text', text },
|
||||
{ type: 'image_url', image_url: { url: fileInfo } },
|
||||
];
|
||||
const imageUrls = await Promise.all(fileInfo.split(',').map(async (url) => ({
|
||||
type: 'image_url',
|
||||
image_url: {
|
||||
url: isConvertToBase64 === '1'
|
||||
? await this.convertUrlToBase64(url.trim())
|
||||
: url.trim(),
|
||||
},
|
||||
})));
|
||||
currentMessageContent = [{ type: 'text', text }, ...imageUrls];
|
||||
}
|
||||
else if (isFileUpload === 1 && fileInfo) {
|
||||
currentMessageContent = fileInfo + '\n' + text;
|
||||
@@ -706,13 +870,30 @@ let ChatService = class ChatService {
|
||||
round: messages.length,
|
||||
};
|
||||
}
|
||||
async convertUrlToBase64(url) {
|
||||
try {
|
||||
console.log(`正在尝试转换URL为Base64: ${url}`);
|
||||
const response = await axios_1.default.get(url, { responseType: 'arraybuffer' });
|
||||
const buffer = Buffer.from(response.data, 'binary');
|
||||
console.log(`成功获取图片,正在转换为Base64: ${url}`);
|
||||
const base64Data = `data:${response.headers['content-type']};base64,${buffer.toString('base64')}`;
|
||||
console.log(`成功转换URL为Base64: ${url}`);
|
||||
return base64Data;
|
||||
}
|
||||
catch (error) {
|
||||
console.error('转换URL为Base64时发生错误:', error);
|
||||
console.warn(`返回原始链接: ${url}`);
|
||||
return url;
|
||||
}
|
||||
}
|
||||
async ttsProcess(body, req, res) {
|
||||
const { chatId, prompt } = body;
|
||||
const detailKeyInfo = await this.modelsService.getCurrentModelKeyInfo('tts-1');
|
||||
const { openaiTimeout, openaiBaseUrl, openaiBaseKey } = await this.globalConfigService.getConfigs([
|
||||
const { openaiTimeout, openaiBaseUrl, openaiBaseKey, openaiVoice } = await this.globalConfigService.getConfigs([
|
||||
'openaiTimeout',
|
||||
'openaiBaseUrl',
|
||||
'openaiBaseKey',
|
||||
'openaiVoice',
|
||||
]);
|
||||
const { key, proxyUrl, deduct, deductType, timeout } = detailKeyInfo;
|
||||
const useKey = key || openaiBaseKey;
|
||||
@@ -732,7 +913,7 @@ let ChatService = class ChatService {
|
||||
data: {
|
||||
model: 'tts-1',
|
||||
input: prompt,
|
||||
voice: 'onyx',
|
||||
voice: openaiVoice || 'onyx',
|
||||
},
|
||||
};
|
||||
try {
|
||||
@@ -773,12 +954,15 @@ ChatService = __decorate([
|
||||
userBalance_service_1.UserBalanceService,
|
||||
user_service_1.UserService,
|
||||
upload_service_1.UploadService,
|
||||
badwords_service_1.BadwordsService,
|
||||
badWords_service_1.BadWordsService,
|
||||
autoreply_service_1.AutoreplyService,
|
||||
globalConfig_service_1.GlobalConfigService,
|
||||
chatGroup_service_1.ChatGroupService,
|
||||
models_service_1.ModelsService,
|
||||
openaiDraw_service_1.OpenAIDrawService,
|
||||
lumaVideo_service_1.LumaVideoService])
|
||||
lumaVideo_service_1.LumaVideoService,
|
||||
cogVideo_service_1.CogVideoService,
|
||||
fluxDraw_service_1.FluxDrawService,
|
||||
aiPPT_1.AiPptService])
|
||||
], ChatService);
|
||||
exports.ChatService = ChatService;
|
||||
|
14
dist/modules/chatGroup/chatGroup.entity.js
vendored
14
dist/modules/chatGroup/chatGroup.entity.js
vendored
@@ -10,8 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ChatGroupEntity = void 0;
|
||||
const typeorm_1 = require("typeorm");
|
||||
const baseEntity_1 = require("../../common/entity/baseEntity");
|
||||
const typeorm_1 = require("typeorm");
|
||||
let ChatGroupEntity = class ChatGroupEntity extends baseEntity_1.BaseEntity {
|
||||
};
|
||||
__decorate([
|
||||
@@ -38,6 +38,18 @@ __decorate([
|
||||
(0, typeorm_1.Column)({ comment: '配置', nullable: true, default: null, type: 'text' }),
|
||||
__metadata("design:type", String)
|
||||
], ChatGroupEntity.prototype, "config", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '附加参数', nullable: true, type: 'text' }),
|
||||
__metadata("design:type", String)
|
||||
], ChatGroupEntity.prototype, "params", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '文件链接', nullable: true, default: null, type: 'text' }),
|
||||
__metadata("design:type", String)
|
||||
], ChatGroupEntity.prototype, "fileUrl", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: 'PDF中的文字内容', nullable: true, type: 'mediumtext' }),
|
||||
__metadata("design:type", String)
|
||||
], ChatGroupEntity.prototype, "pdfTextContent", void 0);
|
||||
ChatGroupEntity = __decorate([
|
||||
(0, typeorm_1.Entity)({ name: 'chat_group' })
|
||||
], ChatGroupEntity);
|
||||
|
64
dist/modules/chatGroup/chatGroup.service.js
vendored
64
dist/modules/chatGroup/chatGroup.service.js
vendored
@@ -11,10 +11,23 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ChatGroupService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const axios_1 = require("axios");
|
||||
const pdf = require("pdf-parse");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const app_entity_1 = require("../app/app.entity");
|
||||
const models_service_1 = require("../models/models.service");
|
||||
@@ -27,13 +40,13 @@ let ChatGroupService = class ChatGroupService {
|
||||
}
|
||||
async create(body, req) {
|
||||
const { id } = req.user;
|
||||
const { appId, modelConfig: bodyModelConfig } = body;
|
||||
const { appId, modelConfig: bodyModelConfig, params } = body;
|
||||
let modelConfig = bodyModelConfig || (await this.modelsService.getBaseConfig());
|
||||
if (!modelConfig) {
|
||||
throw new common_1.HttpException('管理员未配置任何AI模型、请先联系管理员开通聊天模型配置!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
modelConfig = JSON.parse(JSON.stringify(modelConfig));
|
||||
const params = { title: '新对话', userId: id, appId };
|
||||
const groupParams = { title: '新对话', userId: id, appId, params };
|
||||
if (appId) {
|
||||
const appInfo = await this.appEntity.findOne({ where: { id: appId } });
|
||||
if (!appInfo) {
|
||||
@@ -59,10 +72,10 @@ let ChatGroupService = class ChatGroupService {
|
||||
throw new common_1.HttpException('非法操作、您在使用一个未启用的应用!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (name) {
|
||||
params.title = name;
|
||||
groupParams.title = name;
|
||||
}
|
||||
}
|
||||
const newGroup = await this.chatGroupEntity.save(Object.assign(Object.assign({}, params), { config: JSON.stringify(modelConfig) }));
|
||||
const newGroup = await this.chatGroupEntity.save(Object.assign(Object.assign({}, groupParams), { config: JSON.stringify(modelConfig) }));
|
||||
return newGroup;
|
||||
}
|
||||
async query(req) {
|
||||
@@ -87,7 +100,7 @@ let ChatGroupService = class ChatGroupService {
|
||||
}
|
||||
}
|
||||
async update(body, req) {
|
||||
const { title, isSticky, groupId, config } = body;
|
||||
const { title, isSticky, groupId, config, fileUrl } = body;
|
||||
const { id } = req.user;
|
||||
const g = await this.chatGroupEntity.findOne({
|
||||
where: { id: groupId, userId: id },
|
||||
@@ -110,14 +123,41 @@ let ChatGroupService = class ChatGroupService {
|
||||
title && (data['title'] = title);
|
||||
typeof isSticky !== 'undefined' && (data['isSticky'] = isSticky);
|
||||
config && (data['config'] = config);
|
||||
fileUrl && (data['fileUrl'] = fileUrl);
|
||||
const u = await this.chatGroupEntity.update({ id: groupId }, data);
|
||||
if (u.affected) {
|
||||
if (fileUrl) {
|
||||
this.handlePdfExtraction(fileUrl, groupId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
throw new common_1.HttpException('更新对话失败!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async handlePdfExtraction(fileUrl, groupId) {
|
||||
try {
|
||||
const pdfText = await this.extractPdfText(fileUrl);
|
||||
await this.chatGroupEntity.update({ id: groupId }, { pdfTextContent: pdfText });
|
||||
}
|
||||
catch (error) {
|
||||
console.error('PDF 读取失败:', error);
|
||||
}
|
||||
}
|
||||
async extractPdfText(fileUrl) {
|
||||
try {
|
||||
const response = await axios_1.default.get(fileUrl, {
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
const dataBuffer = Buffer.from(response.data);
|
||||
const pdfData = await pdf(dataBuffer);
|
||||
return pdfData.text;
|
||||
}
|
||||
catch (error) {
|
||||
console.error('PDF 解析失败:', error);
|
||||
throw new Error('PDF 解析失败');
|
||||
}
|
||||
}
|
||||
async updateTime(groupId) {
|
||||
await this.chatGroupEntity.update(groupId, {
|
||||
updatedAt: new Date(),
|
||||
@@ -153,7 +193,19 @@ let ChatGroupService = class ChatGroupService {
|
||||
async getGroupInfoFromId(id) {
|
||||
if (!id)
|
||||
return;
|
||||
return await this.chatGroupEntity.findOne({ where: { id } });
|
||||
const groupInfo = await this.chatGroupEntity.findOne({ where: { id } });
|
||||
if (groupInfo) {
|
||||
const { pdfTextContent } = groupInfo, rest = __rest(groupInfo, ["pdfTextContent"]);
|
||||
return rest;
|
||||
}
|
||||
}
|
||||
async getGroupPdfText(groupId) {
|
||||
const groupInfo = await this.chatGroupEntity.findOne({
|
||||
where: { id: groupId },
|
||||
});
|
||||
if (groupInfo) {
|
||||
return groupInfo.pdfTextContent;
|
||||
}
|
||||
}
|
||||
};
|
||||
ChatGroupService = __decorate([
|
||||
|
16
dist/modules/chatGroup/dto/createGroup.dto.js
vendored
16
dist/modules/chatGroup/dto/createGroup.dto.js
vendored
@@ -10,8 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CreateGroupDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const class_validator_1 = require("class-validator");
|
||||
class CreateGroupDto {
|
||||
}
|
||||
__decorate([
|
||||
@@ -20,7 +20,19 @@ __decorate([
|
||||
__metadata("design:type", Number)
|
||||
], CreateGroupDto.prototype, "appId", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: "", description: '对话模型配置项序列化的字符串', required: false }),
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: '',
|
||||
description: '对话模型配置项序列化的字符串',
|
||||
required: false,
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], CreateGroupDto.prototype, "modelConfig", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: '',
|
||||
description: '对话组参数序列化的字符串',
|
||||
required: false,
|
||||
}),
|
||||
__metadata("design:type", String)
|
||||
], CreateGroupDto.prototype, "params", void 0);
|
||||
exports.CreateGroupDto = CreateGroupDto;
|
||||
|
13
dist/modules/chatGroup/dto/updateGroup.dto.js
vendored
13
dist/modules/chatGroup/dto/updateGroup.dto.js
vendored
@@ -10,8 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UpdateGroupDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const class_validator_1 = require("class-validator");
|
||||
class UpdateGroupDto {
|
||||
}
|
||||
__decorate([
|
||||
@@ -30,7 +30,16 @@ __decorate([
|
||||
__metadata("design:type", Boolean)
|
||||
], UpdateGroupDto.prototype, "isSticky", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: "", description: '对话模型配置项序列化的字符串', required: false }),
|
||||
(0, swagger_1.ApiProperty)({ example: '', description: '对话组文件地址', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], UpdateGroupDto.prototype, "fileUrl", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: '',
|
||||
description: '对话模型配置项序列化的字符串',
|
||||
required: false,
|
||||
}),
|
||||
__metadata("design:type", String)
|
||||
], UpdateGroupDto.prototype, "config", void 0);
|
||||
exports.UpdateGroupDto = UpdateGroupDto;
|
||||
|
4
dist/modules/chatLog/chatLog.entity.js
vendored
4
dist/modules/chatLog/chatLog.entity.js
vendored
@@ -134,6 +134,10 @@ __decorate([
|
||||
(0, typeorm_1.Column)({ comment: '音频Url', nullable: true, type: 'text' }),
|
||||
__metadata("design:type", String)
|
||||
], ChatLogEntity.prototype, "audioUrl", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '提问参考', nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], ChatLogEntity.prototype, "promptReference", void 0);
|
||||
ChatLogEntity = __decorate([
|
||||
(0, typeorm_1.Entity)({ name: 'chatlog' })
|
||||
], ChatLogEntity);
|
||||
|
8
dist/modules/chatLog/chatLog.module.js
vendored
8
dist/modules/chatLog/chatLog.module.js
vendored
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ChatLogModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const badwords_entity_1 = require("../badwords/badwords.entity");
|
||||
const chatGroup_entity_1 = require("../chatGroup/chatGroup.entity");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const chatLog_controller_1 = require("./chatLog.controller");
|
||||
@@ -21,12 +20,7 @@ ChatLogModule = __decorate([
|
||||
(0, common_1.Global)(),
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
typeorm_1.TypeOrmModule.forFeature([
|
||||
chatLog_entity_1.ChatLogEntity,
|
||||
user_entity_1.UserEntity,
|
||||
badwords_entity_1.BadWordsEntity,
|
||||
chatGroup_entity_1.ChatGroupEntity,
|
||||
]),
|
||||
typeorm_1.TypeOrmModule.forFeature([chatLog_entity_1.ChatLogEntity, user_entity_1.UserEntity, chatGroup_entity_1.ChatGroupEntity]),
|
||||
],
|
||||
controllers: [chatLog_controller_1.ChatLogController],
|
||||
providers: [chatLog_service_1.ChatLogService],
|
||||
|
3
dist/modules/chatLog/chatLog.service.js
vendored
3
dist/modules/chatLog/chatLog.service.js
vendored
@@ -236,7 +236,7 @@ let ChatLogService = class ChatLogService {
|
||||
}
|
||||
const list = await this.chatLogEntity.find({ where });
|
||||
return list.map((item) => {
|
||||
const { prompt, role, answer, createdAt, model, modelName, type, status, action, drawId, id, fileInfo, ttsUrl, videoUrl, audioUrl, customId, pluginParam, modelAvatar, taskData, } = item;
|
||||
const { prompt, role, answer, createdAt, model, modelName, type, status, action, drawId, id, fileInfo, ttsUrl, videoUrl, audioUrl, customId, pluginParam, modelAvatar, taskData, promptReference, } = item;
|
||||
return {
|
||||
chatId: id,
|
||||
dateTime: (0, utils_1.formatDate)(createdAt),
|
||||
@@ -257,6 +257,7 @@ let ChatLogService = class ChatLogService {
|
||||
pluginParam: pluginParam,
|
||||
modelAvatar: modelAvatar,
|
||||
taskData: taskData,
|
||||
promptReference: promptReference,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
4
dist/modules/crami/crami.module.js
vendored
4
dist/modules/crami/crami.module.js
vendored
@@ -12,8 +12,6 @@ const typeorm_1 = require("@nestjs/typeorm");
|
||||
const chatGroup_entity_1 = require("../chatGroup/chatGroup.entity");
|
||||
const chatLog_entity_1 = require("../chatLog/chatLog.entity");
|
||||
const config_entity_1 = require("../globalConfig/config.entity");
|
||||
const midjourney_entity_1 = require("../midjourney/midjourney.entity");
|
||||
const salesUsers_entity_1 = require("../sales/salesUsers.entity");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const accountLog_entity_1 = require("../userBalance/accountLog.entity");
|
||||
const balance_entity_1 = require("../userBalance/balance.entity");
|
||||
@@ -31,7 +29,6 @@ CramiModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
typeorm_1.TypeOrmModule.forFeature([
|
||||
salesUsers_entity_1.SalesUsersEntity,
|
||||
crami_entity_1.CramiEntity,
|
||||
cramiPackage_entity_1.CramiPackageEntity,
|
||||
user_entity_1.UserEntity,
|
||||
@@ -42,7 +39,6 @@ CramiModule = __decorate([
|
||||
fingerprint_entity_1.FingerprintLogEntity,
|
||||
chatLog_entity_1.ChatLogEntity,
|
||||
chatGroup_entity_1.ChatGroupEntity,
|
||||
midjourney_entity_1.MidjourneyEntity,
|
||||
]),
|
||||
],
|
||||
providers: [crami_service_1.CramiService, userBalance_service_1.UserBalanceService],
|
||||
|
101
dist/modules/database/database.service.js
vendored
101
dist/modules/database/database.service.js
vendored
@@ -20,7 +20,6 @@ let DatabaseService = class DatabaseService {
|
||||
async onModuleInit() {
|
||||
await this.checkSuperAdmin();
|
||||
await this.checkSiteBaseConfig();
|
||||
await this.createSystemReservedApps();
|
||||
}
|
||||
async checkSuperAdmin() {
|
||||
const user = await this.connection.query(`SELECT * FROM users WHERE role = 'super'`);
|
||||
@@ -63,13 +62,7 @@ let DatabaseService = class DatabaseService {
|
||||
}
|
||||
}
|
||||
async checkSiteBaseConfig() {
|
||||
const keys = [
|
||||
'siteName',
|
||||
'qqNumber',
|
||||
'vxNumber',
|
||||
'robotAvatar',
|
||||
'userDefautlAvatar',
|
||||
];
|
||||
const keys = ['siteName', 'robotAvatar'];
|
||||
const result = await this.connection.query(`
|
||||
SELECT COUNT(*) AS count FROM config WHERE \`configKey\` IN (${keys
|
||||
.map((k) => `'${k}'`)
|
||||
@@ -91,8 +84,6 @@ let DatabaseService = class DatabaseService {
|
||||
`;
|
||||
const defaultConfig = [
|
||||
{ configKey: 'siteName', configVal: '', public: 1, encry: 0 },
|
||||
{ configKey: 'qqNumber', configVal: '', public: 1, encry: 0 },
|
||||
{ configKey: 'vxNumber', configVal: '', public: 1, encry: 0 },
|
||||
{ configKey: 'robotAvatar', configVal: '', public: 1, encry: 0 },
|
||||
{
|
||||
configKey: 'userDefautlAvatar',
|
||||
@@ -178,44 +169,16 @@ let DatabaseService = class DatabaseService {
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{ configKey: 'inviteSendStatus', configVal: '1', public: 1, encry: 0 },
|
||||
{
|
||||
configKey: 'inviteGiveSendModel3Count',
|
||||
configVal: '0',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'inviteGiveSendModel4Count',
|
||||
configVal: '0',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'inviteGiveSendDrawMjCount',
|
||||
configVal: '0',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'invitedGuestSendModel3Count',
|
||||
configVal: '10',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'invitedGuestSendModel4Count',
|
||||
configVal: '10',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'invitedGuestSendDrawMjCount',
|
||||
configVal: '10',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{ configKey: 'isVerifyEmail', configVal: '1', public: 1, encry: 0 },
|
||||
{ configKey: 'model3Name', configVal: '普通积分', public: 1, encry: 0 },
|
||||
{ configKey: 'model4Name', configVal: '高级积分', public: 1, encry: 0 },
|
||||
{ configKey: 'drawMjName', configVal: '绘画积分', public: 1, encry: 0 },
|
||||
{
|
||||
configKey: 'drawingStyles',
|
||||
configVal: '油画风格,像素风格,赛博朋克,动漫,日系,超现实主义,油画,卡通,插画,海报,写实,扁平,中国风,水墨画,唯美二次元,印象派,炫彩插画,像素艺术,艺术创想,色彩主义,数字艺术',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
];
|
||||
const res = await this.connection.query(`INSERT INTO config (configKey, configVal, public, encry) VALUES ${defaultConfig
|
||||
.map((d) => `('${d.configKey}', '${d.configVal.replace(/'/g, "\\'")}', '${d.public}', '${d.encry}')`)
|
||||
@@ -227,50 +190,6 @@ let DatabaseService = class DatabaseService {
|
||||
throw new common_1.HttpException('创建默认网站配置失败!', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
async createSystemReservedApps() {
|
||||
const systemApps = [
|
||||
{
|
||||
name: '提示词优化PromptOptimization',
|
||||
catId: 9900,
|
||||
des: 'PromptOptimization',
|
||||
preset: "Translate any given phrase from any language into English. For instance, when I input '{可爱的熊猫}', you should output '{cute panda}', with no period at the end.",
|
||||
appModel: 'gpt-3.5-turbo',
|
||||
isFixedModel: 1,
|
||||
isSystemReserved: 1,
|
||||
},
|
||||
{
|
||||
name: '思维导图MindMap',
|
||||
catId: 9900,
|
||||
des: 'MindMap',
|
||||
preset: '我希望你使用markdown格式回答我得问题、我的需求是得到一份markdown格式的大纲、尽量做的精细、层级多一点、不管我问你什么、都需要您回复我一个大纲出来、我想使用大纲做思维导图、除了大纲之外、不要无关内容和总结。',
|
||||
appModel: 'gpt-3.5-turbo',
|
||||
isFixedModel: 1,
|
||||
isSystemReserved: 1,
|
||||
},
|
||||
];
|
||||
try {
|
||||
for (const app of systemApps) {
|
||||
const result = await this.connection.query(`SELECT COUNT(*) AS count FROM app WHERE name = ? AND des = ? AND isSystemReserved = ?`, [app.name, app.des, app.isSystemReserved]);
|
||||
const count = parseInt(result[0].count, 10);
|
||||
if (count === 0) {
|
||||
await this.connection.query(`INSERT INTO app (name, catId, des, preset, appModel, isFixedModel, isSystemReserved) VALUES (?, ?, ?, ?, ?, ?, ?)`, [
|
||||
app.name,
|
||||
app.catId,
|
||||
app.des,
|
||||
app.preset,
|
||||
app.appModel,
|
||||
app.isFixedModel,
|
||||
app.isSystemReserved,
|
||||
]);
|
||||
common_1.Logger.log(`系统预留应用${app.name}创建成功`, 'DatabaseService');
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.log('创建系统预留应用过程中出现错误: ', error);
|
||||
throw new Error('创建系统预留应用失败!');
|
||||
}
|
||||
}
|
||||
};
|
||||
DatabaseService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
|
@@ -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([
|
||||
|
22
dist/modules/menu/dto/queryMenu.dto.js
vendored
22
dist/modules/menu/dto/queryMenu.dto.js
vendored
@@ -1,22 +0,0 @@
|
||||
"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.QueryMenuDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class QueryMenuDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '菜单平台 0:移动端 1:pc端', required: true }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], QueryMenuDto.prototype, "menuPlatform", void 0);
|
||||
exports.QueryMenuDto = QueryMenuDto;
|
59
dist/modules/menu/dto/setMenu.dto.js
vendored
59
dist/modules/menu/dto/setMenu.dto.js
vendored
@@ -1,59 +0,0 @@
|
||||
"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.SetMenuDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class SetMenuDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '菜单id', required: false }),
|
||||
__metadata("design:type", Number)
|
||||
], SetMenuDto.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '测试菜单', description: '菜单文字提示', required: true }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], SetMenuDto.prototype, "menuTipText", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'https:baidu.com', description: '三方网页地址', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], SetMenuDto.prototype, "menuIframeUrl", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: false, description: '是否跳转', required: true }),
|
||||
__metadata("design:type", Boolean)
|
||||
], SetMenuDto.prototype, "isJump", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: true, description: '是否打开菜单', required: true }),
|
||||
__metadata("design:type", Boolean)
|
||||
], SetMenuDto.prototype, "isShow", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'ri:message-3-line', description: '菜单ICON图标代码', required: true }),
|
||||
__metadata("design:type", String)
|
||||
], SetMenuDto.prototype, "menuIcon", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '/chat', description: '站内系统路径', required: true }),
|
||||
__metadata("design:type", String)
|
||||
], SetMenuDto.prototype, "menuPath", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1000, description: '菜单排序id 数字越小越靠前', required: true }),
|
||||
__metadata("design:type", Number)
|
||||
], SetMenuDto.prototype, "order", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: true, description: '是否系统预设', required: true }),
|
||||
__metadata("design:type", Boolean)
|
||||
], SetMenuDto.prototype, "isSystem", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: true, description: '是否需要登录才可访问', required: true }),
|
||||
__metadata("design:type", Boolean)
|
||||
], SetMenuDto.prototype, "isNeedAuth", void 0);
|
||||
exports.SetMenuDto = SetMenuDto;
|
108
dist/modules/menu/menu.controller.js
vendored
108
dist/modules/menu/menu.controller.js
vendored
@@ -1,108 +0,0 @@
|
||||
"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.MenuController = void 0;
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const menu_service_1 = require("./menu.service");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const superAuth_guard_1 = require("../../common/auth/superAuth.guard");
|
||||
const queryMenu_dto_1 = require("./dto/queryMenu.dto");
|
||||
const setMenu_dto_1 = require("./dto/setMenu.dto");
|
||||
const adminAuth_guard_1 = require("../../common/auth/adminAuth.guard");
|
||||
let MenuController = class MenuController {
|
||||
constructor(menuService) {
|
||||
this.menuService = menuService;
|
||||
}
|
||||
queryMenu(query) {
|
||||
return this.menuService.queryMenu(query);
|
||||
}
|
||||
menuListFront(query) {
|
||||
return this.menuService.menuListFront(query);
|
||||
}
|
||||
visibleMenu(params) {
|
||||
return this.menuService.visibleMenu(params);
|
||||
}
|
||||
setMenu(params) {
|
||||
return this.menuService.setMenu(params);
|
||||
}
|
||||
delMenu(params) {
|
||||
return this.menuService.delMenu(params);
|
||||
}
|
||||
updateIcon(params) {
|
||||
return this.menuService.updateIcon(params);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)('query'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '管理端查询菜单列表' }),
|
||||
(0, common_1.UseGuards)(adminAuth_guard_1.AdminAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [queryMenu_dto_1.QueryMenuDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], MenuController.prototype, "queryMenu", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('list'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '用户端查询菜单列表' }),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [queryMenu_dto_1.QueryMenuDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], MenuController.prototype, "menuListFront", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('visible'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '显示或者隐藏菜单' }),
|
||||
(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)
|
||||
], MenuController.prototype, "visibleMenu", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('setMenu'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '设置修改菜单' }),
|
||||
(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", [setMenu_dto_1.SetMenuDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], MenuController.prototype, "setMenu", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('delete'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '删除菜单' }),
|
||||
(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)
|
||||
], MenuController.prototype, "delMenu", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('updateIcon'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '修改菜单ICON' }),
|
||||
(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)
|
||||
], MenuController.prototype, "updateIcon", null);
|
||||
MenuController = __decorate([
|
||||
(0, common_1.Controller)('menu'),
|
||||
__metadata("design:paramtypes", [menu_service_1.MenuService])
|
||||
], MenuController);
|
||||
exports.MenuController = MenuController;
|
64
dist/modules/menu/menu.entity.js
vendored
64
dist/modules/menu/menu.entity.js
vendored
@@ -1,64 +0,0 @@
|
||||
"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.MenuEntity = void 0;
|
||||
const typeorm_1 = require("typeorm");
|
||||
const baseEntity_1 = require("../../common/entity/baseEntity");
|
||||
let MenuEntity = class MenuEntity extends baseEntity_1.BaseEntity {
|
||||
};
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '菜单名称', length: 64, default: null }),
|
||||
__metadata("design:type", String)
|
||||
], MenuEntity.prototype, "menuName", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '菜单路径、跳转的系统路径', length: 64 }),
|
||||
__metadata("design:type", String)
|
||||
], MenuEntity.prototype, "menuPath", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '菜单图标 icon图标名称' }),
|
||||
__metadata("design:type", String)
|
||||
], MenuEntity.prototype, "menuIcon", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '菜单文字提示信息' }),
|
||||
__metadata("design:type", String)
|
||||
], MenuEntity.prototype, "menuTipText", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '菜单类型: 系统预设|自定义菜单', default: 1 }),
|
||||
__metadata("design:type", Number)
|
||||
], MenuEntity.prototype, "menuType", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '菜单平台: 0:移动端 1:pc端', default: 1 }),
|
||||
__metadata("design:type", Number)
|
||||
], MenuEntity.prototype, "menuPlatform", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '菜单加载地址: 系统菜单|自定义菜单', default: null }),
|
||||
__metadata("design:type", String)
|
||||
], MenuEntity.prototype, "menuIframeUrl", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '排序ID', default: 100 }),
|
||||
__metadata("design:type", Number)
|
||||
], MenuEntity.prototype, "order", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '是否显示 1:是|0:不是', default: 1 }),
|
||||
__metadata("design:type", Boolean)
|
||||
], MenuEntity.prototype, "isShow", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '是否跳转到新窗口 0不跳转 1跳转 仅设置为iframe窗口时候有效', default: 0 }),
|
||||
__metadata("design:type", Boolean)
|
||||
], MenuEntity.prototype, "isJump", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '是否权限 登录才可以访问', default: 0 }),
|
||||
__metadata("design:type", Boolean)
|
||||
], MenuEntity.prototype, "isNeedAuth", void 0);
|
||||
MenuEntity = __decorate([
|
||||
(0, typeorm_1.Entity)({ name: 'menu' })
|
||||
], MenuEntity);
|
||||
exports.MenuEntity = MenuEntity;
|
24
dist/modules/menu/menu.module.js
vendored
24
dist/modules/menu/menu.module.js
vendored
@@ -1,24 +0,0 @@
|
||||
"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.MenuModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const menu_controller_1 = require("./menu.controller");
|
||||
const menu_service_1 = require("./menu.service");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const menu_entity_1 = require("./menu.entity");
|
||||
let MenuModule = class MenuModule {
|
||||
};
|
||||
MenuModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [typeorm_1.TypeOrmModule.forFeature([menu_entity_1.MenuEntity])],
|
||||
controllers: [menu_controller_1.MenuController],
|
||||
providers: [menu_service_1.MenuService]
|
||||
})
|
||||
], MenuModule);
|
||||
exports.MenuModule = MenuModule;
|
120
dist/modules/menu/menu.service.js
vendored
120
dist/modules/menu/menu.service.js
vendored
@@ -1,120 +0,0 @@
|
||||
"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.MenuService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const menu_entity_1 = require("./menu.entity");
|
||||
let MenuService = class MenuService {
|
||||
constructor(menuEntity) {
|
||||
this.menuEntity = menuEntity;
|
||||
}
|
||||
async onModuleInit() {
|
||||
await this.initMenu();
|
||||
}
|
||||
async initMenu() {
|
||||
const menuCount = await this.menuEntity.count();
|
||||
if (menuCount > 0)
|
||||
return;
|
||||
const pcMenuData = [
|
||||
{ menuTipText: '对话聊天', menuIcon: 'ri:message-3-line', menuName: 'Chat', menuPath: '/chat', menuType: 0, menuPlatform: 1, order: 100 },
|
||||
{ menuTipText: '应用广场', menuIcon: 'ant-design:appstore-outlined', menuName: 'AppStore', menuPath: '/app-store', menuType: 0, menuPlatform: 1, order: 200 },
|
||||
{ menuTipText: '专业绘画', menuIcon: 'ri:landscape-line', menuName: 'Midjourney', menuPath: '/midjourney', menuType: 0, menuPlatform: 1, order: 300 },
|
||||
{ menuTipText: '绘画广场', menuIcon: 'solar:album-line-duotone', menuName: 'Market', menuPath: '/market', menuType: 0, menuPlatform: 1, order: 400 },
|
||||
{ menuTipText: '思维导图', menuIcon: 'icon-park-outline:mindmap-map', menuName: 'Mind', menuPath: '/mind', menuType: 0, menuPlatform: 1, order: 600 },
|
||||
{ menuTipText: '会员中心', menuIcon: 'icon-park-outline:shopping', menuName: 'Pay', menuPath: '/pay', menuType: 0, menuPlatform: 1, order: 700 },
|
||||
{ menuTipText: '推广计划', menuIcon: 'uiw:share', menuName: 'Share', menuPath: '/share', menuType: 0, menuPlatform: 1, order: 800 },
|
||||
];
|
||||
const mobileMenuData = [
|
||||
{ menuTipText: '对话聊天', menuIcon: 'ri:message-3-line', menuName: 'Chat', menuPath: '/chat', menuType: 0, menuPlatform: 0, order: 100 },
|
||||
{ menuTipText: '应用广场', menuIcon: 'ant-design:appstore-outlined', menuName: 'AppStore', menuPath: '/app-store', menuType: 0, menuPlatform: 0, order: 200 },
|
||||
{ menuTipText: '专业绘画', menuIcon: 'ri:landscape-line', menuName: 'Midjourney', menuPath: '/midjourney', menuType: 0, menuPlatform: 0, order: 300 },
|
||||
{ menuTipText: '思维导图', menuIcon: 'icon-park-outline:mindmap-map', menuName: 'Mind', menuPath: '/mind', menuType: 0, menuPlatform: 0, order: 400 },
|
||||
{ menuTipText: '个人中心', menuIcon: 'ri:account-pin-box-line', menuName: 'UserCenter', menuPath: '/user-center', menuType: 0, menuPlatform: 0, order: 500 },
|
||||
];
|
||||
const initMenuData = [...pcMenuData, ...mobileMenuData];
|
||||
await this.menuEntity.save(initMenuData);
|
||||
}
|
||||
async queryMenu(query) {
|
||||
const { menuPlatform } = query;
|
||||
let where = {};
|
||||
menuPlatform && (where.menuPlatform = menuPlatform);
|
||||
return await this.menuEntity.find({ where, order: { order: 'ASC' } });
|
||||
}
|
||||
async menuListFront(query) {
|
||||
const { menuPlatform } = query;
|
||||
let where = {
|
||||
isShow: true
|
||||
};
|
||||
menuPlatform && (where.menuPlatform = menuPlatform);
|
||||
return await this.menuEntity.find({ where, order: { order: 'ASC' } });
|
||||
}
|
||||
async visibleMenu(params) {
|
||||
const { id } = params;
|
||||
if (!id)
|
||||
return;
|
||||
const m = await this.menuEntity.findOne({ where: { id } });
|
||||
if (!m)
|
||||
return;
|
||||
const { isShow } = m;
|
||||
const res = await this.menuEntity.update({ id }, { isShow: !isShow });
|
||||
return res.affected > 0;
|
||||
}
|
||||
async setMenu(params) {
|
||||
const { id } = params;
|
||||
if (params.isSystem) {
|
||||
params.menuPath = '';
|
||||
}
|
||||
else {
|
||||
params.menuIframeUrl = '';
|
||||
}
|
||||
delete params.isSystem;
|
||||
try {
|
||||
if (id) {
|
||||
const res = await this.menuEntity.update({ id }, params);
|
||||
return res.affected > 0;
|
||||
}
|
||||
else {
|
||||
const res = await this.menuEntity.save(params);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
throw new common_1.HttpException('操作菜单失败!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async delMenu(params) {
|
||||
const { id } = params;
|
||||
if (!id) {
|
||||
throw new common_1.HttpException('缺失必要参数!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const res = await this.menuEntity.delete({ id });
|
||||
return res;
|
||||
}
|
||||
async updateIcon(params) {
|
||||
const { id, menuIcon, menuTipText, order } = params;
|
||||
if (!id || !menuIcon || !menuTipText || !order) {
|
||||
throw new common_1.HttpException('缺失必要参数!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const res = await this.menuEntity.update({ id }, { menuIcon, menuTipText, order });
|
||||
return res.affected > 0;
|
||||
}
|
||||
};
|
||||
MenuService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(0, (0, typeorm_1.InjectRepository)(menu_entity_1.MenuEntity)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository])
|
||||
], MenuService);
|
||||
exports.MenuService = MenuService;
|
42
dist/modules/midjourney/dto/getList.dto.js
vendored
42
dist/modules/midjourney/dto/getList.dto.js
vendored
@@ -1,42 +0,0 @@
|
||||
"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.GetListDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class GetListDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '查询页数', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], GetListDto.prototype, "page", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 10, description: '每页数量', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], GetListDto.prototype, "size", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '是否推荐0: 默认 1: 推荐', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], GetListDto.prototype, "rec", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 99, description: '生成图片的用户id', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], GetListDto.prototype, "userId", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '绘制状态', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], GetListDto.prototype, "status", void 0);
|
||||
exports.GetListDto = GetListDto;
|
75
dist/modules/midjourney/dto/mjDraw.dto.js
vendored
75
dist/modules/midjourney/dto/mjDraw.dto.js
vendored
@@ -1,75 +0,0 @@
|
||||
"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.MjDrawDto = void 0;
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const class_validator_1 = require("class-validator");
|
||||
class MjDrawDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: 'close-up polaroid photo, of a little joyful cute panda, in the forest, sun rays coming, photographic, sharp focus, depth of field, soft lighting, heigh quality, 24mm, Nikon Z FX',
|
||||
description: '绘画提示词!',
|
||||
required: true,
|
||||
}),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], MjDrawDto.prototype, "prompt", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: '--ar 16:9 --c 0',
|
||||
description: '除了prompt的额外参数',
|
||||
}),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], MjDrawDto.prototype, "extraParam", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: 'https://xsdasdasd.com',
|
||||
description: '垫图图片地址',
|
||||
}),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], MjDrawDto.prototype, "imgUrl", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: 'IMAGINE',
|
||||
description: '任务类型,可用值:IMAGINE,UPSCALE,VARIATION,ZOOM,PAN,DESCRIBE,BLEND,SHORTEN,SWAP_FACE',
|
||||
}),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], MjDrawDto.prototype, "action", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '变体或者放大的序号' }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], MjDrawDto.prototype, "orderId", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '绘画的DBID' }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], MjDrawDto.prototype, "drawId", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: 'customId' }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], MjDrawDto.prototype, "customId", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: 'base64' }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], MjDrawDto.prototype, "base64", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '任务ID' }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], MjDrawDto.prototype, "taskId", void 0);
|
||||
exports.MjDrawDto = MjDrawDto;
|
204
dist/modules/midjourney/midjourney.controller.js
vendored
204
dist/modules/midjourney/midjourney.controller.js
vendored
@@ -1,204 +0,0 @@
|
||||
"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.MidjourneyController = void 0;
|
||||
const adminAuth_guard_1 = require("../../common/auth/adminAuth.guard");
|
||||
const jwtAuth_guard_1 = require("../../common/auth/jwtAuth.guard");
|
||||
const superAuth_guard_1 = require("../../common/auth/superAuth.guard");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const axios_1 = require("axios");
|
||||
const getList_dto_1 = require("./dto/getList.dto");
|
||||
const mjDraw_dto_1 = require("./dto/mjDraw.dto");
|
||||
const midjourney_service_1 = require("./midjourney.service");
|
||||
let MidjourneyController = class MidjourneyController {
|
||||
constructor(midjourneyService) {
|
||||
this.midjourneyService = midjourneyService;
|
||||
}
|
||||
async getDrawList(req, params) {
|
||||
return await this.midjourneyService.getDrawList(req, params);
|
||||
}
|
||||
async getList(params) {
|
||||
return await this.midjourneyService.getList(params);
|
||||
}
|
||||
async getFullPrompt(id) {
|
||||
return await this.midjourneyService.getFullPrompt(id);
|
||||
}
|
||||
async getAdminDrawList(req, params) {
|
||||
return await this.midjourneyService.getAdminDrawList(req, params);
|
||||
}
|
||||
async recDraw(params) {
|
||||
return await this.midjourneyService.recDraw(params);
|
||||
}
|
||||
async download(url, res) {
|
||||
const response = await axios_1.default.get(url, { responseType: 'arraybuffer' });
|
||||
const buffer = Buffer.from(response.data, 'binary');
|
||||
res.set({ 'Content-Type': 'image/png' });
|
||||
res.send(buffer);
|
||||
}
|
||||
async deleteDraw(id, req) {
|
||||
return await this.midjourneyService.deleteDraw(id, req);
|
||||
}
|
||||
async delLog(req, body) {
|
||||
return await this.midjourneyService.delLog(req, body);
|
||||
}
|
||||
async setPrompt(req, body) {
|
||||
return await this.midjourneyService.setPrompt(req, body);
|
||||
}
|
||||
async delPrompt(req, body) {
|
||||
return await this.midjourneyService.delPrompt(req, body);
|
||||
}
|
||||
async queryPrompt() {
|
||||
return await this.midjourneyService.queryPrompt();
|
||||
}
|
||||
async proxyImg(params) {
|
||||
return await this.midjourneyService.proxyImg(params);
|
||||
}
|
||||
async mjDraw(body, req) {
|
||||
return await this.midjourneyService.addMjDrawQueue(body, req);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)('drawList'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '获取我的绘画列表' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MidjourneyController.prototype, "getDrawList", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('getList'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '获取绘画列表' }),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [getList_dto_1.GetListDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MidjourneyController.prototype, "getList", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('getFullPrompt'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '获取绘画列表' }),
|
||||
__param(0, (0, common_1.Query)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MidjourneyController.prototype, "getFullPrompt", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('adminDrawList'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '管理端获取绘画列表' }),
|
||||
(0, common_1.UseGuards)(adminAuth_guard_1.AdminAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, getList_dto_1.GetListDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MidjourneyController.prototype, "getAdminDrawList", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('rec'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '推荐图片' }),
|
||||
(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", Promise)
|
||||
], MidjourneyController.prototype, "recDraw", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('download'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '下载绘画' }),
|
||||
__param(0, (0, common_1.Body)('url')),
|
||||
__param(1, (0, common_1.Res)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MidjourneyController.prototype, "download", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('delete'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '删除绘画' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Body)('id')),
|
||||
__param(1, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MidjourneyController.prototype, "deleteDraw", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('del'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '删除log' }),
|
||||
(0, common_1.UseGuards)(superAuth_guard_1.SuperAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MidjourneyController.prototype, "delLog", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('setPrompt'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '添加修改prompt提示词' }),
|
||||
(0, common_1.UseGuards)(superAuth_guard_1.SuperAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MidjourneyController.prototype, "setPrompt", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('delPrompt'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '添加修改prompt提示词' }),
|
||||
(0, common_1.UseGuards)(superAuth_guard_1.SuperAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MidjourneyController.prototype, "delPrompt", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('queryPrompts'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '查询prompt列表' }),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MidjourneyController.prototype, "queryPrompt", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('proxy'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '代理图片' }),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MidjourneyController.prototype, "proxyImg", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('addMjDrawQueue'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '提交绘制图片任务' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [mjDraw_dto_1.MjDrawDto, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], MidjourneyController.prototype, "mjDraw", null);
|
||||
MidjourneyController = __decorate([
|
||||
(0, common_1.Controller)('midjourney'),
|
||||
__metadata("design:paramtypes", [midjourney_service_1.MidjourneyService])
|
||||
], MidjourneyController);
|
||||
exports.MidjourneyController = MidjourneyController;
|
96
dist/modules/midjourney/midjourney.entity.js
vendored
96
dist/modules/midjourney/midjourney.entity.js
vendored
@@ -1,96 +0,0 @@
|
||||
"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.MidjourneyEntity = void 0;
|
||||
const typeorm_1 = require("typeorm");
|
||||
const baseEntity_1 = require("../../common/entity/baseEntity");
|
||||
let MidjourneyEntity = class MidjourneyEntity extends baseEntity_1.BaseEntity {
|
||||
};
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '用户ID' }),
|
||||
__metadata("design:type", Number)
|
||||
], MidjourneyEntity.prototype, "userId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '任务ID', nullable: true }),
|
||||
__metadata("design:type", Number)
|
||||
], MidjourneyEntity.prototype, "jobId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '额外参数', nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], MidjourneyEntity.prototype, "extraParam", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '绘画描述词', type: 'text' }),
|
||||
__metadata("design:type", String)
|
||||
], MidjourneyEntity.prototype, "prompt", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '垫图图片基础地址', nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], MidjourneyEntity.prototype, "imgUrl", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '垫图图片 + 绘画描述词 + 额外参数 = 完整的prompt', type: 'text' }),
|
||||
__metadata("design:type", String)
|
||||
], MidjourneyEntity.prototype, "fullPrompt", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '当前绘制任务的进度', nullable: true }),
|
||||
__metadata("design:type", Number)
|
||||
], MidjourneyEntity.prototype, "progress", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '当前绘制任务的耗时', nullable: true }),
|
||||
__metadata("design:type", Number)
|
||||
], MidjourneyEntity.prototype, "durationSpent", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '当前绘制任务的状态' }),
|
||||
__metadata("design:type", Number)
|
||||
], MidjourneyEntity.prototype, "status", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: 'mj绘画的动作、绘图、放大、变换、图生图' }),
|
||||
__metadata("design:type", String)
|
||||
], MidjourneyEntity.prototype, "action", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '一组图片的第几张、放大或者变换的时候需要使用', nullable: true }),
|
||||
__metadata("design:type", Number)
|
||||
], MidjourneyEntity.prototype, "orderId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '是否推荐0: 默认不推荐 1: 推荐', nullable: true, default: 0 }),
|
||||
__metadata("design:type", Number)
|
||||
], MidjourneyEntity.prototype, "rec", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '对图片操作的', nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], MidjourneyEntity.prototype, "customId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '绘画的ID每条不一样', nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], MidjourneyEntity.prototype, "drawId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '图片链接', nullable: true, type: 'text' }),
|
||||
__metadata("design:type", String)
|
||||
], MidjourneyEntity.prototype, "drawUrl", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '图片比例', nullable: true, type: 'text' }),
|
||||
__metadata("design:type", String)
|
||||
], MidjourneyEntity.prototype, "drawRatio", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '扩展参数', nullable: true, type: 'text' }),
|
||||
__metadata("design:type", String)
|
||||
], MidjourneyEntity.prototype, "extend", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '是否删除 0: 未删除 1: 已删除', nullable: true, default: 0 }),
|
||||
__metadata("design:type", Number)
|
||||
], MidjourneyEntity.prototype, "isDelete", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '是否存入了图片到配置的储存项 配置了则存储 不配置地址则是源地址', default: true }),
|
||||
__metadata("design:type", Boolean)
|
||||
], MidjourneyEntity.prototype, "isSaveImg", void 0);
|
||||
MidjourneyEntity = __decorate([
|
||||
(0, typeorm_1.Entity)({ name: 'midjourney' })
|
||||
], MidjourneyEntity);
|
||||
exports.MidjourneyEntity = MidjourneyEntity;
|
47
dist/modules/midjourney/midjourney.module.js
vendored
47
dist/modules/midjourney/midjourney.module.js
vendored
@@ -1,47 +0,0 @@
|
||||
"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.MidjourneyModule = void 0;
|
||||
const bull_1 = require("@nestjs/bull");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const redisCache_service_1 = require("../redisCache/redisCache.service");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const midjourney_controller_1 = require("./midjourney.controller");
|
||||
const midjourney_entity_1 = require("./midjourney.entity");
|
||||
const midjourney_service_1 = require("./midjourney.service");
|
||||
const prompt_entity_1 = require("./prompt.entity");
|
||||
let MidjourneyModule = class MidjourneyModule {
|
||||
};
|
||||
MidjourneyModule = __decorate([
|
||||
(0, common_1.Global)(),
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
bull_1.BullModule.registerQueueAsync({
|
||||
name: 'MJDRAW',
|
||||
useFactory: () => {
|
||||
const config = {
|
||||
port: +process.env.REDIS_PORT,
|
||||
host: process.env.REDIS_HOST,
|
||||
db: Number(process.env.REDIS_DB || 0),
|
||||
};
|
||||
process.env.REDIS_PASSWORD &&
|
||||
(config.password = process.env.REDIS_PASSWORD);
|
||||
return {
|
||||
redis: config,
|
||||
};
|
||||
},
|
||||
}),
|
||||
typeorm_1.TypeOrmModule.forFeature([midjourney_entity_1.MidjourneyEntity, user_entity_1.UserEntity, prompt_entity_1.mjPromptEntity]),
|
||||
],
|
||||
controllers: [midjourney_controller_1.MidjourneyController],
|
||||
providers: [midjourney_service_1.MidjourneyService, redisCache_service_1.RedisCacheService],
|
||||
exports: [midjourney_service_1.MidjourneyService],
|
||||
})
|
||||
], MidjourneyModule);
|
||||
exports.MidjourneyModule = MidjourneyModule;
|
613
dist/modules/midjourney/midjourney.service.js
vendored
613
dist/modules/midjourney/midjourney.service.js
vendored
@@ -1,613 +0,0 @@
|
||||
"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.MidjourneyService = void 0;
|
||||
const midjourney_constant_1 = require("../../common/constants/midjourney.constant");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const axios_1 = require("axios");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const globalConfig_service_1 = require("../globalConfig/globalConfig.service");
|
||||
const models_service_1 = require("../models/models.service");
|
||||
const upload_service_1 = require("../upload/upload.service");
|
||||
const user_entity_1 = require("./../user/user.entity");
|
||||
const midjourney_entity_1 = require("./midjourney.entity");
|
||||
const utils_1 = require("../../common/utils");
|
||||
const userBalance_service_1 = require("../userBalance/userBalance.service");
|
||||
const bull_1 = require("@nestjs/bull");
|
||||
const image_size_1 = require("image-size");
|
||||
const redisCache_service_1 = require("../redisCache/redisCache.service");
|
||||
const prompt_entity_1 = require("./prompt.entity");
|
||||
let MidjourneyService = class MidjourneyService {
|
||||
constructor(mjDrawQueue, midjourneyEntity, userEntity, mjPromptsEntity, globalConfigService, uploadService, userBalanceService, redisCacheService, modelsService) {
|
||||
this.mjDrawQueue = mjDrawQueue;
|
||||
this.midjourneyEntity = midjourneyEntity;
|
||||
this.userEntity = userEntity;
|
||||
this.mjPromptsEntity = mjPromptsEntity;
|
||||
this.globalConfigService = globalConfigService;
|
||||
this.uploadService = uploadService;
|
||||
this.userBalanceService = userBalanceService;
|
||||
this.redisCacheService = redisCacheService;
|
||||
this.modelsService = modelsService;
|
||||
this.lockPrompt = [];
|
||||
}
|
||||
async onApplicationBootstrap() {
|
||||
await this.mjDrawQueue.clean(0, 'active');
|
||||
await this.cleanQueue();
|
||||
}
|
||||
async addMjDrawQueue(body, req) {
|
||||
const { prompt = '', imgUrl = '', base64 = '', extraParam = '', drawId = null, action = '', orderId = null, customId = '', } = body;
|
||||
await this.checkLimit(req);
|
||||
const modelInfo = await this.modelsService.getCurrentModelKeyInfo('midjourney');
|
||||
const { deduct, deductType, proxyUrl, timeout } = modelInfo;
|
||||
await this.userBalanceService.validateBalance(req, deductType, action === 'UPSCALE' ? deduct : deduct * 4);
|
||||
const params = Object.assign(Object.assign({}, body), { userId: req.user.id });
|
||||
const drawInfo = await this.addDrawQueue(params);
|
||||
if (action === 'IMAGINE') {
|
||||
this.sendDrawCommand(drawInfo, modelInfo)
|
||||
.then((result) => this.pollComparisonResultDraw(result, modelInfo))
|
||||
.then((drawRes) => {
|
||||
console.log('drawRes', drawRes);
|
||||
return this.updateDrawData(drawInfo, drawRes);
|
||||
})
|
||||
.catch((error) => {
|
||||
common_1.Logger.error('Error in IMAGINE draw operation:', error);
|
||||
});
|
||||
}
|
||||
else {
|
||||
let resultPromise;
|
||||
if (action === 'MODAL') {
|
||||
common_1.Logger.debug('customId:', customId);
|
||||
drawInfo.drawId = (await this.getDrawActionDetail(drawId, customId)).drawId;
|
||||
resultPromise = this.sendDrawCommand(drawInfo, modelInfo);
|
||||
}
|
||||
else {
|
||||
resultPromise = this.sendDrawCommand(drawInfo, modelInfo);
|
||||
}
|
||||
resultPromise
|
||||
.then((result) => this.pollComparisonResultDraw(result, modelInfo))
|
||||
.then((drawRes) => {
|
||||
console.log('drawRes', drawRes);
|
||||
return this.updateDrawData(drawInfo, drawRes);
|
||||
})
|
||||
.catch((error) => {
|
||||
common_1.Logger.error('Error in other draw operation:', error);
|
||||
});
|
||||
}
|
||||
common_1.Logger.log(`执行预扣费,扣除费用:${action === 'UPSCALE' ? deduct : deduct * 4}积分。`, 'MidjourneyService');
|
||||
await this.userBalanceService.deductFromBalance(req.user.id, deductType, action === 'UPSCALE' ? deduct : deduct * 4);
|
||||
return true;
|
||||
}
|
||||
async sleep(time) {
|
||||
return new Promise((resolve) => setTimeout(resolve, time));
|
||||
}
|
||||
async getImageSizeFromUrl(imageUrl) {
|
||||
try {
|
||||
const response = await axios_1.default.get(imageUrl, {
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
const buffer = Buffer.from(response.data, 'binary');
|
||||
const dimensions = (0, image_size_1.default)(buffer);
|
||||
return { width: dimensions.width, height: dimensions.height };
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Error fetching image size:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
async addDrawQueue(params) {
|
||||
try {
|
||||
const { prompt, imgUrl = '', extraParam = '', action, userId, customId, drawId, base64, } = params;
|
||||
const fullPrompt = imgUrl
|
||||
? `${imgUrl} ${prompt} ${extraParam}`
|
||||
: `${prompt} ${extraParam}`;
|
||||
const drawInfo = {
|
||||
userId,
|
||||
drawId,
|
||||
extraParam,
|
||||
prompt,
|
||||
imgUrl,
|
||||
fullPrompt,
|
||||
status: midjourney_constant_1.MidjourneyStatusEnum.WAITING,
|
||||
action,
|
||||
customId,
|
||||
base64,
|
||||
};
|
||||
const res = await this.midjourneyEntity.save(drawInfo);
|
||||
return res;
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Error in addDrawQueue:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
async updateDrawStatus(id, status) {
|
||||
await this.midjourneyEntity.update({ id }, { status });
|
||||
}
|
||||
async updateDrawData(jobData, drawRes) {
|
||||
try {
|
||||
const { id, imageUrl, action, submitTime, finishTime, progress } = drawRes;
|
||||
const durationSpent = finishTime - submitTime;
|
||||
const { mjNotSaveImg, mjProxyImgUrl, mjNotUseProxy } = await this.globalConfigService.getConfigs([
|
||||
'mjNotSaveImg',
|
||||
'mjProxyImgUrl',
|
||||
'mjNotUseProxy',
|
||||
]);
|
||||
let cosUrl = '';
|
||||
let isSaveImg = true;
|
||||
common_1.Logger.log(`绘制成功, 获取到的URL: ${imageUrl}`, 'MidjourneyService');
|
||||
let processedUrl = imageUrl;
|
||||
const shouldReplaceUrl = mjNotUseProxy === '0' && mjProxyImgUrl;
|
||||
let logMessage = '';
|
||||
if (shouldReplaceUrl) {
|
||||
const newUrlBase = new URL(mjProxyImgUrl);
|
||||
const parsedUrl = new URL(imageUrl);
|
||||
parsedUrl.protocol = newUrlBase.protocol;
|
||||
parsedUrl.hostname = newUrlBase.hostname;
|
||||
parsedUrl.port = newUrlBase.port ? newUrlBase.port : '';
|
||||
processedUrl = parsedUrl.toString();
|
||||
logMessage = `使用代理替换后的 URL: ${processedUrl}`;
|
||||
common_1.Logger.log(logMessage, 'MidjourneyService');
|
||||
}
|
||||
if (mjNotSaveImg !== '1') {
|
||||
try {
|
||||
common_1.Logger.debug(`------> 开始上传图片!!!`);
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(now.getDate()).padStart(2, '0');
|
||||
const currentDate = `${year}${month}/${day}`;
|
||||
common_1.Logger.debug(`------> 上传图片的URL: ${processedUrl}`);
|
||||
if (!processedUrl) {
|
||||
throw new Error('processedUrl is undefined or empty');
|
||||
}
|
||||
processedUrl = await this.uploadService.uploadFileFromUrl({
|
||||
url: processedUrl,
|
||||
dir: `midjourney/${currentDate}`,
|
||||
});
|
||||
logMessage = `上传成功 URL: ${processedUrl}`;
|
||||
common_1.Logger.debug(logMessage);
|
||||
}
|
||||
catch (uploadError) {
|
||||
common_1.Logger.error('存储图片失败,使用原始/代理图片链接');
|
||||
common_1.Logger.error(uploadError.message);
|
||||
common_1.Logger.error(uploadError.stack);
|
||||
logMessage = `存储图片失败,使用原始/代理图片链接 ${processedUrl}`;
|
||||
common_1.Logger.debug(logMessage);
|
||||
}
|
||||
common_1.Logger.log(logMessage, 'MidjourneyService');
|
||||
}
|
||||
else {
|
||||
logMessage = `不保存图片,使用 URL: ${processedUrl}`;
|
||||
common_1.Logger.log(logMessage, 'MidjourneyService');
|
||||
}
|
||||
const { width, height } = await this.getImageSizeFromUrl(processedUrl);
|
||||
const drawInfo = {
|
||||
status: midjourney_constant_1.MidjourneyStatusEnum.DRAWED,
|
||||
drawId: id,
|
||||
action: action,
|
||||
drawUrl: processedUrl,
|
||||
drawRatio: `${width}x${height}`,
|
||||
progress: 100,
|
||||
extend: JSON.stringify(drawRes),
|
||||
durationSpent,
|
||||
isSaveImg,
|
||||
};
|
||||
await this.midjourneyEntity.update({ id: jobData.id }, drawInfo);
|
||||
}
|
||||
catch (error) {
|
||||
throw new common_1.HttpException('更新绘画数据失败', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async sendDrawCommand(drawInfo, modelInfo) {
|
||||
const { openaiBaseUrl, openaiBaseKey } = await this.globalConfigService.getConfigs([
|
||||
'openaiBaseUrl',
|
||||
'openaiBaseKey',
|
||||
]);
|
||||
const { key, proxyUrl } = modelInfo;
|
||||
const mjProxyUrl = proxyUrl || openaiBaseUrl;
|
||||
const mjKey = key || openaiBaseKey;
|
||||
const { id, fullPrompt, imgUrl, drawId, customId, action, base64 } = drawInfo;
|
||||
const prompt = imgUrl ? `${imgUrl} ${fullPrompt}` : `${fullPrompt}`;
|
||||
let url = '';
|
||||
let payloadJson = {};
|
||||
const MAX_RETRIES = 3;
|
||||
let retryCount = 0;
|
||||
const headers = { 'mj-api-secret': mjKey };
|
||||
while (retryCount < MAX_RETRIES) {
|
||||
try {
|
||||
if (action === 'IMAGINE') {
|
||||
url = `${mjProxyUrl}/mj/submit/imagine`;
|
||||
payloadJson = { prompt: prompt };
|
||||
}
|
||||
else if (action === 'MODAL') {
|
||||
url = `${mjProxyUrl}/mj/submit/modal`;
|
||||
payloadJson = { maskBase64: base64, taskId: drawId, prompt: prompt };
|
||||
console.log('提交参数', payloadJson);
|
||||
}
|
||||
else {
|
||||
url = `${mjProxyUrl}/mj/submit/action`;
|
||||
payloadJson = { taskId: drawId, customId: customId };
|
||||
}
|
||||
const res = await axios_1.default.post(url, payloadJson, { headers });
|
||||
const { result } = res.data;
|
||||
if (result) {
|
||||
common_1.Logger.log(`绘画任务提交成功 绘画ID: ${result}`, 'MidjourneyService');
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
throw new Error('未能获取结果数据');
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error(`请求失败:${error.message}`);
|
||||
retryCount++;
|
||||
if (retryCount >= MAX_RETRIES) {
|
||||
await this.updateDrawStatus(id, midjourney_constant_1.MidjourneyStatusEnum.DRAWFAIL);
|
||||
throw new common_1.HttpException('发送绘图指令失败、请联系管理员检测绘画配置!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
async pollComparisonResultDraw(drawId, modelInfo) {
|
||||
const { key, proxyUrl, timeout, id } = modelInfo;
|
||||
const { openaiTimeout, openaiBaseUrl, openaiBaseKey } = await this.globalConfigService.getConfigs([
|
||||
'openaiTimeout',
|
||||
'openaiBaseUrl',
|
||||
'openaiBaseKey',
|
||||
]);
|
||||
const effectiveTimeout = Math.max(timeout || openaiTimeout || 300, 300);
|
||||
const TIMEOUT = effectiveTimeout * 1000;
|
||||
const mjProxyUrl = proxyUrl || openaiBaseUrl;
|
||||
const mjKey = key || openaiBaseKey;
|
||||
const startTime = Date.now();
|
||||
const POLL_INTERVAL = 5000;
|
||||
let pollingCount = 0;
|
||||
let retryCount = 0;
|
||||
const MAX_RETRIES = 5;
|
||||
try {
|
||||
while (Date.now() - startTime < TIMEOUT && retryCount < MAX_RETRIES) {
|
||||
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL));
|
||||
common_1.Logger.log(`【绘制图片】第 ${pollingCount + 1} 次开始查询, 使用 drawId: ${drawId}`, 'MidjourneyService');
|
||||
try {
|
||||
const headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'mj-api-secret': mjKey,
|
||||
};
|
||||
const url = `${mjProxyUrl}/mj/task/${drawId}/fetch`;
|
||||
const res = await axios_1.default.get(url, { headers });
|
||||
const responses = res.data;
|
||||
common_1.Logger.debug(`【绘制图片】第 ${pollingCount + 1} 次查询结果: ${JSON.stringify(responses)}`, 'MidjourneyService');
|
||||
const progress = responses.process;
|
||||
await this.midjourneyEntity.update({ id }, { progress: progress });
|
||||
if (responses.status === 'SUCCESS') {
|
||||
common_1.Logger.log(`绘制成功, URL: ${responses.imageUrl}`, 'MidjourneyService');
|
||||
return responses;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
retryCount++;
|
||||
common_1.Logger.error(`轮询过程中发生错误: ${error}`, 'MidjourneyService');
|
||||
}
|
||||
pollingCount++;
|
||||
}
|
||||
if (retryCount >= MAX_RETRIES) {
|
||||
await this.updateDrawStatus(id, midjourney_constant_1.MidjourneyStatusEnum.DRAWFAIL);
|
||||
throw new common_1.HttpException('轮询失败次数过多,请稍后再试!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
common_1.Logger.error('绘画超时,请稍后再试!', 'MidjourneyService');
|
||||
await this.updateDrawStatus(id, midjourney_constant_1.MidjourneyStatusEnum.DRAWFAIL);
|
||||
throw new common_1.HttpException('绘画超时,请稍后再试!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error('获取图片结果失败: ', error, 'MidjourneyService');
|
||||
await this.updateDrawStatus(id, midjourney_constant_1.MidjourneyStatusEnum.DRAWFAIL);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
async bindJobId(id, jobId) {
|
||||
await this.midjourneyEntity.update({ id }, { jobId });
|
||||
}
|
||||
async getDrawList(req, params) {
|
||||
try {
|
||||
const { page = 1, size = 30 } = params;
|
||||
const [rows, count] = await this.midjourneyEntity.findAndCount({
|
||||
where: { userId: req.user.id, isDelete: 0 },
|
||||
order: { id: 'DESC' },
|
||||
take: size,
|
||||
skip: (page - 1) * size,
|
||||
select: [
|
||||
'id',
|
||||
'userId',
|
||||
'prompt',
|
||||
'extraParam',
|
||||
'fullPrompt',
|
||||
'rec',
|
||||
'orderId',
|
||||
'drawId',
|
||||
'drawUrl',
|
||||
'drawRatio',
|
||||
'isDelete',
|
||||
'status',
|
||||
'action',
|
||||
'extend',
|
||||
],
|
||||
});
|
||||
const countQueue = await this.midjourneyEntity.count({
|
||||
where: { isDelete: 0, status: (0, typeorm_2.In)([1, 2]) },
|
||||
});
|
||||
const data = {
|
||||
rows: (0, utils_1.formatCreateOrUpdateDate)(rows),
|
||||
count,
|
||||
countQueue,
|
||||
};
|
||||
return data;
|
||||
}
|
||||
catch (error) {
|
||||
throw new common_1.HttpException('获取我得绘制列表失败', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async getDrawActionDetail(drawId, customId) {
|
||||
const modelInfo = await this.modelsService.getSpecialModelKeyInfo('midjourney');
|
||||
const { openaiBaseUrl, openaiBaseKey } = await this.globalConfigService.getConfigs([
|
||||
'openaiBaseUrl',
|
||||
'openaiBaseKey',
|
||||
]);
|
||||
const { key, id: keyId, maxRounds, proxyUrl, maxModelTokens, timeout, model: useModel, } = modelInfo;
|
||||
const mjProxyUrl = proxyUrl;
|
||||
const mjKey = key || openaiBaseKey;
|
||||
const headers = { 'mj-api-secret': mjKey || openaiBaseUrl };
|
||||
let resultId;
|
||||
const payloadJson = { taskId: drawId, customId: customId };
|
||||
const url = `${mjProxyUrl}/mj/submit/action`;
|
||||
const res = await axios_1.default.post(url, payloadJson, { headers });
|
||||
resultId = res.data.result;
|
||||
console.log('Received response from action submission:', resultId);
|
||||
return { drawId: resultId };
|
||||
}
|
||||
async deleteDraw(id, req) {
|
||||
const d = await this.midjourneyEntity.findOne({
|
||||
where: { id, userId: req.user.id, isDelete: 0 },
|
||||
});
|
||||
if (!d) {
|
||||
throw new common_1.HttpException('当前图片不存在!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (d.status === 2) {
|
||||
throw new common_1.HttpException('绘制中的图片任务、禁止删除!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const res = await this.midjourneyEntity.update({ id }, { isDelete: 1 });
|
||||
if (res.affected > 0) {
|
||||
return '删除成功!';
|
||||
}
|
||||
else {
|
||||
throw new common_1.HttpException('删除失败!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async checkLimit(req) {
|
||||
const { role, id } = req.user;
|
||||
const count = await this.midjourneyEntity.count({
|
||||
where: { userId: id, isDelete: 0, status: (0, typeorm_2.In)([1, 2]) },
|
||||
});
|
||||
const mjLimitCount = await this.globalConfigService.getConfigs([
|
||||
'mjLimitCount',
|
||||
]);
|
||||
const max = mjLimitCount ? Number(mjLimitCount) : 2;
|
||||
if (count >= max) {
|
||||
throw new common_1.HttpException(`当前管理员限制单用户同时最多能执行${max}个任务`, common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async drawFailed(jobData) {
|
||||
const { id, userId, action } = jobData;
|
||||
await this.midjourneyEntity.update({ id }, { status: 4 });
|
||||
}
|
||||
async getList(params) {
|
||||
const { page = 1, size = 20, rec, userId, status } = params;
|
||||
if (Number(size) === 999) {
|
||||
const cache = await this.redisCacheService.get({
|
||||
key: 'midjourney:getList',
|
||||
});
|
||||
if (cache) {
|
||||
try {
|
||||
return JSON.parse(cache);
|
||||
}
|
||||
catch (error) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
const where = { isDelete: 0 };
|
||||
rec && Object.assign(where, { rec });
|
||||
userId && Object.assign(where, { userId });
|
||||
status && Object.assign(where, { status });
|
||||
const [rows, count] = await this.midjourneyEntity.findAndCount({
|
||||
where,
|
||||
order: { id: 'DESC' },
|
||||
take: size,
|
||||
skip: (page - 1) * size,
|
||||
select: [
|
||||
'id',
|
||||
'drawId',
|
||||
'drawUrl',
|
||||
'drawRatio',
|
||||
'prompt',
|
||||
'fullPrompt',
|
||||
'rec',
|
||||
'createdAt',
|
||||
'action',
|
||||
'status',
|
||||
'extend',
|
||||
],
|
||||
});
|
||||
if (Number(size) === 999) {
|
||||
const data = {
|
||||
rows: rows.map((item) => {
|
||||
const { id, drawId, drawUrl, drawRatio, prompt, fullPrompt, createdAt, rec, action, status, extend, } = item;
|
||||
return {
|
||||
id,
|
||||
drawId,
|
||||
drawUrl,
|
||||
drawRatio,
|
||||
prompt,
|
||||
fullPrompt,
|
||||
createdAt,
|
||||
rec,
|
||||
action,
|
||||
status,
|
||||
extend,
|
||||
};
|
||||
}),
|
||||
count,
|
||||
};
|
||||
await this.redisCacheService.set({ key: 'midjourney:getList', val: JSON.stringify(data) }, 60 * 5);
|
||||
return data;
|
||||
}
|
||||
const data = { rows, count };
|
||||
return data;
|
||||
}
|
||||
async getFullPrompt(id) {
|
||||
const m = await this.midjourneyEntity.findOne({ where: { id } });
|
||||
if (!m)
|
||||
return '';
|
||||
const { fullPrompt } = m;
|
||||
return fullPrompt;
|
||||
}
|
||||
async getAdminDrawList(req, params) {
|
||||
try {
|
||||
const { page = 1, size = 10, rec, userId, status } = params;
|
||||
const where = { isDelete: 0 };
|
||||
rec && Object.assign(where, { rec });
|
||||
userId && Object.assign(where, { userId });
|
||||
status && Object.assign(where, { status });
|
||||
const [rows, count] = await this.midjourneyEntity.findAndCount({
|
||||
where,
|
||||
order: { id: 'DESC' },
|
||||
take: size,
|
||||
skip: (page - 1) * size,
|
||||
});
|
||||
const userIds = rows
|
||||
.map((item) => item.userId)
|
||||
.filter((id) => id < 100000);
|
||||
const userInfos = await this.userEntity.find({
|
||||
where: { id: (0, typeorm_2.In)(userIds) },
|
||||
select: ['id', 'username', 'avatar', 'email'],
|
||||
});
|
||||
rows.forEach((item) => {
|
||||
item.userInfo = userInfos.find((user) => user.id === item.userId);
|
||||
});
|
||||
if (req.user.role !== 'super') {
|
||||
rows.forEach((item) => {
|
||||
if (item.userInfo && item.userInfo.email) {
|
||||
item.userInfo.email = item.userInfo.email.replace(/(.{2}).+(.{2}@.+)/, '$1****$2');
|
||||
}
|
||||
});
|
||||
}
|
||||
return { rows, count };
|
||||
}
|
||||
catch (error) {
|
||||
throw new common_1.HttpException('查询失败!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async recDraw(params) {
|
||||
const { id } = params;
|
||||
const draw = await this.midjourneyEntity.findOne({
|
||||
where: { id, status: 3, isDelete: 0 },
|
||||
});
|
||||
if (!draw) {
|
||||
throw new common_1.HttpException('当前图片不存在!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const { rec } = draw;
|
||||
const res = await this.midjourneyEntity.update({ id }, { rec: rec === 1 ? 0 : 1 });
|
||||
if (res.affected > 0) {
|
||||
return '操作成功!';
|
||||
}
|
||||
}
|
||||
async cleanQueue() {
|
||||
try {
|
||||
await this.midjourneyEntity.update({ status: 2 }, { status: 4 });
|
||||
}
|
||||
catch (error) {
|
||||
console.log('TODO->error: ', error);
|
||||
}
|
||||
}
|
||||
async delLog(req, body) {
|
||||
const { id } = body;
|
||||
if (!id) {
|
||||
throw new common_1.HttpException('非法操作!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const res = await this.midjourneyEntity.delete({ id });
|
||||
if (res.affected > 0) {
|
||||
return '删除记录成功!';
|
||||
}
|
||||
else {
|
||||
throw new common_1.HttpException('删除记录失败!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async setPrompt(req, body) {
|
||||
try {
|
||||
const { prompt, status, isCarryParams, title, order, id, aspect } = body;
|
||||
if (id) {
|
||||
return await this.mjPromptsEntity.update({ id }, { prompt, status, isCarryParams, order, aspect });
|
||||
}
|
||||
else {
|
||||
return await this.mjPromptsEntity.save({
|
||||
prompt,
|
||||
status,
|
||||
isCarryParams,
|
||||
title,
|
||||
order,
|
||||
aspect,
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.log('error: ', error);
|
||||
}
|
||||
}
|
||||
async delPrompt(req, body) {
|
||||
const { id } = body;
|
||||
if (!id) {
|
||||
throw new common_1.HttpException('非法操作!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
return await this.mjPromptsEntity.delete({ id });
|
||||
}
|
||||
async queryPrompt() {
|
||||
return await this.mjPromptsEntity.find({
|
||||
order: { order: 'DESC' },
|
||||
});
|
||||
}
|
||||
async proxyImg(params) {
|
||||
const { url } = params;
|
||||
if (!url)
|
||||
return;
|
||||
const response = await axios_1.default.get(url, { responseType: 'arraybuffer' });
|
||||
const base64 = Buffer.from(response.data).toString('base64');
|
||||
return base64;
|
||||
}
|
||||
};
|
||||
MidjourneyService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(0, (0, bull_1.InjectQueue)('MJDRAW')),
|
||||
__param(1, (0, typeorm_1.InjectRepository)(midjourney_entity_1.MidjourneyEntity)),
|
||||
__param(2, (0, typeorm_1.InjectRepository)(user_entity_1.UserEntity)),
|
||||
__param(3, (0, typeorm_1.InjectRepository)(prompt_entity_1.mjPromptEntity)),
|
||||
__metadata("design:paramtypes", [Object, typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
globalConfig_service_1.GlobalConfigService,
|
||||
upload_service_1.UploadService,
|
||||
userBalance_service_1.UserBalanceService,
|
||||
redisCache_service_1.RedisCacheService,
|
||||
models_service_1.ModelsService])
|
||||
], MidjourneyService);
|
||||
exports.MidjourneyService = MidjourneyService;
|
48
dist/modules/midjourney/prompt.entity.js
vendored
48
dist/modules/midjourney/prompt.entity.js
vendored
@@ -1,48 +0,0 @@
|
||||
"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.mjPromptEntity = void 0;
|
||||
const typeorm_1 = require("typeorm");
|
||||
const baseEntity_1 = require("../../common/entity/baseEntity");
|
||||
let mjPromptEntity = class mjPromptEntity extends baseEntity_1.BaseEntity {
|
||||
};
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '绘画描述词', type: 'text' }),
|
||||
__metadata("design:type", String)
|
||||
], mjPromptEntity.prototype, "prompt", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '开启状态', default: true }),
|
||||
__metadata("design:type", Boolean)
|
||||
], mjPromptEntity.prototype, "status", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '是否携带左边的参数', default: true }),
|
||||
__metadata("design:type", Boolean)
|
||||
], mjPromptEntity.prototype, "isCarryParams", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '提示词名称', type: 'text' }),
|
||||
__metadata("design:type", String)
|
||||
], mjPromptEntity.prototype, "title", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '排序id', default: 100 }),
|
||||
__metadata("design:type", Number)
|
||||
], mjPromptEntity.prototype, "order", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '图片比例' }),
|
||||
__metadata("design:type", String)
|
||||
], mjPromptEntity.prototype, "aspect", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '描述', nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], mjPromptEntity.prototype, "desc", void 0);
|
||||
mjPromptEntity = __decorate([
|
||||
(0, typeorm_1.Entity)({ name: 'mj_prompt' })
|
||||
], mjPromptEntity);
|
||||
exports.mjPromptEntity = mjPromptEntity;
|
18
dist/modules/models/dto/queryModel.dto.js
vendored
18
dist/modules/models/dto/queryModel.dto.js
vendored
@@ -26,15 +26,27 @@ __decorate([
|
||||
__metadata("design:type", Number)
|
||||
], QueryModelDto.prototype, "keyType", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'dsadgadaorjoqm', description: '模型key', required: true }),
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: 'dsadgadaorjoqm',
|
||||
description: '模型key',
|
||||
required: true,
|
||||
}),
|
||||
__metadata("design:type", String)
|
||||
], QueryModelDto.prototype, "key", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: true, description: '是否开启当前key对应的模型', required: true }),
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: true,
|
||||
description: '是否开启当前key对应的模型',
|
||||
required: true,
|
||||
}),
|
||||
__metadata("design:type", Boolean)
|
||||
], QueryModelDto.prototype, "status", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'gpt-3.5', description: '当前key绑定的模型是多少 需要调用的模型', required: true }),
|
||||
(0, swagger_1.ApiProperty)({
|
||||
example: 'gpt-3.5',
|
||||
description: '当前key绑定的模型是多少 需要调用的模型',
|
||||
required: true,
|
||||
}),
|
||||
__metadata("design:type", String)
|
||||
], QueryModelDto.prototype, "model", void 0);
|
||||
exports.QueryModelDto = QueryModelDto;
|
||||
|
22
dist/modules/official/dto/getQrSceneStr.dto.js
vendored
22
dist/modules/official/dto/getQrSceneStr.dto.js
vendored
@@ -1,22 +0,0 @@
|
||||
"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.GetQrSceneStrDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class GetQrSceneStrDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'SNINE', description: '用户邀请码', required: true }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], GetQrSceneStrDto.prototype, "invitedBy", void 0);
|
||||
exports.GetQrSceneStrDto = GetQrSceneStrDto;
|
12
dist/modules/official/official.controller.js
vendored
12
dist/modules/official/official.controller.js
vendored
@@ -18,7 +18,6 @@ const utils_1 = require("../../common/utils");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const getQrCode_dto_1 = require("./dto/getQrCode.dto");
|
||||
const getQrSceneStr_dto_1 = require("./dto/getQrSceneStr.dto");
|
||||
const official_service_1 = require("./official.service");
|
||||
let OfficialController = class OfficialController {
|
||||
constructor(officialService) {
|
||||
@@ -76,8 +75,8 @@ let OfficialController = class OfficialController {
|
||||
}
|
||||
return 'success';
|
||||
}
|
||||
async getQRSceneStr(body) {
|
||||
return this.officialService.getQRSceneStr(body);
|
||||
async getQRSceneStr() {
|
||||
return this.officialService.getQRSceneStr();
|
||||
}
|
||||
async getQRSceneStrByBind(req) {
|
||||
return this.officialService.getQRSceneStrByBind(req);
|
||||
@@ -90,7 +89,7 @@ let OfficialController = class OfficialController {
|
||||
return `${Url}/cgi-bin/showqrcode?ticket=${encodeURIComponent(ticket)}`;
|
||||
}
|
||||
async loginBySceneStr(req, body) {
|
||||
return this.officialService.loginBySceneStr(req, body.sceneStr);
|
||||
return this.officialService.loginBySceneStr(req, body);
|
||||
}
|
||||
async bindWxBySceneStr(req, body) {
|
||||
return this.officialService.bindWxBySceneStr(req, body.sceneStr);
|
||||
@@ -129,9 +128,8 @@ __decorate([
|
||||
__decorate([
|
||||
(0, common_1.Post)('getQRSceneStr'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '获取登录二维码sceneStr' }),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [getQrSceneStr_dto_1.GetQrSceneStrDto]),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], OfficialController.prototype, "getQRSceneStr", null);
|
||||
__decorate([
|
||||
@@ -157,7 +155,7 @@ __decorate([
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, getQrCode_dto_1.GetQrCodeDto]),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], OfficialController.prototype, "loginBySceneStr", null);
|
||||
__decorate([
|
||||
|
7
dist/modules/official/official.service.js
vendored
7
dist/modules/official/official.service.js
vendored
@@ -32,10 +32,8 @@ let OfficialService = class OfficialService {
|
||||
async onModuleInit() {
|
||||
await this.globalConfigService.getWechatAccessToken(true);
|
||||
}
|
||||
async getQRSceneStr(body) {
|
||||
const { invitedBy } = body;
|
||||
async getQRSceneStr() {
|
||||
let sceneStr = (0, utils_1.createRandomNonceStr)(32);
|
||||
invitedBy && (sceneStr += `:${invitedBy}`);
|
||||
this.sceneStrMap[sceneStr] = true;
|
||||
return sceneStr;
|
||||
}
|
||||
@@ -124,7 +122,8 @@ let OfficialService = class OfficialService {
|
||||
throw new common_1.HttpException('处理扫码事件时发生错误', common_1.HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
async loginBySceneStr(req, sceneStr) {
|
||||
async loginBySceneStr(req, body) {
|
||||
const { sceneStr } = body;
|
||||
if (!this.sceneStrMap[sceneStr])
|
||||
return;
|
||||
const userId = this.scanedSceneStrMap[sceneStr];
|
||||
|
37
dist/modules/sales/dto/appForMoney.dto.js
vendored
37
dist/modules/sales/dto/appForMoney.dto.js
vendored
@@ -1,37 +0,0 @@
|
||||
"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.AppForMoneyDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class AppForMoneyDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 10, description: '提现金额', required: true }),
|
||||
(0, class_validator_1.IsNumber)({}, { message: '提现金额必须为数字' }),
|
||||
(0, class_validator_1.Min)(0, { message: '提现金额必须大于0' }),
|
||||
__metadata("design:type", Number)
|
||||
], AppForMoneyDto.prototype, "withdrawalAmount", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '提现渠道', required: true }),
|
||||
(0, class_validator_1.IsIn)([1, 2], { message: '提现渠道非法' }),
|
||||
__metadata("design:type", Number)
|
||||
], AppForMoneyDto.prototype, "withdrawalChannels", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 10, description: '提款联系方式', required: true }),
|
||||
__metadata("design:type", String)
|
||||
], AppForMoneyDto.prototype, "contactInformation", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 10, description: '提款备注', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], AppForMoneyDto.prototype, "remark", void 0);
|
||||
exports.AppForMoneyDto = AppForMoneyDto;
|
27
dist/modules/sales/dto/auditOrder.dto.js
vendored
27
dist/modules/sales/dto/auditOrder.dto.js
vendored
@@ -1,27 +0,0 @@
|
||||
"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.AuditOrderDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class AuditOrderDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '审核工单状态', required: true }),
|
||||
(0, class_validator_1.IsIn)([1, -1], { message: '非法工单状态' }),
|
||||
__metadata("design:type", Number)
|
||||
], AuditOrderDto.prototype, "status", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '工单id', required: true }),
|
||||
(0, class_validator_1.IsNumber)({}, { message: '工单id必须为数字' }),
|
||||
__metadata("design:type", Number)
|
||||
], AuditOrderDto.prototype, "id", void 0);
|
||||
exports.AuditOrderDto = AuditOrderDto;
|
32
dist/modules/sales/dto/drawMoneyOrder.dto.js
vendored
32
dist/modules/sales/dto/drawMoneyOrder.dto.js
vendored
@@ -1,32 +0,0 @@
|
||||
"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.drawMoneyOrderDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class drawMoneyOrderDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '查询页数', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], drawMoneyOrderDto.prototype, "page", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 10, description: '每页数量', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], drawMoneyOrderDto.prototype, "size", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 10, description: '工单状态', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], drawMoneyOrderDto.prototype, "orderStatus", void 0);
|
||||
exports.drawMoneyOrderDto = drawMoneyOrderDto;
|
37
dist/modules/sales/dto/recordsQuery.dto.js
vendored
37
dist/modules/sales/dto/recordsQuery.dto.js
vendored
@@ -1,37 +0,0 @@
|
||||
"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.RecordsQueryDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class RecordsQueryDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '查询页数', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], RecordsQueryDto.prototype, "page", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 10, description: '每页数量', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], RecordsQueryDto.prototype, "size", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'c8c479601c1e11eea4c49fad2cbd3ccd', description: '订单ID', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], RecordsQueryDto.prototype, "orderId", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 10, description: '订单价格', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], RecordsQueryDto.prototype, "orderPrice", void 0);
|
||||
exports.RecordsQueryDto = RecordsQueryDto;
|
37
dist/modules/sales/dto/salesOrder.dto.js
vendored
37
dist/modules/sales/dto/salesOrder.dto.js
vendored
@@ -1,37 +0,0 @@
|
||||
"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.salesOrderDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class salesOrderDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '查询页数', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], salesOrderDto.prototype, "page", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 10, description: '每页数量', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], salesOrderDto.prototype, "size", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 10, description: '工单状态', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Object)
|
||||
], salesOrderDto.prototype, "orderStatus", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '提现渠道', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], salesOrderDto.prototype, "withdrawalChannels", void 0);
|
||||
exports.salesOrderDto = salesOrderDto;
|
52
dist/modules/sales/dto/salesUserList.dto.js
vendored
52
dist/modules/sales/dto/salesUserList.dto.js
vendored
@@ -1,52 +0,0 @@
|
||||
"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.SalesUserListDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class SalesUserListDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '查询页数', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], SalesUserListDto.prototype, "page", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 10, description: '每页数量', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], SalesUserListDto.prototype, "size", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 99, description: '支付的用户id', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], SalesUserListDto.prototype, "userId", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 'epay', description: '支付的平台', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], SalesUserListDto.prototype, "platform", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '订单状态', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], SalesUserListDto.prototype, "status", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '分销人称号', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], SalesUserListDto.prototype, "salesOutletName", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '返佣比例', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], SalesUserListDto.prototype, "performanceRatio", void 0);
|
||||
exports.SalesUserListDto = SalesUserListDto;
|
33
dist/modules/sales/dto/updateUserSales.dto.js
vendored
33
dist/modules/sales/dto/updateUserSales.dto.js
vendored
@@ -1,33 +0,0 @@
|
||||
"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.UpdateUserSalesDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
class UpdateUserSalesDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 10, description: '佣金比例', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsNumber)({}, { message: '佣金比例必须是数字' }),
|
||||
__metadata("design:type", Number)
|
||||
], UpdateUserSalesDto.prototype, "performanceRatio", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: '超级合伙人', description: '自定义分销商名称', required: false }),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], UpdateUserSalesDto.prototype, "salesOutletName", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiProperty)({ example: 1, description: '用户ID' }),
|
||||
(0, class_validator_1.IsNumber)({}, { message: '用户ID必须是数字' }),
|
||||
__metadata("design:type", Number)
|
||||
], UpdateUserSalesDto.prototype, "userId", void 0);
|
||||
exports.UpdateUserSalesDto = UpdateUserSalesDto;
|
163
dist/modules/sales/sales.controller.js
vendored
163
dist/modules/sales/sales.controller.js
vendored
@@ -1,163 +0,0 @@
|
||||
"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.SalesController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const sales_service_1 = require("./sales.service");
|
||||
const jwtAuth_guard_1 = require("../../common/auth/jwtAuth.guard");
|
||||
const recordsQuery_dto_1 = require("./dto/recordsQuery.dto");
|
||||
const appForMoney_dto_1 = require("./dto/appForMoney.dto");
|
||||
const drawMoneyOrder_dto_1 = require("./dto/drawMoneyOrder.dto");
|
||||
const salesOrder_dto_1 = require("./dto/salesOrder.dto");
|
||||
const adminAuth_guard_1 = require("../../common/auth/adminAuth.guard");
|
||||
const superAuth_guard_1 = require("../../common/auth/superAuth.guard");
|
||||
const auditOrder_dto_1 = require("./dto/auditOrder.dto");
|
||||
const salesUserList_dto_1 = require("./dto/salesUserList.dto");
|
||||
const updateUserSales_dto_1 = require("./dto/updateUserSales.dto");
|
||||
let SalesController = class SalesController {
|
||||
constructor(salesService) {
|
||||
this.salesService = salesService;
|
||||
}
|
||||
async getMineAccount(req) {
|
||||
return this.salesService.getMineAccount(req);
|
||||
}
|
||||
async getMineRecords(req, query) {
|
||||
return this.salesService.getMineRecords(req, query);
|
||||
}
|
||||
async inviteRecords(req, query) {
|
||||
return this.salesService.inviteRecords(req, query);
|
||||
}
|
||||
async appForMoney(req, body) {
|
||||
return this.salesService.appForMoney(req, body);
|
||||
}
|
||||
async drawMoneyOrder(req, query) {
|
||||
return this.salesService.drawMoneyOrder(req, query);
|
||||
}
|
||||
async salesOrder(req, query) {
|
||||
return this.salesService.salesOrder(req, query);
|
||||
}
|
||||
async auditOrder(req, body) {
|
||||
return this.salesService.auditOrder(req, body);
|
||||
}
|
||||
async salesUserList(req, query) {
|
||||
return this.salesService.salesUserList(req, query);
|
||||
}
|
||||
async updateUserSales(req, body) {
|
||||
return this.salesService.updateUserSales(req, body);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)('mineAccount'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '获取个人分销账户' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], SalesController.prototype, "getMineAccount", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('mineRecords'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '获取个人推介记录' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, recordsQuery_dto_1.RecordsQueryDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], SalesController.prototype, "getMineRecords", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('inviteRecords'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '管理端获取个人推介记录' }),
|
||||
(0, common_1.UseGuards)(adminAuth_guard_1.AdminAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, recordsQuery_dto_1.RecordsQueryDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], SalesController.prototype, "inviteRecords", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('appForMoney'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '申请提现' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, appForMoney_dto_1.AppForMoneyDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], SalesController.prototype, "appForMoney", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('drawMoneyOrder'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '获取个人提款工单列表' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, drawMoneyOrder_dto_1.drawMoneyOrderDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], SalesController.prototype, "drawMoneyOrder", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('salesOrder'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '管理端获取工单列表' }),
|
||||
(0, common_1.UseGuards)(adminAuth_guard_1.AdminAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, salesOrder_dto_1.salesOrderDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], SalesController.prototype, "salesOrder", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('auditOrder'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '审核工单' }),
|
||||
(0, common_1.UseGuards)(superAuth_guard_1.SuperAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, auditOrder_dto_1.AuditOrderDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], SalesController.prototype, "auditOrder", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('salesUserList'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '查询用户佣金账户' }),
|
||||
(0, common_1.UseGuards)(adminAuth_guard_1.AdminAuthGuard),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, salesUserList_dto_1.SalesUserListDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], SalesController.prototype, "salesUserList", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('updateUserSales'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '修改用户佣金账户' }),
|
||||
(0, common_1.UseGuards)(superAuth_guard_1.SuperAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, updateUserSales_dto_1.UpdateUserSalesDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], SalesController.prototype, "updateUserSales", null);
|
||||
SalesController = __decorate([
|
||||
(0, swagger_1.ApiTags)('sales'),
|
||||
(0, common_1.Controller)('sales'),
|
||||
__metadata("design:paramtypes", [sales_service_1.SalesService])
|
||||
], SalesController);
|
||||
exports.SalesController = SalesController;
|
29
dist/modules/sales/sales.module.js
vendored
29
dist/modules/sales/sales.module.js
vendored
@@ -1,29 +0,0 @@
|
||||
"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.SalesModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const sales_controller_1 = require("./sales.controller");
|
||||
const sales_service_1 = require("./sales.service");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const salesUsers_entity_1 = require("./salesUsers.entity");
|
||||
const salesRecords_entity_1 = require("./salesRecords.entity");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const salesOrder_entity_1 = require("./salesOrder.entity");
|
||||
let SalesModule = class SalesModule {
|
||||
};
|
||||
SalesModule = __decorate([
|
||||
(0, common_1.Global)(),
|
||||
(0, common_1.Module)({
|
||||
imports: [typeorm_1.TypeOrmModule.forFeature([salesUsers_entity_1.SalesUsersEntity, salesRecords_entity_1.SalesRecordsEntity, user_entity_1.UserEntity, salesOrder_entity_1.SalesOrderEntity])],
|
||||
controllers: [sales_controller_1.SalesController],
|
||||
providers: [sales_service_1.SalesService],
|
||||
exports: [sales_service_1.SalesService],
|
||||
})
|
||||
], SalesModule);
|
||||
exports.SalesModule = SalesModule;
|
292
dist/modules/sales/sales.service.js
vendored
292
dist/modules/sales/sales.service.js
vendored
@@ -1,292 +0,0 @@
|
||||
"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.SalesService = void 0;
|
||||
const globalConfig_service_1 = require("./../globalConfig/globalConfig.service");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const salesUsers_entity_1 = require("./salesUsers.entity");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const salesRecords_entity_1 = require("./salesRecords.entity");
|
||||
const utils_1 = require("../../common/utils");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const decimal_js_1 = require("decimal.js");
|
||||
const salesOrder_entity_1 = require("./salesOrder.entity");
|
||||
let SalesService = class SalesService {
|
||||
constructor(salesUsersEntity, salesRecordsEntity, userEntity, salesOrderEntity, globalConfigService) {
|
||||
this.salesUsersEntity = salesUsersEntity;
|
||||
this.salesRecordsEntity = salesRecordsEntity;
|
||||
this.userEntity = userEntity;
|
||||
this.salesOrderEntity = salesOrderEntity;
|
||||
this.globalConfigService = globalConfigService;
|
||||
}
|
||||
async getMineAccount(req) {
|
||||
try {
|
||||
const { id: userId } = req.user;
|
||||
let u = await this.salesUsersEntity.findOne({ where: { userId } });
|
||||
if (!u) {
|
||||
const { salesBaseRatio = 10, salesBaseTitle = '新秀分销商' } = await this.globalConfigService.getConfigs([
|
||||
'salesBaseRatio',
|
||||
'salesBaseTitle',
|
||||
]);
|
||||
u = await this.creaetUserBaseSalesInfo({ userId, performanceRatio: Number(salesBaseRatio), salesOutletName: salesBaseTitle });
|
||||
}
|
||||
const account = (0, utils_1.formatCreateOrUpdateDate)(u);
|
||||
const orderCount = await this.salesRecordsEntity.count({ where: { inviterUserId: userId } });
|
||||
const userInfo = await this.userEntity.findOne({ where: { id: userId } }) || { inviteLinkCount: 0, inviteCode: 'xxxxxxx' };
|
||||
const { inviteLinkCount, inviteCode } = userInfo;
|
||||
const inviteCount = await this.userEntity.count({ where: { invitedBy: inviteCode } });
|
||||
return Object.assign(Object.assign({}, account), { orderCount,
|
||||
inviteCount,
|
||||
inviteLinkCount });
|
||||
}
|
||||
catch (error) {
|
||||
console.log('error: ', error);
|
||||
}
|
||||
}
|
||||
async getMineRecords(req, query) {
|
||||
try {
|
||||
const { id: inviterUserId } = req.user;
|
||||
const { page, size } = query;
|
||||
const [rows, count] = await this.salesRecordsEntity.findAndCount({
|
||||
where: { inviterUserId },
|
||||
order: { createdAt: 'DESC' },
|
||||
skip: (page - 1) * size,
|
||||
take: size,
|
||||
});
|
||||
return {
|
||||
rows: (0, utils_1.formatCreateOrUpdateDate)(rows),
|
||||
count,
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
console.log('error: ', error);
|
||||
}
|
||||
}
|
||||
async inviteRecords(req, query) {
|
||||
try {
|
||||
const { page, size, orderId, orderPrice } = query;
|
||||
let where = {};
|
||||
orderId && (where = { orderId });
|
||||
orderPrice && (where = { orderPrice });
|
||||
const [rows, count] = await this.salesRecordsEntity.findAndCount({
|
||||
where,
|
||||
order: { createdAt: 'DESC' },
|
||||
skip: (page - 1) * size,
|
||||
take: size,
|
||||
});
|
||||
const userIds = [];
|
||||
rows.map((item) => {
|
||||
userIds.push(item.inviterUserId);
|
||||
userIds.push(item.inviteeUserId);
|
||||
});
|
||||
const userInfo = await this.userEntity.find({ where: { id: (0, typeorm_2.In)(userIds) } });
|
||||
rows.forEach((item) => {
|
||||
const inviterUser = userInfo.find((u) => u.id === item.inviterUserId);
|
||||
const inviteeUser = userInfo.find((u) => u.id === item.inviteeUserId);
|
||||
const { username, email, avatar } = userInfo.find((u) => u.id === item.inviterUserId);
|
||||
item.inviterUsername = inviterUser === null || inviterUser === void 0 ? void 0 : inviterUser.username;
|
||||
item.inviterEmail = inviterUser === null || inviterUser === void 0 ? void 0 : inviterUser.email;
|
||||
item.inviterAvatar = inviterUser === null || inviterUser === void 0 ? void 0 : inviterUser.avatar;
|
||||
item.inviteeUsername = inviteeUser === null || inviteeUser === void 0 ? void 0 : inviteeUser.username;
|
||||
item.inviteeEmail = inviteeUser === null || inviteeUser === void 0 ? void 0 : inviteeUser.email;
|
||||
item.inviteeAvatar = inviteeUser === null || inviteeUser === void 0 ? void 0 : inviteeUser.avatar;
|
||||
});
|
||||
if (req.user.role !== 'super') {
|
||||
rows.forEach((item) => {
|
||||
item.inviterEmail = item.inviterEmail ? (0, utils_1.hideString)(item.inviterEmail) : '';
|
||||
item.inviteeEmail = item.inviteeEmail ? (0, utils_1.hideString)(item.inviteeEmail) : '';
|
||||
});
|
||||
}
|
||||
return {
|
||||
rows: (0, utils_1.formatCreateOrUpdateDate)(rows),
|
||||
count,
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
console.log('error: ', error);
|
||||
}
|
||||
}
|
||||
async creaetUserBaseSalesInfo(salesInfo) {
|
||||
const { userId, performanceRatio, salesOutletName } = salesInfo;
|
||||
return await this.salesUsersEntity.save({ userId, performanceRatio, salesOutletName });
|
||||
}
|
||||
async changeUserBaseSalesInfo(salesInfo) {
|
||||
return await this.salesUsersEntity.save(salesInfo);
|
||||
}
|
||||
async createSalesRecords(salesRecords) {
|
||||
return await this.salesRecordsEntity.save(salesRecords);
|
||||
}
|
||||
async saveCommissionAmount(userId, amount) {
|
||||
const inviteUserInfo = await this.salesUsersEntity.findOne({ where: { userId } });
|
||||
if (!inviteUserInfo)
|
||||
return;
|
||||
const { totalAmount, distributionBalance } = inviteUserInfo;
|
||||
console.log('totalAmount, distributionBalance: ', totalAmount, distributionBalance);
|
||||
return await this.salesUsersEntity.update({ userId }, {
|
||||
totalAmount: new decimal_js_1.default(totalAmount).plus(amount).toNumber(),
|
||||
distributionBalance: new decimal_js_1.default(distributionBalance).plus(amount).toNumber(),
|
||||
});
|
||||
}
|
||||
async appForMoney(req, body) {
|
||||
const { id: userId } = req.user;
|
||||
const { withdrawalAmount, withdrawalChannels, contactInformation, remark } = body;
|
||||
const salesAllowDrawMoney = (await this.globalConfigService.getConfigs(['salesAllowDrawMoney'])) || 10;
|
||||
if (typeof withdrawalAmount !== 'number' || withdrawalAmount <= 0) {
|
||||
throw new common_1.HttpException('提现金额必须为数字且大于0', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (Number(withdrawalAmount) < Number(salesAllowDrawMoney)) {
|
||||
throw new common_1.HttpException(`提现金额最低必须为${salesAllowDrawMoney}元`, common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const salesBalanceInfo = await this.salesUsersEntity.findOne({ where: { userId } });
|
||||
const { distributionBalance, drawMoneyIn } = salesBalanceInfo;
|
||||
if (Number(distributionBalance) < Number(withdrawalAmount)) {
|
||||
throw new common_1.HttpException('提现金额不足', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const newDistributionBalance = new decimal_js_1.default(distributionBalance).minus(withdrawalAmount).toNumber();
|
||||
const orderInfo = { userId, withdrawalAmount, orderStatus: 0, auditStatus: 0, withdrawalChannels, contactInformation, remark };
|
||||
await this.createOrder(orderInfo);
|
||||
const res = await this.salesUsersEntity.update({ userId }, { distributionBalance: newDistributionBalance, drawMoneyIn: new decimal_js_1.default(drawMoneyIn).plus(withdrawalAmount).toNumber() });
|
||||
}
|
||||
async drawMoneyOrder(req, query) {
|
||||
const { id: userId } = req.user;
|
||||
const { page, size } = query;
|
||||
const [rows, count] = await this.salesOrderEntity.findAndCount({
|
||||
where: { userId },
|
||||
order: { createdAt: 'DESC' },
|
||||
skip: (page - 1) * size,
|
||||
take: size,
|
||||
});
|
||||
const auditUserIds = rows.map((item) => item.auditUserId);
|
||||
const userInfos = await this.userEntity.find({ where: { id: (0, typeorm_2.In)(auditUserIds) } });
|
||||
rows.forEach((item) => {
|
||||
const curUserInfo = userInfos.find((user) => user.id === item.auditUserId);
|
||||
item.auditUserName = curUserInfo ? curUserInfo.username : '';
|
||||
});
|
||||
return {
|
||||
rows: (0, utils_1.formatCreateOrUpdateDate)(rows),
|
||||
count,
|
||||
};
|
||||
}
|
||||
async salesOrder(req, query) {
|
||||
const { page, size } = query;
|
||||
const where = {};
|
||||
query.orderStatus !== undefined && query.orderStatus !== '' && (where.orderStatus = query.orderStatus);
|
||||
query.withdrawalChannels && (where.withdrawalChannels = query.withdrawalChannels);
|
||||
const [rows, count] = await this.salesOrderEntity.findAndCount({
|
||||
where,
|
||||
order: { createdAt: 'DESC' },
|
||||
skip: (page - 1) * size,
|
||||
take: size,
|
||||
});
|
||||
const userIds = rows.map((item) => item.userId);
|
||||
const userInfo = await this.userEntity.find({ where: { id: (0, typeorm_2.In)(userIds) } });
|
||||
rows.forEach((item) => {
|
||||
const curUser = userInfo.find((user) => user.id === item.userId);
|
||||
if (curUser) {
|
||||
const { username, email, avatar } = curUser;
|
||||
item.userInfo = { username, avatar, email: (0, utils_1.hideString)(email) };
|
||||
}
|
||||
});
|
||||
return {
|
||||
rows: (0, utils_1.formatCreateOrUpdateDate)(rows),
|
||||
count,
|
||||
};
|
||||
}
|
||||
async createOrder(orderInfo) {
|
||||
try {
|
||||
return await this.salesOrderEntity.save(orderInfo);
|
||||
}
|
||||
catch (error) {
|
||||
console.log('error: ', error);
|
||||
throw new common_1.HttpException('创建提现工单失败', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async auditOrder(req, body) {
|
||||
try {
|
||||
const { id: userId } = req.user;
|
||||
const { id, status } = body;
|
||||
if (![1, -1].includes(status)) {
|
||||
throw new common_1.HttpException('审核状态错误', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const orderInfo = await this.salesOrderEntity.findOne({ where: { id } });
|
||||
if (orderInfo.orderStatus !== 0) {
|
||||
throw new common_1.HttpException('该工单已审核过', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const userBalanceInfo = await this.salesUsersEntity.findOne({ where: { userId: orderInfo.userId } });
|
||||
const { withdrawalAmount, drawMoneyIn } = userBalanceInfo;
|
||||
const newWithdrawalAmount = new decimal_js_1.default(withdrawalAmount).plus(orderInfo.withdrawalAmount).toNumber();
|
||||
const newDrawMoneyIn = new decimal_js_1.default(drawMoneyIn).minus(orderInfo.withdrawalAmount).toNumber();
|
||||
await this.salesUsersEntity.update({ userId: orderInfo.userId }, { withdrawalAmount: newWithdrawalAmount, drawMoneyIn: newDrawMoneyIn });
|
||||
await this.salesOrderEntity.update({ id }, { orderStatus: status, auditStatus: status, auditUserId: userId, paymentStatus: status });
|
||||
return '审核完成';
|
||||
}
|
||||
catch (error) {
|
||||
console.log('error: ', error);
|
||||
throw new common_1.HttpException('审核失败', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async salesUserList(req, query) {
|
||||
const { page, size, salesOutletName, performanceRatio } = query;
|
||||
const where = {};
|
||||
salesOutletName && (where.salesOutletName = (0, typeorm_2.Like)(`%${salesOutletName}%`));
|
||||
performanceRatio && (where.performanceRatio = performanceRatio);
|
||||
const [rows, count] = await this.salesUsersEntity.findAndCount({
|
||||
where,
|
||||
order: { id: 'DESC' },
|
||||
skip: (page - 1) * size,
|
||||
take: size,
|
||||
});
|
||||
const userIds = rows.map((item) => item.userId);
|
||||
const userInfos = await this.userEntity.find({ where: { id: (0, typeorm_2.In)(userIds) } });
|
||||
rows.forEach((item) => {
|
||||
const curUserInfo = userInfos.find((user) => user.id === item.userId);
|
||||
item.userInfo = curUserInfo ? curUserInfo : {};
|
||||
});
|
||||
if (req.user.role !== 'super') {
|
||||
rows.forEach((item) => {
|
||||
var _a, _b;
|
||||
item.userInfo.email = ((_a = item.userInfo) === null || _a === void 0 ? void 0 : _a.email) ? (0, utils_1.hideString)((_b = item.userInfo) === null || _b === void 0 ? void 0 : _b.email) : '';
|
||||
});
|
||||
}
|
||||
return { rows, count };
|
||||
}
|
||||
async updateUserSales(req, body) {
|
||||
const { performanceRatio, salesOutletName, userId } = body;
|
||||
const salesU = await this.salesUsersEntity.findOne({ where: { userId } });
|
||||
if (!salesU) {
|
||||
throw new common_1.HttpException('用户不存在', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const res = await this.salesUsersEntity.update({ userId }, { performanceRatio, salesOutletName });
|
||||
if (res.affected > 0) {
|
||||
return '修改成功';
|
||||
}
|
||||
else {
|
||||
throw new common_1.HttpException('修改失败', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
};
|
||||
SalesService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(0, (0, typeorm_1.InjectRepository)(salesUsers_entity_1.SalesUsersEntity)),
|
||||
__param(1, (0, typeorm_1.InjectRepository)(salesRecords_entity_1.SalesRecordsEntity)),
|
||||
__param(2, (0, typeorm_1.InjectRepository)(user_entity_1.UserEntity)),
|
||||
__param(3, (0, typeorm_1.InjectRepository)(salesOrder_entity_1.SalesOrderEntity)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
globalConfig_service_1.GlobalConfigService])
|
||||
], SalesService);
|
||||
exports.SalesService = SalesService;
|
56
dist/modules/sales/salesOrder.entity.js
vendored
56
dist/modules/sales/salesOrder.entity.js
vendored
@@ -1,56 +0,0 @@
|
||||
"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.SalesOrderEntity = void 0;
|
||||
const typeorm_1 = require("typeorm");
|
||||
const baseEntity_1 = require("../../common/entity/baseEntity");
|
||||
let SalesOrderEntity = class SalesOrderEntity extends baseEntity_1.BaseEntity {
|
||||
};
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '申请提现人用户Id' }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesOrderEntity.prototype, "userId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '申请提现的金额' }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesOrderEntity.prototype, "withdrawalAmount", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '工单状态' }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesOrderEntity.prototype, "orderStatus", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '审核状态' }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesOrderEntity.prototype, "auditStatus", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '审核人', nullable: true }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesOrderEntity.prototype, "auditUserId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '打款状态', nullable: true }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesOrderEntity.prototype, "paymentStatus", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '提现渠道 1: 支付宝 2: 微信', nullable: true }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesOrderEntity.prototype, "withdrawalChannels", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '提现联系信息、备注即可', nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], SalesOrderEntity.prototype, "contactInformation", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '提现备注留言', nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], SalesOrderEntity.prototype, "remark", void 0);
|
||||
SalesOrderEntity = __decorate([
|
||||
(0, typeorm_1.Entity)({ name: 'sales_order' })
|
||||
], SalesOrderEntity);
|
||||
exports.SalesOrderEntity = SalesOrderEntity;
|
44
dist/modules/sales/salesRecords.entity.js
vendored
44
dist/modules/sales/salesRecords.entity.js
vendored
@@ -1,44 +0,0 @@
|
||||
"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.SalesRecordsEntity = void 0;
|
||||
const typeorm_1 = require("typeorm");
|
||||
const baseEntity_1 = require("../../common/entity/baseEntity");
|
||||
let SalesRecordsEntity = class SalesRecordsEntity extends baseEntity_1.BaseEntity {
|
||||
};
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '邀请人ID' }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesRecordsEntity.prototype, "inviterUserId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '被邀请人ID' }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesRecordsEntity.prototype, "inviteeUserId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '订单ID' }),
|
||||
__metadata("design:type", String)
|
||||
], SalesRecordsEntity.prototype, "orderId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '订单价格', type: 'decimal', scale: 2, precision: 10 }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesRecordsEntity.prototype, "orderPrice", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '佣金金额', type: 'decimal', scale: 2, precision: 10 }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesRecordsEntity.prototype, "commissionAmount", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '佣金比例', type: 'decimal', scale: 2, precision: 10 }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesRecordsEntity.prototype, "commissionPercentage", void 0);
|
||||
SalesRecordsEntity = __decorate([
|
||||
(0, typeorm_1.Entity)({ name: 'sales_records' })
|
||||
], SalesRecordsEntity);
|
||||
exports.SalesRecordsEntity = SalesRecordsEntity;
|
52
dist/modules/sales/salesUsers.entity.js
vendored
52
dist/modules/sales/salesUsers.entity.js
vendored
@@ -1,52 +0,0 @@
|
||||
"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.SalesUsersEntity = void 0;
|
||||
const typeorm_1 = require("typeorm");
|
||||
const baseEntity_1 = require("../../common/entity/baseEntity");
|
||||
let SalesUsersEntity = class SalesUsersEntity extends baseEntity_1.BaseEntity {
|
||||
};
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '分销人用户Id' }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesUsersEntity.prototype, "userId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '分销人的提成比例' }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesUsersEntity.prototype, "performanceRatio", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '分销人的自定义称号等级', nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], SalesUsersEntity.prototype, "salesOutletName", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '分销人账户总金额', type: 'decimal', scale: 2, precision: 10, default: 0 }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesUsersEntity.prototype, "totalAmount", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '分销人账户已经提现金额', type: 'decimal', scale: 2, precision: 10, default: 0 }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesUsersEntity.prototype, "withdrawalAmount", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '分销人账户可提现金额', type: 'decimal', scale: 2, precision: 10, default: 0 }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesUsersEntity.prototype, "distributionBalance", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '分销人账户正在提现的金额', type: 'decimal', scale: 2, precision: 10, default: 0 }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesUsersEntity.prototype, "drawMoneyIn", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '累计成功提成的订单量', default: 0 }),
|
||||
__metadata("design:type", Number)
|
||||
], SalesUsersEntity.prototype, "orderCount", void 0);
|
||||
SalesUsersEntity = __decorate([
|
||||
(0, typeorm_1.Entity)({ name: 'sales_users' })
|
||||
], SalesUsersEntity);
|
||||
exports.SalesUsersEntity = SalesUsersEntity;
|
@@ -13,11 +13,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.StatisticController = void 0;
|
||||
const statistic_service_1 = require("./statistic.service");
|
||||
const adminAuth_guard_1 = require("../../common/auth/adminAuth.guard");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const queryStatisticDto_dto_1 = require("./dto/queryStatisticDto.dto");
|
||||
const adminAuth_guard_1 = require("../../common/auth/adminAuth.guard");
|
||||
const statistic_service_1 = require("./statistic.service");
|
||||
let StatisticController = class StatisticController {
|
||||
constructor(statisticService) {
|
||||
this.statisticService = statisticService;
|
||||
|
16
dist/modules/statistic/statistic.module.js
vendored
16
dist/modules/statistic/statistic.module.js
vendored
@@ -8,19 +8,25 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.StatisticModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const statistic_controller_1 = require("./statistic.controller");
|
||||
const statistic_service_1 = require("./statistic.service");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const chatLog_entity_1 = require("../chatLog/chatLog.entity");
|
||||
const config_entity_1 = require("../globalConfig/config.entity");
|
||||
const order_entity_1 = require("../order/order.entity");
|
||||
const midjourney_entity_1 = require("../midjourney/midjourney.entity");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const statistic_controller_1 = require("./statistic.controller");
|
||||
const statistic_service_1 = require("./statistic.service");
|
||||
let StatisticModule = class StatisticModule {
|
||||
};
|
||||
StatisticModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [typeorm_1.TypeOrmModule.forFeature([user_entity_1.UserEntity, chatLog_entity_1.ChatLogEntity, config_entity_1.ConfigEntity, order_entity_1.OrderEntity, midjourney_entity_1.MidjourneyEntity])],
|
||||
imports: [
|
||||
typeorm_1.TypeOrmModule.forFeature([
|
||||
user_entity_1.UserEntity,
|
||||
chatLog_entity_1.ChatLogEntity,
|
||||
config_entity_1.ConfigEntity,
|
||||
order_entity_1.OrderEntity,
|
||||
]),
|
||||
],
|
||||
controllers: [statistic_controller_1.StatisticController],
|
||||
providers: [statistic_service_1.StatisticService],
|
||||
})
|
||||
|
54
dist/modules/statistic/statistic.service.js
vendored
54
dist/modules/statistic/statistic.service.js
vendored
@@ -14,7 +14,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.StatisticService = void 0;
|
||||
const balance_constant_1 = require("../../common/constants/balance.constant");
|
||||
const midjourney_constant_1 = require("../../common/constants/midjourney.constant");
|
||||
const date_1 = require("../../common/utils/date");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
@@ -23,16 +22,14 @@ const typeorm_2 = require("typeorm");
|
||||
const chatLog_entity_1 = require("../chatLog/chatLog.entity");
|
||||
const config_entity_1 = require("../globalConfig/config.entity");
|
||||
const globalConfig_service_1 = require("../globalConfig/globalConfig.service");
|
||||
const midjourney_entity_1 = require("../midjourney/midjourney.entity");
|
||||
const order_entity_1 = require("../order/order.entity");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
let StatisticService = class StatisticService {
|
||||
constructor(userEntity, chatLogEntity, configEntity, orderEntity, midjourneyEntity, globalConfigService) {
|
||||
constructor(userEntity, chatLogEntity, configEntity, orderEntity, globalConfigService) {
|
||||
this.userEntity = userEntity;
|
||||
this.chatLogEntity = chatLogEntity;
|
||||
this.configEntity = configEntity;
|
||||
this.orderEntity = orderEntity;
|
||||
this.midjourneyEntity = midjourneyEntity;
|
||||
this.globalConfigService = globalConfigService;
|
||||
}
|
||||
async getBaseStatistic() {
|
||||
@@ -42,7 +39,6 @@ let StatisticService = class StatisticService {
|
||||
const newChatCount = await this.countNewChatsToday();
|
||||
const drawCount = await this.countDraws();
|
||||
const dellDrawCount = await this.countNewDrawsToday();
|
||||
const mjDrawCount = await this.countNewMidhourneysToday();
|
||||
const orderCount = await this.countOrders();
|
||||
const newOrderCount = await this.countNewOrdersToday();
|
||||
return {
|
||||
@@ -51,7 +47,7 @@ let StatisticService = class StatisticService {
|
||||
chatCount,
|
||||
newChatCount,
|
||||
drawCount,
|
||||
newDrawCount: mjDrawCount + dellDrawCount,
|
||||
newDrawCount: dellDrawCount,
|
||||
orderCount,
|
||||
newOrderCount,
|
||||
};
|
||||
@@ -59,12 +55,11 @@ let StatisticService = class StatisticService {
|
||||
async getChatStatistic({ days = 7 }) {
|
||||
const chatData = await this.countChatsByTimeRange(days);
|
||||
const drawData = await this.countDrawsByTimeRange(days);
|
||||
const mjDrawData = await this.countMjDrawsByTimeRange(days);
|
||||
return {
|
||||
date: chatData.map((item) => item.date),
|
||||
chat: chatData.map((item) => item.value),
|
||||
draw: drawData.map((item, index) => {
|
||||
return item.value + mjDrawData[index].value;
|
||||
return item.value;
|
||||
}),
|
||||
};
|
||||
}
|
||||
@@ -123,17 +118,6 @@ let StatisticService = class StatisticService {
|
||||
.getCount();
|
||||
return drawCount;
|
||||
}
|
||||
async countNewMidhourneysToday() {
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000);
|
||||
const queryBuilder = this.midjourneyEntity.createQueryBuilder('midjourney');
|
||||
const midjourneyCount = await queryBuilder
|
||||
.where('midjourney.createdAt >= :today', { today })
|
||||
.andWhere('midjourney.createdAt < :tomorrow', { tomorrow })
|
||||
.getCount();
|
||||
return midjourneyCount;
|
||||
}
|
||||
async countChatsByTimeRange(days) {
|
||||
var _a, _b;
|
||||
const today = new Date();
|
||||
@@ -190,36 +174,6 @@ let StatisticService = class StatisticService {
|
||||
}
|
||||
return dailyData;
|
||||
}
|
||||
async countMjDrawsByTimeRange(days) {
|
||||
var _a, _b;
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const startDate = new Date(today.getTime() - (days - 1) * 24 * 60 * 60 * 1000);
|
||||
const queryBuilder = this.midjourneyEntity.createQueryBuilder('midjourney');
|
||||
const result = await queryBuilder
|
||||
.select(`DATE(midjourney.createdAt) as date, COUNT(*) as count`)
|
||||
.where(`midjourney.status = :status`, {
|
||||
status: midjourney_constant_1.MidjourneyStatusEnum.DRAWED,
|
||||
})
|
||||
.andWhere('midjourney.createdAt >= :startDate', { startDate })
|
||||
.groupBy('date')
|
||||
.orderBy('date')
|
||||
.getRawMany();
|
||||
const dailyData = [];
|
||||
const currentDate = startDate;
|
||||
for (let i = 0; i < days; i++) {
|
||||
const dateString = (0, date_1.formatDate)(new Date(currentDate), 'M.DD');
|
||||
const count = (_b = (_a = result.find((r) => (0, date_1.formatDate)(new Date(r.date), 'M.DD') === dateString)) === null || _a === void 0 ? void 0 : _a.count) !== null && _b !== void 0 ? _b : 0;
|
||||
if (count > 0) {
|
||||
dailyData.push({ date: dateString, value: Number(count) });
|
||||
}
|
||||
else {
|
||||
dailyData.push({ date: dateString, value: 0 });
|
||||
}
|
||||
currentDate.setDate(currentDate.getDate() + 1);
|
||||
}
|
||||
return dailyData;
|
||||
}
|
||||
async getNewAccessToken(baiduApiKey, baiduSecretKey, baiduRefreshToken) {
|
||||
const tokenUrl = `http://openapi.baidu.com/oauth/2.0/token?grant_type=refresh_token&refresh_token=${baiduRefreshToken}&client_id=${baiduApiKey}&client_secret=${baiduSecretKey}`;
|
||||
common_1.Logger.log('获取新 accessToken', tokenUrl);
|
||||
@@ -317,12 +271,10 @@ StatisticService = __decorate([
|
||||
__param(1, (0, typeorm_1.InjectRepository)(chatLog_entity_1.ChatLogEntity)),
|
||||
__param(2, (0, typeorm_1.InjectRepository)(config_entity_1.ConfigEntity)),
|
||||
__param(3, (0, typeorm_1.InjectRepository)(order_entity_1.OrderEntity)),
|
||||
__param(4, (0, typeorm_1.InjectRepository)(midjourney_entity_1.MidjourneyEntity)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
globalConfig_service_1.GlobalConfigService])
|
||||
], StatisticService);
|
||||
exports.StatisticService = StatisticService;
|
||||
|
14
dist/modules/upload/upload.service.js
vendored
14
dist/modules/upload/upload.service.js
vendored
@@ -44,19 +44,27 @@ let UploadService = class UploadService {
|
||||
const timestamp = now.getTime();
|
||||
const randomString = Math.random().toString(36).substring(2, 6);
|
||||
const filename = `${timestamp}_${randomString}.${fileExtension}`;
|
||||
const { tencentCosStatus = 0, aliOssStatus = 0, cheveretoStatus = 0, } = await this.globalConfigService.getConfigs([
|
||||
const { tencentCosStatus = 0, aliOssStatus = 0, cheveretoStatus = 0, localStorageStatus = 0, } = await this.globalConfigService.getConfigs([
|
||||
'tencentCosStatus',
|
||||
'aliOssStatus',
|
||||
'cheveretoStatus',
|
||||
'localStorageStatus',
|
||||
]);
|
||||
common_1.Logger.log(`上传配置状态 - 腾讯云: ${tencentCosStatus}, 阿里云: ${aliOssStatus}, Chevereto: ${cheveretoStatus}`, 'UploadService');
|
||||
common_1.Logger.log(`上传配置状态 - 腾讯云:本地存储: ${localStorageStatus}, ${tencentCosStatus}, 阿里云: ${aliOssStatus}, Chevereto: ${cheveretoStatus}`, 'UploadService');
|
||||
if (!Number(tencentCosStatus) &&
|
||||
!Number(aliOssStatus) &&
|
||||
!Number(cheveretoStatus)) {
|
||||
!Number(cheveretoStatus) &&
|
||||
!Number(localStorageStatus)) {
|
||||
common_1.Logger.error('未配置任何上传方式', 'UploadService');
|
||||
throw new common_1.HttpException('请先前往后台配置上传图片的方式', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
try {
|
||||
if (Number(localStorageStatus)) {
|
||||
common_1.Logger.log('使用本地存储上传文件', 'UploadService');
|
||||
const result = await this.uploadFileToLocal({ filename, buffer, dir });
|
||||
common_1.Logger.log(`文件已上传到本地存储。访问 URL: ${result}`, 'UploadService');
|
||||
return result;
|
||||
}
|
||||
if (Number(tencentCosStatus)) {
|
||||
common_1.Logger.log('使用腾讯云 COS 上传文件', 'UploadService');
|
||||
const result = await this.uploadFileByTencentCos({
|
||||
|
39
dist/modules/user/user.controller.js
vendored
39
dist/modules/user/user.controller.js
vendored
@@ -19,7 +19,6 @@ const superAuth_guard_1 = require("../../common/auth/superAuth.guard");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const queryAllUser_dto_1 = require("./dto/queryAllUser.dto");
|
||||
const queryInviteRecord_dto_1 = require("./dto/queryInviteRecord.dto");
|
||||
const queryOne_dto_1 = require("./dto/queryOne.dto");
|
||||
const resetUserPass_dto_1 = require("./dto/resetUserPass.dto");
|
||||
const updateUser_dto_1 = require("./dto/updateUser.dto");
|
||||
@@ -33,15 +32,6 @@ let UserController = class UserController {
|
||||
async update(body, req) {
|
||||
return await this.userService.updateInfo(body, req);
|
||||
}
|
||||
async genInviteCode(req) {
|
||||
return await this.userService.genInviteCode(req);
|
||||
}
|
||||
async getInviteRecord(req, query) {
|
||||
return await this.userService.getInviteRecord(req, query);
|
||||
}
|
||||
async inviteLink(code) {
|
||||
return await this.userService.inviteLink(code);
|
||||
}
|
||||
async userRecharge(body) {
|
||||
return await this.userService.userRecharge(body);
|
||||
}
|
||||
@@ -69,35 +59,6 @@ __decorate([
|
||||
__metadata("design:paramtypes", [updateUser_dto_1.UpdateUserDto, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], UserController.prototype, "update", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('genInviteCode'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '生成邀请码' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], UserController.prototype, "genInviteCode", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('inviteRecord'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '获取我的邀请记录' }),
|
||||
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
|
||||
(0, swagger_1.ApiBearerAuth)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, queryInviteRecord_dto_1.queryInviteRecordDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], UserController.prototype, "getInviteRecord", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('inviteLink'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '邀请链接被点击' }),
|
||||
__param(0, (0, common_1.Query)('code')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], UserController.prototype, "inviteLink", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('recharge'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '用户充值' }),
|
||||
|
8
dist/modules/user/user.entity.js
vendored
8
dist/modules/user/user.entity.js
vendored
@@ -101,6 +101,14 @@ __decorate([
|
||||
(0, typeorm_1.Column)({ comment: '用户违规记录次数', default: 0 }),
|
||||
__metadata("design:type", Number)
|
||||
], UserEntity.prototype, "violationCount", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '真实姓名', nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], UserEntity.prototype, "realName", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ comment: '身份证号', nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], UserEntity.prototype, "idCard", void 0);
|
||||
UserEntity = __decorate([
|
||||
(0, typeorm_1.Entity)({ name: 'users' })
|
||||
], UserEntity);
|
||||
|
4
dist/modules/user/user.module.js
vendored
4
dist/modules/user/user.module.js
vendored
@@ -14,9 +14,7 @@ const chatLog_entity_1 = require("../chatLog/chatLog.entity");
|
||||
const cramiPackage_entity_1 = require("../crami/cramiPackage.entity");
|
||||
const config_entity_1 = require("../globalConfig/config.entity");
|
||||
const mailer_service_1 = require("../mailer/mailer.service");
|
||||
const midjourney_entity_1 = require("../midjourney/midjourney.entity");
|
||||
const redisCache_service_1 = require("../redisCache/redisCache.service");
|
||||
const salesUsers_entity_1 = require("../sales/salesUsers.entity");
|
||||
const accountLog_entity_1 = require("../userBalance/accountLog.entity");
|
||||
const balance_entity_1 = require("../userBalance/balance.entity");
|
||||
const fingerprint_entity_1 = require("../userBalance/fingerprint.entity");
|
||||
@@ -41,11 +39,9 @@ UserModule = __decorate([
|
||||
config_entity_1.ConfigEntity,
|
||||
cramiPackage_entity_1.CramiPackageEntity,
|
||||
userBalance_entity_1.UserBalanceEntity,
|
||||
salesUsers_entity_1.SalesUsersEntity,
|
||||
fingerprint_entity_1.FingerprintLogEntity,
|
||||
chatLog_entity_1.ChatLogEntity,
|
||||
chatGroup_entity_1.ChatGroupEntity,
|
||||
midjourney_entity_1.MidjourneyEntity,
|
||||
]),
|
||||
],
|
||||
controllers: [user_controller_1.UserController],
|
||||
|
125
dist/modules/user/user.service.js
vendored
125
dist/modules/user/user.service.js
vendored
@@ -39,15 +39,7 @@ let UserService = class UserService {
|
||||
this.configEntity = configEntity;
|
||||
}
|
||||
async createUserAndVerifycation(user, req) {
|
||||
const { username, email, password, invitedBy, client = 0 } = user;
|
||||
if (invitedBy) {
|
||||
const b = await this.userEntity.findOne({
|
||||
where: { inviteCode: invitedBy },
|
||||
});
|
||||
if (!b) {
|
||||
throw new common_1.HttpException('无效的邀请码!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
const { username, email, password, client = 0 } = user;
|
||||
const where = [{ username }, { email }];
|
||||
const u = await this.userEntity.findOne({ where: where });
|
||||
if (u && u.status !== user_constant_1.UserStatusEnum.PENDING) {
|
||||
@@ -101,13 +93,9 @@ let UserService = class UserService {
|
||||
console.log(`尝试发送邮件到: ${email}`);
|
||||
}
|
||||
else {
|
||||
const { username, email, id, invitedBy } = n;
|
||||
const { id } = n;
|
||||
await this.updateUserStatus(id, user_constant_1.UserStatusEnum.ACTIVE);
|
||||
let inviteUser;
|
||||
if (invitedBy) {
|
||||
inviteUser = await this.qureyUserInfoByInviteCode(invitedBy);
|
||||
}
|
||||
await this.userBalanceService.addBalanceToNewUser(id, inviteUser === null || inviteUser === void 0 ? void 0 : inviteUser.id);
|
||||
await this.userBalanceService.addBalanceToNewUser(id);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
@@ -196,7 +184,6 @@ let UserService = class UserService {
|
||||
'role',
|
||||
'email',
|
||||
'sign',
|
||||
'inviteCode',
|
||||
'openId',
|
||||
'consecutiveDays',
|
||||
],
|
||||
@@ -256,73 +243,6 @@ let UserService = class UserService {
|
||||
throw new common_1.HttpException('修改密码失败、请重新试试吧。', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async genInviteCode(req) {
|
||||
const { id } = req.user;
|
||||
const u = await this.userEntity.findOne({ where: { id } });
|
||||
if (!u || u.inviteCode) {
|
||||
throw new common_1.HttpException('已生成过邀请码、请勿重复生成', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const inviteCode = (0, utils_1.generateRandomString)();
|
||||
const user = await this.userEntity.findOne({ where: { inviteCode } });
|
||||
if (user) {
|
||||
throw new common_1.HttpException('生成邀请码失败,请重新试一次吧!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const r = await this.userEntity.update({ id }, { inviteCode });
|
||||
if (r.affected <= 0) {
|
||||
throw new common_1.HttpException('生成邀请码失败,请重新试一次吧!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
return inviteCode;
|
||||
}
|
||||
async getInviteRecord(req, query) {
|
||||
try {
|
||||
const { id } = req.user;
|
||||
const { page = 1, size = 10 } = query;
|
||||
const u = await this.userEntity.findOne({ where: { id } });
|
||||
const { inviteCode } = u;
|
||||
if (!inviteCode)
|
||||
return [];
|
||||
const invitedBy = inviteCode;
|
||||
const [rows, count] = await this.userEntity.findAndCount({
|
||||
where: { invitedBy },
|
||||
order: { id: 'DESC' },
|
||||
select: [
|
||||
'username',
|
||||
'email',
|
||||
'createdAt',
|
||||
'status',
|
||||
'avatar',
|
||||
'updatedAt',
|
||||
],
|
||||
take: size,
|
||||
skip: (page - 1) * size,
|
||||
});
|
||||
(0, utils_1.formatCreateOrUpdateDate)(rows).map((t) => {
|
||||
t.email = (0, utils_1.maskEmail)(t.email);
|
||||
return t;
|
||||
});
|
||||
return { rows, count };
|
||||
}
|
||||
catch (error) {
|
||||
console.log('error: ', error);
|
||||
throw new common_1.HttpException('获取邀请记录失败!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async inviteLink(code) {
|
||||
const u = await this.userEntity.findOne({ where: { inviteCode: code } });
|
||||
if (!u)
|
||||
return 1;
|
||||
const { inviteLinkCount = 0 } = u;
|
||||
const res = await this.userEntity.update({ inviteCode: code }, { inviteLinkCount: inviteLinkCount + 1 });
|
||||
if (res.affected) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
async qureyUserInfoByInviteCode(inviteCode) {
|
||||
return await this.userEntity.findOne({ where: { inviteCode } });
|
||||
}
|
||||
async userRecharge(body) {
|
||||
const { userId, model3Count = 0, model4Count = 0, drawMjCount = 0 } = body;
|
||||
await this.userBalanceService.addBalanceToUser(userId, {
|
||||
@@ -363,7 +283,6 @@ let UserService = class UserService {
|
||||
select: [
|
||||
'username',
|
||||
'avatar',
|
||||
'inviteCode',
|
||||
'role',
|
||||
'sign',
|
||||
'status',
|
||||
@@ -372,6 +291,8 @@ let UserService = class UserService {
|
||||
'createdAt',
|
||||
'lastLoginIp',
|
||||
'phone',
|
||||
'realName',
|
||||
'idCard',
|
||||
],
|
||||
});
|
||||
const ids = rows.map((t) => t.id);
|
||||
@@ -388,7 +309,7 @@ let UserService = class UserService {
|
||||
async queryOne({ id }) {
|
||||
return await this.userEntity.findOne({
|
||||
where: { id },
|
||||
select: ['username', 'avatar', 'inviteCode', 'role', 'sign', 'status'],
|
||||
select: ['username', 'avatar', 'role', 'sign', 'status'],
|
||||
});
|
||||
}
|
||||
async updateStatus(body) {
|
||||
@@ -429,15 +350,13 @@ let UserService = class UserService {
|
||||
async getUserFromOpenId(openId, sceneStr) {
|
||||
const user = await this.userEntity.findOne({ where: { openId } });
|
||||
if (!user) {
|
||||
const inviteCode = sceneStr ? sceneStr.split(':')[1] : '';
|
||||
const inviteUser = await this.qureyUserInfoByInviteCode(inviteCode);
|
||||
const user = await this.createUserFromOpenId(openId, inviteCode);
|
||||
await this.userBalanceService.addBalanceToNewUser(user.id, inviteCode ? inviteUser === null || inviteUser === void 0 ? void 0 : inviteUser.id : null);
|
||||
const user = await this.createUserFromOpenId(openId);
|
||||
await this.userBalanceService.addBalanceToNewUser(user.id);
|
||||
return user;
|
||||
}
|
||||
return user;
|
||||
}
|
||||
async createUserFromOpenId(openId, invitedBy) {
|
||||
async createUserFromOpenId(openId) {
|
||||
const userDefautlAvatar = await this.globalConfigService.getConfigs([
|
||||
'userDefautlAvatar',
|
||||
]);
|
||||
@@ -447,14 +366,13 @@ let UserService = class UserService {
|
||||
status: user_constant_1.UserStatusEnum.ACTIVE,
|
||||
sex: 0,
|
||||
email: `${(0, utils_1.createRandomUid)()}@default.com`,
|
||||
invitedBy,
|
||||
openId,
|
||||
};
|
||||
const user = await this.userEntity.save(userInfo);
|
||||
return user;
|
||||
}
|
||||
async createUserFromContact(params) {
|
||||
const { username, email, phone, invitedBy } = params;
|
||||
const { username, email, phone } = params;
|
||||
const userDefautlAvatar = await this.globalConfigService.getConfigs([
|
||||
'userDefautlAvatar',
|
||||
]);
|
||||
@@ -473,9 +391,6 @@ let UserService = class UserService {
|
||||
if (phone) {
|
||||
userInfo.phone = phone;
|
||||
}
|
||||
if (invitedBy) {
|
||||
userInfo.invitedBy = invitedBy;
|
||||
}
|
||||
const user = await this.userEntity.save(userInfo);
|
||||
return user;
|
||||
}
|
||||
@@ -572,6 +487,26 @@ let UserService = class UserService {
|
||||
async createUser(userInfo) {
|
||||
return await this.userEntity.save(userInfo);
|
||||
}
|
||||
async saveRealNameInfo(userId, realName, idCard) {
|
||||
const user = await this.userEntity.findOne({ where: { id: userId } });
|
||||
if (!user) {
|
||||
common_1.Logger.error('用户不存在');
|
||||
}
|
||||
await this.userEntity.update({ id: userId }, { realName, idCard });
|
||||
return;
|
||||
}
|
||||
async updateUserPhone(userId, phone, username, password) {
|
||||
const user = await this.userEntity.findOne({ where: { id: userId } });
|
||||
const hashedPassword = bcrypt.hashSync(password, 10);
|
||||
if (!user) {
|
||||
common_1.Logger.error('用户不存在');
|
||||
}
|
||||
if (!phone || !username || !hashedPassword) {
|
||||
throw new common_1.HttpException('参数错误!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
await this.userEntity.update({ id: userId }, { phone, username, password: hashedPassword });
|
||||
return;
|
||||
}
|
||||
};
|
||||
UserService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
|
@@ -13,9 +13,7 @@ const chatGroup_entity_1 = require("../chatGroup/chatGroup.entity");
|
||||
const chatLog_entity_1 = require("../chatLog/chatLog.entity");
|
||||
const cramiPackage_entity_1 = require("../crami/cramiPackage.entity");
|
||||
const config_entity_1 = require("../globalConfig/config.entity");
|
||||
const midjourney_entity_1 = require("../midjourney/midjourney.entity");
|
||||
const redisCache_service_1 = require("../redisCache/redisCache.service");
|
||||
const salesUsers_entity_1 = require("../sales/salesUsers.entity");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const verification_service_1 = require("../verification/verification.service");
|
||||
const verifycation_entity_1 = require("../verification/verifycation.entity");
|
||||
@@ -39,11 +37,9 @@ UserBalanceModule = __decorate([
|
||||
config_entity_1.ConfigEntity,
|
||||
cramiPackage_entity_1.CramiPackageEntity,
|
||||
user_entity_1.UserEntity,
|
||||
salesUsers_entity_1.SalesUsersEntity,
|
||||
fingerprint_entity_1.FingerprintLogEntity,
|
||||
chatLog_entity_1.ChatLogEntity,
|
||||
chatGroup_entity_1.ChatGroupEntity,
|
||||
midjourney_entity_1.MidjourneyEntity,
|
||||
]),
|
||||
],
|
||||
controllers: [userBalance_controller_1.UserBalanceController],
|
||||
|
121
dist/modules/userBalance/userBalance.service.js
vendored
121
dist/modules/userBalance/userBalance.service.js
vendored
@@ -27,28 +27,22 @@ const userBalance_entity_1 = require("./userBalance.entity");
|
||||
const date_1 = require("../../common/utils/date");
|
||||
const chatGroup_entity_1 = require("../chatGroup/chatGroup.entity");
|
||||
const chatLog_entity_1 = require("../chatLog/chatLog.entity");
|
||||
const midjourney_entity_1 = require("../midjourney/midjourney.entity");
|
||||
const sales_service_1 = require("../sales/sales.service");
|
||||
const salesUsers_entity_1 = require("../sales/salesUsers.entity");
|
||||
const user_entity_1 = require("../user/user.entity");
|
||||
const fingerprint_entity_1 = require("./fingerprint.entity");
|
||||
let UserBalanceService = class UserBalanceService {
|
||||
constructor(balanceEntity, userBalanceEntity, accountLogEntity, cramiPackageEntity, configEntity, userEntity, salesUsersEntity, fingerprintLogEntity, chatGroupEntity, chatLogEntity, midjourneyEntity, salesService, globalConfigService) {
|
||||
constructor(balanceEntity, userBalanceEntity, accountLogEntity, cramiPackageEntity, configEntity, userEntity, fingerprintLogEntity, chatGroupEntity, chatLogEntity, globalConfigService) {
|
||||
this.balanceEntity = balanceEntity;
|
||||
this.userBalanceEntity = userBalanceEntity;
|
||||
this.accountLogEntity = accountLogEntity;
|
||||
this.cramiPackageEntity = cramiPackageEntity;
|
||||
this.configEntity = configEntity;
|
||||
this.userEntity = userEntity;
|
||||
this.salesUsersEntity = salesUsersEntity;
|
||||
this.fingerprintLogEntity = fingerprintLogEntity;
|
||||
this.chatGroupEntity = chatGroupEntity;
|
||||
this.chatLogEntity = chatLogEntity;
|
||||
this.midjourneyEntity = midjourneyEntity;
|
||||
this.salesService = salesService;
|
||||
this.globalConfigService = globalConfigService;
|
||||
}
|
||||
async addBalanceToNewUser(userId, invitedId) {
|
||||
async addBalanceToNewUser(userId) {
|
||||
try {
|
||||
const registerConfigs = await this.configEntity.find({
|
||||
where: {
|
||||
@@ -62,13 +56,6 @@ let UserBalanceService = class UserBalanceService {
|
||||
'firstRregisterSendModel3Count',
|
||||
'firstRregisterSendModel4Count',
|
||||
'firstRregisterSendDrawMjCount',
|
||||
'inviteSendStatus',
|
||||
'inviteGiveSendModel3Count',
|
||||
'inviteGiveSendModel4Count',
|
||||
'inviteGiveSendDrawMjCount',
|
||||
'invitedGuestSendModel3Count',
|
||||
'invitedGuestSendDrawMjCount',
|
||||
'invitedGuestSendModel4Count',
|
||||
]),
|
||||
},
|
||||
});
|
||||
@@ -100,35 +87,6 @@ let UserBalanceService = class UserBalanceService {
|
||||
drawMjCount,
|
||||
model4Count,
|
||||
});
|
||||
if (invitedId) {
|
||||
if (Number(configMap.inviteSendStatus) === 1) {
|
||||
model3Count =
|
||||
model3Count + Number(configMap.invitedGuestSendModel3Count);
|
||||
model4Count =
|
||||
model4Count + Number(configMap.invitedGuestSendModel4Count);
|
||||
drawMjCount =
|
||||
drawMjCount + Number(configMap.invitedGuestSendDrawMjCount);
|
||||
await this.saveRecordRechargeLog({
|
||||
userId,
|
||||
rechargeType: balance_constant_1.RechargeType.INVITE_GIFT,
|
||||
model3Count: configMap.invitedGuestSendModel3Count,
|
||||
model4Count: configMap.invitedGuestSendModel4Count,
|
||||
drawMjCount: configMap.invitedGuestSendDrawMjCount,
|
||||
});
|
||||
await this.addBalanceToUser(invitedId, {
|
||||
model3Count: configMap.inviteGiveSendModel3Count,
|
||||
model4Count: configMap.inviteGiveSendModel4Count,
|
||||
drawMjCount: configMap.inviteGiveSendDrawMjCount,
|
||||
});
|
||||
await this.saveRecordRechargeLog({
|
||||
userId: invitedId,
|
||||
rechargeType: balance_constant_1.RechargeType.REFER_GIFT,
|
||||
model3Count: configMap.inviteGiveSendModel3Count,
|
||||
model4Count: configMap.inviteGiveSendModel4Count,
|
||||
drawMjCount: configMap.inviteGiveSendDrawMjCount,
|
||||
});
|
||||
}
|
||||
}
|
||||
await this.userBalanceEntity.save({
|
||||
userId,
|
||||
model3Count,
|
||||
@@ -151,10 +109,6 @@ let UserBalanceService = class UserBalanceService {
|
||||
if (role === 'visitor') {
|
||||
return this.validateVisitorBalance(req, type, amount);
|
||||
}
|
||||
const res = await this.configEntity.findOne({
|
||||
where: { configKey: 'vxNumber' },
|
||||
});
|
||||
const vxNumber = res ? res.configVal : '---';
|
||||
const memberKey = type === 1
|
||||
? 'memberModel3Count'
|
||||
: type === 2
|
||||
@@ -476,30 +430,6 @@ let UserBalanceService = class UserBalanceService {
|
||||
pkgName,
|
||||
days,
|
||||
});
|
||||
const userInfo = await this.userEntity.findOne({ where: { id: userId } });
|
||||
const { invitedBy } = userInfo;
|
||||
if (invitedBy) {
|
||||
const inviteUserInfo = await this.userEntity.findOne({
|
||||
where: { inviteCode: invitedBy },
|
||||
});
|
||||
const inviteUserSalesInfo = await this.salesUsersEntity.findOne({
|
||||
where: { userId: inviteUserInfo.id },
|
||||
});
|
||||
if (!inviteUserInfo)
|
||||
return;
|
||||
const { id: inviterUserId } = inviteUserInfo;
|
||||
const { performanceRatio } = inviteUserSalesInfo;
|
||||
const recordsInfo = {
|
||||
inviterUserId,
|
||||
inviteeUserId: userId,
|
||||
orderId: order.id,
|
||||
orderPrice: order.total,
|
||||
commissionPercentage: performanceRatio,
|
||||
commissionAmount: ((order.total * performanceRatio) / 100).toFixed(2),
|
||||
};
|
||||
await this.salesService.createSalesRecords(recordsInfo);
|
||||
await this.salesService.saveCommissionAmount(inviterUserId, recordsInfo.commissionAmount);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.log('error: ', error);
|
||||
@@ -570,7 +500,6 @@ let UserBalanceService = class UserBalanceService {
|
||||
const { id: userId } = req.user;
|
||||
await this.chatLogEntity.update({ userId: Number(fingerprint) }, { userId });
|
||||
await this.chatGroupEntity.update({ userId: Number(fingerprint) }, { userId });
|
||||
await this.midjourneyEntity.update({ userId: Number(fingerprint) }, { userId });
|
||||
return 1;
|
||||
}
|
||||
async getVisitorCount(req) {
|
||||
@@ -581,10 +510,39 @@ let UserBalanceService = class UserBalanceService {
|
||||
const countChatGroup = await this.chatGroupEntity.count({
|
||||
where: { userId: fingerprint },
|
||||
});
|
||||
const countMj = await this.midjourneyEntity.count({
|
||||
where: { userId: fingerprint },
|
||||
return countChat || countChatGroup || 0;
|
||||
}
|
||||
async checkUserCertification(userId) {
|
||||
const userInfo = await this.userEntity.findOne({
|
||||
where: { id: userId },
|
||||
});
|
||||
return countChat || countChatGroup || countMj || 0;
|
||||
const userBalance = await this.userBalanceEntity.findOne({
|
||||
where: { userId },
|
||||
});
|
||||
if (!userInfo || !userBalance) {
|
||||
return;
|
||||
}
|
||||
const { phoneValidationMessageCount, identityVerificationMessageCount, openIdentity, openPhoneValidation, } = await this.globalConfigService.getConfigs([
|
||||
'phoneValidationMessageCount',
|
||||
'identityVerificationMessageCount',
|
||||
'openIdentity',
|
||||
'openPhoneValidation',
|
||||
]);
|
||||
const phoneValidationCount = Number(phoneValidationMessageCount);
|
||||
const identityValidationCount = Number(identityVerificationMessageCount);
|
||||
const model3Count = Number(userBalance.useModel3Count) || 0;
|
||||
const model4Count = Number(userBalance.useModel4Count) || 0;
|
||||
const totalTokens = model3Count + model4Count;
|
||||
if (openPhoneValidation === '1' &&
|
||||
totalTokens >= phoneValidationCount &&
|
||||
!userInfo.phone) {
|
||||
throw new common_1.HttpException('请完成手机号绑定', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
if (openIdentity === '1' &&
|
||||
totalTokens >= identityValidationCount &&
|
||||
(!userInfo.realName || !userInfo.idCard)) {
|
||||
throw new common_1.HttpException('请完成实名认证', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
};
|
||||
UserBalanceService = __decorate([
|
||||
@@ -595,11 +553,9 @@ UserBalanceService = __decorate([
|
||||
__param(3, (0, typeorm_1.InjectRepository)(cramiPackage_entity_1.CramiPackageEntity)),
|
||||
__param(4, (0, typeorm_1.InjectRepository)(config_entity_1.ConfigEntity)),
|
||||
__param(5, (0, typeorm_1.InjectRepository)(user_entity_1.UserEntity)),
|
||||
__param(6, (0, typeorm_1.InjectRepository)(salesUsers_entity_1.SalesUsersEntity)),
|
||||
__param(7, (0, typeorm_1.InjectRepository)(fingerprint_entity_1.FingerprintLogEntity)),
|
||||
__param(8, (0, typeorm_1.InjectRepository)(chatGroup_entity_1.ChatGroupEntity)),
|
||||
__param(9, (0, typeorm_1.InjectRepository)(chatLog_entity_1.ChatLogEntity)),
|
||||
__param(10, (0, typeorm_1.InjectRepository)(midjourney_entity_1.MidjourneyEntity)),
|
||||
__param(6, (0, typeorm_1.InjectRepository)(fingerprint_entity_1.FingerprintLogEntity)),
|
||||
__param(7, (0, typeorm_1.InjectRepository)(chatGroup_entity_1.ChatGroupEntity)),
|
||||
__param(8, (0, typeorm_1.InjectRepository)(chatLog_entity_1.ChatLogEntity)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
@@ -609,9 +565,6 @@ UserBalanceService = __decorate([
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
typeorm_2.Repository,
|
||||
sales_service_1.SalesService,
|
||||
globalConfig_service_1.GlobalConfigService])
|
||||
], UserBalanceService);
|
||||
exports.UserBalanceService = UserBalanceService;
|
||||
|
@@ -22,6 +22,7 @@ const redisCache_service_1 = require("../redisCache/redisCache.service");
|
||||
const status_constant_1 = require("./../../common/constants/status.constant");
|
||||
const verifycation_entity_1 = require("./verifycation.entity");
|
||||
const Core = require("@alicloud/pop-core");
|
||||
const axios_1 = require("axios");
|
||||
let VerificationService = class VerificationService {
|
||||
constructor(verifycationEntity, globalConfigService, redisCacheService) {
|
||||
this.verifycationEntity = verifycationEntity;
|
||||
@@ -101,6 +102,43 @@ let VerificationService = class VerificationService {
|
||||
throw new common_1.HttpException(((_a = error === null || error === void 0 ? void 0 : error.data) === null || _a === void 0 ? void 0 : _a.Message) || '验证码发送失败!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
async verifyIdentity(identityInfo) {
|
||||
const appCode = await this.globalConfigService.getConfigs(['appCode']);
|
||||
const { name, idCard } = identityInfo;
|
||||
if (!name || !idCard) {
|
||||
throw new common_1.HttpException('缺少必要参数!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
common_1.Logger.debug(`Received identityInfo: ${name}, ${idCard}`);
|
||||
const apiUrl = 'https://eid.shumaidata.com/eid/check';
|
||||
const headers = {
|
||||
Authorization: `APPCODE ${appCode}`,
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
};
|
||||
const params = new URLSearchParams({
|
||||
name: name,
|
||||
idcard: idCard,
|
||||
});
|
||||
try {
|
||||
const response = await axios_1.default.post(apiUrl, params, { headers });
|
||||
const responseString = JSON.stringify(response.data);
|
||||
common_1.Logger.debug(`Received response: ${responseString}`);
|
||||
switch (response.data.result.res) {
|
||||
case '1':
|
||||
return true;
|
||||
case '2':
|
||||
common_1.Logger.log('验证不一致', 'VerificationService');
|
||||
case '3':
|
||||
common_1.Logger.log('实名认证异常', 'VerificationService');
|
||||
default:
|
||||
common_1.Logger.log('未知的认证结果', 'VerificationService');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (error) {
|
||||
common_1.Logger.error(`Error: ${error.message}`, error.stack, 'Verification');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
VerificationService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "99ai",
|
||||
"version": "3.7.0",
|
||||
"version": "4.0.0",
|
||||
"description": "",
|
||||
"author": "vastxie",
|
||||
"private": true,
|
||||
@@ -68,6 +68,7 @@
|
||||
"nodemailer": "^6.9.14",
|
||||
"passport": "^0.6.0",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"pdf-parse": "^1.1.1",
|
||||
"qs": "^6.12.3",
|
||||
"redis": "^4.6.14",
|
||||
"reflect-metadata": "^0.1.14",
|
||||
|
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{_ as f}from"./index-CAe0BuuW.js";export{f as default};
|
||||
import{_ as f}from"./index-nGFMSQGw.js";export{f as default};
|
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{_ as m}from"./HCheckList.vue_vue_type_script_setup_true_lang-Sefr8RNZ.js";import"./index-CAe0BuuW.js";export{m as default};
|
||||
import{_ as m}from"./HCheckList.vue_vue_type_script_setup_true_lang-BdsCC1UG.js";import"./index-nGFMSQGw.js";export{m as default};
|
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{d as u,av as n,aw as m,Z as b,g as a,c as t,F as o,s as p,Q as _,z as g,h,t as v,j as f}from"./index-CAe0BuuW.js";const k={class:"inline-flex select-none items-center justify-center of-hidden rounded-md bg-stone-3 dark-bg-stone-7"},y=["disabled","onClick"],V=u({__name:"HCheckList",props:n({options:{},disabled:{type:Boolean,default:!1}},{modelValue:{},modelModifiers:{}}),emits:n(["change"],["update:modelValue"]),setup(i,{emit:d}){const r=d,l=m(i,"modelValue");return b(l,s=>{r("change",s)}),(s,x)=>{const c=f;return a(),t("div",k,[(a(!0),t(o,null,p(s.options,e=>(a(),t("button",{key:e.value,disabled:s.disabled||e.disabled,class:_(["flex cursor-pointer items-center truncate border-size-0 bg-inherit px-2 py-1.5 text-sm disabled-cursor-not-allowed disabled-opacity-50 hover-not-disabled-bg-ui-primary hover-not-disabled-text-ui-text",{"text-ui-text bg-ui-primary":l.value===e.value}]),onClick:C=>l.value=e.value},[e.icon?(a(),g(c,{key:0,name:e.icon},null,8,["name"])):(a(),t(o,{key:1},[h(v(e.label),1)],64))],10,y))),128))])}}});export{V as _};
|
||||
import{d as u,as as n,at as m,X as b,g as s,c as t,F as o,s as p,Q as _,z as g,h,t as f,j as v}from"./index-nGFMSQGw.js";const k={class:"inline-flex select-none items-center justify-center of-hidden rounded-md bg-stone-3 dark-bg-stone-7"},y=["disabled","onClick"],V=u({__name:"HCheckList",props:n({options:{},disabled:{type:Boolean,default:!1}},{modelValue:{},modelModifiers:{}}),emits:n(["change"],["update:modelValue"]),setup(i,{emit:d}){const r=d,l=m(i,"modelValue");return b(l,a=>{r("change",a)}),(a,x)=>{const c=v;return s(),t("div",k,[(s(!0),t(o,null,p(a.options,e=>(s(),t("button",{key:e.value,disabled:a.disabled||e.disabled,class:_(["flex cursor-pointer items-center truncate border-size-0 bg-inherit px-2 py-1.5 text-sm disabled-cursor-not-allowed disabled-opacity-50 hover-not-disabled-bg-ui-primary hover-not-disabled-text-ui-text",{"text-ui-text bg-ui-primary":l.value===e.value}]),onClick:C=>l.value=e.value},[e.icon?(s(),g(c,{key:0,name:e.icon},null,8,["name"])):(s(),t(o,{key:1},[h(f(e.label),1)],64))],10,y))),128))])}}});export{V as _};
|
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{_ as m}from"./HDialog.vue_vue_type_script_setup_true_lang-DFArSwGc.js";import"./index-CAe0BuuW.js";export{m as default};
|
||||
import{_ as m}from"./HDialog.vue_vue_type_script_setup_true_lang-BZ2dbV3K.js";import"./index-nGFMSQGw.js";export{m as default};
|
@@ -0,0 +1,8 @@
|
||||
|
||||
/**
|
||||
* 由 Fantastic-admin 提供技术支持
|
||||
* Powered by Fantastic-admin
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{d as h,as as i,at as w,U as b,r as k,n as C,g as d,z as B,w as t,b as s,i as e,ah as p,ai as c,e as o,Q as V,aj as T,au as j,h as S,t as F,al as N,P as u,c as $,A as z,an as M,ao as D,j as P}from"./index-nGFMSQGw.js";const A={class:"fixed inset-0 overflow-y-auto"},E={class:"min-h-full flex items-end justify-center p-4 text-center lg-items-center"},G={flex:"~ items-center justify-between","px-4":"","py-3":"","border-b":"~ solid stone/15","text-6":""},H={key:0,flex:"~ items-center justify-end","px-4":"","py-3":"","border-t":"~ solid stone/15"},O=h({__name:"HDialog",props:i({appear:{type:Boolean,default:!1},title:{},preventClose:{type:Boolean,default:!1},overlay:{type:Boolean,default:!1}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:i(["close"],["update:modelValue"]),setup(f,{emit:m}){const y=m,l=w(f,"modelValue"),v=b(),g=k({enter:"ease-in-out duration-500",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in-out duration-500",leaveFrom:"opacity-100",leaveTo:"opacity-0"}),x=C(()=>({enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 lg-translate-y-0 lg-scale-95",enterTo:"opacity-100 translate-y-0 lg-scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 lg-scale-100",leaveTo:"opacity-0 translate-y-4 lg-translate-y-0 lg-scale-95"}));function n(){l.value=!1,y("close")}return(a,r)=>{const _=P;return d(),B(e(D),{as:"template",appear:a.appear,show:l.value},{default:t(()=>[s(e(M),{class:"fixed inset-0 z-2000 flex",onClose:r[0]||(r[0]=I=>!a.preventClose&&n())},{default:t(()=>[s(e(p),c({as:"template",appear:a.appear},e(g)),{default:t(()=>[o("div",{class:V(["fixed inset-0 bg-stone-2/75 transition-opacity dark-bg-stone-8/75",{"backdrop-blur-sm":a.overlay}])},null,2)]),_:1},16,["appear"]),o("div",A,[o("div",E,[s(e(p),c({as:"template",appear:a.appear},e(x)),{default:t(()=>[s(e(T),{class:"relative w-full flex flex-col overflow-hidden rounded-xl bg-white text-left shadow-xl lg-my-8 lg-max-w-lg dark-bg-stone-8"},{default:t(()=>[o("div",G,[s(e(j),{"m-0":"","text-lg":"","text-dark":"","dark-text-white":""},{default:t(()=>[S(F(a.title),1)]),_:1}),s(_,{name:"i-carbon:close","cursor-pointer":"",onClick:n})]),s(e(N),{"m-0":"","overflow-y-auto":"","p-4":""},{default:t(()=>[u(a.$slots,"default")]),_:3}),e(v).footer?(d(),$("div",H,[u(a.$slots,"footer")])):z("",!0)]),_:3})]),_:3},16,["appear"])])])]),_:3})]),_:3},8,["appear","show"])}}});export{O as _};
|
@@ -1,8 +0,0 @@
|
||||
|
||||
/**
|
||||
* 由 Fantastic-admin 提供技术支持
|
||||
* Powered by Fantastic-admin
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{d as w,av as i,aw as h,O as b,r as k,p as C,g as p,z as B,w as t,b as s,i as e,ak as d,X as c,e as o,Q as V,al as T,ax as S,h as j,t as F,an as N,P as u,c as $,A as z,ap as M,aq as D,j as O}from"./index-CAe0BuuW.js";const P={class:"fixed inset-0 overflow-y-auto"},q={class:"min-h-full flex items-end justify-center p-4 text-center lg-items-center"},A={flex:"~ items-center justify-between","px-4":"","py-3":"","border-b":"~ solid stone/15","text-6":""},E={key:0,flex:"~ items-center justify-end","px-4":"","py-3":"","border-t":"~ solid stone/15"},I=w({__name:"HDialog",props:i({appear:{type:Boolean,default:!1},title:{},preventClose:{type:Boolean,default:!1},overlay:{type:Boolean,default:!1}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:i(["close"],["update:modelValue"]),setup(f,{emit:m}){const y=m,l=h(f,"modelValue"),v=b(),g=k({enter:"ease-in-out duration-500",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in-out duration-500",leaveFrom:"opacity-100",leaveTo:"opacity-0"}),x=C(()=>({enter:"ease-out duration-300",enterFrom:"opacity-0 translate-y-4 lg-translate-y-0 lg-scale-95",enterTo:"opacity-100 translate-y-0 lg-scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 translate-y-0 lg-scale-100",leaveTo:"opacity-0 translate-y-4 lg-translate-y-0 lg-scale-95"}));function r(){l.value=!1,y("close")}return(a,n)=>{const _=O;return p(),B(e(D),{as:"template",appear:a.appear,show:l.value},{default:t(()=>[s(e(M),{class:"fixed inset-0 z-2000 flex",onClose:n[0]||(n[0]=G=>!a.preventClose&&r())},{default:t(()=>[s(e(d),c({as:"template",appear:a.appear},e(g)),{default:t(()=>[o("div",{class:V(["fixed inset-0 bg-stone-2/75 transition-opacity dark-bg-stone-8/75",{"backdrop-blur-sm":a.overlay}])},null,2)]),_:1},16,["appear"]),o("div",P,[o("div",q,[s(e(d),c({as:"template",appear:a.appear},e(x)),{default:t(()=>[s(e(T),{class:"relative w-full flex flex-col overflow-hidden rounded-xl bg-white text-left shadow-xl lg-my-8 lg-max-w-lg dark-bg-stone-8"},{default:t(()=>[o("div",A,[s(e(S),{"m-0":"","text-lg":"","text-dark":"","dark-text-white":""},{default:t(()=>[j(F(a.title),1)]),_:1}),s(_,{name:"i-carbon:close","cursor-pointer":"",onClick:r})]),s(e(N),{"m-0":"","overflow-y-auto":"","p-4":""},{default:t(()=>[u(a.$slots,"default")]),_:3}),e(v).footer?(p(),$("div",E,[u(a.$slots,"footer")])):z("",!0)]),_:3})]),_:3},16,["appear"])])])]),_:3})]),_:3},8,["appear","show"])}}});export{I as _};
|
8
public/admin/assets/HDropdown-BjwO9ikd.js
Normal file
8
public/admin/assets/HDropdown-BjwO9ikd.js
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
/**
|
||||
* 由 Fantastic-admin 提供技术支持
|
||||
* Powered by Fantastic-admin
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{l as t,p as n,g as a,z as p,w as o,P as r,ai as d}from"./index-nGFMSQGw.js";const l={};function c(e,_){const s=n("VDropdown");return a(),p(s,d({"show-triggers":["hover"],"hide-triggers":["hover"],"auto-hide":!1,"popper-triggers":["hover"],delay:200},e.$attrs),{popper:o(()=>[r(e.$slots,"dropdown")]),default:o(()=>[r(e.$slots,"default")]),_:3},16)}const f=t(l,[["render",c]]);export{f as default};
|
@@ -1,8 +0,0 @@
|
||||
|
||||
/**
|
||||
* 由 Fantastic-admin 提供技术支持
|
||||
* Powered by Fantastic-admin
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{l as t,n,g as a,z as p,w as o,P as r,X as d}from"./index-CAe0BuuW.js";const l={};function c(e,_){const s=n("VDropdown");return a(),p(s,d({"show-triggers":["hover"],"hide-triggers":["hover"],"auto-hide":!1,"popper-triggers":["hover"],delay:200},e.$attrs),{popper:o(()=>[r(e.$slots,"dropdown")]),default:o(()=>[r(e.$slots,"default")]),_:3},16)}const f=t(l,[["render",c]]);export{f as default};
|
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{_ as m}from"./HDropdownMenu.vue_vue_type_script_setup_true_lang-DvGMfvHr.js";import"./index-CAe0BuuW.js";export{m as default};
|
||||
import{_ as m}from"./HDropdownMenu.vue_vue_type_script_setup_true_lang-Dgz-jknv.js";import"./index-nGFMSQGw.js";export{m as default};
|
@@ -0,0 +1,8 @@
|
||||
|
||||
/**
|
||||
* 由 Fantastic-admin 提供技术支持
|
||||
* Powered by Fantastic-admin
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{d as h,n as g,p as k,g as t,z as f,w as n,c as s,s as a,i as _,F as l,P as w,ai as y,t as x}from"./index-nGFMSQGw.js";const C=["disabled","onClick"],z=h({__name:"HDropdownMenu",props:{items:{}},setup(d){const i=d,p=g(()=>i.items.map(e=>e.filter(o=>!o.hide)).filter(e=>e.length));return(e,o)=>{const c=k("VMenu");return t(),f(c,y({"show-triggers":["hover"],"auto-hide":!1,"popper-triggers":["hover","click"],delay:200},e.$attrs),{popper:n(()=>[(t(!0),s(l,null,a(_(p),(u,b)=>(t(),s("div",{key:b,class:"b-b-stone-2 b-b-solid p-1 last-b-b-size-0 dark-b-b-stone-7"},[(t(!0),s(l,null,a(u,(r,m)=>(t(),s("button",{key:m,disabled:r.disabled,class:"w-full flex cursor-pointer items-center gap-2 border-size-0 rounded-md bg-inherit px-2 py-1.5 text-sm text-dark disabled-cursor-not-allowed dark-text-white disabled-opacity-50 hover-not-disabled-bg-stone-1 dark-hover-not-disabled-bg-stone-9",onClick:r.handle},x(r.label),9,C))),128))]))),128))]),default:n(()=>[w(e.$slots,"default")]),_:3},16)}}});export{z as _};
|
@@ -1,8 +0,0 @@
|
||||
|
||||
/**
|
||||
* 由 Fantastic-admin 提供技术支持
|
||||
* Powered by Fantastic-admin
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{d as h,p as g,n as k,g as t,z as f,w as n,c as s,s as a,i as _,F as l,P as w,X as y,t as x}from"./index-CAe0BuuW.js";const C=["disabled","onClick"],z=h({__name:"HDropdownMenu",props:{items:{}},setup(d){const i=d,p=g(()=>i.items.map(e=>e.filter(o=>!o.hide)).filter(e=>e.length));return(e,o)=>{const c=k("VMenu");return t(),f(c,y({"show-triggers":["hover"],"auto-hide":!1,"popper-triggers":["hover","click"],delay:200},e.$attrs),{popper:n(()=>[(t(!0),s(l,null,a(_(p),(u,b)=>(t(),s("div",{key:b,class:"b-b-stone-2 b-b-solid p-1 last-b-b-size-0 dark-b-b-stone-7"},[(t(!0),s(l,null,a(u,(r,m)=>(t(),s("button",{key:m,disabled:r.disabled,class:"w-full flex cursor-pointer items-center gap-2 border-size-0 rounded-md bg-inherit px-2 py-1.5 text-sm text-dark disabled-cursor-not-allowed dark-text-white disabled-opacity-50 hover-not-disabled-bg-stone-1 dark-hover-not-disabled-bg-stone-9",onClick:r.handle},x(r.label),9,C))),128))]))),128))]),default:n(()=>[w(e.$slots,"default")]),_:3},16)}}});export{z as _};
|
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{_ as m}from"./HInput.vue_vue_type_script_setup_true_lang-DIeRn7Zh.js";import"./index-CAe0BuuW.js";export{m as default};
|
||||
import{_ as m}from"./HInput.vue_vue_type_script_setup_true_lang-DzYqFXwU.js";import"./index-nGFMSQGw.js";export{m as default};
|
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{d as r,av as n,aw as i,r as u,g as p,c,y as m,am as f,e as g}from"./index-CAe0BuuW.js";const b={class:"relative w-full lg-w-48"},h=["placeholder","disabled"],w=r({__name:"HInput",props:n({placeholder:{},disabled:{type:Boolean,default:!1}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(o,{expose:s}){const e=i(o,"modelValue"),d=u();return s({ref:d}),(l,a)=>(p(),c("div",b,[m(g("input",{"onUpdate:modelValue":a[0]||(a[0]=t=>e.value=t),type:"text",placeholder:l.placeholder,disabled:l.disabled,class:"relative block w-full border-0 rounded-md bg-white px-2.5 py-1.5 text-sm shadow-sm ring-1 ring-stone-2 ring-inset disabled-cursor-not-allowed dark-bg-dark disabled-opacity-50 focus-outline-none focus-ring-2 dark-ring-stone-8 focus-ring-ui-primary placeholder-stone-4 dark-placeholder-stone-5"},null,8,h),[[f,e.value]])]))}});export{w as _};
|
||||
import{d as r,as as n,at as i,r as u,g as p,c,y as m,ak as f,e as g}from"./index-nGFMSQGw.js";const b={class:"relative w-full lg-w-48"},h=["placeholder","disabled"],v=r({__name:"HInput",props:n({placeholder:{},disabled:{type:Boolean,default:!1}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(o,{expose:s}){const e=i(o,"modelValue"),d=u();return s({ref:d}),(l,a)=>(p(),c("div",b,[m(g("input",{"onUpdate:modelValue":a[0]||(a[0]=t=>e.value=t),type:"text",placeholder:l.placeholder,disabled:l.disabled,class:"relative block w-full border-0 rounded-md bg-white px-2.5 py-1.5 text-sm shadow-sm ring-1 ring-stone-2 ring-inset disabled-cursor-not-allowed dark-bg-dark disabled-opacity-50 focus-outline-none focus-ring-2 dark-ring-stone-8 focus-ring-ui-primary placeholder-stone-4 dark-placeholder-stone-5"},null,8,h),[[f,e.value]])]))}});export{v as _};
|
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{l as t,g as n,c as r,P as s}from"./index-CAe0BuuW.js";const o={},a={class:"mr-[4px] h-6 min-w-[24px] inline-flex items-center justify-center rounded bg-stone-1 px-1 text-[12px] text-dark font-medium font-sans ring-1 ring-stone-3 ring-inset last:mr-0 dark-bg-dark-9 dark-text-white dark-ring-stone-7"};function c(e,i){return n(),r("kbd",a,[s(e.$slots,"default")])}const l=t(o,[["render",c]]);export{l as default};
|
||||
import{l as t,g as n,c as r,P as s}from"./index-nGFMSQGw.js";const o={},a={class:"mr-[4px] h-6 min-w-[24px] inline-flex items-center justify-center rounded bg-stone-1 px-1 text-[12px] text-dark font-medium font-sans ring-1 ring-stone-3 ring-inset last:mr-0 dark-bg-dark-9 dark-text-white dark-ring-stone-7"};function c(e,i){return n(),r("kbd",a,[s(e.$slots,"default")])}const l=t(o,[["render",c]]);export{l as default};
|
@@ -1,8 +0,0 @@
|
||||
|
||||
/**
|
||||
* 由 Fantastic-admin 提供技术支持
|
||||
* Powered by Fantastic-admin
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{d as b,av as m,aw as f,p as g,n as v,g as l,z as h,w as r,e as o,c as i,s as _,F as w,t as c,i as k,b as x,X as y,j as V,Q as C}from"./index-CAe0BuuW.js";const B={class:"w-full inline-flex"},M=["disabled"],z={class:"block truncate"},S={class:"pointer-events-none absolute end-0 inset-y-0 flex items-center pe-2.5"},$={class:"max-h-60 w-full scroll-py-1 overflow-y-auto p-1 lg-w-48 focus-outline-none"},F=["disabled","onClick"],E=b({__name:"HSelect",props:m({options:{},disabled:{type:Boolean,default:!1}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const a=t,n=f(t,"modelValue"),d=g({get(){return a.options.find(e=>e.value===n.value)??a.options[0]},set(e){n.value=e.value}});return(e,N)=>{const u=V,p=v("VMenu");return l(),h(p,y({triggers:["click"],"popper-triggers":["click"],delay:0,disabled:e.disabled},e.$attrs),{popper:r(()=>[o("div",$,[(l(!0),i(w,null,_(e.options,s=>(l(),i("button",{key:s.value,disabled:s.disabled,class:C(["w-full cursor-pointer truncate border-size-0 rounded-md bg-inherit px-2 py-1.5 text-left text-sm disabled-cursor-not-allowed hover-not-disabled-bg-stone-1 dark-hover-not-disabled-bg-stone-9",{"font-bold":t.modelValue===s.value}]),onClick:j=>d.value=s},c(s.label),11,F))),128))])]),default:r(()=>[o("div",B,[o("button",{class:"relative block w-full flex cursor-default items-center gap-x-2 border-0 rounded-md bg-white px-2.5 py-1.5 pe-9 text-left text-sm shadow-sm ring-1 ring-stone-2 ring-inset lg-w-48 disabled-cursor-not-allowed dark-bg-dark focus-outline-none focus-ring-2 dark-ring-stone-8 focus-ring-ui-primary",disabled:e.disabled},[o("span",z,c(k(d).label),1),o("span",S,[x(u,{name:"i-carbon:chevron-down",class:"h-5 w-5 flex-shrink-0 text-stone-5"})])],8,M)])]),_:1},16,["disabled"])}}});export{E as default};
|
8
public/admin/assets/HSelect-CYtELVq1.js
Normal file
8
public/admin/assets/HSelect-CYtELVq1.js
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
/**
|
||||
* 由 Fantastic-admin 提供技术支持
|
||||
* Powered by Fantastic-admin
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{d as b,as as m,at as f,n as g,p as v,g as a,z as h,w as r,e as t,c as i,s as _,F as k,t as c,i as w,b as x,ai as y,j as V,Q as C}from"./index-nGFMSQGw.js";const B={class:"w-full inline-flex"},M=["disabled"],z={class:"block truncate"},S={class:"pointer-events-none absolute end-0 inset-y-0 flex items-center pe-2.5"},$={class:"max-h-60 w-full scroll-py-1 overflow-y-auto p-1 lg-w-48 focus-outline-none"},F=["disabled","onClick"],E=b({__name:"HSelect",props:m({options:{},disabled:{type:Boolean,default:!1}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const l=o,n=f(o,"modelValue"),d=g({get(){return l.options.find(e=>e.value===n.value)??l.options[0]},set(e){n.value=e.value}});return(e,N)=>{const u=V,p=v("VMenu");return a(),h(p,y({triggers:["click"],"popper-triggers":["click"],delay:0,disabled:e.disabled},e.$attrs),{popper:r(()=>[t("div",$,[(a(!0),i(k,null,_(e.options,s=>(a(),i("button",{key:s.value,disabled:s.disabled,class:C(["w-full cursor-pointer truncate border-size-0 rounded-md bg-inherit px-2 py-1.5 text-left text-sm disabled-cursor-not-allowed hover-not-disabled-bg-stone-1 dark-hover-not-disabled-bg-stone-9",{"font-bold":o.modelValue===s.value}]),onClick:j=>d.value=s},c(s.label),11,F))),128))])]),default:r(()=>[t("div",B,[t("button",{class:"relative block w-full flex cursor-default items-center gap-x-2 border-0 rounded-md bg-white px-2.5 py-1.5 pe-9 text-left text-sm shadow-sm ring-1 ring-stone-2 ring-inset lg-w-48 disabled-cursor-not-allowed dark-bg-dark focus-outline-none focus-ring-2 dark-ring-stone-8 focus-ring-ui-primary",disabled:e.disabled},[t("span",z,c(w(d).label),1),t("span",S,[x(u,{name:"i-carbon:chevron-down",class:"h-5 w-5 flex-shrink-0 text-stone-5"})])],8,M)])]),_:1},16,["disabled"])}}});export{E as default};
|
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{cA as f}from"./index-CAe0BuuW.js";export{f as default};
|
||||
import{cy as f}from"./index-nGFMSQGw.js";export{f as default};
|
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{_ as o}from"./HTabList.vue_vue_type_script_setup_true_lang-DVNTO8pP.js";import"./index-CAe0BuuW.js";import"./use-resolve-button-type-CIWo_h_W.js";export{o as default};
|
||||
import{_ as o}from"./HTabList.vue_vue_type_script_setup_true_lang-P9EIXJZ1.js";import"./index-nGFMSQGw.js";import"./use-resolve-button-type-CVaAVCZ2.js";export{o as default};
|
File diff suppressed because one or more lines are too long
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{_ as o}from"./HToggle.vue_vue_type_script_setup_true_lang-BMpWofWF.js";import"./index-CAe0BuuW.js";import"./use-resolve-button-type-CIWo_h_W.js";export{o as default};
|
||||
import{_ as o}from"./HToggle.vue_vue_type_script_setup_true_lang-iKBpmqsT.js";import"./index-nGFMSQGw.js";import"./use-resolve-button-type-CVaAVCZ2.js";export{o as default};
|
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{r as V,p as i,d as x,cs as D,$ as M,co as P,a as U,Z as A,a4 as y,cm as K,cB as L,cl as O,cp as q,cq as z,F,ct as h,av as H,aw as R,g,z as k,w as G,e as w,A as Q,Q as I,i as Z,j as J}from"./index-CAe0BuuW.js";import{s as W}from"./use-resolve-button-type-CIWo_h_W.js";function X(a,l,t){let o=V(t==null?void 0:t.value),n=i(()=>a.value!==void 0);return[i(()=>n.value?a.value:o.value),function(s){return n.value||(o.value=s),l==null?void 0:l(s)}]}function Y(a){var l,t;let o=(l=a==null?void 0:a.form)!=null?l:a.closest("form");if(o){for(let n of o.elements)if(n!==a&&(n.tagName==="INPUT"&&n.type==="submit"||n.tagName==="BUTTON"&&n.type==="submit"||n.nodeName==="INPUT"&&n.type==="image")){n.click();return}(t=o.requestSubmit)==null||t.call(o)}}let ee=Symbol("GroupContext"),ae=x({name:"Switch",emits:{"update:modelValue":a=>!0},props:{as:{type:[Object,String],default:"button"},modelValue:{type:Boolean,default:void 0},defaultChecked:{type:Boolean,optional:!0},form:{type:String,optional:!0},name:{type:String,optional:!0},value:{type:String,optional:!0},id:{type:String,default:null},disabled:{type:Boolean,default:!1},tabIndex:{type:Number,default:0}},inheritAttrs:!1,setup(a,{emit:l,attrs:t,slots:o,expose:n}){var s;let C=(s=a.id)!=null?s:`headlessui-switch-${D()}`,r=M(ee,null),[d,m]=X(i(()=>a.modelValue),e=>l("update:modelValue",e),i(()=>a.defaultChecked));function p(){m(!d.value)}let $=V(null),c=r===null?$:r.switchRef,B=W(i(()=>({as:a.as,type:t.type})),c);n({el:c,$el:c});function S(e){e.preventDefault(),p()}function N(e){e.key===h.Space?(e.preventDefault(),p()):e.key===h.Enter&&Y(e.currentTarget)}function T(e){e.preventDefault()}let f=i(()=>{var e,u;return(u=(e=P(c))==null?void 0:e.closest)==null?void 0:u.call(e,"form")});return U(()=>{A([f],()=>{if(!f.value||a.defaultChecked===void 0)return;function e(){m(a.defaultChecked)}return f.value.addEventListener("reset",e),()=>{var u;(u=f.value)==null||u.removeEventListener("reset",e)}},{immediate:!0})}),()=>{let{name:e,value:u,form:_,tabIndex:v,...b}=a,E={checked:d.value},j={id:C,ref:c,role:"switch",type:B.value,tabIndex:v===-1?0:v,"aria-checked":d.value,"aria-labelledby":r==null?void 0:r.labelledby.value,"aria-describedby":r==null?void 0:r.describedby.value,onClick:S,onKeyup:N,onKeypress:T};return y(F,[e!=null&&d.value!=null?y(K,L({features:O.Hidden,as:"input",type:"checkbox",hidden:!0,readOnly:!0,checked:d.value,form:_,disabled:b.disabled,name:e,value:u})):null,q({ourProps:j,theirProps:{...t,...z(b,["modelValue","defaultChecked"])},slot:E,attrs:t,slots:o,name:"Switch"})])}}});const le={class:"absolute inset-0 h-full w-full flex items-center justify-center"},oe=x({__name:"HToggle",props:H({disabled:{type:Boolean,default:!1},onIcon:{},offIcon:{}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:["update:modelValue"],setup(a){const l=R(a,"modelValue");return(t,o)=>{const n=J;return g(),k(Z(ae),{modelValue:l.value,"onUpdate:modelValue":o[0]||(o[0]=s=>l.value=s),disabled:t.disabled,class:I(["relative h-5 w-10 inline-flex flex-shrink-0 cursor-pointer border-2 border-transparent rounded-full p-0 vertical-middle disabled-cursor-not-allowed disabled-opacity-50 focus-outline-none focus-visible-ring-2 focus-visible-ring-offset-2 focus-visible-ring-offset-white dark-focus-visible-ring-offset-gray-900",[l.value?"bg-ui-primary":"bg-stone-3 dark-bg-stone-7"]])},{default:G(()=>[w("span",{class:I(["pointer-events-none relative inline-block h-4 w-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out dark-bg-dark",[l.value?"translate-x-5":"translate-x-0"]])},[w("span",le,[l.value&&t.onIcon||!l.value&&t.offIcon?(g(),k(n,{key:0,name:l.value?t.onIcon:t.offIcon,class:"h-3 w-3 text-stone-7 dark-text-stone-3"},null,8,["name"])):Q("",!0)])],2)]),_:1},8,["modelValue","disabled","class"])}}});export{oe as _};
|
||||
import{r as V,n as i,d as x,cq as D,W as M,cm as P,a as U,X as z,a1 as y,ck as A,cz as K,cj as L,cn as O,co as q,F,cr as h,as as H,at as R,g,z as k,w as G,e as w,A as Q,Q as I,i as W,j as X}from"./index-nGFMSQGw.js";import{s as J}from"./use-resolve-button-type-CVaAVCZ2.js";function Y(a,l,t){let o=V(t==null?void 0:t.value),n=i(()=>a.value!==void 0);return[i(()=>n.value?a.value:o.value),function(s){return n.value||(o.value=s),l==null?void 0:l(s)}]}function Z(a){var l,t;let o=(l=a==null?void 0:a.form)!=null?l:a.closest("form");if(o){for(let n of o.elements)if(n!==a&&(n.tagName==="INPUT"&&n.type==="submit"||n.tagName==="BUTTON"&&n.type==="submit"||n.nodeName==="INPUT"&&n.type==="image")){n.click();return}(t=o.requestSubmit)==null||t.call(o)}}let ee=Symbol("GroupContext"),ae=x({name:"Switch",emits:{"update:modelValue":a=>!0},props:{as:{type:[Object,String],default:"button"},modelValue:{type:Boolean,default:void 0},defaultChecked:{type:Boolean,optional:!0},form:{type:String,optional:!0},name:{type:String,optional:!0},value:{type:String,optional:!0},id:{type:String,default:null},disabled:{type:Boolean,default:!1},tabIndex:{type:Number,default:0}},inheritAttrs:!1,setup(a,{emit:l,attrs:t,slots:o,expose:n}){var s;let C=(s=a.id)!=null?s:`headlessui-switch-${D()}`,r=M(ee,null),[d,m]=Y(i(()=>a.modelValue),e=>l("update:modelValue",e),i(()=>a.defaultChecked));function p(){m(!d.value)}let S=V(null),c=r===null?S:r.switchRef,$=J(i(()=>({as:a.as,type:t.type})),c);n({el:c,$el:c});function B(e){e.preventDefault(),p()}function N(e){e.key===h.Space?(e.preventDefault(),p()):e.key===h.Enter&&Z(e.currentTarget)}function T(e){e.preventDefault()}let f=i(()=>{var e,u;return(u=(e=P(c))==null?void 0:e.closest)==null?void 0:u.call(e,"form")});return U(()=>{z([f],()=>{if(!f.value||a.defaultChecked===void 0)return;function e(){m(a.defaultChecked)}return f.value.addEventListener("reset",e),()=>{var u;(u=f.value)==null||u.removeEventListener("reset",e)}},{immediate:!0})}),()=>{let{name:e,value:u,form:_,tabIndex:v,...b}=a,j={checked:d.value},E={id:C,ref:c,role:"switch",type:$.value,tabIndex:v===-1?0:v,"aria-checked":d.value,"aria-labelledby":r==null?void 0:r.labelledby.value,"aria-describedby":r==null?void 0:r.describedby.value,onClick:B,onKeyup:N,onKeypress:T};return y(F,[e!=null&&d.value!=null?y(A,K({features:L.Hidden,as:"input",type:"checkbox",hidden:!0,readOnly:!0,checked:d.value,form:_,disabled:b.disabled,name:e,value:u})):null,O({ourProps:E,theirProps:{...t,...q(b,["modelValue","defaultChecked"])},slot:j,attrs:t,slots:o,name:"Switch"})])}}});const le={class:"absolute inset-0 h-full w-full flex items-center justify-center"},oe=x({__name:"HToggle",props:H({disabled:{type:Boolean,default:!1},onIcon:{},offIcon:{}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:["update:modelValue"],setup(a){const l=R(a,"modelValue");return(t,o)=>{const n=X;return g(),k(W(ae),{modelValue:l.value,"onUpdate:modelValue":o[0]||(o[0]=s=>l.value=s),disabled:t.disabled,class:I(["relative h-5 w-10 inline-flex flex-shrink-0 cursor-pointer border-2 border-transparent rounded-full p-0 vertical-middle disabled-cursor-not-allowed disabled-opacity-50 focus-outline-none focus-visible-ring-2 focus-visible-ring-offset-2 focus-visible-ring-offset-white dark-focus-visible-ring-offset-gray-900",[l.value?"bg-ui-primary":"bg-stone-3 dark-bg-stone-7"]])},{default:G(()=>[w("span",{class:I(["pointer-events-none relative inline-block h-4 w-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out dark-bg-dark",[l.value?"translate-x-5":"translate-x-0"]])},[w("span",le,[l.value&&t.onIcon||!l.value&&t.offIcon?(g(),k(n,{key:0,name:l.value?t.onIcon:t.offIcon,class:"h-3 w-3 text-stone-7 dark-text-stone-3"},null,8,["name"])):Q("",!0)])],2)]),_:1},8,["modelValue","disabled","class"])}}});export{oe as _};
|
@@ -5,4 +5,4 @@
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{_ as m}from"./HTooltip.vue_vue_type_script_setup_true_lang-DkOhIXEM.js";import"./index-CAe0BuuW.js";export{m as default};
|
||||
import{_ as m}from"./HTooltip.vue_vue_type_script_setup_true_lang-BEZk-UXU.js";import"./index-nGFMSQGw.js";export{m as default};
|
@@ -0,0 +1,8 @@
|
||||
|
||||
/**
|
||||
* 由 Fantastic-admin 提供技术支持
|
||||
* Powered by Fantastic-admin
|
||||
* https://fantastic-admin.github.io
|
||||
*/
|
||||
|
||||
import{d as r,p,g as o,z as l,w as s,P as t,ai as n,c as i,h as d,t as c}from"./index-nGFMSQGw.js";const m={key:1},g=r({__name:"HTooltip",props:{text:{default:""},enable:{type:Boolean,default:!0}},setup(u){return(e,f)=>{const a=p("VTooltip");return e.enable?(o(),l(a,n({key:0,"popper-triggers":["hover"]},e.$attrs),{popper:s(()=>[t(e.$slots,"text",{},()=>[d(c(e.text),1)])]),default:s(()=>[t(e.$slots,"default")]),_:3},16)):(o(),i("div",m,[t(e.$slots,"default")]))}}});export{g as _};
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user