@shun-js/vicvic-server 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.js +2 -1
- package/package.json +3 -2
- package/server/controller/ModelItemController.js +12 -0
- package/server/db/db_vicvic.sql +1 -0
- package/server/db/t_model_item.sql +15 -0
- package/server/model/ModelItemModel.js +60 -0
- package/server/service/ModelItemService.js +17 -0
- package/server/sql/ModelItemSQL.js +34 -0
package/app.js
CHANGED
|
@@ -16,8 +16,9 @@ const { parseServerConfig } = require("@shun-js/shun-config");
|
|
|
16
16
|
// options cros
|
|
17
17
|
options.cros = true;
|
|
18
18
|
|
|
19
|
-
// options
|
|
19
|
+
// options mysql
|
|
20
20
|
options.config = config;
|
|
21
|
+
options.mysql = require("qiao-mysql");
|
|
21
22
|
|
|
22
23
|
// options redis
|
|
23
24
|
options.redis = require("qiao-redis");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shun-js/vicvic-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "uikoo9 <uikoo9@qq.com>",
|
|
6
6
|
"homepage": "https://github.com/uikoo9/shun-js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@shun-js/shun-config": "^0.3.1",
|
|
20
20
|
"@shun-js/shun-service": "^0.3.1",
|
|
21
21
|
"qiao-log": "^6.0.0",
|
|
22
|
+
"qiao-mysql": "^6.0.0",
|
|
22
23
|
"qiao-rate-limit": "^6.0.0",
|
|
23
24
|
"qiao-redis": "^6.0.0",
|
|
24
25
|
"qiao-z": "^6.0.0",
|
|
@@ -31,5 +32,5 @@
|
|
|
31
32
|
"access": "public",
|
|
32
33
|
"registry": "https://registry.npmjs.org/"
|
|
33
34
|
},
|
|
34
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "0b29135b8ce9e1ef12773cbcfe2900702d616909"
|
|
35
36
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
create database if not exists db_vicvic default character set utf8mb4 default collate utf8mb4_general_ci;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
create table if not exists t_model_item (
|
|
2
|
+
id int auto_increment primary key,
|
|
3
|
+
model_name varchar(64) not null comment '展示名称,如 DeepSeek、GPT-4o',
|
|
4
|
+
model_slug varchar(64) not null comment '唯一标识,如 deepseek-v3',
|
|
5
|
+
provider varchar(32) not null comment '厂商,如 openai / anthropic / deepseek / google',
|
|
6
|
+
provider_region varchar(8) default 'global' comment '区域: cn / global',
|
|
7
|
+
avatar_url varchar(512) default null comment '头像/图标 URL',
|
|
8
|
+
description varchar(256) default null comment '一句话简介',
|
|
9
|
+
api_endpoint varchar(256) default null comment 'API 地址',
|
|
10
|
+
api_model_id varchar(128) default null comment 'API 调用的 model 参数值',
|
|
11
|
+
is_active tinyint(1) default 1 comment '是否启用: 1=启用 0=停用',
|
|
12
|
+
sort_order int default 0 comment '排序,越小越靠前',
|
|
13
|
+
create_time datetime default now() comment '创建时间',
|
|
14
|
+
del_tag char(1) default '0' comment '删除标记: 0=正常 1=已删除'
|
|
15
|
+
) engine=InnoDB default charset=utf8mb4 comment='AI 模型表';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// sql
|
|
2
|
+
const sql = require('../sql/ModelItemSQL.js');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* modelItemList
|
|
6
|
+
* @param {*} req
|
|
7
|
+
* @param {*} res
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
exports.modelItemList = async (req, res) => {
|
|
11
|
+
const methodName = 'modelItemList';
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
return await req.db.query(sql.modelItemList);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
const msg = '获取模型列表失败!';
|
|
17
|
+
req.logger.error(methodName, msg, error.name, error.message);
|
|
18
|
+
res.jsonFail(msg);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* getModelItemBySlug
|
|
24
|
+
* @param {*} req
|
|
25
|
+
* @param {*} res
|
|
26
|
+
* @param {*} slug
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
exports.getModelItemBySlug = async (req, res, slug) => {
|
|
30
|
+
const methodName = 'getModelItemBySlug';
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const rows = await req.db.query(sql.getModelItemBySlug, [slug]);
|
|
34
|
+
return rows.length === 1 ? rows[0] : null;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
const msg = '获取模型信息失败!';
|
|
37
|
+
req.logger.error(methodName, msg, error.name, error.message);
|
|
38
|
+
res.jsonFail(msg);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* getModelItemById
|
|
44
|
+
* @param {*} req
|
|
45
|
+
* @param {*} res
|
|
46
|
+
* @param {*} id
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
exports.getModelItemById = async (req, res, id) => {
|
|
50
|
+
const methodName = 'getModelItemById';
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const rows = await req.db.query(sql.getModelItemById, [id]);
|
|
54
|
+
return rows.length === 1 ? rows[0] : null;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
const msg = '获取模型信息失败!';
|
|
57
|
+
req.logger.error(methodName, msg, error.name, error.message);
|
|
58
|
+
res.jsonFail(msg);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// model
|
|
2
|
+
const { modelItemList } = require('../model/ModelItemModel.js');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* modelItemList
|
|
6
|
+
* @param {*} req
|
|
7
|
+
* @param {*} res
|
|
8
|
+
*/
|
|
9
|
+
exports.modelItemList = async (req, res) => {
|
|
10
|
+
const methodName = 'modelItemList';
|
|
11
|
+
|
|
12
|
+
const list = await modelItemList(req, res);
|
|
13
|
+
if (!list) return;
|
|
14
|
+
|
|
15
|
+
req.logger.info(methodName, `模型数量: ${list.length}`);
|
|
16
|
+
res.jsonSuccess('获取模型列表成功!', list);
|
|
17
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
exports.modelItemList = `
|
|
2
|
+
select
|
|
3
|
+
*
|
|
4
|
+
from
|
|
5
|
+
t_model_item
|
|
6
|
+
where
|
|
7
|
+
del_tag='0'
|
|
8
|
+
order by
|
|
9
|
+
sort_order asc
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
exports.getModelItemBySlug = `
|
|
13
|
+
select
|
|
14
|
+
*
|
|
15
|
+
from
|
|
16
|
+
t_model_item
|
|
17
|
+
where
|
|
18
|
+
model_slug=?
|
|
19
|
+
and
|
|
20
|
+
del_tag='0'
|
|
21
|
+
limit 1
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
exports.getModelItemById = `
|
|
25
|
+
select
|
|
26
|
+
*
|
|
27
|
+
from
|
|
28
|
+
t_model_item
|
|
29
|
+
where
|
|
30
|
+
id=?
|
|
31
|
+
and
|
|
32
|
+
del_tag='0'
|
|
33
|
+
limit 1
|
|
34
|
+
`;
|