From 5c3bcaf6cce1cf4a57304d456ff024dd547d3467 Mon Sep 17 00:00:00 2001 From: mh-swift Date: Tue, 9 Jul 2024 17:21:32 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E6=A0=BC=E5=BC=8F=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hgexample/logic/sys/tenant_order.go | 2 -- server/internal/global/httproutes.go | 8 ++++---- server/internal/library/hggen/hggen.go | 11 ++++++----- server/internal/library/hggen/views/curd.go | 19 ++++++++++--------- .../library/hggen/views/gohtml/formatter.go | 1 - .../library/hggen/views/gohtml/parser.go | 7 ++++--- server/internal/logic/admin/site.go | 17 +++++++++-------- server/internal/logic/sys/curd_demo.go | 2 -- server/internal/logic/sys/test_category.go | 2 -- 9 files changed, 33 insertions(+), 36 deletions(-) diff --git a/server/addons/hgexample/logic/sys/tenant_order.go b/server/addons/hgexample/logic/sys/tenant_order.go index 22e27ef..ac8094d 100644 --- a/server/addons/hgexample/logic/sys/tenant_order.go +++ b/server/addons/hgexample/logic/sys/tenant_order.go @@ -133,7 +133,6 @@ func (s *sSysTenantOrder) Export(ctx context.Context, in *sysin.TenantOrderListI // Edit 修改/新增多租户功能演示 func (s *sSysTenantOrder) Edit(ctx context.Context, in *sysin.TenantOrderEditInp) (err error) { return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) { - // 修改 if in.Id > 0 { if _, err = s.Model(ctx). @@ -158,7 +157,6 @@ func (s *sSysTenantOrder) Edit(ctx context.Context, in *sysin.TenantOrderEditInp // Delete 删除多租户功能演示 func (s *sSysTenantOrder) Delete(ctx context.Context, in *sysin.TenantOrderDeleteInp) (err error) { - if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil { err = gerror.Wrap(err, "删除多租户功能演示失败,请稍后重试!") return diff --git a/server/internal/global/httproutes.go b/server/internal/global/httproutes.go index 23952ea..8a4e535 100644 --- a/server/internal/global/httproutes.go +++ b/server/internal/global/httproutes.go @@ -6,12 +6,13 @@ package global import ( - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/util/gmeta" - "github.com/gogf/gf/v2/util/gtag" "reflect" "strings" "sync" + + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/util/gmeta" + "github.com/gogf/gf/v2/util/gtag" ) // HTTPRouter http路由 @@ -77,7 +78,6 @@ func LoadHTTPRoutes(r *ghttp.Request) map[string]*HTTPRouter { httpRoutes[key] = setRouterMeta(router) } } - } return httpRoutes } diff --git a/server/internal/library/hggen/hggen.go b/server/internal/library/hggen/hggen.go index a42738e..fce4b60 100644 --- a/server/internal/library/hggen/hggen.go +++ b/server/internal/library/hggen/hggen.go @@ -6,15 +6,13 @@ package hggen import ( - "github.com/gogf/gf/v2/os/gfile" _ "hotgo/internal/library/hggen/internal/cmd/gendao" "hotgo/internal/library/hggen/internal/utility/utils" _ "unsafe" + "github.com/gogf/gf/v2/os/gfile" + "context" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/util/gconv" "hotgo/internal/consts" "hotgo/internal/library/addons" "hotgo/internal/library/hggen/internal/cmd" @@ -26,6 +24,10 @@ import ( "hotgo/internal/model/input/sysin" "hotgo/internal/service" "sort" + + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/util/gconv" ) //go:linkname doGenDaoForArray hotgo/internal/library/hggen/internal/cmd/gendao.doGenDaoForArray @@ -33,7 +35,6 @@ func doGenDaoForArray(ctx context.Context, index int, in gendao.CGenDaoInput) // Dao 生成数据库实体 func Dao(ctx context.Context) (err error) { - // 在执行gf gen dao时,先将生成文件放在临时路径,生成完成后再拷贝到项目 // 目的是希望减少触发gf热编译的几率,防止热编译运行时代码生成流程未结束被自动重启打断 // gf gen dao 的执行时长主要取决于需要生成数据库表的数量,表越多速度越慢 diff --git a/server/internal/library/hggen/views/curd.go b/server/internal/library/hggen/views/curd.go index 9acde1b..b84ad67 100644 --- a/server/internal/library/hggen/views/curd.go +++ b/server/internal/library/hggen/views/curd.go @@ -7,14 +7,6 @@ package views import ( "context" - "github.com/gogf/gf/v2/container/gvar" - "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/os/gtime" - "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" @@ -27,6 +19,15 @@ import ( "hotgo/utility/tree" "runtime" "strings" + + "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/os/gview" + "github.com/gogf/gf/v2/text/gstr" ) var Curd = gCurd{} @@ -118,7 +119,7 @@ type CurdOptions struct { type FuncDict struct { ValueColumn string // 选项值 - LabelColumn string //选项名称 + LabelColumn string // 选项名称 Value *sysin.GenCodesColumnListModel Label *sysin.GenCodesColumnListModel } diff --git a/server/internal/library/hggen/views/gohtml/formatter.go b/server/internal/library/hggen/views/gohtml/formatter.go index baed679..0f1e1f6 100644 --- a/server/internal/library/hggen/views/gohtml/formatter.go +++ b/server/internal/library/hggen/views/gohtml/formatter.go @@ -33,5 +33,4 @@ func AddLineNo(s string) string { bf.WriteString(strings.Repeat(" ", maxLineNoStrLen-len(lineNoStr)) + lineNoStr + " " + line) } return bf.String() - } diff --git a/server/internal/library/hggen/views/gohtml/parser.go b/server/internal/library/hggen/views/gohtml/parser.go index 3442ad5..2ca7444 100644 --- a/server/internal/library/hggen/views/gohtml/parser.go +++ b/server/internal/library/hggen/views/gohtml/parser.go @@ -1,10 +1,11 @@ package gohtml import ( - "golang.org/x/net/html" "io" "regexp" "strings" + + "golang.org/x/net/html" ) // parse parses a stirng and converts it into an html. @@ -106,9 +107,9 @@ func getTagName(tokenizer *html.Tokenizer) string { } // setEndTagRaw sets an endTagRaw to the parent. -func setEndTagRaw(tokenizer *html.Tokenizer, parent *tagElement, tagName string) string { +func setEndTagRaw(_ *html.Tokenizer, parent *tagElement, tagName string) string { if parent != nil && parent.tagName == tagName { - parent.endTagRaw = `` //string(tokenizer.Raw()) + parent.endTagRaw = `` // string(tokenizer.Raw()) return "" } return tagName diff --git a/server/internal/logic/admin/site.go b/server/internal/logic/admin/site.go index d22948c..519ea76 100644 --- a/server/internal/logic/admin/site.go +++ b/server/internal/logic/admin/site.go @@ -7,12 +7,6 @@ package admin import ( "context" - "github.com/gogf/gf/v2/crypto/gmd5" - "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/grand" "hotgo/internal/consts" "hotgo/internal/dao" "hotgo/internal/library/contexts" @@ -23,6 +17,13 @@ import ( "hotgo/internal/model/input/sysin" "hotgo/internal/service" "hotgo/utility/simple" + + "github.com/gogf/gf/v2/crypto/gmd5" + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/grand" ) type sAdminSite struct{} @@ -292,8 +293,8 @@ func (s *sAdminSite) getLoginRoleAndDept(ctx context.Context, roleId, deptId int // BindUserContext 绑定用户上下文 func (s *sAdminSite) BindUserContext(ctx context.Context, claims *model.Identity) (err error) { //// 如果不想每次访问都重新加载用户信息,可以放开注释。但在本次登录未失效前,用户信息不会刷新 - //contexts.SetUser(ctx, claims) - //return + // contexts.SetUser(ctx, claims) + // return var mb *entity.AdminMember if err = dao.AdminMember.Ctx(ctx).WherePri(claims.Id).Scan(&mb); err != nil { diff --git a/server/internal/logic/sys/curd_demo.go b/server/internal/logic/sys/curd_demo.go index 3f601b4..72c8828 100644 --- a/server/internal/logic/sys/curd_demo.go +++ b/server/internal/logic/sys/curd_demo.go @@ -145,7 +145,6 @@ func (s *sSysCurdDemo) Export(ctx context.Context, in *sysin.CurdDemoListInp) (e // Edit 修改/新增CURD列表 func (s *sSysCurdDemo) Edit(ctx context.Context, in *sysin.CurdDemoEditInp) (err error) { return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) { - // 修改 if in.Id > 0 { in.UpdatedBy = contexts.GetUserId(ctx) @@ -170,7 +169,6 @@ func (s *sSysCurdDemo) Edit(ctx context.Context, in *sysin.CurdDemoEditInp) (err // Delete 删除CURD列表 func (s *sSysCurdDemo) Delete(ctx context.Context, in *sysin.CurdDemoDeleteInp) (err error) { - if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil { err = gerror.Wrap(err, "删除CURD列表失败,请稍后重试!") return diff --git a/server/internal/logic/sys/test_category.go b/server/internal/logic/sys/test_category.go index aedf8a4..31dbf68 100644 --- a/server/internal/logic/sys/test_category.go +++ b/server/internal/logic/sys/test_category.go @@ -84,7 +84,6 @@ func (s *sSysTestCategory) List(ctx context.Context, in *sysin.TestCategoryListI // Edit 修改/新增测试分类 func (s *sSysTestCategory) Edit(ctx context.Context, in *sysin.TestCategoryEditInp) (err error) { return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) { - // 修改 if in.Id > 0 { if _, err = s.Model(ctx). @@ -107,7 +106,6 @@ func (s *sSysTestCategory) Edit(ctx context.Context, in *sysin.TestCategoryEditI // Delete 删除测试分类 func (s *sSysTestCategory) Delete(ctx context.Context, in *sysin.TestCategoryDeleteInp) (err error) { - if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil { err = gerror.Wrap(err, "删除测试分类失败,请稍后重试!") return