befly 3.23.5 → 3.23.6

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.
@@ -9,7 +9,8 @@ export default {
9
9
  code: dictTypeTable.code,
10
10
  name: dictTypeTable.name,
11
11
  description: dictTypeTable.description,
12
- sort: dictTypeTable.sort
12
+ sort: dictTypeTable.sort,
13
+ state: dictTypeTable.state
13
14
  },
14
15
  required: ["code", "name"],
15
16
  handler: async (befly, ctx) => {
@@ -28,7 +29,8 @@ export default {
28
29
  code: ctx.body.code,
29
30
  name: ctx.body.name,
30
31
  description: ctx.body.description,
31
- sort: ctx.body.sort
32
+ sort: ctx.body.sort,
33
+ state: ctx.body.state
32
34
  }
33
35
  });
34
36
 
@@ -1,3 +1,5 @@
1
+ import dictTypeTable from "../../tables/dictType.json";
2
+
1
3
  export default {
2
4
  name: "获取字典类型列表",
3
5
  method: "POST",
@@ -7,14 +9,15 @@ export default {
7
9
  page: { name: "页码", input: "integer", min: 1, max: 9999 },
8
10
  limit: { name: "每页数量", input: "integer", min: 1, max: 100 },
9
11
  keyword: { name: "关键词", input: "string", min: 0, max: 50 },
10
- state: { name: "状态", input: "integer", min: 0, max: 2 }
12
+ state: dictTypeTable.state
11
13
  },
12
14
  required: [],
13
15
  handler: async (befly, ctx) => {
14
16
  const result = await befly.mysql.getList({
15
17
  table: "beflyDictType",
16
18
  where: {
17
- name$like: ctx.body.keyword
19
+ $or: [{ name$like: ctx.body.keyword }, { code$like: ctx.body.keyword }],
20
+ state: ctx.body.state
18
21
  },
19
22
  orderBy: ["sort#ASC", "id#ASC"],
20
23
  page: ctx.body.page,
@@ -10,40 +10,33 @@ export default {
10
10
  code: dictTypeTable.code,
11
11
  name: dictTypeTable.name,
12
12
  description: dictTypeTable.description,
13
- sort: dictTypeTable.sort
13
+ sort: dictTypeTable.sort,
14
+ state: dictTypeTable.state
14
15
  },
15
16
  required: ["id"],
16
17
  handler: async (befly, ctx) => {
17
- const id = ctx.body.id;
18
- const code = ctx.body.code;
19
- const name = ctx.body.name;
20
- const description = ctx.body.description;
21
- const sort = ctx.body.sort;
22
-
23
- if (code) {
24
- const existing = await befly.mysql.getOne({
25
- table: "beflyDictType",
26
- where: {
27
- code: code,
28
- id$not: id
29
- }
30
- });
31
-
32
- if (existing.data && existing.data.id) {
33
- return befly.tool.No("类型代码已被使用");
18
+ const existing = await befly.mysql.getList({
19
+ table: "beflyDictType",
20
+ where: {
21
+ code: ctx.body.code,
22
+ id$not: ctx.body.id
34
23
  }
35
- }
24
+ });
36
25
 
37
- const updateData = {};
38
- if (code !== undefined) updateData["code"] = code;
39
- if (name !== undefined) updateData["name"] = name;
40
- if (description !== undefined) updateData["description"] = description;
41
- if (sort !== undefined) updateData["sort"] = sort;
26
+ if (existing.data.total > 0) {
27
+ return befly.tool.No("类型代码已被使用");
28
+ }
42
29
 
43
30
  await befly.mysql.updData({
44
31
  table: "beflyDictType",
45
- data: updateData,
46
- where: { id: id }
32
+ data: {
33
+ code: ctx.body.code,
34
+ name: ctx.body.name,
35
+ description: ctx.body.description,
36
+ sort: ctx.body.sort,
37
+ state: ctx.body.state
38
+ },
39
+ where: { id: ctx.body.id }
47
40
  });
48
41
 
49
42
  return befly.tool.Yes("更新成功");
package/checks/menu.js CHANGED
@@ -5,8 +5,9 @@ import { formatZodIssues } from "../utils/formatZodIssues.js";
5
5
 
6
6
  z.config(z.locales.zhCN());
7
7
 
8
- const fullMenuPathRegex = /^\/(?:core(?:\/[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*)*|(?:[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*(?:\/[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*)*)?)$/;
9
- const childMenuPathRegex = /^\/[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$/;
8
+ const menuPathSegmentRegexSource = "[a-z][a-z0-9]*(?:-[a-z0-9]+)*";
9
+ const fullMenuPathRegex = new RegExp(`^/(?:core(?:/${menuPathSegmentRegexSource})*|(?:${menuPathSegmentRegexSource}(?:/${menuPathSegmentRegexSource})*)?)$`);
10
+ const childMenuPathRegex = new RegExp(`^/${menuPathSegmentRegexSource}$`);
10
11
 
11
12
  const childMenuSchema = z
12
13
  .object({
@@ -45,7 +45,7 @@
45
45
  "children": [
46
46
  {
47
47
  "name": "字典类型",
48
- "path": "/dictType",
48
+ "path": "/dict-type",
49
49
  "sort": 1
50
50
  },
51
51
  {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "3.23.5",
4
- "gitHead": "fa567235c96410c1f0bc921ab652e0517269060c",
3
+ "version": "3.23.6",
4
+ "gitHead": "50fca5a7f581822abfdc886fcd77f2fce3db47ca",
5
5
  "private": false,
6
6
  "description": "Befly - 为 Bun 专属打造的 JavaScript API 接口框架核心引擎",
7
7
  "keywords": [
@@ -52,7 +52,7 @@
52
52
  "test": "bun test"
53
53
  },
54
54
  "dependencies": {
55
- "fast-xml-parser": "^5.7.2",
55
+ "fast-xml-parser": "^5.7.3",
56
56
  "nodemailer": "^8.0.7",
57
57
  "pathe": "^2.0.3",
58
58
  "picomatch": "^4.0.4",