mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 13:03:22 +08:00
代码规范过滤,移除冗余代码,替换掉不推荐的包
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package views
|
||||
|
||||
import (
|
||||
@@ -236,7 +235,6 @@ func setDefaultList(field *sysin.GenCodesColumnListModel) {
|
||||
if df, ok := defaultListSwitch[field.Name]; ok {
|
||||
field.IsList = df
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// setDefaultExport 设置默认导出
|
||||
@@ -256,7 +254,6 @@ func setDefaultExport(field *sysin.GenCodesColumnListModel) {
|
||||
if df, ok := defaultExportSwitch[field.Name]; ok {
|
||||
field.IsExport = df
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// setDefaultQuery 设置默认查询
|
||||
|
@@ -97,12 +97,14 @@ func (l *gCurd) initInput(ctx context.Context, in *CurdPreviewInput) (err error)
|
||||
in.content.Views = make(map[string]*sysin.GenFile)
|
||||
|
||||
// 加载主表配置
|
||||
err = in.In.MasterColumns.Scan(&in.masterFields)
|
||||
if err != nil {
|
||||
return err
|
||||
if err = in.In.MasterColumns.Scan(&in.masterFields); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if len(in.masterFields) == 0 {
|
||||
in.masterFields, err = DoTableColumns(ctx, sysin.GenCodesColumnListInp{Name: in.In.DbName, Table: in.In.TableName}, in.DaoConfig)
|
||||
if in.masterFields, err = DoTableColumns(ctx, sysin.GenCodesColumnListInp{Name: in.In.DbName, Table: in.In.TableName}, in.DaoConfig); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 主键属性
|
||||
@@ -112,9 +114,8 @@ func (l *gCurd) initInput(ctx context.Context, in *CurdPreviewInput) (err error)
|
||||
}
|
||||
|
||||
// 加载选项
|
||||
err = in.In.Options.Scan(&in.options)
|
||||
if err != nil {
|
||||
return err
|
||||
if err = in.In.Options.Scan(&in.options); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
initStep(in)
|
||||
@@ -131,8 +132,7 @@ func (l *gCurd) initInput(ctx context.Context, in *CurdPreviewInput) (err error)
|
||||
}
|
||||
in.options.ApiPrefix = apiPrefix
|
||||
|
||||
err = checkCurdPath(in.Config.Application.Crud.Templates[in.In.GenTemplate], in.In.AddonName)
|
||||
if err != nil {
|
||||
if err = checkCurdPath(in.Config.Application.Crud.Templates[in.In.GenTemplate], in.In.AddonName); err != nil {
|
||||
return
|
||||
}
|
||||
in.options.TemplateGroup = in.Config.Application.Crud.Templates[in.In.GenTemplate].MasterPackage
|
||||
@@ -338,9 +338,7 @@ func (l *gCurd) DoPreview(ctx context.Context, in *CurdPreviewInput) (res *sysin
|
||||
}
|
||||
|
||||
in.content.Config = in.Config
|
||||
res = new(sysin.GenCodesPreviewModel)
|
||||
res = in.content
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ const (
|
||||
LogicWhereComments = "\n\t// 查询%s\n"
|
||||
LogicWhereNoSupport = "\t// TODO 暂不支持生成[ %s ]查询方式,请自行补充此处代码!"
|
||||
LogicListSimpleSelect = "\tfields, err := hgorm.GenSelect(ctx, sysin.%sListModel{}, dao.%s)\n\tif err != nil {\n\t\treturn\n\t}"
|
||||
LogicListJoinSelect = "\t//关联表select\n\tfields, err := hgorm.GenJoinSelect(ctx, %sin.%sListModel{}, dao.%s, []*hgorm.Join{\n%v\t})"
|
||||
LogicListJoinSelect = "\t//关联表select\n\tfields, err := hgorm.GenJoinSelect(ctx, %sin.%sListModel{}, dao.%s, []*hgorm.Join{\n%v\t})\n\n\tif err != nil {\n\t\treturn\n\t}"
|
||||
LogicListJoinOnRelation = "\t// 关联表%s\n\tmod = mod.%s(hgorm.GenJoinOnRelation(\n\t\tdao.%s.Table(), dao.%s.Columns().%s, // 主表表名,关联字段\n\t\tdao.%s.Table(), \"%s\", dao.%s.Columns().%s, // 关联表表名,别名,关联字段\n\t)...)\n\n"
|
||||
LogicEditUpdate = "\t\t_, err = s.Model(ctx%s).\n\t\t\tFields(%sin.%sUpdateFields{}).\n\t\t\tWherePri(in.%s).Data(in).Update()\n\t\treturn "
|
||||
LogicEditInsert = "\t_, err = s.Model(ctx, &handler.Option{FilterAuth: false}).\n\t\tFields(%sin.%sInsertFields{}).\n\t\tData(in).Insert()"
|
||||
|
@@ -31,9 +31,9 @@ func (l *gCurd) webIndexTplData(ctx context.Context, in *CurdPreviewInput) (g.Ma
|
||||
iconsImport = append(iconsImport, " PlusOutlined")
|
||||
}
|
||||
|
||||
// 编辑
|
||||
if in.options.Step.HasEdit {
|
||||
}
|
||||
//// 编辑
|
||||
//if in.options.Step.HasEdit {
|
||||
//}
|
||||
|
||||
// 导出
|
||||
if in.options.Step.HasExport {
|
||||
@@ -64,17 +64,17 @@ func (l *gCurd) webIndexTplData(ctx context.Context, in *CurdPreviewInput) (g.Ma
|
||||
// 没有需要查询的字段则隐藏搜索表单
|
||||
isSearchForm := false
|
||||
for _, field := range in.masterFields {
|
||||
if field.IsQuery == true {
|
||||
if field.IsQuery {
|
||||
isSearchForm = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if isSearchForm == false {
|
||||
if !isSearchForm {
|
||||
if len(in.options.Join) > 0 {
|
||||
LoopOut:
|
||||
for _, v := range in.options.Join {
|
||||
for _, column := range v.Columns {
|
||||
if column.IsQuery == true {
|
||||
if column.IsQuery {
|
||||
isSearchForm = true
|
||||
break LoopOut
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ import (
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/model"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -77,7 +77,7 @@ func removeEndWrap(comment string) string {
|
||||
|
||||
// ImportSql 导出sql文件
|
||||
func ImportSql(ctx context.Context, path string) error {
|
||||
rows, err := ioutil.ReadFile(path)
|
||||
rows, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user