mirror of
https://github.com/vastxie/99AI.git
synced 2025-11-11 11:13:43 +08:00
v3.5.0
This commit is contained in:
181
dist/modules/database/database.service.js
vendored
181
dist/modules/database/database.service.js
vendored
@@ -29,8 +29,22 @@ let DatabaseService = class DatabaseService {
|
||||
const adminPassword = bcrypt.hashSync('123456', 10);
|
||||
const superEmail = 'super';
|
||||
const adminEmail = 'admin';
|
||||
const superUserinfo = { username: 'super', password: superPassword, status: 1, email: superEmail, sex: 1, role: 'super' };
|
||||
const adminUserinfo = { username: 'admin', password: adminPassword, status: 0, email: adminEmail, sex: 1, role: 'admin' };
|
||||
const superUserinfo = {
|
||||
username: 'super',
|
||||
password: superPassword,
|
||||
status: 1,
|
||||
email: superEmail,
|
||||
sex: 1,
|
||||
role: 'super',
|
||||
};
|
||||
const adminUserinfo = {
|
||||
username: 'admin',
|
||||
password: adminPassword,
|
||||
status: 0,
|
||||
email: adminEmail,
|
||||
sex: 1,
|
||||
role: 'admin',
|
||||
};
|
||||
await this.createDefaultUser(superUserinfo);
|
||||
await this.createDefaultUser(adminUserinfo);
|
||||
}
|
||||
@@ -41,7 +55,7 @@ let DatabaseService = class DatabaseService {
|
||||
const user = await this.connection.query(`INSERT INTO users (username, password, status, email, role) VALUES ('${username}', '${password}', '${status}', '${email}', '${role}')`);
|
||||
const userId = user.insertId;
|
||||
const balance = await this.connection.query(`INSERT INTO balance (userId, balance, usesLeft, paintCount) VALUES ('${userId}', 0, 1000, 100)`);
|
||||
common_1.Logger.log(`初始化创建${role}用户成功、用户名为[${username}]、初始密码为[${username === 'super' ? 'nine-super' : '123456'}] ==============> 请注意查阅`, 'DatabaseService');
|
||||
common_1.Logger.log(`初始化创建${role}用户成功、用户名为[${username}]、初始密码为[${username === 'super' ? 'super' : '123456'}] ==============> 请注意查阅`, 'DatabaseService');
|
||||
}
|
||||
catch (error) {
|
||||
console.log('error: ', error);
|
||||
@@ -49,9 +63,17 @@ let DatabaseService = class DatabaseService {
|
||||
}
|
||||
}
|
||||
async checkSiteBaseConfig() {
|
||||
const keys = ['siteName', 'qqNumber', 'vxNumber', 'robotAvatar', 'userDefautlAvatar'];
|
||||
const keys = [
|
||||
'siteName',
|
||||
'qqNumber',
|
||||
'vxNumber',
|
||||
'robotAvatar',
|
||||
'userDefautlAvatar',
|
||||
];
|
||||
const result = await this.connection.query(`
|
||||
SELECT COUNT(*) AS count FROM config WHERE \`configKey\` IN (${keys.map((k) => `'${k}'`).join(',')})
|
||||
SELECT COUNT(*) AS count FROM config WHERE \`configKey\` IN (${keys
|
||||
.map((k) => `'${k}'`)
|
||||
.join(',')})
|
||||
`);
|
||||
const count = parseInt(result[0].count);
|
||||
if (count === 0) {
|
||||
@@ -87,27 +109,112 @@ let DatabaseService = class DatabaseService {
|
||||
encry: 0,
|
||||
},
|
||||
{ configKey: 'buyCramiAddress', configVal: '', public: 1, encry: 0 },
|
||||
{ configKey: 'openaiBaseUrl', configVal: 'https://api.lightai.io', public: 0, encry: 0 },
|
||||
{
|
||||
configKey: 'openaiBaseUrl',
|
||||
configVal: 'https://api.lightai.io',
|
||||
public: 0,
|
||||
encry: 0,
|
||||
},
|
||||
{ configKey: 'openaiTimeout', configVal: '300', public: 0, encry: 0 },
|
||||
{ configKey: 'openaiBaseKey', configVal: 'sk-', public: 0, encry: 0 },
|
||||
{ configKey: 'mjTranslatePrompt', configVal: `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.`, public: 0, encry: 0 },
|
||||
{
|
||||
configKey: 'mjTranslatePrompt',
|
||||
configVal: `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.`,
|
||||
public: 0,
|
||||
encry: 0,
|
||||
},
|
||||
{ configKey: 'noticeInfo', configVal: noticeInfo, public: 1, encry: 0 },
|
||||
{ configKey: 'registerSendStatus', configVal: '1', public: 1, encry: 0 },
|
||||
{ configKey: 'registerSendModel3Count', configVal: '30', public: 1, encry: 0 },
|
||||
{ configKey: 'registerSendModel4Count', configVal: '3', public: 1, encry: 0 },
|
||||
{ configKey: 'registerSendDrawMjCount', configVal: '3', public: 1, encry: 0 },
|
||||
{ configKey: 'firstRegisterSendStatus', configVal: '1', public: 1, encry: 0 },
|
||||
{ configKey: 'firstRegisterSendRank', configVal: '500', public: 1, encry: 0 },
|
||||
{ configKey: 'firstRregisterSendModel3Count', configVal: '10', public: 1, encry: 0 },
|
||||
{ configKey: 'firstRregisterSendModel4Count', configVal: '10', public: 1, encry: 0 },
|
||||
{ configKey: 'firstRregisterSendDrawMjCount', configVal: '10', public: 1, encry: 0 },
|
||||
{
|
||||
configKey: 'registerSendStatus',
|
||||
configVal: '1',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'registerSendModel3Count',
|
||||
configVal: '30',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'registerSendModel4Count',
|
||||
configVal: '3',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'registerSendDrawMjCount',
|
||||
configVal: '3',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'firstRegisterSendStatus',
|
||||
configVal: '1',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'firstRegisterSendRank',
|
||||
configVal: '500',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'firstRregisterSendModel3Count',
|
||||
configVal: '10',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'firstRregisterSendModel4Count',
|
||||
configVal: '10',
|
||||
public: 1,
|
||||
encry: 0,
|
||||
},
|
||||
{
|
||||
configKey: 'firstRregisterSendDrawMjCount',
|
||||
configVal: '10',
|
||||
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: '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 },
|
||||
];
|
||||
const res = await this.connection.query(`INSERT INTO config (configKey, configVal, public, encry) VALUES ${defaultConfig
|
||||
@@ -122,15 +229,39 @@ let DatabaseService = class DatabaseService {
|
||||
}
|
||||
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 },
|
||||
{
|
||||
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]);
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user