Skip to content

Commit

Permalink
0.5.2
Browse files Browse the repository at this point in the history
增加chatbot配置接口
  • Loading branch information
atorber committed Dec 7, 2023
1 parent 536613c commit a91eeac
Show file tree
Hide file tree
Showing 17 changed files with 561 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chatflow-admin",
"version": "0.5.1",
"version": "0.5.2",
"description": "",
"author": "",
"private": true,
Expand Down
6 changes: 6 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ import { StatisticsModule } from './modules/statistics/statistics.module';
import { OrdersService } from './modules/orders/orders.service';
import { OrdersController } from './modules/orders/orders.controller';
import { OrdersModule } from './modules/orders/orders.module';
import { ChatbotsService } from './modules/chatbots/chatbots.service';
import { ChatbotsController } from './modules/chatbots/chatbots.controller';
import { ChatbotsModule } from './modules/chatbots/chatbots.module';

@Module({
imports: [
Expand All @@ -52,6 +55,7 @@ import { OrdersModule } from './modules/orders/orders.module';
KeywordsModule,
StatisticsModule,
OrdersModule,
ChatbotsModule,
],
controllers: [
AppController,
Expand All @@ -66,6 +70,7 @@ import { OrdersModule } from './modules/orders/orders.module';
KeywordsController,
StatisticsController,
OrdersController,
ChatbotsController,
],
providers: [
AppService,
Expand All @@ -78,6 +83,7 @@ import { OrdersModule } from './modules/orders/orders.module';
KeywordsService,
StatisticsService,
OrdersService,
ChatbotsService,
],
})
export class AppModule {}
4 changes: 4 additions & 0 deletions src/db/vika-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export interface DateBase {
stockSheet: string;
groupNoticeSheet: string;
qaSheet: string;
chatBotSheet: string;
chatBotUserSheet: string;
}

export class KeyDisplaynameMap {
Expand Down Expand Up @@ -97,6 +99,8 @@ export class VikaDB {
stockSheet: '',
groupNoticeSheet: '',
qaSheet: '',
chatBotSheet: '',
chatBotUserSheet: '',
};
this.dataBaseNames = { ...this.dataBaseIds };
this.config = {};
Expand Down
6 changes: 4 additions & 2 deletions src/db/vika-orm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export abstract class BaseEntity {
static async findByField(
fieldName: string,
value: any,
pageSize: number | undefined = 100,
): Promise<IRecord[] | undefined[]> {
const field = this.mappingOptions.fieldMapping[fieldName];
let records: IRecord[] = [];
Expand All @@ -263,7 +264,7 @@ export abstract class BaseEntity {

const query = {
filterByFormula: `{${field}}="${value}"`,
pageSize: 1000,
pageSize: pageSize,
};
console.info('query:', JSON.stringify(query));
// 分页获取记录,默认返回第一页
Expand All @@ -282,10 +283,11 @@ export abstract class BaseEntity {
*/
static async findByQuery(
filterByFormula: string,
pageSize: number | undefined = 100,
): Promise<IRecord[] | undefined[]> {
const query = {
filterByFormula,
pageSize: 1000,
pageSize: pageSize,
};
console.info('query:', JSON.stringify(query));
// 分页获取记录,默认返回第一页
Expand Down
87 changes: 87 additions & 0 deletions src/db/vikaModel/ChatBot/fields.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"code": 200,
"success": true,
"data": {
"fields": [
{
"id": "fldA47yx9L3bk",
"name": "机器人ID|id",
"type": "SingleText",
"property": {
"defaultValue": ""
},
"editable": true,
"isPrimary": true
},
{
"id": "fldPrcQ5QfhxV",
"name": "昵称|botname",
"type": "SingleText",
"property": {},
"editable": true
},
{
"id": "fld6rYKTZ0zQV",
"name": "用户ID|wxid",
"type": "SingleText",
"property": {},
"editable": true
},
{
"id": "fldxD8wwu1hGy",
"name": "用户名称|name",
"type": "SingleText",
"property": {},
"editable": true
},
{
"id": "fld4P2sX0CHco",
"name": "用户提示词|prompt",
"type": "Text",
"editable": true
},
{
"id": "fldguMiluobGu",
"name": "配额|quota",
"type": "Number",
"property": {
"precision": 0
},
"editable": true
},
{
"id": "fldUcpFFLyMo7",
"name": "启用状态|state",
"type": "SingleSelect",
"property": {
"options": [
{
"id": "optMTJ3j2fMr4",
"name": "启用",
"color": {
"name": "deepPurple_0",
"value": "#E5E1FC"
}
},
{
"id": "opt4bTBzh2Mx6",
"name": "禁用",
"color": {
"name": "indigo_0",
"value": "#DDE7FF"
}
}
]
},
"editable": true
},
{
"id": "fldsG69W4KzJa",
"name": "备注|info",
"type": "Text",
"editable": true
}
]
},
"message": "SUCCESS"
}
118 changes: 118 additions & 0 deletions src/db/vikaModel/ChatBot/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/* eslint-disable sort-keys */

import type {
Sheet,
// Field,
} from '../Model';

import { replaceSyncStatus, actionState } from '../actionBar';

const name = '智聊|Chatbot';
const code = 'chatBotSheet';

const vikaFields = {
code: 200,
success: true,
data: {
fields: [
{
id: 'fldA47yx9L3bk',
name: '机器人ID|id',
type: 'SingleText',
property: {
defaultValue: '',
},
editable: true,
isPrimary: true,
},
{
id: 'fldPrcQ5QfhxV',
name: '昵称|botname',
type: 'SingleText',
property: {},
editable: true,
},
{
id: 'fld6rYKTZ0zQV',
name: '用户ID|wxid',
type: 'SingleText',
property: {},
editable: true,
},
{
id: 'fldxD8wwu1hGy',
name: '用户名称|name',
type: 'SingleText',
property: {},
editable: true,
},
{
id: 'fld4P2sX0CHco',
name: '用户提示词|prompt',
type: 'Text',
editable: true,
},
{
id: 'fldguMiluobGu',
name: '配额|quota',
type: 'Number',
property: {
precision: 0,
},
editable: true,
},
{
id: 'fldUcpFFLyMo7',
name: '启用状态|state',
type: 'SingleSelect',
property: {
options: [
{
id: 'optMTJ3j2fMr4',
name: '启用',
color: {
name: 'deepPurple_0',
value: '#E5E1FC',
},
},
{
id: 'opt4bTBzh2Mx6',
name: '禁用',
color: {
name: 'indigo_0',
value: '#DDE7FF',
},
},
],
},
editable: true,
},
{
id: 'fldsG69W4KzJa',
name: '备注|info',
type: 'Text',
editable: true,
},
],
},
message: 'SUCCESS',
};

let fields: any = vikaFields.data.fields;

if (actionState[code]) {
fields = replaceSyncStatus(fields);
}

const defaultRecords: any = {
code: 200,
success: true,
data: { total: 0, records: [], pageNum: 1, pageSize: 0 },
message: 'SUCCESS',
};

export const sheet: Sheet = {
fields,
name,
defaultRecords: defaultRecords.data.records,
};
1 change: 1 addition & 0 deletions src/db/vikaModel/ChatBot/records.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"code":200,"success":true,"data":{"total":0,"records":[],"pageNum":1,"pageSize":0},"message":"SUCCESS"}
Loading

0 comments on commit a91eeac

Please sign in to comment.