befly 3.53.0 → 3.55.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.
@@ -72,10 +72,9 @@ function buildEmptyVisitStats(reportDate, monthStartDate, recentDateList, projec
72
72
 
73
73
  for (const item of projectLists) {
74
74
  products.push({
75
- key: item.productCode,
76
- productName: item.productName,
77
- productCode: item.productCode,
78
- productVersion: item.productVersion || "",
75
+ key: item.code,
76
+ productName: item.name,
77
+ productCode: item.code,
79
78
  today: 0,
80
79
  yesterday: 0,
81
80
  dayBeforeYesterday: 0,
@@ -117,13 +116,12 @@ async function buildVisitStatsProducts(befly, now, reportDate, monthStartDate, r
117
116
  const products = [];
118
117
 
119
118
  for (const item of projectLists) {
120
- const summary = await getVisitStatsSummary(befly, now, reportDate, monthStartDate, recentDateList, item.productCode);
119
+ const summary = await getVisitStatsSummary(befly, now, reportDate, monthStartDate, recentDateList, item.code);
121
120
 
122
121
  products.push({
123
- key: item.productCode,
124
- productName: item.productName,
125
- productCode: item.productCode,
126
- productVersion: item.productVersion || "",
122
+ key: item.code,
123
+ productName: item.name,
124
+ productCode: item.code,
127
125
  today: summary.today.count,
128
126
  yesterday: summary.yesterday.count,
129
127
  dayBeforeYesterday: summary.dayBeforeYesterday.count,
@@ -19,11 +19,10 @@ async function buildOnlineStatsProducts(befly, projectLists, now) {
19
19
 
20
20
  for (const item of projectLists) {
21
21
  products.push({
22
- key: item.productCode,
23
- productName: item.productName,
24
- productCode: item.productCode,
25
- productVersion: item.productVersion || "",
26
- onlineCount: await getOnlineStatsProductOnlineCount(befly, item.productCode, now)
22
+ key: item.code,
23
+ productName: item.name,
24
+ productCode: item.code,
25
+ onlineCount: await getOnlineStatsProductOnlineCount(befly, item.code, now)
27
26
  });
28
27
  }
29
28
 
@@ -41,10 +40,9 @@ function buildEmptyOnlineStatsProducts(projectLists) {
41
40
 
42
41
  for (const item of projectLists) {
43
42
  products.push({
44
- key: item.productCode,
45
- productName: item.productName,
46
- productCode: item.productCode,
47
- productVersion: item.productVersion || "",
43
+ key: item.code,
44
+ productName: item.name,
45
+ productCode: item.code,
48
46
  onlineCount: 0
49
47
  });
50
48
  }
package/checks/config.js CHANGED
@@ -16,19 +16,14 @@ const projectListCodeSchema = z.string().regex(/^[a-z][a-zA-Z0-9]*$/, "必须是
16
16
  const projectListItemSchema = z
17
17
  .object({
18
18
  code: projectListCodeSchema,
19
- name: noTrimString.min(1),
20
- productName: noTrimString.min(1),
21
- productCode: noTrimString.min(1),
22
- productVersion: noTrimString.optional()
19
+ name: noTrimString.min(1)
23
20
  })
24
21
  .strict();
25
22
  const projectListsSchema = z.array(projectListItemSchema).superRefine((projectLists, ctx) => {
26
23
  const codeSet = new Set();
27
- const productCodeSet = new Set();
28
24
 
29
25
  for (let index = 0; index < projectLists.length; index += 1) {
30
26
  const code = projectLists[index].code;
31
- const productCode = projectLists[index].productCode;
32
27
 
33
28
  if (codeSet.has(code)) {
34
29
  ctx.addIssue({
@@ -36,21 +31,9 @@ const projectListsSchema = z.array(projectListItemSchema).superRefine((projectLi
36
31
  message: `projectLists[${index}].code 重复`,
37
32
  path: [index, "code"]
38
33
  });
39
- continue;
40
34
  }
41
35
 
42
36
  codeSet.add(code);
43
-
44
- if (productCodeSet.has(productCode)) {
45
- ctx.addIssue({
46
- code: "custom",
47
- message: `projectLists[${index}].productCode 重复`,
48
- path: [index, "productCode"]
49
- });
50
- continue;
51
- }
52
-
53
- productCodeSet.add(productCode);
54
37
  }
55
38
  });
56
39
 
@@ -52,11 +52,6 @@
52
52
  "name": "字典列表",
53
53
  "path": "/dict",
54
54
  "sort": 2
55
- },
56
- {
57
- "name": "系统配置",
58
- "path": "/system",
59
- "sort": 3
60
55
  }
61
56
  ]
62
57
  },
package/index.js CHANGED
@@ -64,6 +64,7 @@ function mergeProjectListsByCode(projectLists) {
64
64
 
65
65
  for (const item of projectLists) {
66
66
  const code = String(item?.code || "");
67
+ const name = String(item?.name || "");
67
68
 
68
69
  if (!code) {
69
70
  continue;
@@ -73,7 +74,10 @@ function mergeProjectListsByCode(projectLists) {
73
74
  itemMap.delete(code);
74
75
  }
75
76
 
76
- itemMap.set(code, item);
77
+ itemMap.set(code, {
78
+ code: code,
79
+ name: name
80
+ });
77
81
  }
78
82
 
79
83
  return Array.from(itemMap.values());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "3.53.0",
3
+ "version": "3.55.0",
4
4
  "gitHead": "49c39d36695036e85fc64083cc43c1652fff96cb",
5
5
  "private": false,
6
6
  "description": "Befly - 为 Bun 专属打造的 JavaScript API 接口框架核心引擎",
@@ -1,16 +0,0 @@
1
- export default {
2
- name: "获取所有系统配置",
3
- method: "POST",
4
- body: "none",
5
- auth: true,
6
- fields: {},
7
- required: [],
8
- handler: async (befly) => {
9
- const result = await befly.mysql.getAll({
10
- table: "beflySysConfig",
11
- orderBy: ["id#ASC"]
12
- });
13
-
14
- return befly.tool.Yes("操作成功", { lists: result.data.lists });
15
- }
16
- };
@@ -1,36 +0,0 @@
1
- export default {
2
- name: "删除系统配置",
3
- method: "POST",
4
- body: "none",
5
- auth: true,
6
- fields: {
7
- id: { name: "ID", input: "integer", min: 1, max: null }
8
- },
9
- required: ["id"],
10
- handler: async (befly, ctx) => {
11
- try {
12
- const config = await befly.mysql.getOne({
13
- table: "beflySysConfig",
14
- where: { id: ctx.body.id }
15
- });
16
-
17
- if (!config.data?.id) {
18
- return befly.tool.No("配置不存在");
19
- }
20
-
21
- if (config.data.isSystem === 1) {
22
- return befly.tool.No("系统配置不允许删除");
23
- }
24
-
25
- await befly.mysql.delData({
26
- table: "beflySysConfig",
27
- where: { id: ctx.body.id }
28
- });
29
-
30
- return befly.tool.Yes("操作成功");
31
- } catch (error) {
32
- befly.logger.error("删除系统配置失败", error);
33
- return befly.tool.No("操作失败");
34
- }
35
- }
36
- };
@@ -1,37 +0,0 @@
1
- import sysConfigTable from "#befly/tables/sysConfig.json";
2
-
3
- export default {
4
- name: "根据代码获取配置值",
5
- method: "POST",
6
- body: "none",
7
- auth: false,
8
- fields: {
9
- code: sysConfigTable.code
10
- },
11
- required: ["code"],
12
- handler: async (befly, ctx) => {
13
- const config = await befly.mysql.getOne({
14
- table: "beflySysConfig",
15
- where: { code: ctx.body.code }
16
- });
17
-
18
- if (!config.data?.id) {
19
- return befly.tool.No("配置不存在");
20
- }
21
-
22
- let value = config.data.value;
23
- if (config.data.valueType === "number") {
24
- value = Number(config.data.value);
25
- } else if (config.data.valueType === "boolean") {
26
- value = config.data.value === "true" || config.data.value === "1";
27
- } else if (config.data.valueType === "json") {
28
- try {
29
- value = JSON.parse(config.data.value);
30
- } catch {
31
- value = config.data.value;
32
- }
33
- }
34
-
35
- return befly.tool.Yes("操作成功", { code: config.data.code, value: value });
36
- }
37
- };
@@ -1,45 +0,0 @@
1
- import sysConfigTable from "#befly/tables/sysConfig.json";
2
-
3
- export default {
4
- name: "添加系统配置",
5
- method: "POST",
6
- body: "none",
7
- auth: true,
8
- fields: {
9
- name: sysConfigTable.name,
10
- code: sysConfigTable.code,
11
- value: sysConfigTable.value,
12
- valueType: sysConfigTable.valueType,
13
- group: sysConfigTable.group,
14
- sort: sysConfigTable.sort,
15
- isSystem: sysConfigTable.isSystem,
16
- description: sysConfigTable.description
17
- },
18
- required: ["name", "code", "value"],
19
- handler: async (befly, ctx) => {
20
- const existing = await befly.mysql.getOne({
21
- table: "beflySysConfig",
22
- where: { code: ctx.body.code }
23
- });
24
-
25
- if (existing.data?.id) {
26
- return befly.tool.No("配置代码已存在");
27
- }
28
-
29
- const configId = await befly.mysql.insData({
30
- table: "beflySysConfig",
31
- data: {
32
- name: ctx.body.name,
33
- code: ctx.body.code,
34
- value: ctx.body.value,
35
- valueType: ctx.body.valueType === undefined ? "string" : ctx.body.valueType,
36
- group: ctx.body.group === undefined ? "" : ctx.body.group,
37
- sort: ctx.body.sort === undefined ? 0 : ctx.body.sort,
38
- isSystem: ctx.body.isSystem === undefined ? 0 : ctx.body.isSystem,
39
- description: ctx.body.description === undefined ? "" : ctx.body.description
40
- }
41
- });
42
-
43
- return befly.tool.Yes("操作成功", { id: configId.data });
44
- }
45
- };
@@ -1,30 +0,0 @@
1
- import { queryFields } from "#befly/apis/_apis.js";
2
- import sysConfigTable from "#befly/tables/sysConfig.json";
3
-
4
- export default {
5
- name: "获取系统配置列表",
6
- method: "POST",
7
- body: "none",
8
- auth: true,
9
- fields: {
10
- ...queryFields,
11
- state: sysConfigTable.state
12
- },
13
- required: [],
14
- handler: async (befly, ctx) => {
15
- const result = await befly.mysql.getList({
16
- table: "beflySysConfig",
17
- where: {
18
- name$like$or: ctx.body.keyword,
19
- code$like$or: ctx.body.keyword,
20
- group$like$or: ctx.body.keyword,
21
- state: ctx.body.state
22
- },
23
- page: ctx.body.page,
24
- limit: ctx.body.limit,
25
- orderBy: ["group#ASC", "sort#ASC", "id#ASC"]
26
- });
27
-
28
- return befly.tool.Yes("操作成功", result.data);
29
- }
30
- };
@@ -1,57 +0,0 @@
1
- import sysConfigTable from "#befly/tables/sysConfig.json";
2
-
3
- export default {
4
- name: "更新系统配置",
5
- method: "POST",
6
- body: "none",
7
- auth: true,
8
- fields: {
9
- id: sysConfigTable.id,
10
- name: sysConfigTable.name,
11
- code: sysConfigTable.code,
12
- value: sysConfigTable.value,
13
- valueType: sysConfigTable.valueType,
14
- group: sysConfigTable.group,
15
- sort: sysConfigTable.sort,
16
- description: sysConfigTable.description,
17
- state: sysConfigTable.state
18
- },
19
- required: ["id"],
20
- handler: async (befly, ctx) => {
21
- const config = await befly.mysql.getOne({
22
- table: "beflySysConfig",
23
- where: { id: ctx.body.id }
24
- });
25
-
26
- if (!config.data?.id) {
27
- return befly.tool.No("配置不存在");
28
- }
29
-
30
- if (config.data.isSystem === 1) {
31
- await befly.mysql.updData({
32
- table: "beflySysConfig",
33
- data: {
34
- value: ctx.body.value
35
- },
36
- where: { id: ctx.body.id }
37
- });
38
- } else {
39
- await befly.mysql.updData({
40
- table: "beflySysConfig",
41
- data: {
42
- name: ctx.body.name,
43
- code: ctx.body.code,
44
- value: ctx.body.value,
45
- valueType: ctx.body.valueType,
46
- group: ctx.body.group,
47
- sort: ctx.body.sort,
48
- description: ctx.body.description,
49
- state: ctx.body.state
50
- },
51
- where: { id: ctx.body.id }
52
- });
53
- }
54
-
55
- return befly.tool.Yes("操作成功");
56
- }
57
- };
@@ -1,68 +0,0 @@
1
- {
2
- "id": {
3
- "name": "ID",
4
- "input": "integer",
5
- "min": 1,
6
- "max": null
7
- },
8
- "name": {
9
- "name": "配置名称",
10
- "min": 2,
11
- "max": 50,
12
- "input": "string"
13
- },
14
- "code": {
15
- "name": "配置代码",
16
- "input": "regexp",
17
- "check": "@alphanumeric_",
18
- "min": 2,
19
- "max": 100
20
- },
21
- "value": {
22
- "name": "配置值",
23
- "input": "string"
24
- },
25
- "valueType": {
26
- "name": "值类型",
27
- "input": "enum",
28
- "check": "string|number|boolean|json",
29
- "max": 20
30
- },
31
- "group": {
32
- "name": "配置分组",
33
- "input": "string",
34
- "max": 50
35
- },
36
- "sort": {
37
- "name": "排序",
38
- "input": "number",
39
- "max": 9999
40
- },
41
- "isSystem": {
42
- "name": "是否系统配置",
43
- "input": "number",
44
- "max": 1
45
- },
46
- "description": {
47
- "name": "描述说明",
48
- "input": "string",
49
- "max": 500
50
- },
51
- "state": {
52
- "name": "状态(0=已删除,1=正常,2=禁用)",
53
- "input": "enumInteger",
54
- "check": "0|1|2"
55
- },
56
- "createdAt": {
57
- "name": "创建时间",
58
- "input": "number"
59
- },
60
- "updatedAt": {
61
- "name": "更新时间",
62
- "input": "number"
63
- },
64
- "deletedAt": {
65
- "name": "删除时间",
66
- "input": "number"
67
- }
68
- }