diff --git a/README.md b/README.md index 87609ff..a0ac564 100644 --- a/README.md +++ b/README.md @@ -6,19 +6,19 @@
-
+
-
+
-
+
-
+
diff --git a/docs/guide-zh-CN/start-environment.md b/docs/guide-zh-CN/start-environment.md
index 2cf4f06..fa40501 100644
--- a/docs/guide-zh-CN/start-environment.md
+++ b/docs/guide-zh-CN/start-environment.md
@@ -10,7 +10,7 @@
1. 前往https://nodejs.org/zh-cn/下载当前版本node
2. 命令行运行 `node -v` 若控制台输出版本号则node安装成功
-3. node 版本需大于 `16.0`
+3. node 版本需大于等于 `16.0`
4. 安装yarn:`npm install -g yarn`
5. 命令行运行 `yarn -v` 若控制台输出版本号则前端环境搭建成功
diff --git a/docs/guide-zh-CN/start-installation.md b/docs/guide-zh-CN/start-installation.md
index ab8d287..836e0e1 100644
--- a/docs/guide-zh-CN/start-installation.md
+++ b/docs/guide-zh-CN/start-installation.md
@@ -9,7 +9,7 @@
- node版本 >= v16.0.0
- golang版本 >= v1.19
-- goframe版本 >=v2.4.1
+- goframe版本 >=v2.6.1
- mysql版本 >=5.7
> 必须先看[环境搭建文档](start-environment.md),如果安装遇到问题务必先查看[常见问题文档](start-issue.md)
diff --git a/docs/guide-zh-CN/start-issue.md b/docs/guide-zh-CN/start-issue.md
index 8f6e272..cadd9a7 100644
--- a/docs/guide-zh-CN/start-issue.md
+++ b/docs/guide-zh-CN/start-issue.md
@@ -42,7 +42,21 @@
- http服务没有启动或正在启动
- 通过一键启动所有服务运行时属正常情况,多服务启动时存在先后顺序问题,`tcpClient`比`tcpServer`先启动完成导致的,等`tcpServer`启动完成后会自动重连
-
-
-
详细请参考 - [系统安装](start-installation.md)
+
+
+### 四、前端相关
+
+#### 1、Error: connect ECONNREFUSED ::1:8000
+
+```text
+11:44:52 [vite] http proxy error at /member/info:
+Error: connect ECONNREFUSED ::1:8000
+ at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1246:16)
+```
+
+- 服务端没有启动
+- `.\wen\.env.development`中的`VITE_PROXY`配置的服务器地址或端口与实际不一致
+
+
+
diff --git a/docs/guide-zh-CN/start-update-log.md b/docs/guide-zh-CN/start-update-log.md
index 05044a8..a02d730 100644
--- a/docs/guide-zh-CN/start-update-log.md
+++ b/docs/guide-zh-CN/start-update-log.md
@@ -11,6 +11,16 @@
> 如果升级(覆盖)代码后打开会出现 sql 报错, 请检查更新的数据库格式或自行调整
+### v2.12.1
+updated 2023.12.29
+
+- 修复:修复访问日志权限过滤
+- 优化:gf版本升级到v2.6.1
+- 优化:naive-ui版本升级到2.36.0,vue版本升级到3.4.0,vite版本升级到4.2.7
+- 优化:优化curd代码生成,编辑表单增加自适应,详情改为`抽屉`,修复菜单权限关系树,简化`State`
+- 优化:优化字典编辑和查询
+- 优化:优化角色列表数据加载缓慢问题
+
### v2.11.5
updated 2023.11.25
diff --git a/server/go.mod b/server/go.mod
index 2f82680..af21786 100644
--- a/server/go.mod
+++ b/server/go.mod
@@ -13,15 +13,15 @@ require (
github.com/casbin/casbin/v2 v2.55.0
github.com/forgoer/openssl v1.4.0
github.com/go-pay/gopay v1.5.91
- github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.7
- github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.7
- github.com/gogf/gf/contrib/trace/jaeger/v2 v2.5.7
- github.com/gogf/gf/v2 v2.5.7
+ github.com/gogf/gf/contrib/drivers/mysql/v2 v2.6.1
+ github.com/gogf/gf/contrib/nosql/redis/v2 v2.6.1
+ github.com/gogf/gf/contrib/trace/jaeger/v2 v2.6.1
+ github.com/gogf/gf/v2 v2.6.1
+ github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f
github.com/golang-jwt/jwt/v5 v5.0.0
github.com/gorilla/websocket v1.5.1
github.com/kayon/iploc v0.0.0-20200312105652-bda3e968a794
github.com/minio/minio-go/v7 v7.0.63
- github.com/minio/selfupdate v0.6.0
github.com/mojocn/base64Captcha v1.3.5
github.com/olekukonko/tablewriter v0.0.5
github.com/qiniu/go-sdk/v7 v7.14.0
@@ -63,7 +63,7 @@ require (
github.com/fatih/color v1.16.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
- github.com/go-logr/logr v1.3.0 // indirect
+ github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
@@ -102,7 +102,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
- github.com/redis/go-redis/v9 v9.3.0 // indirect
+ github.com/redis/go-redis/v9 v9.3.1 // indirect
github.com/richardlehane/mscfb v1.0.4 // indirect
github.com/richardlehane/msoleps v1.0.1 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
@@ -124,11 +124,11 @@ require (
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
- golang.org/x/crypto v0.15.0 // indirect
+ golang.org/x/crypto v0.16.0 // indirect
golang.org/x/image v0.1.0 // indirect
- golang.org/x/net v0.18.0 // indirect
+ golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.1.0 // indirect
- golang.org/x/sys v0.14.0 // indirect
+ golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
diff --git a/server/go.sum b/server/go.sum
index e9edc19..8b7ae23 100644
--- a/server/go.sum
+++ b/server/go.sum
@@ -150,8 +150,8 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
-github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
-github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
+github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
+github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
@@ -170,14 +170,16 @@ github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrt
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
-github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.7 h1:S6r4QJSoqmOv/Vqhu/gHt4if4dHrNyaQIUbjWc4W7sg=
-github.com/gogf/gf/contrib/drivers/mysql/v2 v2.5.7/go.mod h1:1/X4iVHxtSHjOMGYvnmFMTdk5zLLhQ6PEkslKTBcTSI=
-github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.7 h1:HgOudyYp8F6iVC6YgbqKhPMKgxQJj4MO8VBdJEMPTpk=
-github.com/gogf/gf/contrib/nosql/redis/v2 v2.5.7/go.mod h1:jiRz86SerTb+z4KD4LtxgVw3IEcsWRBnL40FvIAg/sY=
-github.com/gogf/gf/contrib/trace/jaeger/v2 v2.5.7 h1:ipIYW9q+Olkg9s86WpdPQ+wTFi1v6rsTiYAZ2ekqxH8=
-github.com/gogf/gf/contrib/trace/jaeger/v2 v2.5.7/go.mod h1:KhUqGtEifCUd9pI274UkgSCMByof3aq2nW9GJRbwcOk=
-github.com/gogf/gf/v2 v2.5.7 h1:h+JSoD6z3d2q0uGszvtahrSm4DiM2ECyNjyTwKIo8wE=
-github.com/gogf/gf/v2 v2.5.7/go.mod h1:x2XONYcI4hRQ/4gMNbWHmZrNzSEIg20s2NULbzom5k0=
+github.com/gogf/gf/contrib/drivers/mysql/v2 v2.6.1 h1:5VW1vlaFNSHHhMliRkGTcDshMeA52Il8T+gffJJaVMc=
+github.com/gogf/gf/contrib/drivers/mysql/v2 v2.6.1/go.mod h1:jxCa1WV/W+q0F4ILebakUsqRrl7iL3qvP+Uci0eXAew=
+github.com/gogf/gf/contrib/nosql/redis/v2 v2.6.1 h1:5NWx7rZa8CbPNw1vbLzIXQFEMbKvoJVQM0GyReBRvJ8=
+github.com/gogf/gf/contrib/nosql/redis/v2 v2.6.1/go.mod h1:iy1Dwp5xWfGfuWixCgGQ06ZX6lp+d9onbmSWWzi111A=
+github.com/gogf/gf/contrib/trace/jaeger/v2 v2.6.1 h1:d3/8lWFWmaQ/8mzJ5GxyRpO4racPpZ3yZ8kCuejhhiY=
+github.com/gogf/gf/contrib/trace/jaeger/v2 v2.6.1/go.mod h1:O0nzQLfNJtRApGHJluraTy41jc3LIvTsSkR8WAHb4f0=
+github.com/gogf/gf/v2 v2.6.1 h1:n/cfXM506WjhPa6Z1CEDuHNM1XZ7C8JzSDPn2AfuxgQ=
+github.com/gogf/gf/v2 v2.6.1/go.mod h1:x2XONYcI4hRQ/4gMNbWHmZrNzSEIg20s2NULbzom5k0=
+github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f h1:7xfXR/BhG3JDqO1s45n65Oyx9t4E/UqDOXep6jXdLCM=
+github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f/go.mod h1:HnYoio6S7VaFJdryKcD/r9HgX+4QzYfr00XiXUo/xz0=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE=
github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
@@ -335,8 +337,6 @@ github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.63 h1:GbZ2oCvaUdgT5640WJOpyDhhDxvknAJU2/T3yurwcbQ=
github.com/minio/minio-go/v7 v7.0.63/go.mod h1:Q6X7Qjb7WMhvG65qKf4gUgA5XaiSox74kR1uAEjxRS4=
-github.com/minio/selfupdate v0.6.0 h1:i76PgT0K5xO9+hjzKcacQtO7+MjJ4JKA8Ak8XQ9DDwU=
-github.com/minio/selfupdate v0.6.0/go.mod h1:bO02GTIPCMQFTEvE5h4DjYB58bCoZ35XLeBf0buTDdM=
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
@@ -410,8 +410,8 @@ github.com/qiniu/go-sdk/v7 v7.14.0/go.mod h1:btsaOc8CA3hdVloULfFdDgDc+g4f3TDZEFs
github.com/qiniu/x v1.10.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
-github.com/redis/go-redis/v9 v9.3.0 h1:RiVDjmig62jIWp7Kk4XVLs0hzV6pI3PyTnnL0cnn0u0=
-github.com/redis/go-redis/v9 v9.3.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
+github.com/redis/go-redis/v9 v9.3.1 h1:KqdY8U+3X6z+iACvumCNxnoluToB+9Me+TvyFa21Mds=
+github.com/redis/go-redis/v9 v9.3.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
github.com/richardlehane/msoleps v1.0.1 h1:RfrALnSNXzmXLbGct/P2b4xkFz4e8Gmj/0Vj9M9xC1o=
@@ -541,12 +541,11 @@ golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220408190544-5352b0902921/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
-golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
-golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
+golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
+golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -624,8 +623,8 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
-golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
-golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
+golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
+golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -706,8 +705,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
-golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
+golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
diff --git a/server/internal/consts/upload.go b/server/internal/consts/upload.go
index 11ae4c7..b760381 100644
--- a/server/internal/consts/upload.go
+++ b/server/internal/consts/upload.go
@@ -12,5 +12,5 @@ const (
UploadDriveCos = "cos" // 腾讯云cos
UploadDriveOss = "oss" // 阿里云oss
UploadDriveQiNiu = "qiniu" // 七牛云对象存储
- UploadDriveMinio = "minio" // minio
+ UploadDriveMinio = "minio" // minio对象存储
)
diff --git a/server/internal/consts/version.go b/server/internal/consts/version.go
index c52eefd..6b433b0 100644
--- a/server/internal/consts/version.go
+++ b/server/internal/consts/version.go
@@ -7,5 +7,5 @@ package consts
// VersionApp HotGo版本
const (
- VersionApp = "2.11.5"
+ VersionApp = "2.12.1"
)
diff --git a/server/internal/library/hggen/internal/cmd/cmd_run.go b/server/internal/library/hggen/internal/cmd/cmd_run.go
index 39ad065..614bfc6 100644
--- a/server/internal/library/hggen/internal/cmd/cmd_run.go
+++ b/server/internal/library/hggen/internal/cmd/cmd_run.go
@@ -82,11 +82,11 @@ func init() {
type (
cRunInput struct {
g.Meta `name:"run"`
- File string `name:"FILE" arg:"true" brief:"{cRunFileBrief}" v:"required"`
- Path string `name:"path" short:"p" brief:"{cRunPathBrief}" d:"./"`
- Extra string `name:"extra" short:"e" brief:"{cRunExtraBrief}"`
- Args string `name:"args" short:"a" brief:"{cRunArgsBrief}"`
- WatchPaths string `name:"watchPaths" short:"w" brief:"{cRunWatchPathsBrief}"`
+ File string `name:"FILE" arg:"true" brief:"{cRunFileBrief}" v:"required"`
+ Path string `name:"path" short:"p" brief:"{cRunPathBrief}" d:"./"`
+ Extra string `name:"extra" short:"e" brief:"{cRunExtraBrief}"`
+ Args string `name:"args" short:"a" brief:"{cRunArgsBrief}"`
+ WatchPaths []string `name:"watchPaths" short:"w" brief:"{cRunWatchPathsBrief}"`
}
cRunOutput struct{}
)
@@ -97,12 +97,16 @@ func (c cRun) Index(ctx context.Context, in cRunInput) (out *cRunOutput, err err
mlog.Fatalf(`command "go" not found in your environment, please install golang first to proceed this command`)
}
+ if len(in.WatchPaths) == 1 {
+ in.WatchPaths = strings.Split(in.WatchPaths[0], ",")
+ }
+
app := &cRunApp{
File: in.File,
Path: in.Path,
Options: in.Extra,
Args: in.Args,
- WatchPaths: strings.Split(in.WatchPaths, ","),
+ WatchPaths: in.WatchPaths,
}
dirty := gtype.NewBool()
_, err = gfsnotify.Add(gfile.RealPath("."), func(event *gfsnotify.Event) {
diff --git a/server/internal/library/hggen/internal/cmd/cmd_up.go b/server/internal/library/hggen/internal/cmd/cmd_up.go
index 43ed308..af97007 100644
--- a/server/internal/library/hggen/internal/cmd/cmd_up.go
+++ b/server/internal/library/hggen/internal/cmd/cmd_up.go
@@ -11,7 +11,7 @@ import (
"fmt"
"runtime"
- "github.com/minio/selfupdate"
+ "github.com/gogf/selfupdate"
"github.com/gogf/gf/v2/container/gset"
"github.com/gogf/gf/v2/frame/g"
diff --git a/server/internal/library/hggen/internal/cmd/cmd_z_init_test.go b/server/internal/library/hggen/internal/cmd/cmd_z_init_test.go
index 8ad499f..1e71cbd 100644
--- a/server/internal/library/hggen/internal/cmd/cmd_z_init_test.go
+++ b/server/internal/library/hggen/internal/cmd/cmd_z_init_test.go
@@ -6,6 +6,33 @@
package cmd
-import "context"
+import (
+ "context"
+ "fmt"
-var ctx = context.Background()
+ "github.com/gogf/gf/v2/database/gdb"
+ "github.com/gogf/gf/v2/test/gtest"
+)
+
+var (
+ ctx = context.Background()
+ testDB gdb.DB
+ link = "mysql:root:12345678@tcp(127.0.0.1:3306)/test?loc=Local&parseTime=true"
+)
+
+func init() {
+ var err error
+ testDB, err = gdb.New(gdb.ConfigNode{
+ Link: link,
+ })
+ if err != nil {
+ panic(err)
+ }
+}
+
+func dropTableWithDb(db gdb.DB, table string) {
+ dropTableStmt := fmt.Sprintf("DROP TABLE IF EXISTS `%s`", table)
+ if _, err := db.Exec(ctx, dropTableStmt); err != nil {
+ gtest.Error(err)
+ }
+}
diff --git a/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_dao_test.go b/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_dao_test.go
index 7b3cff0..5dd345b 100644
--- a/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_dao_test.go
+++ b/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_dao_test.go
@@ -11,7 +11,6 @@ import (
"path/filepath"
"testing"
- "github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/text/gstr"
@@ -20,22 +19,11 @@ import (
"hotgo/internal/library/hggen/internal/cmd/gendao"
)
-func dropTableWithDb(db gdb.DB, table string) {
- dropTableStmt := fmt.Sprintf("DROP TABLE IF EXISTS `%s`", table)
- if _, err := db.Exec(ctx, dropTableStmt); err != nil {
- gtest.Error(err)
- }
-}
-
func Test_Gen_Dao_Default(t *testing.T) {
- link := "mysql:root:12345678@tcp(127.0.0.1:3306)/test?loc=Local&parseTime=true"
- db, err := gdb.New(gdb.ConfigNode{
- Link: link,
- })
- gtest.AssertNil(err)
-
gtest.C(t, func(t *gtest.T) {
var (
+ err error
+ db = testDB
table = "table_user"
sqlContent = fmt.Sprintf(
gtest.DataContent(`gendao`, `user.tpl.sql`),
@@ -123,14 +111,10 @@ func Test_Gen_Dao_Default(t *testing.T) {
}
func Test_Gen_Dao_TypeMapping(t *testing.T) {
- link := "mysql:root:12345678@tcp(127.0.0.1:3306)/test?loc=Local&parseTime=true"
- db, err := gdb.New(gdb.ConfigNode{
- Link: link,
- })
- gtest.AssertNil(err)
-
gtest.C(t, func(t *gtest.T) {
var (
+ err error
+ db = testDB
table = "table_user"
sqlContent = fmt.Sprintf(
gtest.DataContent(`gendao`, `user.tpl.sql`),
diff --git a/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_pbentity_test.go b/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_pbentity_test.go
new file mode 100644
index 0000000..48ebdb9
--- /dev/null
+++ b/server/internal/library/hggen/internal/cmd/cmd_z_unit_gen_pbentity_test.go
@@ -0,0 +1,70 @@
+// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
+//
+// This Source Code Form is subject to the terms of the MIT License.
+// If a copy of the MIT was not distributed with this file,
+// You can obtain one at https://github.com/gogf/gf.
+
+package cmd
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+ "testing"
+
+ "github.com/gogf/gf/v2/os/gcmd"
+ "github.com/gogf/gf/v2/os/gfile"
+ "github.com/gogf/gf/v2/test/gtest"
+ "github.com/gogf/gf/v2/text/gstr"
+ "github.com/gogf/gf/v2/util/guid"
+)
+
+func Test_Gen_Pbentity_NameCase(t *testing.T) {
+ gtest.C(t, func(t *gtest.T) {
+ var (
+ err error
+ db = testDB
+ table = "table_user"
+ sqlContent = fmt.Sprintf(
+ gtest.DataContent(`genpbentity`, `user.tpl.sql`),
+ table,
+ )
+ )
+ dropTableWithDb(db, table)
+ array := gstr.SplitAndTrim(sqlContent, ";")
+ for _, v := range array {
+ if _, err = db.Exec(ctx, v); err != nil {
+ t.AssertNil(err)
+ }
+ }
+ defer dropTableWithDb(db, table)
+ var path = gfile.Temp(guid.S())
+ err = gfile.Mkdir(path)
+ t.AssertNil(err)
+ defer gfile.Remove(path)
+
+ root, err := gcmd.NewFromObject(GF)
+ t.AssertNil(err)
+ err = root.AddObject(
+ Gen,
+ )
+ t.AssertNil(err)
+ os.Args = []string{"gf", "gen", "pbentity", "-l", link, "-p", path, "-package=unittest", "-nameCase=SnakeScreaming"}
+
+ err = root.RunWithError(ctx)
+ t.AssertNil(err)
+
+ files := []string{
+ filepath.FromSlash(path + "/table_user.proto"),
+ }
+
+ testPath := gtest.DataPath("genpbentity", "generated_user")
+ expectFiles := []string{
+ filepath.FromSlash(testPath + "/table_user.proto"),
+ }
+ // check files content
+ for i := range files {
+ t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i]))
+ }
+ })
+}
diff --git a/server/internal/library/hggen/internal/cmd/genctrl/genctrl.go b/server/internal/library/hggen/internal/cmd/genctrl/genctrl.go
index 1c34e3a..990ed8f 100644
--- a/server/internal/library/hggen/internal/cmd/genctrl/genctrl.go
+++ b/server/internal/library/hggen/internal/cmd/genctrl/genctrl.go
@@ -74,7 +74,7 @@ type (
SdkStdVersion bool `short:"v" name:"sdkStdVersion" brief:"{CGenCtrlBriefSdkStdVersion}" orphan:"true"`
SdkNoV1 bool `short:"n" name:"sdkNoV1" brief:"{CGenCtrlBriefSdkNoV1}" orphan:"true"`
Clear bool `short:"c" name:"clear" brief:"{CGenCtrlBriefClear}" orphan:"true"`
- Merge bool `short:"m" name:"merge" brief:"{CGenCtrlControllerMerge}" orphan:"true"`
+ Merge bool `short:"m" name:"merge" brief:"{CGenCtrlControllerMerge}" orphan:"true"`
}
CGenCtrlOutput struct{}
)
diff --git a/server/internal/library/hggen/internal/cmd/gendao/gendao.go b/server/internal/library/hggen/internal/cmd/gendao/gendao.go
index da8d8f1..b37d6b5 100644
--- a/server/internal/library/hggen/internal/cmd/gendao/gendao.go
+++ b/server/internal/library/hggen/internal/cmd/gendao/gendao.go
@@ -59,28 +59,29 @@ CONFIGURATION SUPPORT
numeric:
type: string
`
- CGenDaoBriefPath = `directory path for generated files`
- CGenDaoBriefLink = `database configuration, the same as the ORM configuration of GoFrame`
- CGenDaoBriefTables = `generate models only for given tables, multiple table names separated with ','`
- CGenDaoBriefTablesEx = `generate models excluding given tables, multiple table names separated with ','`
- CGenDaoBriefPrefix = `add prefix for all table of specified link/database tables`
- CGenDaoBriefRemovePrefix = `remove specified prefix of the table, multiple prefix separated with ','`
- CGenDaoBriefStdTime = `use time.Time from stdlib instead of gtime.Time for generated time/date fields of tables`
- CGenDaoBriefWithTime = `add created time for auto produced go files`
- CGenDaoBriefGJsonSupport = `use gJsonSupport to use *gjson.Json instead of string for generated json fields of tables`
- CGenDaoBriefImportPrefix = `custom import prefix for generated go files`
- CGenDaoBriefDaoPath = `directory path for storing generated dao files under path`
- CGenDaoBriefDoPath = `directory path for storing generated do files under path`
- CGenDaoBriefEntityPath = `directory path for storing generated entity files under path`
- CGenDaoBriefOverwriteDao = `overwrite all dao files both inside/outside internal folder`
- CGenDaoBriefModelFile = `custom file name for storing generated model content`
- CGenDaoBriefModelFileForDao = `custom file name generating model for DAO operations like Where/Data. It's empty in default`
- CGenDaoBriefDescriptionTag = `add comment to description tag for each field`
- CGenDaoBriefNoJsonTag = `no json tag will be added for each field`
- CGenDaoBriefNoModelComment = `no model comment will be added for each field`
- CGenDaoBriefClear = `delete all generated go files that do not exist in database`
- CGenDaoBriefTypeMapping = `custom local type mapping for generated struct attributes relevant to fields of table`
- CGenDaoBriefGroup = `
+ CGenDaoBriefPath = `directory path for generated files`
+ CGenDaoBriefLink = `database configuration, the same as the ORM configuration of GoFrame`
+ CGenDaoBriefTables = `generate models only for given tables, multiple table names separated with ','`
+ CGenDaoBriefTablesEx = `generate models excluding given tables, multiple table names separated with ','`
+ CGenDaoBriefPrefix = `add prefix for all table of specified link/database tables`
+ CGenDaoBriefRemovePrefix = `remove specified prefix of the table, multiple prefix separated with ','`
+ CGenDaoBriefRemoveFieldPrefix = `remove specified prefix of the field, multiple prefix separated with ','`
+ CGenDaoBriefStdTime = `use time.Time from stdlib instead of gtime.Time for generated time/date fields of tables`
+ CGenDaoBriefWithTime = `add created time for auto produced go files`
+ CGenDaoBriefGJsonSupport = `use gJsonSupport to use *gjson.Json instead of string for generated json fields of tables`
+ CGenDaoBriefImportPrefix = `custom import prefix for generated go files`
+ CGenDaoBriefDaoPath = `directory path for storing generated dao files under path`
+ CGenDaoBriefDoPath = `directory path for storing generated do files under path`
+ CGenDaoBriefEntityPath = `directory path for storing generated entity files under path`
+ CGenDaoBriefOverwriteDao = `overwrite all dao files both inside/outside internal folder`
+ CGenDaoBriefModelFile = `custom file name for storing generated model content`
+ CGenDaoBriefModelFileForDao = `custom file name generating model for DAO operations like Where/Data. It's empty in default`
+ CGenDaoBriefDescriptionTag = `add comment to description tag for each field`
+ CGenDaoBriefNoJsonTag = `no json tag will be added for each field`
+ CGenDaoBriefNoModelComment = `no model comment will be added for each field`
+ CGenDaoBriefClear = `delete all generated go files that do not exist in database`
+ CGenDaoBriefTypeMapping = `custom local type mapping for generated struct attributes relevant to fields of table`
+ CGenDaoBriefGroup = `
specifying the configuration group name of database for generated ORM instance,
it's not necessary and the default value is "default"
`
@@ -145,6 +146,7 @@ func init() {
`CGenDaoBriefTablesEx`: CGenDaoBriefTablesEx,
`CGenDaoBriefPrefix`: CGenDaoBriefPrefix,
`CGenDaoBriefRemovePrefix`: CGenDaoBriefRemovePrefix,
+ `CGenDaoBriefRemoveFieldPrefix`: CGenDaoBriefRemoveFieldPrefix,
`CGenDaoBriefStdTime`: CGenDaoBriefStdTime,
`CGenDaoBriefWithTime`: CGenDaoBriefWithTime,
`CGenDaoBriefDaoPath`: CGenDaoBriefDaoPath,
@@ -180,6 +182,7 @@ type (
Group string `name:"group" short:"g" brief:"{CGenDaoBriefGroup}" d:"default"`
Prefix string `name:"prefix" short:"f" brief:"{CGenDaoBriefPrefix}"`
RemovePrefix string `name:"removePrefix" short:"r" brief:"{CGenDaoBriefRemovePrefix}"`
+ RemoveFieldPrefix string `name:"removeFieldPrefix" short:"rf" brief:"{CGenDaoBriefRemoveFieldPrefix}"`
JsonCase string `name:"jsonCase" short:"j" brief:"{CGenDaoBriefJsonCase}" d:"CamelLower"`
ImportPrefix string `name:"importPrefix" short:"i" brief:"{CGenDaoBriefImportPrefix}"`
DaoPath string `name:"daoPath" short:"d" brief:"{CGenDaoBriefDaoPath}" d:"dao"`
diff --git a/server/internal/library/hggen/internal/cmd/gendao/gendao_dao.go b/server/internal/library/hggen/internal/cmd/gendao/gendao_dao.go
index 98fad83..896995e 100644
--- a/server/internal/library/hggen/internal/cmd/gendao/gendao_dao.go
+++ b/server/internal/library/hggen/internal/cmd/gendao/gendao_dao.go
@@ -138,6 +138,7 @@ type generateDaoInternalInput struct {
func generateDaoInternal(in generateDaoInternalInput) {
path := filepath.FromSlash(gfile.Join(in.DirPathDaoInternal, in.FileName+".go"))
+ removeFieldPrefixArray := gstr.SplitAndTrim(in.RemoveFieldPrefix, ",")
modelContent := gstr.ReplaceByMap(
getTemplateFromPathOrDefault(in.TplDaoInternalPath, consts.TemplateGenDaoInternalContent),
g.MapStrStr{
@@ -146,8 +147,8 @@ func generateDaoInternal(in generateDaoInternalInput) {
tplVarGroupName: in.Group,
tplVarTableNameCamelCase: in.TableNameCamelCase,
tplVarTableNameCamelLowerCase: in.TableNameCamelLowerCase,
- tplVarColumnDefine: gstr.Trim(generateColumnDefinitionForDao(in.FieldMap)),
- tplVarColumnNames: gstr.Trim(generateColumnNamesForDao(in.FieldMap)),
+ tplVarColumnDefine: gstr.Trim(generateColumnDefinitionForDao(in.FieldMap, removeFieldPrefixArray)),
+ tplVarColumnNames: gstr.Trim(generateColumnNamesForDao(in.FieldMap, removeFieldPrefixArray)),
})
modelContent = replaceDefaultVar(in.CGenDaoInternalInput, modelContent)
if err := gfile.PutContents(path, strings.TrimSpace(modelContent)); err != nil {
@@ -160,16 +161,23 @@ func generateDaoInternal(in generateDaoInternalInput) {
// generateColumnNamesForDao generates and returns the column names assignment content of column struct
// for specified table.
-func generateColumnNamesForDao(fieldMap map[string]*gdb.TableField) string {
+func generateColumnNamesForDao(fieldMap map[string]*gdb.TableField, removeFieldPrefixArray []string) string {
var (
buffer = bytes.NewBuffer(nil)
array = make([][]string, len(fieldMap))
names = sortFieldKeyForDao(fieldMap)
)
+
for index, name := range names {
field := fieldMap[name]
+
+ newFiledName := field.Name
+ for _, v := range removeFieldPrefixArray {
+ newFiledName = gstr.TrimLeftStr(newFiledName, v, 1)
+ }
+
array[index] = []string{
- " #" + gstr.CaseCamel(field.Name) + ":",
+ " #" + gstr.CaseCamel(newFiledName) + ":",
fmt.Sprintf(` #"%s",`, field.Name),
}
}
@@ -189,12 +197,13 @@ func generateColumnNamesForDao(fieldMap map[string]*gdb.TableField) string {
}
// generateColumnDefinitionForDao generates and returns the column names definition for specified table.
-func generateColumnDefinitionForDao(fieldMap map[string]*gdb.TableField) string {
+func generateColumnDefinitionForDao(fieldMap map[string]*gdb.TableField, removeFieldPrefixArray []string) string {
var (
buffer = bytes.NewBuffer(nil)
array = make([][]string, len(fieldMap))
names = sortFieldKeyForDao(fieldMap)
)
+
for index, name := range names {
var (
field = fieldMap[name]
@@ -203,8 +212,12 @@ func generateColumnDefinitionForDao(fieldMap map[string]*gdb.TableField) string
"\r", " ",
}))
)
+ newFiledName := field.Name
+ for _, v := range removeFieldPrefixArray {
+ newFiledName = gstr.TrimLeftStr(newFiledName, v, 1)
+ }
array[index] = []string{
- " #" + gstr.CaseCamel(field.Name),
+ " #" + gstr.CaseCamel(newFiledName),
" # " + "string",
" #" + fmt.Sprintf(`// %s`, comment),
}
diff --git a/server/internal/library/hggen/internal/cmd/gendao/gendao_structure.go b/server/internal/library/hggen/internal/cmd/gendao/gendao_structure.go
index 77d84b6..c4398c8 100644
--- a/server/internal/library/hggen/internal/cmd/gendao/gendao_structure.go
+++ b/server/internal/library/hggen/internal/cmd/gendao/gendao_structure.go
@@ -126,8 +126,13 @@ func generateStructFieldDefinition(
tagKey = "`"
descriptionTag = gstr.Replace(formatComment(field.Comment), `"`, `\"`)
)
+ removeFieldPrefixArray := gstr.SplitAndTrim(in.RemoveFieldPrefix, ",")
+ newFiledName := field.Name
+ for _, v := range removeFieldPrefixArray {
+ newFiledName = gstr.TrimLeftStr(newFiledName, v, 1)
+ }
attrLines = []string{
- " #" + gstr.CaseCamel(field.Name),
+ " #" + gstr.CaseCamel(newFiledName),
" #" + localTypeNameStr,
}
attrLines = append(attrLines, " #"+fmt.Sprintf(tagKey+`json:"%s"`, jsonTag))
diff --git a/server/internal/library/hggen/internal/cmd/genpbentity/genpbentity.go b/server/internal/library/hggen/internal/cmd/genpbentity/genpbentity.go
index 8bf14c7..1f598e7 100644
--- a/server/internal/library/hggen/internal/cmd/genpbentity/genpbentity.go
+++ b/server/internal/library/hggen/internal/cmd/genpbentity/genpbentity.go
@@ -31,16 +31,17 @@ import (
type (
CGenPbEntity struct{}
CGenPbEntityInput struct {
- g.Meta `name:"pbentity" config:"{CGenPbEntityConfig}" brief:"{CGenPbEntityBrief}" eg:"{CGenPbEntityEg}" ad:"{CGenPbEntityAd}"`
- Path string `name:"path" short:"p" brief:"{CGenPbEntityBriefPath}" d:"manifest/protobuf/pbentity"`
- Package string `name:"package" short:"k" brief:"{CGenPbEntityBriefPackage}"`
- Link string `name:"link" short:"l" brief:"{CGenPbEntityBriefLink}"`
- Tables string `name:"tables" short:"t" brief:"{CGenPbEntityBriefTables}"`
- Prefix string `name:"prefix" short:"f" brief:"{CGenPbEntityBriefPrefix}"`
- RemovePrefix string `name:"removePrefix" short:"r" brief:"{CGenPbEntityBriefRemovePrefix}"`
- NameCase string `name:"nameCase" short:"n" brief:"{CGenPbEntityBriefNameCase}" d:"Camel"`
- JsonCase string `name:"jsonCase" short:"j" brief:"{CGenPbEntityBriefJsonCase}" d:"CamelLower"`
- Option string `name:"option" short:"o" brief:"{CGenPbEntityBriefOption}"`
+ g.Meta `name:"pbentity" config:"{CGenPbEntityConfig}" brief:"{CGenPbEntityBrief}" eg:"{CGenPbEntityEg}" ad:"{CGenPbEntityAd}"`
+ Path string `name:"path" short:"p" brief:"{CGenPbEntityBriefPath}" d:"manifest/protobuf/pbentity"`
+ Package string `name:"package" short:"k" brief:"{CGenPbEntityBriefPackage}"`
+ Link string `name:"link" short:"l" brief:"{CGenPbEntityBriefLink}"`
+ Tables string `name:"tables" short:"t" brief:"{CGenPbEntityBriefTables}"`
+ Prefix string `name:"prefix" short:"f" brief:"{CGenPbEntityBriefPrefix}"`
+ RemovePrefix string `name:"removePrefix" short:"r" brief:"{CGenPbEntityBriefRemovePrefix}"`
+ RemoveFieldPrefix string `name:"removeFieldPrefix" short:"rf" brief:"{CGenPbEntityBriefRemoveFieldPrefix}"`
+ NameCase string `name:"nameCase" short:"n" brief:"{CGenPbEntityBriefNameCase}" d:"Camel"`
+ JsonCase string `name:"jsonCase" short:"j" brief:"{CGenPbEntityBriefJsonCase}" d:"none"`
+ Option string `name:"option" short:"o" brief:"{CGenPbEntityBriefOption}"`
}
CGenPbEntityOutput struct{}
@@ -87,14 +88,15 @@ CONFIGURATION SUPPORT
option java_package = "protobuf/demos";
option php_namespace = "protobuf/demos";
`
- CGenPbEntityBriefPath = `directory path for generated files storing`
- CGenPbEntityBriefPackage = `package path for all entity proto files`
- CGenPbEntityBriefLink = `database configuration, the same as the ORM configuration of GoFrame`
- CGenPbEntityBriefTables = `generate models only for given tables, multiple table names separated with ','`
- CGenPbEntityBriefPrefix = `add specified prefix for all entity names and entity proto files`
- CGenPbEntityBriefRemovePrefix = `remove specified prefix of the table, multiple prefix separated with ','`
- CGenPbEntityBriefOption = `extra protobuf options`
- CGenPbEntityBriefGroup = `
+ CGenPbEntityBriefPath = `directory path for generated files storing`
+ CGenPbEntityBriefPackage = `package path for all entity proto files`
+ CGenPbEntityBriefLink = `database configuration, the same as the ORM configuration of GoFrame`
+ CGenPbEntityBriefTables = `generate models only for given tables, multiple table names separated with ','`
+ CGenPbEntityBriefPrefix = `add specified prefix for all entity names and entity proto files`
+ CGenPbEntityBriefRemovePrefix = `remove specified prefix of the table, multiple prefix separated with ','`
+ CGenPbEntityBriefRemoveFieldPrefix = `remove specified prefix of the field, multiple prefix separated with ','`
+ CGenPbEntityBriefOption = `extra protobuf options`
+ CGenPbEntityBriefGroup = `
specifying the configuration group name of database for generated ORM instance,
it's not necessary and the default value is "default"
`
@@ -120,20 +122,21 @@ set it to "none" to ignore json tag generating.
func init() {
gtag.Sets(g.MapStrStr{
- `CGenPbEntityConfig`: CGenPbEntityConfig,
- `CGenPbEntityBrief`: CGenPbEntityBrief,
- `CGenPbEntityEg`: CGenPbEntityEg,
- `CGenPbEntityAd`: CGenPbEntityAd,
- `CGenPbEntityBriefPath`: CGenPbEntityBriefPath,
- `CGenPbEntityBriefPackage`: CGenPbEntityBriefPackage,
- `CGenPbEntityBriefLink`: CGenPbEntityBriefLink,
- `CGenPbEntityBriefTables`: CGenPbEntityBriefTables,
- `CGenPbEntityBriefPrefix`: CGenPbEntityBriefPrefix,
- `CGenPbEntityBriefRemovePrefix`: CGenPbEntityBriefRemovePrefix,
- `CGenPbEntityBriefGroup`: CGenPbEntityBriefGroup,
- `CGenPbEntityBriefNameCase`: CGenPbEntityBriefNameCase,
- `CGenPbEntityBriefJsonCase`: CGenPbEntityBriefJsonCase,
- `CGenPbEntityBriefOption`: CGenPbEntityBriefOption,
+ `CGenPbEntityConfig`: CGenPbEntityConfig,
+ `CGenPbEntityBrief`: CGenPbEntityBrief,
+ `CGenPbEntityEg`: CGenPbEntityEg,
+ `CGenPbEntityAd`: CGenPbEntityAd,
+ `CGenPbEntityBriefPath`: CGenPbEntityBriefPath,
+ `CGenPbEntityBriefPackage`: CGenPbEntityBriefPackage,
+ `CGenPbEntityBriefLink`: CGenPbEntityBriefLink,
+ `CGenPbEntityBriefTables`: CGenPbEntityBriefTables,
+ `CGenPbEntityBriefPrefix`: CGenPbEntityBriefPrefix,
+ `CGenPbEntityBriefRemovePrefix`: CGenPbEntityBriefRemovePrefix,
+ `CGenPbEntityBriefRemoveFieldPrefix`: CGenPbEntityBriefRemoveFieldPrefix,
+ `CGenPbEntityBriefGroup`: CGenPbEntityBriefGroup,
+ `CGenPbEntityBriefNameCase`: CGenPbEntityBriefNameCase,
+ `CGenPbEntityBriefJsonCase`: CGenPbEntityBriefJsonCase,
+ `CGenPbEntityBriefOption`: CGenPbEntityBriefOption,
})
}
@@ -339,6 +342,7 @@ func generateMessageFieldForPbEntity(index int, field *gdb.TableField, in CGenPb
comment = gstr.Replace(comment, `\n`, " ")
comment, _ = gregex.ReplaceString(`\s{2,}`, ` `, comment)
if jsonTagName := formatCase(field.Name, in.JsonCase); jsonTagName != "" {
+ jsonTagStr = fmt.Sprintf(`[json_name = "%s"]`, jsonTagName)
// beautiful indent.
if index < 10 {
// 3 spaces
@@ -351,9 +355,16 @@ func generateMessageFieldForPbEntity(index int, field *gdb.TableField, in CGenPb
jsonTagStr = " " + jsonTagStr
}
}
+
+ removeFieldPrefixArray := gstr.SplitAndTrim(in.RemoveFieldPrefix, ",")
+ newFiledName := field.Name
+ for _, v := range removeFieldPrefixArray {
+ newFiledName = gstr.TrimLeftStr(newFiledName, v, 1)
+ }
+
return []string{
" #" + localTypeNameStr,
- " #" + formatCase(field.Name, in.NameCase),
+ " #" + formatCase(newFiledName, in.NameCase),
" #= " + gconv.String(index) + jsonTagStr + ";",
" #" + fmt.Sprintf(`// %s`, comment),
}
@@ -368,32 +379,10 @@ func getTplPbEntityContent(tplEntityPath string) string {
// formatCase call gstr.Case* function to convert the s to specified case.
func formatCase(str, caseStr string) string {
- switch gstr.ToLower(caseStr) {
- case gstr.ToLower("Camel"):
- return gstr.CaseCamel(str)
-
- case gstr.ToLower("CamelLower"):
- return gstr.CaseCamelLower(str)
-
- case gstr.ToLower("Kebab"):
- return gstr.CaseKebab(str)
-
- case gstr.ToLower("KebabScreaming"):
- return gstr.CaseKebabScreaming(str)
-
- case gstr.ToLower("Snake"):
- return gstr.CaseSnake(str)
-
- case gstr.ToLower("SnakeFirstUpper"):
- return gstr.CaseSnakeFirstUpper(str)
-
- case gstr.ToLower("SnakeScreaming"):
- return gstr.CaseSnakeScreaming(str)
-
- case "none":
+ if caseStr == "none" {
return ""
}
- return str
+ return gstr.CaseConvert(str, gstr.CaseTypeMatch(caseStr))
}
func sortFieldKeyForPbEntity(fieldMap map[string]*gdb.TableField) []string {
diff --git a/server/internal/library/hggen/internal/cmd/testdata/genpbentity/generated_user/table_user.proto b/server/internal/library/hggen/internal/cmd/testdata/genpbentity/generated_user/table_user.proto
new file mode 100644
index 0000000..365999e
--- /dev/null
+++ b/server/internal/library/hggen/internal/cmd/testdata/genpbentity/generated_user/table_user.proto
@@ -0,0 +1,21 @@
+// ==========================================================================
+// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
+// ==========================================================================
+
+syntax = "proto3";
+
+package unittest;
+
+option go_package = "unittest";
+
+import "google/protobuf/timestamp.proto";
+
+message TableUser {
+ uint32 ID = 1; // User ID
+ string PASSPORT = 2; // User Passport
+ string PASSWORD = 3; // User Password
+ string NICKNAME = 4; // User Nickname
+ string SCORE = 5; // Total score amount.
+ google.protobuf.Timestamp CREATE_AT = 6; // Created Time
+ google.protobuf.Timestamp UPDATE_AT = 7; // Updated Time
+}
\ No newline at end of file
diff --git a/server/internal/library/hggen/internal/cmd/testdata/genpbentity/user.tpl.sql b/server/internal/library/hggen/internal/cmd/testdata/genpbentity/user.tpl.sql
new file mode 100644
index 0000000..f27fc11
--- /dev/null
+++ b/server/internal/library/hggen/internal/cmd/testdata/genpbentity/user.tpl.sql
@@ -0,0 +1,10 @@
+CREATE TABLE `%s` (
+ `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID',
+ `passport` varchar(45) NOT NULL COMMENT 'User Passport',
+ `password` varchar(45) NOT NULL COMMENT 'User Password',
+ `nickname` varchar(45) NOT NULL COMMENT 'User Nickname',
+ `score` decimal(10,2) unsigned DEFAULT NULL COMMENT 'Total score amount.',
+ `create_at` datetime DEFAULT NULL COMMENT 'Created Time',
+ `update_at` datetime DEFAULT NULL COMMENT 'Updated Time',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/server/internal/library/hggen/internal/utility/mlog/mlog.go b/server/internal/library/hggen/internal/utility/mlog/mlog.go
index d7af655..7cbaa76 100644
--- a/server/internal/library/hggen/internal/utility/mlog/mlog.go
+++ b/server/internal/library/hggen/internal/utility/mlog/mlog.go
@@ -24,15 +24,19 @@ var (
)
func init() {
- logger.SetStack(false)
if genv.Get(headerPrintEnvName).String() == "1" {
logger.SetHeaderPrint(true)
} else {
logger.SetHeaderPrint(false)
}
+
if gcmd.GetOpt("debug") != nil || gcmd.GetOpt("gf.debug") != nil {
+ logger.SetHeaderPrint(true)
+ logger.SetStackSkip(4)
+ logger.SetFlags(logger.GetFlags() | glog.F_FILE_LONG)
logger.SetDebug(true)
} else {
+ logger.SetStack(false)
logger.SetDebug(false)
}
}
diff --git a/server/internal/library/hggen/views/column_map.go b/server/internal/library/hggen/views/column_map.go
index f5e49b0..43d03da 100644
--- a/server/internal/library/hggen/views/column_map.go
+++ b/server/internal/library/hggen/views/column_map.go
@@ -219,6 +219,8 @@ func IsNumberType(goType string) bool {
switch goType {
case GoTypeInt, GoTypeUint, GoTypeInt64, GoTypeUint64:
return true
+ case GoTypeFloat32, GoTypeFloat64:
+ return true
}
return false
}
diff --git a/server/internal/library/hggen/views/curd.go b/server/internal/library/hggen/views/curd.go
index d1f1607..616e70a 100644
--- a/server/internal/library/hggen/views/curd.go
+++ b/server/internal/library/hggen/views/curd.go
@@ -14,8 +14,10 @@ import (
"github.com/gogf/gf/v2/os/gview"
"github.com/gogf/gf/v2/text/gstr"
"hotgo/internal/consts"
+ "hotgo/internal/dao"
"hotgo/internal/library/hggen/internal/cmd/gendao"
"hotgo/internal/library/hggen/internal/utility/utils"
+ "hotgo/internal/library/hgorm"
"hotgo/internal/model"
"hotgo/internal/model/input/sysin"
"hotgo/utility/convert"
@@ -668,6 +670,15 @@ func (l *gCurd) generateSqlContent(ctx context.Context, in *CurdPreviewInput) (e
genFile = new(sysin.GenFile)
)
+ tplData["dirPid"], tplData["dirLevel"], tplData["dirTree"], err = hgorm.AutoUpdateTree(ctx, &dao.AdminMenu, 0, int64(in.options.Menu.Pid))
+ if err != nil {
+ return err
+ }
+
+ tplData["listLevel"] = tplData["dirLevel"].(int) + 1
+ tplData["btnLevel"] = tplData["dirLevel"].(int) + 2
+ tplData["sortLevel"] = tplData["dirLevel"].(int) + 3
+
if in.options.Menu.Pid > 0 {
tplData["mainComponent"] = "ParentLayout"
}
diff --git a/server/internal/library/hggen/views/curd_generate_web_edit.go b/server/internal/library/hggen/views/curd_generate_web_edit.go
index d8edf6d..fc6cb72 100644
--- a/server/internal/library/hggen/views/curd_generate_web_edit.go
+++ b/server/internal/library/hggen/views/curd_generate_web_edit.go
@@ -32,7 +32,7 @@ func (l *gCurd) generateWebEditFormItem(ctx context.Context, in *CurdPreviewInpu
}
var (
- defaultComponent = fmt.Sprintf("