diff --git a/apps/develop/entity/dev_gen_table.go b/apps/develop/entity/dev_gen_table.go index 92969f7..1d8e502 100644 --- a/apps/develop/entity/dev_gen_table.go +++ b/apps/develop/entity/dev_gen_table.go @@ -13,7 +13,7 @@ type DevGenTable struct { BusinessName string `gorm:"business_name" json:"businessName"` // 生成业务名 FunctionName string `gorm:"function_name" json:"functionName"` // 生成功能名 FunctionAuthor string `gorm:"function_author" json:"functionAuthor"` // 生成功能作者 - TreeCode string `gorm:"tree_code" json:"treeCode"` + TreeCode string `gorm:"tree_code" json:"treeCode"` TreeParentCode string `gorm:"tree_parent_code" json:"treeParentCode"` TreeName string `gorm:"tree_name" json:"treeName"` Options string `gorm:"options" json:"options"` // 其它生成选项 diff --git a/apps/develop/gen/gen.go b/apps/develop/gen/gen.go index d07f050..178134e 100644 --- a/apps/develop/gen/gen.go +++ b/apps/develop/gen/gen.go @@ -3,6 +3,7 @@ package gen import ( "bytes" "github.com/kakuilan/kgo" + "log" "os" "pandax/apps/develop/entity" "pandax/apps/develop/services" @@ -21,9 +22,9 @@ var ( ColumnTypeStr: []string{"char", "varchar", "narchar", "varchar2", "tinytext", "text", "mediumtext", "longtext"}, ColumnTypeTime: []string{"datetime", "time", "date", "timestamp"}, ColumnTypeNumber: []string{"tinyint", "smallint", "mediumint", "int", "number", "integer", "bigint", "float", "float", "double", "decimal"}, - ColumnNameNotEdit: []string{"id", "created_by", "created_at", "updated_by", "updated_at", "deleted_at"}, - ColumnNameNotList: []string{"id", "created_by", "updated_by", "created_at", "updated_at", "deleted_at"}, - ColumnNameNotQuery: []string{"id", "created_by", "updated_by", "created_at", "updated_at", "deleted_at", "remark"}, + ColumnNameNotEdit: []string{"create_by", "update_by", "create_time", "update_time", "delete_time"}, + ColumnNameNotList: []string{"create_by", "update_by", "update_time", "delete_time"}, + ColumnNameNotQuery: []string{"create_by", "update_by", "create_time", "update_time", "delete_time", "remark"}, } ) @@ -84,6 +85,9 @@ func (s *toolsGenTableColumn) IsNumberObject(dataType string) bool { // IsNotEdit 是否不可编辑 func (s *toolsGenTableColumn) IsNotEdit(name string) bool { + if strings.Contains(name, "id") { + return true + } return s.IsExistInArray(name, s.ColumnNameNotEdit) } @@ -173,14 +177,12 @@ func (s *toolsGenTableColumn) GenTableInit(tableName string) entity.DevGenTable strEnd := string([]byte(tableNameList[i])[1:]) // 大驼峰表名 结构体使用 data.ClassName += strings.ToUpper(strStart) + strEnd - // 小驼峰表名 js函数名和权限标识使用 - if i == 0 { + // js函数名和权限标识使用 + if i >= 1 { data.BusinessName += strings.ToLower(strStart) + strEnd - } else { - data.BusinessName += strings.ToUpper(strStart) + strEnd } } - data.PackageName = "admin" + data.PackageName = "system" data.TplCategory = "crud" // 中横线表名称,接口路径、前端文件夹名称和js名称使用 data.ModuleName = strings.Replace(tableName, "_", "-", -1) @@ -188,11 +190,11 @@ func (s *toolsGenTableColumn) GenTableInit(tableName string) entity.DevGenTable dbTable := services.DevGenTableModelDao.FindDbTableOne(tableName) dbColumn := services.DevTableColumnModelDao.FindDbTableColumnList(tableName) - data.TableComment = dbTable.TableComment + data.TableComment = dbTable.TableComment //表描述 if dbTable.TableComment == "" { data.TableComment = data.ClassName } - data.FunctionName = data.TableComment + data.FunctionName = strings.ToUpper(data.BusinessName) data.FunctionAuthor = "panda" wg := sync.WaitGroup{} dcs := *dbColumn @@ -200,6 +202,7 @@ func (s *toolsGenTableColumn) GenTableInit(tableName string) entity.DevGenTable index := i wg.Add(1) go func(wg *sync.WaitGroup, i int) { + log.Println(dcs[i].ColumnName) var column entity.DevGenTableColumn column.ColumnComment = dcs[i].ColumnComment column.ColumnName = dcs[i].ColumnName @@ -229,6 +232,10 @@ func (s *toolsGenTableColumn) GenTableInit(tableName string) entity.DevGenTable } } + if column.ColumnComment == "" { + column.ColumnComment = column.GoField + } + dataType := s.GetDbType(column.ColumnType) if s.IsStringObject(dataType) { //字段为字符串类型 diff --git a/apps/develop/router/gen.go b/apps/develop/router/gen.go index b55428d..b6e0c96 100644 --- a/apps/develop/router/gen.go +++ b/apps/develop/router/gen.go @@ -23,4 +23,9 @@ func InitGenRouter(router *gin.RouterGroup) { gen.GET("code/:tableId", func(c *gin.Context) { ctx.NewReqCtxWithGin(c).WithLog(genCodeLog).Handle(genApi.GenCode) }) + + genConfigureLog := ctx.NewLogInfo("生成配置") + gen.GET("configure/:tableId", func(c *gin.Context) { + ctx.NewReqCtxWithGin(c).WithLog(genConfigureLog).Handle(genApi.GenCode) + }) } diff --git a/apps/develop/services/gen_table.go b/apps/develop/services/gen_table.go index c4580c1..022ae51 100644 --- a/apps/develop/services/gen_table.go +++ b/apps/develop/services/gen_table.go @@ -231,5 +231,6 @@ func (e *devGenTableModelImpl) DeleteTables(tableId int64) bool { func (m *devGenTableModelImpl) Delete(configIds []int64) { err := global.Db.Table(m.table).Delete(&entity.DevGenTable{}, "table_id in (?)", configIds).Error biz.ErrIsNil(err, "删除生成代码信息失败") + DevTableColumnModelDao.Delete(configIds) return } diff --git a/apps/develop/services/gen_table_column.go b/apps/develop/services/gen_table_column.go index 011b0c7..2f4cd8f 100644 --- a/apps/develop/services/gen_table_column.go +++ b/apps/develop/services/gen_table_column.go @@ -22,6 +22,7 @@ type ( Insert(data entity.DevGenTableColumn) *entity.DevGenTableColumn FindList(data entity.DevGenTableColumn, exclude bool) *[]entity.DevGenTableColumn Update(data entity.DevGenTableColumn) *entity.DevGenTableColumn + Delete(tableId []int64) } devTableColumnModelImpl struct { @@ -92,10 +93,10 @@ func (m *devTableColumnModelImpl) FindList(data entity.DevGenTableColumn, exclud notIn = append(notIn, "id") notIn = append(notIn, "create_by") notIn = append(notIn, "update_by") - notIn = append(notIn, "created_at") - notIn = append(notIn, "updated_at") - notIn = append(notIn, "deleted_at") - db = db.Where(" column_name not in(?)", notIn) + notIn = append(notIn, "create_time") + notIn = append(notIn, "update_time") + notIn = append(notIn, "delete_time") + db = db.Where("column_name not in(?)", notIn) } err := db.Find(&list).Error biz.ErrIsNil(err, "查询生成代码字段表信息失败") @@ -107,3 +108,9 @@ func (m *devTableColumnModelImpl) Update(data entity.DevGenTableColumn) *entity. biz.ErrIsNil(err, "修改生成代码字段表失败") return &data } + +func (m *devTableColumnModelImpl) Delete(tableId []int64) { + err := global.Db.Table(m.table).Delete(&entity.DevGenTableColumn{}, "table_id in (?)", tableId).Error + biz.ErrIsNil(err, "删除生成代码字段表失败") + return +} diff --git a/apps/system/entity/tenant.go b/apps/system/entity/tenant.go index 8c0cb05..1536437 100644 --- a/apps/system/entity/tenant.go +++ b/apps/system/entity/tenant.go @@ -12,8 +12,7 @@ import ( **/ type SysTenants struct { - model.BaseModel - TenantId int64 `json:"tenantId" gorm:"primary_key;AUTO_INCREMENT"` + model.BaseAutoModel TenantName string `json:"tenantName" gorm:"type:varchar(255);comment:租户名"` Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"` ExpireTime time.Time `json:"expireTime" gorm:"comment:过期时间"` diff --git a/apps/system/router/tenant.go b/apps/system/router/tenant.go index 5e0712d..bdc39e1 100644 --- a/apps/system/router/tenant.go +++ b/apps/system/router/tenant.go @@ -17,7 +17,7 @@ func InitSysTenantRouter(router *gin.RouterGroup) { s := &api.SysTenantsApi{ SysTenantsApp: services.SysTenantModelDao, } - routerGroup := router.Group("SysTenant") + routerGroup := router.Group("tenant") SysTenantListLog := ctx.NewLogInfo("获取SysTenant分页列表") routerGroup.GET("list", func(c *gin.Context) { diff --git a/apps/system/services/tenant.go b/apps/system/services/tenant.go index 94097b2..9389603 100644 --- a/apps/system/services/tenant.go +++ b/apps/system/services/tenant.go @@ -48,9 +48,11 @@ func (m *SysTenantModelImpl) FindListPage(page, pageSize int, data entity.SysTen var total int64 = 0 offset := pageSize * (page - 1) db := global.Db.Table(m.table) - // 此处填写 where参数判断 - if data.TenantId != 0 { - db = db.Where("tenant_id = ?", data.TenantId) + if data.TenantName != "" { + db = db.Where("tenant_name like ?", "%"+data.TenantName+"%") + } + if data.Id != 0 { + db = db.Where("id = ?", data.Id) } db.Where("delete_time IS NULL") err := db.Count(&total).Error @@ -62,9 +64,11 @@ func (m *SysTenantModelImpl) FindListPage(page, pageSize int, data entity.SysTen func (m *SysTenantModelImpl) FindList(data entity.SysTenants) *[]entity.SysTenants { list := make([]entity.SysTenants, 0) db := global.Db.Table(m.table) - // 此处填写 where参数判断 - if data.TenantId != 0 { - db = db.Where("tenant_id = ?", data.TenantId) + if data.TenantName != "" { + db = db.Where("tenant_name like ?", "%"+data.TenantName+"%") + } + if data.Id != 0 { + db = db.Where("id = ?", data.Id) } db.Where("delete_time IS NULL") biz.ErrIsNil(db.Order("create_time").Find(&list).Error, "查询SysTenant列表失败") diff --git a/base/ginx/ginx.go b/base/ginx/ginx.go index afff781..546120a 100644 --- a/base/ginx/ginx.go +++ b/base/ginx/ginx.go @@ -1,6 +1,7 @@ package ginx import ( + "encoding/json" "net/http" "pandax/base/biz" "pandax/base/global" @@ -23,6 +24,16 @@ func BindQuery(g *gin.Context, data any) { panic(any(biz.NewBizErr(err.Error()))) } } +func ParamsToAny(g *gin.Context, in any) { + vars := make(map[string]any) + for _, v := range g.Params { + vars[v.Key] = v.Value + } + marshal, _ := json.Marshal(vars) + err := json.Unmarshal(marshal, in) + biz.ErrIsNil(err, "error get path value encoding unmarshal") + return +} // 获取分页参数 func GetPageParam(g *gin.Context) *model.PageParam { diff --git a/base/logger/logger.go b/base/logger/logger.go index cbd4ead..acf5240 100644 --- a/base/logger/logger.go +++ b/base/logger/logger.go @@ -28,7 +28,7 @@ func init() { if level := logConf.Level; level != "" { l, err := logrus.ParseLevel(level) if err != nil { - panic(fmt.Sprintf("日志级别不存在: %s", level)) + panic(any(fmt.Sprintf("日志级别不存在: %s", level))) } Log.SetLevel(l) } else { @@ -39,7 +39,7 @@ func init() { //写入文件 file, err := os.OpenFile(logFile.GetFilename(), os.O_CREATE|os.O_APPEND|os.O_WRONLY, os.ModeAppend|0666) if err != nil { - panic(fmt.Sprintf("创建日志文件失败: %s", err.Error())) + panic(any(fmt.Sprintf("创建日志文件失败: %s", err.Error()))) } Log.Out = file diff --git a/base/model/base_model.go b/base/model/base_model.go index 156ea81..faaa5c0 100644 --- a/base/model/base_model.go +++ b/base/model/base_model.go @@ -5,15 +5,29 @@ import ( "time" ) +// BaseAutoModel 使用代码生成需要此,不能自由命名id type BaseAutoModel struct { Id int `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"id" form:"id"` - CreatedAt time.Time `gorm:"column:create_time" json:"create_time" form:"create_time"` - UpdatedAt time.Time `gorm:"column:update_time" json:"update_time" form:"update_time"` + CreatedAt time.Time `gorm:"column:create_time" json:"createTime" form:"createTime"` + UpdatedAt time.Time `gorm:"column:update_time" json:"updateTime" form:"updateTime"` DeletedAt gorm.DeletedAt `gorm:"column:delete_time" sql:"index" json:"-"` } +// BaseAutoModelD 表想要硬删除使用他 +type BaseAutoModelD struct { + Id int `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"id" form:"id"` + CreatedAt time.Time `gorm:"column:create_time" json:"createTime" form:"createTime"` + UpdatedAt time.Time `gorm:"column:update_time" json:"updateTime" form:"updateTime"` +} + type BaseModel struct { - CreatedAt time.Time `gorm:"column:create_time" json:"create_time" form:"create_time"` - UpdatedAt time.Time `gorm:"column:update_time" json:"update_time" form:"update_time"` + CreatedAt time.Time `gorm:"column:create_time" json:"createTime" form:"createTime"` + UpdatedAt time.Time `gorm:"column:update_time" json:"updateTime" form:"updateTime"` DeletedAt gorm.DeletedAt `gorm:"column:delete_time" sql:"index" json:"-"` } + +// BaseModelD 硬删除 +type BaseModelD struct { + CreatedAt time.Time `gorm:"column:create_time" json:"createTime" form:"create_time"` + UpdatedAt time.Time `gorm:"column:update_time" json:"updateTime" form:"update_time"` +} diff --git a/base/oss/aliyun.go b/base/oss/aliyun.go index 421b123..33f3956 100644 --- a/base/oss/aliyun.go +++ b/base/oss/aliyun.go @@ -44,7 +44,7 @@ type aliOss struct { func NewAliOss(c AliConfig) Driver { bucket, err := c.CreateBucket() if err != nil { - panic(err) + panic(any(err)) } return &aliOss{ bucket: bucket, diff --git a/config.yml b/config.yml index 0a241be..b45dfcb 100644 --- a/config.yml +++ b/config.yml @@ -13,7 +13,7 @@ server: rate-num: 100 db-type: mysql # 是否开启数据库表初始化 - isInitTable: true + isInitTable: false excel-dir: ./resource/excel/ tls: enable: false diff --git a/initialize/router.go b/initialize/router.go index ecdf07a..71f525b 100644 --- a/initialize/router.go +++ b/initialize/router.go @@ -62,6 +62,7 @@ func InitRouter() *gin.Engine { // 设置路由组 sys := router.Group("system") { + sysRouter.InitSysTenantRouter(sys) sysRouter.InitSystemRouter(sys) sysRouter.InitDeptRouter(sys) sysRouter.InitConfigRouter(sys) diff --git a/resource/template/go/entity.template b/resource/template/go/entity.template index 5d0e4c3..a00d660 100644 --- a/resource/template/go/entity.template +++ b/resource/template/go/entity.template @@ -13,10 +13,9 @@ package entity {{- end -}} {{if $hasGTime -}}import "time"{{- end }} - type {{.ClassName}} struct { {{range $index, $column := .Columns}} - {{if eq $column.IsPk "1"}} {{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"primary_key;{{if eq $column.IsIncrement "1"}}AUTO_INCREMENT{{end}}" json:"{{$column.JsonField}}"` // {{$column.ColumnComment}} {{else}} {{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"{{$column.ColumnName}};type:{{$column.ColumnType}};comment:{{$column.ColumnComment}}" json:"{{$column.JsonField}}" {{if eq $column.IsRequired "1"}}binding:"required"{{end}}` // {{$column.ColumnComment}} {{end}} + {{if eq $column.IsPk "1"}} {{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"primary_key;{{if eq $column.IsIncrement "1"}}AUTO_INCREMENT{{end}}" json:"{{$column.JsonField}}"` // {{$column.ColumnComment}} {{else}} {{$column.GoField}} {{if eq $column.GoType "Time"}}time.Time{{else}}{{$column.GoType}}{{end}} `gorm:"{{$column.ColumnName}};type:{{$column.ColumnType}};comment:{{$column.ColumnComment}}" json:"{{$column.JsonField}}" {{if eq $column.IsRequired "1"}}binding:"required"{{end}}` // {{$column.ColumnComment}} {{end}} {{end}} } diff --git a/resource/template/go/service.template b/resource/template/go/service.template index 0253d00..d66d438 100644 --- a/resource/template/go/service.template +++ b/resource/template/go/service.template @@ -4,7 +4,7 @@ // 生成人:{{.FunctionAuthor}} // ========================================================================== -package service +package services import ( "pandax/apps/{{.PackageName}}/entity" @@ -53,25 +53,62 @@ func (m *{{.BusinessName}}ModelImpl) FindListPage(page, pageSize int, data entit // 此处填写 where参数判断 {{- range $index, $column := .Columns -}} {{- if eq $column.IsQuery "1" -}} - {{ if eq $column.QueryType "LIKE" }} + {{- if eq $column.QueryType "LIKE" }} if data.{{$column.GoField}} != "" { db = db.Where("{{$column.ColumnName}} like ?", "%"+data.{{$column.GoField}}+"%") } {{- end -}} - {{- if eq $column.QueryType "EQ" -}} + {{- if or (eq $column.QueryType "EQ") (eq $column.QueryType "NE") -}} {{- if eq $column.GoType "string" }} if data.{{$column.GoField}} != "" { - m = m.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}}) + {{- if eq $column.QueryType "EQ" }} + db = db.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "NE"}} + db = db.Where("{{$column.ColumnName}} != ?", data.{{$column.GoField}}) + {{- end }} } {{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }} if data.{{$column.GoField}} != 0 { - m = m.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}}) + {{- if eq $column.QueryType "EQ" }} + db = db.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "NE"}} + db = db.Where("{{$column.ColumnName}} != ?", data.{{$column.GoField}}) + {{- end }} + } + {{- end -}} + {{- end -}} + {{- if or (eq $column.QueryType "GT") (eq $column.QueryType "GTE") (eq $column.QueryType "LT") (eq $column.QueryType "LTE")}} + {{- if eq $column.GoType "Time" }} + if data.{{$column.GoField}}.Unix() > 0 { + {{- if eq $column.QueryType "GT" }} + db = db.Where("{{$column.ColumnName}} > ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "GTE"}} + db = db.Where("{{$column.ColumnName}} >= ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "LT"}} + db = db.Where("{{$column.ColumnName}} < ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "LTE"}} + db = db.Where("{{$column.ColumnName}} <= ?", data.{{$column.GoField}}) + {{- end }} + } + {{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }} + if data.{{$column.GoField}} != 0 { + {{- if eq $column.QueryType "GT" }} + db = db.Where("{{$column.ColumnName}} > ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "GTE"}} + db = db.Where("{{$column.ColumnName}} >= ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "LT"}} + db = db.Where("{{$column.ColumnName}} < ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "LTE"}} + db = db.Where("{{$column.ColumnName}} <= ?", data.{{$column.GoField}}) + {{- end }} } {{- end -}} {{- end -}} {{- end -}} + {{- if eq $column.ColumnName "delete_time" }} + db.Where("delete_time IS NULL") + {{- end -}} {{- end}} - db.Where("delete_time IS NULL") err := db.Count(&total).Error err = db.Order("create_time").Limit(pageSize).Offset(offset).Find(&list).Error biz.ErrIsNil(err, "查询{{.TableComment}}分页列表失败") @@ -89,20 +126,57 @@ func (m *{{.BusinessName}}ModelImpl) FindList(data entity.{{$model}}) *[]entity. db = db.Where("{{$column.ColumnName}} like ?", "%"+data.{{$column.GoField}}+"%") } {{- end -}} - {{- if eq $column.QueryType "EQ" -}} + {{- if or (eq $column.QueryType "EQ") (eq $column.QueryType "NE") -}} {{- if eq $column.GoType "string" }} if data.{{$column.GoField}} != "" { + {{- if eq $column.QueryType "EQ" }} db = db.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "NE"}} + db = db.Where("{{$column.ColumnName}} != ?", data.{{$column.GoField}}) + {{- end }} } {{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }} if data.{{$column.GoField}} != 0 { + {{- if eq $column.QueryType "EQ" }} db = db.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "NE"}} + db = db.Where("{{$column.ColumnName}} != ?", data.{{$column.GoField}}) + {{- end }} + } + {{- end -}} + {{- end -}} + {{- if or (eq $column.QueryType "GT") (eq $column.QueryType "GTE") (eq $column.QueryType "LT") (eq $column.QueryType "LTE")}} + {{- if eq $column.GoType "Time" }} + if data.{{$column.GoField}}.Unix() > 0 { + {{- if eq $column.QueryType "GT" }} + db = db.Where("{{$column.ColumnName}} > ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "GTE"}} + db = db.Where("{{$column.ColumnName}} >= ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "LT"}} + db = db.Where("{{$column.ColumnName}} < ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "LTE"}} + db = db.Where("{{$column.ColumnName}} <= ?", data.{{$column.GoField}}) + {{- end }} + } + {{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }} + if data.{{$column.GoField}} != 0 { + {{- if eq $column.QueryType "GT" }} + db = db.Where("{{$column.ColumnName}} > ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "GTE"}} + db = db.Where("{{$column.ColumnName}} >= ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "LT"}} + db = db.Where("{{$column.ColumnName}} < ?", data.{{$column.GoField}}) + {{- else if $column.QueryType "LTE"}} + db = db.Where("{{$column.ColumnName}} <= ?", data.{{$column.GoField}}) + {{- end }} } {{- end -}} {{- end -}} {{- end -}} + {{- if eq $column.ColumnName "delete_time" }} + db.Where("delete_time IS NULL") + {{- end -}} {{- end}} - db.Where("delete_time IS NULL") biz.ErrIsNil(db.Order("create_time").Find(&list).Error, "查询{{.TableComment}}列表失败") return &list } diff --git a/resource/template/js/api.template b/resource/template/js/api.template index af6c6a4..8dd079a 100644 --- a/resource/template/js/api.template +++ b/resource/template/js/api.template @@ -1,7 +1,7 @@ -import request from '/@/utils/request'; +import request from '@/utils/request'; // 查询{{.FunctionName}}列表 -export function list{{.ClassName}}(query:any) { +export function list{{.FunctionName}}(query:any) { return request({ url: '/{{.PackageName}}/{{.BusinessName}}/list', method: 'get', @@ -10,7 +10,7 @@ export function list{{.ClassName}}(query:any) { } // 查询{{.FunctionName}}详细 -export function get{{.ClassName}}({{.PkJsonField}}:number) { +export function get{{.FunctionName}}({{.PkJsonField}}:number) { return request({ url: '/{{.PackageName}}/{{.BusinessName}}/' + {{.PkJsonField}}, method: 'get' @@ -18,7 +18,7 @@ export function get{{.ClassName}}({{.PkJsonField}}:number) { } // 新增{{.FunctionName}} -export function add{{.ClassName}}(data:any) { +export function add{{.FunctionName}}(data:any) { return request({ url: '/{{.PackageName}}/{{.BusinessName}}', method: 'post', @@ -27,7 +27,7 @@ export function add{{.ClassName}}(data:any) { } // 修改{{.FunctionName}} -export function update{{.ClassName}}(data:any) { +export function update{{.FunctionName}}(data:any) { return request({ url: '/{{.PackageName}}/{{.BusinessName}}', method: 'put', @@ -36,7 +36,7 @@ export function update{{.ClassName}}(data:any) { } // 删除{{.FunctionName}} -export function del{{.ClassName}}({{.PkJsonField}}: string) { +export function del{{.FunctionName}}({{.PkJsonField}}: string) { return request({ url: '/{{.PackageName}}/{{.BusinessName}}/' + {{.PkJsonField}}, method: 'delete' diff --git a/resource/template/vue/edit-vue.template b/resource/template/vue/edit-vue.template index 27c3c04..a14037a 100644 --- a/resource/template/vue/edit-vue.template +++ b/resource/template/vue/edit-vue.template @@ -1,8 +1,8 @@