This commit is contained in:
孟帅
2023-12-29 20:08:00 +08:00
parent c68004b6da
commit b54055810b
52 changed files with 1468 additions and 1325 deletions

View File

@@ -12,5 +12,5 @@ const (
UploadDriveCos = "cos" // 腾讯云cos
UploadDriveOss = "oss" // 阿里云oss
UploadDriveQiNiu = "qiniu" // 七牛云对象存储
UploadDriveMinio = "minio" // minio
UploadDriveMinio = "minio" // minio对象存储
)

View File

@@ -7,5 +7,5 @@ package consts
// VersionApp HotGo版本
const (
VersionApp = "2.11.5"
VersionApp = "2.12.1"
)

View File

@@ -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) {

View File

@@ -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"

View File

@@ -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)
}
}

View File

@@ -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`),

View File

@@ -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]))
}
})
}

View File

@@ -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{}
)

View File

@@ -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"`

View File

@@ -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),
}

View File

@@ -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))

View File

@@ -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 {

View File

@@ -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
}

View File

@@ -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;

View File

@@ -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)
}
}

View File

@@ -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"
}

View File

@@ -32,7 +32,7 @@ func (l *gCurd) generateWebEditFormItem(ctx context.Context, in *CurdPreviewInpu
}
var (
defaultComponent = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-input placeholder=\"请输入%s\" v-model:value=\"params.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.Dc, field.TsName)
defaultComponent = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-input placeholder=\"请输入%s\" v-model:value=\"formValue.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.Dc, field.TsName)
component string
)
@@ -41,63 +41,63 @@ func (l *gCurd) generateWebEditFormItem(ctx context.Context, in *CurdPreviewInpu
component = defaultComponent
case FormModeInputNumber:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-input-number placeholder=\"请输入%s\" v-model:value=\"params.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.Dc, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-input-number placeholder=\"请输入%s\" v-model:value=\"formValue.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.Dc, field.TsName)
case FormModeInputTextarea:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-input type=\"textarea\" placeholder=\"%s\" v-model:value=\"params.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.Dc, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-input type=\"textarea\" placeholder=\"%s\" v-model:value=\"formValue.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.Dc, field.TsName)
case FormModeInputEditor:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <Editor style=\"height: 450px\" id=\"%s\" v-model:value=\"params.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <Editor style=\"height: 450px\" id=\"%s\" v-model:value=\"formValue.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName, field.TsName)
case FormModeInputDynamic:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-dynamic-input\n v-model:value=\"params.%s\"\n preset=\"pair\"\n key-placeholder=\"键名\"\n value-placeholder=\"键值\"\n />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-dynamic-input\n v-model:value=\"formValue.%s\"\n preset=\"pair\"\n key-placeholder=\"键名\"\n value-placeholder=\"键值\"\n />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
case FormModeDate:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <DatePicker v-model:formValue=\"params.%s\" type=\"date\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <DatePicker v-model:formValue=\"formValue.%s\" type=\"date\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
// case FormModeDateRange: // 必须要有两个字段,后面优化下
case FormModeTime:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <DatePicker v-model:formValue=\"params.%s\" type=\"datetime\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <DatePicker v-model:formValue=\"formValue.%s\" type=\"datetime\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
// case FormModeTimeRange: // 必须要有两个字段,后面优化下
case FormModeRadio:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-radio-group v-model:value=\"params.%s\" name=\"%s\">\n <n-radio-button\n v-for=\"%s in options.%s\"\n :key=\"%s.value\"\n :value=\"%s.value\"\n :label=\"%s.label\"\n />\n </n-radio-group>\n </n-form-item>", field.Dc, field.TsName, field.TsName, field.TsName, field.TsName, in.options.dictMap[field.TsName], field.TsName, field.TsName, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-radio-group v-model:value=\"formValue.%s\" name=\"%s\">\n <n-radio-button\n v-for=\"%s in options.%s\"\n :key=\"%s.value\"\n :value=\"%s.value\"\n :label=\"%s.label\"\n />\n </n-radio-group>\n </n-form-item>", field.Dc, field.TsName, field.TsName, field.TsName, field.TsName, in.options.dictMap[field.TsName], field.TsName, field.TsName, field.TsName)
case FormModeCheckbox:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-checkbox-group v-model:value=\"params.%s\">\n <n-space>\n <n-checkbox\n v-for=\"item in options.%s\"\n :key=\"item.value\"\n :value=\"item.value\"\n :label=\"item.label\"\n />\n </n-space>\n </n-checkbox-group>\n </n-form-item>", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName])
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-checkbox-group v-model:value=\"formValue.%s\">\n <n-space>\n <n-checkbox\n v-for=\"item in options.%s\"\n :key=\"item.value\"\n :value=\"item.value\"\n :label=\"item.label\"\n />\n </n-space>\n </n-checkbox-group>\n </n-form-item>", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName])
case FormModeSelect:
if in.options.dictMap[field.TsName] != nil {
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-select v-model:value=\"params.%s\" :options=\"options.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName])
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-select v-model:value=\"formValue.%s\" :options=\"options.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName])
} else {
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-select v-model:value=\"params.%s\" options=\"\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-select v-model:value=\"formValue.%s\" options=\"\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
}
case FormModeSelectMultiple:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-select multiple v-model:value=\"params.%s\" :options=\"options.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName])
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-select multiple v-model:value=\"formValue.%s\" :options=\"options.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName])
case FormModeUploadImage:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <UploadImage :maxNumber=\"1\" v-model:value=\"params.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <UploadImage :maxNumber=\"1\" v-model:value=\"formValue.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
case FormModeUploadImages:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <UploadImage :maxNumber=\"10\" v-model:value=\"params.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <UploadImage :maxNumber=\"10\" v-model:value=\"formValue.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
case FormModeUploadFile:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <UploadFile :maxNumber=\"1\" v-model:value=\"params.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <UploadFile :maxNumber=\"1\" v-model:value=\"formValue.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
case FormModeUploadFiles:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <UploadFile :maxNumber=\"10\" v-model:value=\"params.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <UploadFile :maxNumber=\"10\" v-model:value=\"formValue.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
case FormModeSwitch:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-switch :unchecked-value=\"2\" :checked-value=\"1\" v-model:value=\"params.%s\"\n />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-switch :unchecked-value=\"2\" :checked-value=\"1\" v-model:value=\"formValue.%s\"\n />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
case FormModeRate:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-rate allow-half :default-value=\"params.%s\" :on-update:value=\"update%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName, field.GoName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-rate allow-half :default-value=\"formValue.%s\" :on-update:value=\"update%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName, field.GoName)
case FormModeCitySelector:
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <CitySelector v-model:value=\"params.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <CitySelector v-model:value=\"formValue.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
default:
component = defaultComponent
@@ -120,21 +120,21 @@ func (l *gCurd) generateWebEditScript(ctx context.Context, in *CurdPreviewInput)
)
if in.options.Step.HasMaxSort {
importBuffer.WriteString(" import { onMounted, ref, computed, watch } from 'vue';\n")
importBuffer.WriteString(" import { ref } from 'vue';\n")
if in.Config.Application.Crud.Templates[in.In.GenTemplate].IsAddon {
importBuffer.WriteString(" import { Edit, MaxSort, View } from '@/api/addons/" + in.In.AddonName + "/" + gstr.LcFirst(in.In.VarName) + "';\n")
} else {
importBuffer.WriteString(" import { Edit, MaxSort, View } from '@/api/" + gstr.LcFirst(in.In.VarName) + "';\n")
}
setupBuffer.WriteString(" function loadForm(value) {\n loading.value = true;\n\n // 新增\n if (value.id < 1) {\n params.value = newState(value);\n MaxSort()\n .then((res) => {\n params.value.sort = res.sort;\n })\n .finally(() => {\n loading.value = false;\n });\n return;\n }\n\n // 编辑\n View({ id: value.id })\n .then((res) => {\n params.value = res;\n })\n .finally(() => {\n loading.value = false;\n });\n }\n\n watch(\n () => props.formParams,\n (value) => {\n loadForm(value);\n }\n );")
setupBuffer.WriteString(" function openModal(state: State) {\n adaModalWidth(dialogWidth);\n showModal.value = true;\n loading.value = true;\n\n // 新增\n if (!state || state.id < 1) {\n formValue.value = newState(state);\n MaxSort()\n .then((res) => {\n formValue.value.sort = res.sort;\n })\n .finally(() => {\n loading.value = false;\n });\n return;\n }\n\n // 编辑\n View({ id: state.id })\n .then((res) => {\n formValue.value = res;\n })\n .finally(() => {\n loading.value = false;\n });\n }")
} else {
importBuffer.WriteString(" import { onMounted, ref, computed, watch } from 'vue';\n")
importBuffer.WriteString(" import { ref } from 'vue';\n")
if in.Config.Application.Crud.Templates[in.In.GenTemplate].IsAddon {
importBuffer.WriteString(" import { Edit, View } from '@/api/addons/" + in.In.AddonName + "/" + gstr.LcFirst(in.In.VarName) + "';\n")
} else {
importBuffer.WriteString(" import { Edit, View } from '@/api/" + gstr.LcFirst(in.In.VarName) + "';\n")
}
setupBuffer.WriteString(" function loadForm(value) {\n // 新增\n if (value.id < 1) {\n params.value = newState(value);\n loading.value = false;\n return;\n }\n\n loading.value = true;\n // 编辑\n View({ id: value.id })\n .then((res) => {\n params.value = res;\n })\n .finally(() => {\n loading.value = false;\n });\n }\n\n watch(\n () => props.formParams,\n (value) => {\n loadForm(value);\n }\n );")
setupBuffer.WriteString(" function openModal(state: State) {\n adaModalWidth(dialogWidth);\n showModal.value = true;\n loading.value = true;\n\n // 新增\n if (!state || state.id < 1) {\n formValue.value = newState(state);\n return;\n }\n\n // 编辑\n View({ id: state.id })\n .then((res) => {\n formValue.value = res;\n })\n .finally(() => {\n loading.value = false;\n });\n }")
}
for _, field := range in.masterFields {
@@ -159,7 +159,7 @@ func (l *gCurd) generateWebEditScript(ctx context.Context, in *CurdPreviewInput)
importBuffer.WriteString(" import UploadFile from '@/components/Upload/uploadFile.vue';\n")
}
case FormModeRate:
setupBuffer.WriteString(fmt.Sprintf(" function update%s(num) {\n params.value.%s = num;\n }\n", field.GoName, field.TsName))
setupBuffer.WriteString(fmt.Sprintf(" function update%s(num) {\n formValue.value.%s = num;\n }\n", field.GoName, field.TsName))
case FormModeCitySelector:
if !gstr.Contains(importBuffer.String(), `import CitySelector`) {
importBuffer.WriteString(" import CitySelector from '@/components/CitySelector/citySelector.vue';\n")

View File

@@ -22,7 +22,6 @@ const (
func (l *gCurd) webModelTplData(ctx context.Context, in *CurdPreviewInput) (data g.Map, err error) {
data = make(g.Map)
data["state"] = l.generateWebModelState(ctx, in)
data["defaultState"] = l.generateWebModelDefaultState(ctx, in)
data["rules"] = l.generateWebModelRules(ctx, in)
data["formSchema"] = l.generateWebModelFormSchema(ctx, in)
if data["columns"], err = l.generateWebModelColumns(ctx, in); err != nil {
@@ -33,18 +32,7 @@ func (l *gCurd) webModelTplData(ctx context.Context, in *CurdPreviewInput) (data
func (l *gCurd) generateWebModelState(ctx context.Context, in *CurdPreviewInput) string {
buffer := bytes.NewBuffer(nil)
buffer.WriteString("export interface State {\n")
for _, field := range in.masterFields {
buffer.WriteString(fmt.Sprintf(" %s: %s;\n", field.TsName, field.TsType))
}
buffer.WriteString("}")
return buffer.String()
}
func (l *gCurd) generateWebModelDefaultState(ctx context.Context, in *CurdPreviewInput) string {
buffer := bytes.NewBuffer(nil)
buffer.WriteString("export const defaultState: State = {\n")
buffer.WriteString("export class State {\n")
for _, field := range in.masterFields {
var value = field.DefaultValue
if value == nil {
@@ -56,10 +44,9 @@ func (l *gCurd) generateWebModelDefaultState(ctx context.Context, in *CurdPrevie
if field.Name == "status" {
value = 1
}
buffer.WriteString(fmt.Sprintf(" %s: %v,\n", field.TsName, value))
buffer.WriteString(fmt.Sprintf(" public %s = %v; // %s\n", field.TsName, value, field.Dc))
}
buffer.WriteString("};")
buffer.WriteString("}")
return buffer.String()
}
@@ -107,8 +94,10 @@ func (l *gCurd) generateWebModelDictOptions(ctx context.Context, in *CurdPreview
switchLoadOptions string
)
interfaceOptionsBuffer := bytes.NewBuffer(nil)
interfaceOptionsBuffer.WriteString("export interface IOptions extends Options {\n")
constOptionsBuffer := bytes.NewBuffer(nil)
constOptionsBuffer.WriteString("export const options = ref<Options>({\n")
constOptionsBuffer.WriteString("export const options = ref<IOptions>({\n")
for _, v := range dictTypeList {
// 字段映射字典
@@ -120,14 +109,17 @@ func (l *gCurd) generateWebModelDictOptions(ctx context.Context, in *CurdPreview
}
awaitLoadOptions = fmt.Sprintf("%s '%s',\n", awaitLoadOptions, v.Type)
interfaceOptionsBuffer.WriteString(" " + v.Type + ": Option[]; \n")
constOptionsBuffer.WriteString(" " + v.Type + ": [],\n")
}
interfaceOptionsBuffer.WriteString("};\n")
constOptionsBuffer.WriteString("});\n")
loadOptionsBuffer := bytes.NewBuffer(nil)
loadOptionsBuffer.WriteString(fmt.Sprintf(ModelLoadOptionsTemplate, awaitLoadOptions, switchLoadOptions))
options["interface"] = interfaceOptionsBuffer.String()
options["const"] = constOptionsBuffer.String()
options["load"] = loadOptionsBuffer.String()

View File

@@ -197,7 +197,7 @@ func (s *sAdminRole) Edit(ctx context.Context, in *adminin.RoleEditInp) (err err
}
func updateRoleChildrenTree(ctx context.Context, _id int64, _level int, _tree string) (err error) {
var list []*entity.AdminDept
var list []*entity.AdminRole
if err = dao.AdminRole.Ctx(ctx).Where("pid", _id).Scan(&list); err != nil {
return
}

View File

@@ -147,10 +147,6 @@ func (s *sSysDictData) GetTypes(ctx context.Context, id int64) (types []string,
// Select 获取列表
func (s *sSysDictData) Select(ctx context.Context, in *sysin.DataSelectInp) (list sysin.DataSelectModel, err error) {
mod := dao.SysDictData.Ctx(ctx).Where("type", in.Type)
if in.Type != "" {
mod = mod.Where("type", in.Type)
}
if err = mod.Order("sort asc,id desc").Scan(&list); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return

View File

@@ -18,6 +18,7 @@ import (
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/library/contexts"
"hotgo/internal/library/hgorm/handler"
"hotgo/internal/library/hgorm/hook"
"hotgo/internal/library/location"
"hotgo/internal/library/queue"
@@ -236,7 +237,7 @@ func (s *sSysLog) AnalysisLog(ctx context.Context) entity.SysLog {
// View 获取指定字典类型信息
func (s *sSysLog) View(ctx context.Context, in *sysin.LogViewInp) (res *sysin.LogViewModel, err error) {
if err = dao.SysLog.Ctx(ctx).Hook(hook.CityLabel).Where("id", in.Id).Scan(&res); err != nil {
if err = dao.SysLog.Ctx(ctx).Handler(handler.FilterAuth).Hook(hook.CityLabel).Where("id", in.Id).Scan(&res); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return
}
@@ -253,13 +254,13 @@ func (s *sSysLog) View(ctx context.Context, in *sysin.LogViewInp) (res *sysin.Lo
// Delete 删除
func (s *sSysLog) Delete(ctx context.Context, in *sysin.LogDeleteInp) (err error) {
_, err = dao.SysLog.Ctx(ctx).Where("id", in.Id).Delete()
_, err = dao.SysLog.Ctx(ctx).Handler(handler.FilterAuth).Where("id", in.Id).Delete()
return
}
// List 列表
func (s *sSysLog) List(ctx context.Context, in *sysin.LogListInp) (list []*sysin.LogListModel, totalCount int, err error) {
mod := dao.SysLog.Ctx(ctx).FieldsEx("get_data", "header_data", "post_data")
mod := dao.SysLog.Ctx(ctx).Handler(handler.FilterAuth).FieldsEx("get_data", "header_data", "post_data")
// 访问路径
if in.Url != "" {

View File

@@ -18,6 +18,167 @@ import (
)
type (
ISysCurdDemo interface {
// Model 生成演示ORM模型
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
// List 获取生成演示列表
List(ctx context.Context, in *sysin.CurdDemoListInp) (list []*sysin.CurdDemoListModel, totalCount int, err error)
// Export 导出生成演示
Export(ctx context.Context, in *sysin.CurdDemoListInp) (err error)
// Edit 修改/新增生成演示
Edit(ctx context.Context, in *sysin.CurdDemoEditInp) (err error)
// Delete 删除生成演示
Delete(ctx context.Context, in *sysin.CurdDemoDeleteInp) (err error)
// MaxSort 获取生成演示最大排序
MaxSort(ctx context.Context, in *sysin.CurdDemoMaxSortInp) (res *sysin.CurdDemoMaxSortModel, err error)
// View 获取生成演示指定信息
View(ctx context.Context, in *sysin.CurdDemoViewInp) (res *sysin.CurdDemoViewModel, err error)
// Status 更新生成演示状态
Status(ctx context.Context, in *sysin.CurdDemoStatusInp) (err error)
// Switch 更新生成演示开关
Switch(ctx context.Context, in *sysin.CurdDemoSwitchInp) (err error)
}
ISysDictData interface {
// Delete 删除
Delete(ctx context.Context, in *sysin.DictDataDeleteInp) error
// Edit 修改/新增
Edit(ctx context.Context, in *sysin.DictDataEditInp) (err error)
// List 获取列表
List(ctx context.Context, in *sysin.DictDataListInp) (list []*sysin.DictDataListModel, totalCount int, err error)
// GetId 获取指定类型的ID
GetId(ctx context.Context, t string) (id int64, err error)
// GetType 获取指定ID的类型标识
GetType(ctx context.Context, id int64) (types string, err error)
// GetTypes 获取指定ID的所有类型标识包含下级
GetTypes(ctx context.Context, id int64) (types []string, err error)
// Select 获取列表
Select(ctx context.Context, in *sysin.DataSelectInp) (list sysin.DataSelectModel, err error)
}
ISysEmsLog interface {
// Delete 删除
Delete(ctx context.Context, in *sysin.EmsLogDeleteInp) (err error)
// Edit 修改/新增
Edit(ctx context.Context, in *sysin.EmsLogEditInp) (err error)
// Status 更新部门状态
Status(ctx context.Context, in *sysin.EmsLogStatusInp) (err error)
// View 获取指定字典类型信息
View(ctx context.Context, in *sysin.EmsLogViewInp) (res *sysin.EmsLogViewModel, err error)
// List 获取列表
List(ctx context.Context, in *sysin.EmsLogListInp) (list []*sysin.EmsLogListModel, totalCount int, err error)
// Send 发送邮件
Send(ctx context.Context, in *sysin.SendEmsInp) (err error)
// GetTemplate 获取指定邮件模板
GetTemplate(ctx context.Context, template string, config *model.EmailConfig) (val string, err error)
// AllowSend 是否允许发送
AllowSend(ctx context.Context, models *entity.SysEmsLog, config *model.EmailConfig) (err error)
// NowDayCount 当天发送次数
NowDayCount(ctx context.Context, event, email string) (count int, err error)
// VerifyCode 效验验证码
VerifyCode(ctx context.Context, in *sysin.VerifyEmsCodeInp) (err error)
}
ISysLoginLog interface {
// Model 登录日志Orm模型
Model(ctx context.Context) *gdb.Model
// List 获取登录日志列表
List(ctx context.Context, in *sysin.LoginLogListInp) (list []*sysin.LoginLogListModel, totalCount int, err error)
// Export 导出登录日志
Export(ctx context.Context, in *sysin.LoginLogListInp) (err error)
// Delete 删除登录日志
Delete(ctx context.Context, in *sysin.LoginLogDeleteInp) (err error)
// View 获取登录日志指定信息
View(ctx context.Context, in *sysin.LoginLogViewInp) (res *sysin.LoginLogViewModel, err error)
// Push 推送登录日志
Push(ctx context.Context, in *sysin.LoginLogPushInp)
// RealWrite 真实写入
RealWrite(ctx context.Context, models entity.SysLoginLog) (err error)
}
ISysAddons interface {
// List 获取列表
List(ctx context.Context, in *sysin.AddonsListInp) (list []*sysin.AddonsListModel, totalCount int, err error)
// Selects 选项
Selects(ctx context.Context, in *sysin.AddonsSelectsInp) (res *sysin.AddonsSelectsModel, err error)
// Build 提交生成
Build(ctx context.Context, in *sysin.AddonsBuildInp) (err error)
// Install 安装模块
Install(ctx context.Context, in *sysin.AddonsInstallInp) (err error)
// Upgrade 更新模块
Upgrade(ctx context.Context, in *sysin.AddonsUpgradeInp) (err error)
// UnInstall 卸载模块
UnInstall(ctx context.Context, in *sysin.AddonsUnInstallInp) (err error)
}
ISysAttachment interface {
// Model ORM模型
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
// Delete 删除附件
Delete(ctx context.Context, in *sysin.AttachmentDeleteInp) (err error)
// View 获取附件信息
View(ctx context.Context, in *sysin.AttachmentViewInp) (res *sysin.AttachmentViewModel, err error)
// List 获取附件列表
List(ctx context.Context, in *sysin.AttachmentListInp) (list []*sysin.AttachmentListModel, totalCount int, err error)
// ClearKind 清空上传类型
ClearKind(ctx context.Context, in *sysin.AttachmentClearKindInp) (err error)
}
ISysCron interface {
StartCron(ctx context.Context)
// Delete 删除
Delete(ctx context.Context, in *sysin.CronDeleteInp) (err error)
// Edit 修改/新增
Edit(ctx context.Context, in *sysin.CronEditInp) (err error)
// Status 更新状态
Status(ctx context.Context, in *sysin.CronStatusInp) (err error)
// MaxSort 最大排序
MaxSort(ctx context.Context, in *sysin.CronMaxSortInp) (res *sysin.CronMaxSortModel, err error)
// View 获取指定信息
View(ctx context.Context, in *sysin.CronViewInp) (res *sysin.CronViewModel, err error)
// List 获取列表
List(ctx context.Context, in *sysin.CronListInp) (list []*sysin.CronListModel, totalCount int, err error)
// GetName 获取分组名称
GetName(ctx context.Context, id int64) (name string, err error)
// OnlineExec 在线执行
OnlineExec(ctx context.Context, in *sysin.OnlineExecInp) (err error)
// DispatchLog 查看指定任务的调度日志
DispatchLog(ctx context.Context, in *sysin.DispatchLogInp) (res *sysin.DispatchLogModel, err error)
}
ISysServeLicense interface {
// Model 服务许可证ORM模型
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
// List 获取服务许可证列表
List(ctx context.Context, in *sysin.ServeLicenseListInp) (list []*sysin.ServeLicenseListModel, totalCount int, err error)
// Export 导出服务许可证
Export(ctx context.Context, in *sysin.ServeLicenseListInp) (err error)
// Edit 修改/新增服务许可证
Edit(ctx context.Context, in *sysin.ServeLicenseEditInp) (err error)
// Delete 删除服务许可证
Delete(ctx context.Context, in *sysin.ServeLicenseDeleteInp) (err error)
// View 获取服务许可证指定信息
View(ctx context.Context, in *sysin.ServeLicenseViewInp) (res *sysin.ServeLicenseViewModel, err error)
// Status 更新服务许可证状态
Status(ctx context.Context, in *sysin.ServeLicenseStatusInp) (err error)
// AssignRouter 分配服务许可证路由
AssignRouter(ctx context.Context, in *sysin.ServeLicenseAssignRouterInp) (err error)
}
ISysSmsLog interface {
// Delete 删除
Delete(ctx context.Context, in *sysin.SmsLogDeleteInp) (err error)
// Edit 修改/新增
Edit(ctx context.Context, in *sysin.SmsLogEditInp) (err error)
// Status 更新短信状态
Status(ctx context.Context, in *sysin.SmsLogStatusInp) (err error)
// View 获取指定字典类型信息
View(ctx context.Context, in *sysin.SmsLogViewInp) (res *sysin.SmsLogViewModel, err error)
// List 获取列表
List(ctx context.Context, in *sysin.SmsLogListInp) (list []*sysin.SmsLogListModel, totalCount int, err error)
// SendCode 发送验证码
SendCode(ctx context.Context, in *sysin.SendCodeInp) (err error)
// GetTemplate 获取指定短信模板
GetTemplate(ctx context.Context, template string, config *model.SmsConfig) (val string, err error)
// AllowSend 是否允许发送
AllowSend(ctx context.Context, models *entity.SysSmsLog, config *model.SmsConfig) (err error)
// NowDayCount 当天发送次数
NowDayCount(ctx context.Context, event, mobile string) (count int, err error)
// VerifyCode 效验验证码
VerifyCode(ctx context.Context, in *sysin.VerifyCodeInp) (err error)
}
ISysAddonsConfig interface {
// GetConfigByGroup 获取指定分组的配置
GetConfigByGroup(ctx context.Context, in *sysin.GetAddonsConfigInp) (res *sysin.GetAddonsConfigModel, err error)
@@ -46,6 +207,58 @@ type (
// ClusterSync 集群同步
ClusterSync(ctx context.Context, message *gredis.Message)
}
ISysLog interface {
// Export 导出
Export(ctx context.Context, in *sysin.LogListInp) (err error)
// RealWrite 真实写入
RealWrite(ctx context.Context, log entity.SysLog) (err error)
// AutoLog 根据配置自动记录请求日志
AutoLog(ctx context.Context) error
// AnalysisLog 解析日志数据
AnalysisLog(ctx context.Context) entity.SysLog
// View 获取指定字典类型信息
View(ctx context.Context, in *sysin.LogViewInp) (res *sysin.LogViewModel, err error)
// Delete 删除
Delete(ctx context.Context, in *sysin.LogDeleteInp) (err error)
// List 列表
List(ctx context.Context, in *sysin.LogListInp) (list []*sysin.LogListModel, totalCount int, err error)
}
ISysProvinces interface {
// Tree 关系树选项列表
Tree(ctx context.Context) (list []*sysin.ProvincesTree, err error)
// Delete 删除省市区数据
Delete(ctx context.Context, in *sysin.ProvincesDeleteInp) (err error)
// Edit 修改/新增省市区数据
Edit(ctx context.Context, in *sysin.ProvincesEditInp) (err error)
// Status 更新省市区状态
Status(ctx context.Context, in *sysin.ProvincesStatusInp) (err error)
// MaxSort 最大排序
MaxSort(ctx context.Context, in *sysin.ProvincesMaxSortInp) (res *sysin.ProvincesMaxSortModel, err error)
// View 获取省市区信息
View(ctx context.Context, in *sysin.ProvincesViewInp) (res *sysin.ProvincesViewModel, err error)
// List 获取列表
List(ctx context.Context, in *sysin.ProvincesListInp) (list []*sysin.ProvincesListModel, totalCount int, err error)
// ChildrenList 获取省市区下级列表
ChildrenList(ctx context.Context, in *sysin.ProvincesChildrenListInp) (list []*sysin.ProvincesChildrenListModel, totalCount int, err error)
// UniqueId 获取省市区下级列表
UniqueId(ctx context.Context, in *sysin.ProvincesUniqueIdInp) (res *sysin.ProvincesUniqueIdModel, err error)
// Select 省市区选项
Select(ctx context.Context, in *sysin.ProvincesSelectInp) (res *sysin.ProvincesSelectModel, err error)
}
ISysServeLog interface {
// Model 服务日志Orm模型
Model(ctx context.Context) *gdb.Model
// List 获取服务日志列表
List(ctx context.Context, in *sysin.ServeLogListInp) (list []*sysin.ServeLogListModel, totalCount int, err error)
// Export 导出服务日志
Export(ctx context.Context, in *sysin.ServeLogListInp) (err error)
// Delete 删除服务日志
Delete(ctx context.Context, in *sysin.ServeLogDeleteInp) (err error)
// View 获取服务日志指定信息
View(ctx context.Context, in *sysin.ServeLogViewInp) (res *sysin.ServeLogViewModel, err error)
// RealWrite 真实写入
RealWrite(ctx context.Context, models entity.SysServeLog) (err error)
}
ISysConfig interface {
// InitConfig 初始化系统配置
InitConfig(ctx context.Context)
@@ -104,64 +317,6 @@ type (
// Select 选项
Select(ctx context.Context, in *sysin.CronGroupSelectInp) (res *sysin.CronGroupSelectModel, err error)
}
ISysCurdDemo interface {
// Model 生成演示ORM模型
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
// List 获取生成演示列表
List(ctx context.Context, in *sysin.CurdDemoListInp) (list []*sysin.CurdDemoListModel, totalCount int, err error)
// Export 导出生成演示
Export(ctx context.Context, in *sysin.CurdDemoListInp) (err error)
// Edit 修改/新增生成演示
Edit(ctx context.Context, in *sysin.CurdDemoEditInp) (err error)
// Delete 删除生成演示
Delete(ctx context.Context, in *sysin.CurdDemoDeleteInp) (err error)
// MaxSort 获取生成演示最大排序
MaxSort(ctx context.Context, in *sysin.CurdDemoMaxSortInp) (res *sysin.CurdDemoMaxSortModel, err error)
// View 获取生成演示指定信息
View(ctx context.Context, in *sysin.CurdDemoViewInp) (res *sysin.CurdDemoViewModel, err error)
// Status 更新生成演示状态
Status(ctx context.Context, in *sysin.CurdDemoStatusInp) (err error)
// Switch 更新生成演示开关
Switch(ctx context.Context, in *sysin.CurdDemoSwitchInp) (err error)
}
ISysLog interface {
// Export 导出
Export(ctx context.Context, in *sysin.LogListInp) (err error)
// RealWrite 真实写入
RealWrite(ctx context.Context, log entity.SysLog) (err error)
// AutoLog 根据配置自动记录请求日志
AutoLog(ctx context.Context) error
// AnalysisLog 解析日志数据
AnalysisLog(ctx context.Context) entity.SysLog
// View 获取指定字典类型信息
View(ctx context.Context, in *sysin.LogViewInp) (res *sysin.LogViewModel, err error)
// Delete 删除
Delete(ctx context.Context, in *sysin.LogDeleteInp) (err error)
// List 列表
List(ctx context.Context, in *sysin.LogListInp) (list []*sysin.LogListModel, totalCount int, err error)
}
ISysSmsLog interface {
// Delete 删除
Delete(ctx context.Context, in *sysin.SmsLogDeleteInp) (err error)
// Edit 修改/新增
Edit(ctx context.Context, in *sysin.SmsLogEditInp) (err error)
// Status 更新短信状态
Status(ctx context.Context, in *sysin.SmsLogStatusInp) (err error)
// View 获取指定字典类型信息
View(ctx context.Context, in *sysin.SmsLogViewInp) (res *sysin.SmsLogViewModel, err error)
// List 获取列表
List(ctx context.Context, in *sysin.SmsLogListInp) (list []*sysin.SmsLogListModel, totalCount int, err error)
// SendCode 发送验证码
SendCode(ctx context.Context, in *sysin.SendCodeInp) (err error)
// GetTemplate 获取指定短信模板
GetTemplate(ctx context.Context, template string, config *model.SmsConfig) (val string, err error)
// AllowSend 是否允许发送
AllowSend(ctx context.Context, models *entity.SysSmsLog, config *model.SmsConfig) (err error)
// NowDayCount 当天发送次数
NowDayCount(ctx context.Context, event, mobile string) (count int, err error)
// VerifyCode 效验验证码
VerifyCode(ctx context.Context, in *sysin.VerifyCodeInp) (err error)
}
ISysDictType interface {
// Tree 树
Tree(ctx context.Context) (list []*sysin.DictTypeTree, err error)
@@ -172,28 +327,6 @@ type (
// TreeSelect 获取类型关系树选项
TreeSelect(ctx context.Context, in *sysin.DictTreeSelectInp) (list []*sysin.DictTypeTree, err error)
}
ISysEmsLog interface {
// Delete 删除
Delete(ctx context.Context, in *sysin.EmsLogDeleteInp) (err error)
// Edit 修改/新增
Edit(ctx context.Context, in *sysin.EmsLogEditInp) (err error)
// Status 更新部门状态
Status(ctx context.Context, in *sysin.EmsLogStatusInp) (err error)
// View 获取指定字典类型信息
View(ctx context.Context, in *sysin.EmsLogViewInp) (res *sysin.EmsLogViewModel, err error)
// List 获取列表
List(ctx context.Context, in *sysin.EmsLogListInp) (list []*sysin.EmsLogListModel, totalCount int, err error)
// Send 发送邮件
Send(ctx context.Context, in *sysin.SendEmsInp) (err error)
// GetTemplate 获取指定邮件模板
GetTemplate(ctx context.Context, template string, config *model.EmailConfig) (val string, err error)
// AllowSend 是否允许发送
AllowSend(ctx context.Context, models *entity.SysEmsLog, config *model.EmailConfig) (err error)
// NowDayCount 当天发送次数
NowDayCount(ctx context.Context, event, email string) (count int, err error)
// VerifyCode 效验验证码
VerifyCode(ctx context.Context, in *sysin.VerifyEmsCodeInp) (err error)
}
ISysGenCodes interface {
// Delete 删除
Delete(ctx context.Context, in *sysin.GenCodesDeleteInp) (err error)
@@ -220,206 +353,29 @@ type (
// Build 提交生成
Build(ctx context.Context, in *sysin.GenCodesBuildInp) (err error)
}
ISysProvinces interface {
// Tree 关系树选项列表
Tree(ctx context.Context) (list []*sysin.ProvincesTree, err error)
// Delete 删除省市区数据
Delete(ctx context.Context, in *sysin.ProvincesDeleteInp) (err error)
// Edit 修改/新增省市区数据
Edit(ctx context.Context, in *sysin.ProvincesEditInp) (err error)
// Status 更新省市区状态
Status(ctx context.Context, in *sysin.ProvincesStatusInp) (err error)
// MaxSort 最大排序
MaxSort(ctx context.Context, in *sysin.ProvincesMaxSortInp) (res *sysin.ProvincesMaxSortModel, err error)
// View 获取省市区信息
View(ctx context.Context, in *sysin.ProvincesViewInp) (res *sysin.ProvincesViewModel, err error)
// List 获取列表
List(ctx context.Context, in *sysin.ProvincesListInp) (list []*sysin.ProvincesListModel, totalCount int, err error)
// ChildrenList 获取省市区下级列表
ChildrenList(ctx context.Context, in *sysin.ProvincesChildrenListInp) (list []*sysin.ProvincesChildrenListModel, totalCount int, err error)
// UniqueId 获取省市区下级列表
UniqueId(ctx context.Context, in *sysin.ProvincesUniqueIdInp) (res *sysin.ProvincesUniqueIdModel, err error)
// Select 省市区选项
Select(ctx context.Context, in *sysin.ProvincesSelectInp) (res *sysin.ProvincesSelectModel, err error)
}
ISysServeLog interface {
// Model 服务日志Orm模型
Model(ctx context.Context) *gdb.Model
// List 获取服务日志列表
List(ctx context.Context, in *sysin.ServeLogListInp) (list []*sysin.ServeLogListModel, totalCount int, err error)
// Export 导出服务日志
Export(ctx context.Context, in *sysin.ServeLogListInp) (err error)
// Delete 删除服务日志
Delete(ctx context.Context, in *sysin.ServeLogDeleteInp) (err error)
// View 获取服务日志指定信息
View(ctx context.Context, in *sysin.ServeLogViewInp) (res *sysin.ServeLogViewModel, err error)
// RealWrite 真实写入
RealWrite(ctx context.Context, models entity.SysServeLog) (err error)
}
ISysAddons interface {
// List 获取列表
List(ctx context.Context, in *sysin.AddonsListInp) (list []*sysin.AddonsListModel, totalCount int, err error)
// Selects 选项
Selects(ctx context.Context, in *sysin.AddonsSelectsInp) (res *sysin.AddonsSelectsModel, err error)
// Build 提交生成
Build(ctx context.Context, in *sysin.AddonsBuildInp) (err error)
// Install 安装模块
Install(ctx context.Context, in *sysin.AddonsInstallInp) (err error)
// Upgrade 更新模块
Upgrade(ctx context.Context, in *sysin.AddonsUpgradeInp) (err error)
// UnInstall 卸载模块
UnInstall(ctx context.Context, in *sysin.AddonsUnInstallInp) (err error)
}
ISysAttachment interface {
// Model ORM模型
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
// Delete 删除附件
Delete(ctx context.Context, in *sysin.AttachmentDeleteInp) (err error)
// View 获取附件信息
View(ctx context.Context, in *sysin.AttachmentViewInp) (res *sysin.AttachmentViewModel, err error)
// List 获取附件列表
List(ctx context.Context, in *sysin.AttachmentListInp) (list []*sysin.AttachmentListModel, totalCount int, err error)
// ClearKind 清空上传类型
ClearKind(ctx context.Context, in *sysin.AttachmentClearKindInp) (err error)
}
ISysCron interface {
StartCron(ctx context.Context)
// Delete 删除
Delete(ctx context.Context, in *sysin.CronDeleteInp) (err error)
// Edit 修改/新增
Edit(ctx context.Context, in *sysin.CronEditInp) (err error)
// Status 更新状态
Status(ctx context.Context, in *sysin.CronStatusInp) (err error)
// MaxSort 最大排序
MaxSort(ctx context.Context, in *sysin.CronMaxSortInp) (res *sysin.CronMaxSortModel, err error)
// View 获取指定信息
View(ctx context.Context, in *sysin.CronViewInp) (res *sysin.CronViewModel, err error)
// List 获取列表
List(ctx context.Context, in *sysin.CronListInp) (list []*sysin.CronListModel, totalCount int, err error)
// GetName 获取分组名称
GetName(ctx context.Context, id int64) (name string, err error)
// OnlineExec 在线执行
OnlineExec(ctx context.Context, in *sysin.OnlineExecInp) (err error)
// DispatchLog 查看指定任务的调度日志
DispatchLog(ctx context.Context, in *sysin.DispatchLogInp) (res *sysin.DispatchLogModel, err error)
}
ISysDictData interface {
// Delete 删除
Delete(ctx context.Context, in *sysin.DictDataDeleteInp) error
// Edit 修改/新增
Edit(ctx context.Context, in *sysin.DictDataEditInp) (err error)
// List 获取列表
List(ctx context.Context, in *sysin.DictDataListInp) (list []*sysin.DictDataListModel, totalCount int, err error)
// GetId 获取指定类型的ID
GetId(ctx context.Context, t string) (id int64, err error)
// GetType 获取指定ID的类型标识
GetType(ctx context.Context, id int64) (types string, err error)
// GetTypes 获取指定ID的所有类型标识包含下级
GetTypes(ctx context.Context, id int64) (types []string, err error)
// Select 获取列表
Select(ctx context.Context, in *sysin.DataSelectInp) (list sysin.DataSelectModel, err error)
}
ISysLoginLog interface {
// Model 登录日志Orm模型
Model(ctx context.Context) *gdb.Model
// List 获取登录日志列表
List(ctx context.Context, in *sysin.LoginLogListInp) (list []*sysin.LoginLogListModel, totalCount int, err error)
// Export 导出登录日志
Export(ctx context.Context, in *sysin.LoginLogListInp) (err error)
// Delete 删除登录日志
Delete(ctx context.Context, in *sysin.LoginLogDeleteInp) (err error)
// View 获取登录日志指定信息
View(ctx context.Context, in *sysin.LoginLogViewInp) (res *sysin.LoginLogViewModel, err error)
// Push 推送登录日志
Push(ctx context.Context, in *sysin.LoginLogPushInp)
// RealWrite 真实写入
RealWrite(ctx context.Context, models entity.SysLoginLog) (err error)
}
ISysServeLicense interface {
// Model 服务许可证ORM模型
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
// List 获取服务许可证列表
List(ctx context.Context, in *sysin.ServeLicenseListInp) (list []*sysin.ServeLicenseListModel, totalCount int, err error)
// Export 导出服务许可证
Export(ctx context.Context, in *sysin.ServeLicenseListInp) (err error)
// Edit 修改/新增服务许可证
Edit(ctx context.Context, in *sysin.ServeLicenseEditInp) (err error)
// Delete 删除服务许可证
Delete(ctx context.Context, in *sysin.ServeLicenseDeleteInp) (err error)
// View 获取服务许可证指定信息
View(ctx context.Context, in *sysin.ServeLicenseViewInp) (res *sysin.ServeLicenseViewModel, err error)
// Status 更新服务许可证状态
Status(ctx context.Context, in *sysin.ServeLicenseStatusInp) (err error)
// AssignRouter 分配服务许可证路由
AssignRouter(ctx context.Context, in *sysin.ServeLicenseAssignRouterInp) (err error)
}
)
var (
localSysAddons ISysAddons
localSysAttachment ISysAttachment
localSysCurdDemo ISysCurdDemo
localSysLog ISysLog
localSysDictData ISysDictData
localSysEmsLog ISysEmsLog
localSysLoginLog ISysLoginLog
localSysAddonsConfig ISysAddonsConfig
localSysBlacklist ISysBlacklist
localSysCron ISysCron
localSysServeLicense ISysServeLicense
localSysSmsLog ISysSmsLog
localSysConfig ISysConfig
localSysCronGroup ISysCronGroup
localSysLog ISysLog
localSysProvinces ISysProvinces
localSysServeLog ISysServeLog
localSysDictType ISysDictType
localSysEmsLog ISysEmsLog
localSysGenCodes ISysGenCodes
localSysDictData ISysDictData
localSysLoginLog ISysLoginLog
localSysServeLicense ISysServeLicense
localSysAddons ISysAddons
localSysAttachment ISysAttachment
localSysCron ISysCron
localSysCronGroup ISysCronGroup
localSysAddonsConfig ISysAddonsConfig
localSysBlacklist ISysBlacklist
localSysConfig ISysConfig
)
func SysDictData() ISysDictData {
if localSysDictData == nil {
panic("implement not found for interface ISysDictData, forgot register?")
}
return localSysDictData
}
func RegisterSysDictData(i ISysDictData) {
localSysDictData = i
}
func SysLoginLog() ISysLoginLog {
if localSysLoginLog == nil {
panic("implement not found for interface ISysLoginLog, forgot register?")
}
return localSysLoginLog
}
func RegisterSysLoginLog(i ISysLoginLog) {
localSysLoginLog = i
}
func SysServeLicense() ISysServeLicense {
if localSysServeLicense == nil {
panic("implement not found for interface ISysServeLicense, forgot register?")
}
return localSysServeLicense
}
func RegisterSysServeLicense(i ISysServeLicense) {
localSysServeLicense = i
}
func SysAddons() ISysAddons {
if localSysAddons == nil {
panic("implement not found for interface ISysAddons, forgot register?")
}
return localSysAddons
}
func RegisterSysAddons(i ISysAddons) {
localSysAddons = i
}
func SysAttachment() ISysAttachment {
if localSysAttachment == nil {
panic("implement not found for interface ISysAttachment, forgot register?")
@@ -431,61 +387,6 @@ func RegisterSysAttachment(i ISysAttachment) {
localSysAttachment = i
}
func SysCron() ISysCron {
if localSysCron == nil {
panic("implement not found for interface ISysCron, forgot register?")
}
return localSysCron
}
func RegisterSysCron(i ISysCron) {
localSysCron = i
}
func SysCronGroup() ISysCronGroup {
if localSysCronGroup == nil {
panic("implement not found for interface ISysCronGroup, forgot register?")
}
return localSysCronGroup
}
func RegisterSysCronGroup(i ISysCronGroup) {
localSysCronGroup = i
}
func SysAddonsConfig() ISysAddonsConfig {
if localSysAddonsConfig == nil {
panic("implement not found for interface ISysAddonsConfig, forgot register?")
}
return localSysAddonsConfig
}
func RegisterSysAddonsConfig(i ISysAddonsConfig) {
localSysAddonsConfig = i
}
func SysBlacklist() ISysBlacklist {
if localSysBlacklist == nil {
panic("implement not found for interface ISysBlacklist, forgot register?")
}
return localSysBlacklist
}
func RegisterSysBlacklist(i ISysBlacklist) {
localSysBlacklist = i
}
func SysConfig() ISysConfig {
if localSysConfig == nil {
panic("implement not found for interface ISysConfig, forgot register?")
}
return localSysConfig
}
func RegisterSysConfig(i ISysConfig) {
localSysConfig = i
}
func SysCurdDemo() ISysCurdDemo {
if localSysCurdDemo == nil {
panic("implement not found for interface ISysCurdDemo, forgot register?")
@@ -497,15 +398,81 @@ func RegisterSysCurdDemo(i ISysCurdDemo) {
localSysCurdDemo = i
}
func SysLog() ISysLog {
if localSysLog == nil {
panic("implement not found for interface ISysLog, forgot register?")
func SysDictData() ISysDictData {
if localSysDictData == nil {
panic("implement not found for interface ISysDictData, forgot register?")
}
return localSysLog
return localSysDictData
}
func RegisterSysLog(i ISysLog) {
localSysLog = i
func RegisterSysDictData(i ISysDictData) {
localSysDictData = i
}
func SysEmsLog() ISysEmsLog {
if localSysEmsLog == nil {
panic("implement not found for interface ISysEmsLog, forgot register?")
}
return localSysEmsLog
}
func RegisterSysEmsLog(i ISysEmsLog) {
localSysEmsLog = i
}
func SysLoginLog() ISysLoginLog {
if localSysLoginLog == nil {
panic("implement not found for interface ISysLoginLog, forgot register?")
}
return localSysLoginLog
}
func RegisterSysLoginLog(i ISysLoginLog) {
localSysLoginLog = i
}
func SysAddons() ISysAddons {
if localSysAddons == nil {
panic("implement not found for interface ISysAddons, forgot register?")
}
return localSysAddons
}
func RegisterSysAddons(i ISysAddons) {
localSysAddons = i
}
func SysBlacklist() ISysBlacklist {
if localSysBlacklist == nil {
panic("implement not found for interface ISysBlacklist, forgot register?")
}
return localSysBlacklist
}
func RegisterSysBlacklist(i ISysBlacklist) {
localSysBlacklist = i
}
func SysCron() ISysCron {
if localSysCron == nil {
panic("implement not found for interface ISysCron, forgot register?")
}
return localSysCron
}
func RegisterSysCron(i ISysCron) {
localSysCron = i
}
func SysServeLicense() ISysServeLicense {
if localSysServeLicense == nil {
panic("implement not found for interface ISysServeLicense, forgot register?")
}
return localSysServeLicense
}
func RegisterSysServeLicense(i ISysServeLicense) {
localSysServeLicense = i
}
func SysSmsLog() ISysSmsLog {
@@ -519,6 +486,39 @@ func RegisterSysSmsLog(i ISysSmsLog) {
localSysSmsLog = i
}
func SysAddonsConfig() ISysAddonsConfig {
if localSysAddonsConfig == nil {
panic("implement not found for interface ISysAddonsConfig, forgot register?")
}
return localSysAddonsConfig
}
func RegisterSysAddonsConfig(i ISysAddonsConfig) {
localSysAddonsConfig = i
}
func SysCronGroup() ISysCronGroup {
if localSysCronGroup == nil {
panic("implement not found for interface ISysCronGroup, forgot register?")
}
return localSysCronGroup
}
func RegisterSysCronGroup(i ISysCronGroup) {
localSysCronGroup = i
}
func SysLog() ISysLog {
if localSysLog == nil {
panic("implement not found for interface ISysLog, forgot register?")
}
return localSysLog
}
func RegisterSysLog(i ISysLog) {
localSysLog = i
}
func SysProvinces() ISysProvinces {
if localSysProvinces == nil {
panic("implement not found for interface ISysProvinces, forgot register?")
@@ -541,26 +541,15 @@ func RegisterSysServeLog(i ISysServeLog) {
localSysServeLog = i
}
func SysDictType() ISysDictType {
if localSysDictType == nil {
panic("implement not found for interface ISysDictType, forgot register?")
func SysConfig() ISysConfig {
if localSysConfig == nil {
panic("implement not found for interface ISysConfig, forgot register?")
}
return localSysDictType
return localSysConfig
}
func RegisterSysDictType(i ISysDictType) {
localSysDictType = i
}
func SysEmsLog() ISysEmsLog {
if localSysEmsLog == nil {
panic("implement not found for interface ISysEmsLog, forgot register?")
}
return localSysEmsLog
}
func RegisterSysEmsLog(i ISysEmsLog) {
localSysEmsLog = i
func RegisterSysConfig(i ISysConfig) {
localSysConfig = i
}
func SysGenCodes() ISysGenCodes {
@@ -573,3 +562,14 @@ func SysGenCodes() ISysGenCodes {
func RegisterSysGenCodes(i ISysGenCodes) {
localSysGenCodes = i
}
func SysDictType() ISysDictType {
if localSysDictType == nil {
panic("implement not found for interface ISysDictType, forgot register?")
}
return localSysDictType
}
func RegisterSysDictType(i ISysDictType) {
localSysDictType = i
}