chore: seed migration objects batch 12
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
// Package crons
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package crons
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
"hotgo/internal/library/cron"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cron.Register(Test2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test2 测试2任务(带参数)
|
||||||
|
var Test2 = &cTest2{name: "test2"}
|
||||||
|
|
||||||
|
type cTest2 struct {
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *cTest2) GetName() string {
|
||||||
|
return c.name
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute 执行任务
|
||||||
|
func (c *cTest2) Execute(ctx context.Context, parser *cron.Parser) (err error) {
|
||||||
|
if len(parser.Args) != 3 {
|
||||||
|
err = gerror.New("传入参数不正确!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
name = parser.Args[0]
|
||||||
|
age = parser.Args[1]
|
||||||
|
msg = parser.Args[2]
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.Logger.Infof(ctx, "cron test2 Execute:%v, name:%v, age:%v, msg:%v", time.Now(), name, age, msg)
|
||||||
|
return
|
||||||
|
}
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// addonHgexampleTableDao is the data access object for the table hg_addon_hgexample_table.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type addonHgexampleTableDao struct {
|
||||||
|
*internal.AddonHgexampleTableDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AddonHgexampleTable is a globally accessible object for table hg_addon_hgexample_table operations.
|
||||||
|
AddonHgexampleTable = addonHgexampleTableDao{internal.NewAddonHgexampleTableDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// addonHgexampleTenantOrderDao is the data access object for the table hg_addon_hgexample_tenant_order.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type addonHgexampleTenantOrderDao struct {
|
||||||
|
*internal.AddonHgexampleTenantOrderDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AddonHgexampleTenantOrder is a globally accessible object for table hg_addon_hgexample_tenant_order operations.
|
||||||
|
AddonHgexampleTenantOrder = addonHgexampleTenantOrderDao{internal.NewAddonHgexampleTenantOrderDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminCashDao is the data access object for the table hg_admin_cash.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminCashDao struct {
|
||||||
|
*internal.AdminCashDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminCash is a globally accessible object for table hg_admin_cash operations.
|
||||||
|
AdminCash = adminCashDao{internal.NewAdminCashDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminCreditsLogDao is the data access object for the table hg_admin_credits_log.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminCreditsLogDao struct {
|
||||||
|
*internal.AdminCreditsLogDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminCreditsLog is a globally accessible object for table hg_admin_credits_log operations.
|
||||||
|
AdminCreditsLog = adminCreditsLogDao{internal.NewAdminCreditsLogDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminDeptDao is the data access object for the table hg_admin_dept.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminDeptDao struct {
|
||||||
|
*internal.AdminDeptDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminDept is a globally accessible object for table hg_admin_dept operations.
|
||||||
|
AdminDept = adminDeptDao{internal.NewAdminDeptDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminMemberDao is the data access object for the table hg_admin_member.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminMemberDao struct {
|
||||||
|
*internal.AdminMemberDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminMember is a globally accessible object for table hg_admin_member operations.
|
||||||
|
AdminMember = adminMemberDao{internal.NewAdminMemberDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminMemberPostDao is the data access object for the table hg_admin_member_post.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminMemberPostDao struct {
|
||||||
|
*internal.AdminMemberPostDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminMemberPost is a globally accessible object for table hg_admin_member_post operations.
|
||||||
|
AdminMemberPost = adminMemberPostDao{internal.NewAdminMemberPostDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminMemberRoleDao is the data access object for the table hg_admin_member_role.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminMemberRoleDao struct {
|
||||||
|
*internal.AdminMemberRoleDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminMemberRole is a globally accessible object for table hg_admin_member_role operations.
|
||||||
|
AdminMemberRole = adminMemberRoleDao{internal.NewAdminMemberRoleDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminMenuDao is the data access object for the table hg_admin_menu.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminMenuDao struct {
|
||||||
|
*internal.AdminMenuDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminMenu is a globally accessible object for table hg_admin_menu operations.
|
||||||
|
AdminMenu = adminMenuDao{internal.NewAdminMenuDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminNoticeDao is the data access object for the table hg_admin_notice.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminNoticeDao struct {
|
||||||
|
*internal.AdminNoticeDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminNotice is a globally accessible object for table hg_admin_notice operations.
|
||||||
|
AdminNotice = adminNoticeDao{internal.NewAdminNoticeDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminNoticeReadDao is the data access object for the table hg_admin_notice_read.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminNoticeReadDao struct {
|
||||||
|
*internal.AdminNoticeReadDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminNoticeRead is a globally accessible object for table hg_admin_notice_read operations.
|
||||||
|
AdminNoticeRead = adminNoticeReadDao{internal.NewAdminNoticeReadDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminOauthDao is the data access object for the table hg_admin_oauth.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminOauthDao struct {
|
||||||
|
*internal.AdminOauthDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminOauth is a globally accessible object for table hg_admin_oauth operations.
|
||||||
|
AdminOauth = adminOauthDao{internal.NewAdminOauthDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminOrderDao is the data access object for the table hg_admin_order.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminOrderDao struct {
|
||||||
|
*internal.AdminOrderDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminOrder is a globally accessible object for table hg_admin_order operations.
|
||||||
|
AdminOrder = adminOrderDao{internal.NewAdminOrderDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminPostDao is the data access object for the table hg_admin_post.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminPostDao struct {
|
||||||
|
*internal.AdminPostDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminPost is a globally accessible object for table hg_admin_post operations.
|
||||||
|
AdminPost = adminPostDao{internal.NewAdminPostDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminRoleDao is the data access object for the table hg_admin_role.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminRoleDao struct {
|
||||||
|
*internal.AdminRoleDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminRole is a globally accessible object for table hg_admin_role operations.
|
||||||
|
AdminRole = adminRoleDao{internal.NewAdminRoleDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminRoleCasbinDao is the data access object for the table hg_admin_role_casbin.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminRoleCasbinDao struct {
|
||||||
|
*internal.AdminRoleCasbinDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminRoleCasbin is a globally accessible object for table hg_admin_role_casbin operations.
|
||||||
|
AdminRoleCasbin = adminRoleCasbinDao{internal.NewAdminRoleCasbinDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminRoleMenuDao is the data access object for the table hg_admin_role_menu.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminRoleMenuDao struct {
|
||||||
|
*internal.AdminRoleMenuDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminRoleMenu is a globally accessible object for table hg_admin_role_menu operations.
|
||||||
|
AdminRoleMenu = adminRoleMenuDao{internal.NewAdminRoleMenuDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
+151
@@ -0,0 +1,151 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddonHgexampleTableDao is the data access object for the table hg_addon_hgexample_table.
|
||||||
|
type AddonHgexampleTableDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AddonHgexampleTableColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddonHgexampleTableColumns defines and stores column names for the table hg_addon_hgexample_table.
|
||||||
|
type AddonHgexampleTableColumns struct {
|
||||||
|
Id string // ID
|
||||||
|
Pid string // 上级ID
|
||||||
|
Level string // 树等级
|
||||||
|
Tree string // 关系树
|
||||||
|
CategoryId string // 分类ID
|
||||||
|
Flag string // 标签
|
||||||
|
Title string // 标题
|
||||||
|
Description string // 描述
|
||||||
|
Content string // 内容
|
||||||
|
Image string // 单图
|
||||||
|
Images string // 多图
|
||||||
|
Attachfile string // 附件
|
||||||
|
Attachfiles string // 多附件
|
||||||
|
Map string // 动态键值对
|
||||||
|
Star string // 推荐星
|
||||||
|
Price string // 价格
|
||||||
|
Views string // 浏览次数
|
||||||
|
ActivityAt string // 活动时间
|
||||||
|
StartAt string // 开启时间
|
||||||
|
EndAt string // 结束时间
|
||||||
|
Switch string // 开关
|
||||||
|
Sort string // 排序
|
||||||
|
Avatar string // 头像
|
||||||
|
Sex string // 性别
|
||||||
|
Qq string // qq
|
||||||
|
Email string // 邮箱
|
||||||
|
Mobile string // 手机号码
|
||||||
|
Hobby string // 爱好
|
||||||
|
Channel string // 渠道
|
||||||
|
CityId string // 所在城市
|
||||||
|
Remark string // 备注
|
||||||
|
Status string // 状态
|
||||||
|
CreatedBy string // 创建者
|
||||||
|
UpdatedBy string // 更新者
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
DeletedAt string // 删除时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// addonHgexampleTableColumns holds the columns for the table hg_addon_hgexample_table.
|
||||||
|
var addonHgexampleTableColumns = AddonHgexampleTableColumns{
|
||||||
|
Id: "id",
|
||||||
|
Pid: "pid",
|
||||||
|
Level: "level",
|
||||||
|
Tree: "tree",
|
||||||
|
CategoryId: "category_id",
|
||||||
|
Flag: "flag",
|
||||||
|
Title: "title",
|
||||||
|
Description: "description",
|
||||||
|
Content: "content",
|
||||||
|
Image: "image",
|
||||||
|
Images: "images",
|
||||||
|
Attachfile: "attachfile",
|
||||||
|
Attachfiles: "attachfiles",
|
||||||
|
Map: "map",
|
||||||
|
Star: "star",
|
||||||
|
Price: "price",
|
||||||
|
Views: "views",
|
||||||
|
ActivityAt: "activity_at",
|
||||||
|
StartAt: "start_at",
|
||||||
|
EndAt: "end_at",
|
||||||
|
Switch: "switch",
|
||||||
|
Sort: "sort",
|
||||||
|
Avatar: "avatar",
|
||||||
|
Sex: "sex",
|
||||||
|
Qq: "qq",
|
||||||
|
Email: "email",
|
||||||
|
Mobile: "mobile",
|
||||||
|
Hobby: "hobby",
|
||||||
|
Channel: "channel",
|
||||||
|
CityId: "city_id",
|
||||||
|
Remark: "remark",
|
||||||
|
Status: "status",
|
||||||
|
CreatedBy: "created_by",
|
||||||
|
UpdatedBy: "updated_by",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAddonHgexampleTableDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAddonHgexampleTableDao(handlers ...gdb.ModelHandler) *AddonHgexampleTableDao {
|
||||||
|
return &AddonHgexampleTableDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_addon_hgexample_table",
|
||||||
|
columns: addonHgexampleTableColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AddonHgexampleTableDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AddonHgexampleTableDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AddonHgexampleTableDao) Columns() AddonHgexampleTableColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AddonHgexampleTableDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AddonHgexampleTableDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AddonHgexampleTableDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddonHgexampleTenantOrderDao is the data access object for the table hg_addon_hgexample_tenant_order.
|
||||||
|
type AddonHgexampleTenantOrderDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AddonHgexampleTenantOrderColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddonHgexampleTenantOrderColumns defines and stores column names for the table hg_addon_hgexample_tenant_order.
|
||||||
|
type AddonHgexampleTenantOrderColumns struct {
|
||||||
|
Id string // 主键
|
||||||
|
TenantId string // 租户ID
|
||||||
|
MerchantId string // 商户ID
|
||||||
|
UserId string // 用户ID
|
||||||
|
ProductName string // 购买产品
|
||||||
|
OrderSn string // 订单号
|
||||||
|
Money string // 充值金额
|
||||||
|
Remark string // 备注
|
||||||
|
Status string // 订单状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// addonHgexampleTenantOrderColumns holds the columns for the table hg_addon_hgexample_tenant_order.
|
||||||
|
var addonHgexampleTenantOrderColumns = AddonHgexampleTenantOrderColumns{
|
||||||
|
Id: "id",
|
||||||
|
TenantId: "tenant_id",
|
||||||
|
MerchantId: "merchant_id",
|
||||||
|
UserId: "user_id",
|
||||||
|
ProductName: "product_name",
|
||||||
|
OrderSn: "order_sn",
|
||||||
|
Money: "money",
|
||||||
|
Remark: "remark",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAddonHgexampleTenantOrderDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAddonHgexampleTenantOrderDao(handlers ...gdb.ModelHandler) *AddonHgexampleTenantOrderDao {
|
||||||
|
return &AddonHgexampleTenantOrderDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_addon_hgexample_tenant_order",
|
||||||
|
columns: addonHgexampleTenantOrderColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AddonHgexampleTenantOrderDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AddonHgexampleTenantOrderDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AddonHgexampleTenantOrderDao) Columns() AddonHgexampleTenantOrderColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AddonHgexampleTenantOrderDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AddonHgexampleTenantOrderDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AddonHgexampleTenantOrderDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+97
@@ -0,0 +1,97 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminCashDao is the data access object for the table hg_admin_cash.
|
||||||
|
type AdminCashDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminCashColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminCashColumns defines and stores column names for the table hg_admin_cash.
|
||||||
|
type AdminCashColumns struct {
|
||||||
|
Id string // ID
|
||||||
|
MemberId string // 管理员ID
|
||||||
|
Money string // 提现金额
|
||||||
|
Fee string // 手续费
|
||||||
|
LastMoney string // 最终到账金额
|
||||||
|
Ip string // 申请人IP
|
||||||
|
Status string // 状态码
|
||||||
|
Msg string // 处理结果
|
||||||
|
HandleAt string // 处理时间
|
||||||
|
CreatedAt string // 申请时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminCashColumns holds the columns for the table hg_admin_cash.
|
||||||
|
var adminCashColumns = AdminCashColumns{
|
||||||
|
Id: "id",
|
||||||
|
MemberId: "member_id",
|
||||||
|
Money: "money",
|
||||||
|
Fee: "fee",
|
||||||
|
LastMoney: "last_money",
|
||||||
|
Ip: "ip",
|
||||||
|
Status: "status",
|
||||||
|
Msg: "msg",
|
||||||
|
HandleAt: "handle_at",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminCashDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminCashDao(handlers ...gdb.ModelHandler) *AdminCashDao {
|
||||||
|
return &AdminCashDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_cash",
|
||||||
|
columns: adminCashColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminCashDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminCashDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminCashDao) Columns() AdminCashColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminCashDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminCashDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminCashDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+107
@@ -0,0 +1,107 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminCreditsLogDao is the data access object for the table hg_admin_credits_log.
|
||||||
|
type AdminCreditsLogDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminCreditsLogColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminCreditsLogColumns defines and stores column names for the table hg_admin_credits_log.
|
||||||
|
type AdminCreditsLogColumns struct {
|
||||||
|
Id string // 变动ID
|
||||||
|
MemberId string // 管理员ID
|
||||||
|
AppId string // 应用id
|
||||||
|
AddonsName string // 插件名称
|
||||||
|
CreditType string // 变动类型
|
||||||
|
CreditGroup string // 变动组别
|
||||||
|
BeforeNum string // 变动前
|
||||||
|
Num string // 变动数据
|
||||||
|
AfterNum string // 变动后
|
||||||
|
Remark string // 备注
|
||||||
|
Ip string // 操作人IP
|
||||||
|
MapId string // 关联ID
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminCreditsLogColumns holds the columns for the table hg_admin_credits_log.
|
||||||
|
var adminCreditsLogColumns = AdminCreditsLogColumns{
|
||||||
|
Id: "id",
|
||||||
|
MemberId: "member_id",
|
||||||
|
AppId: "app_id",
|
||||||
|
AddonsName: "addons_name",
|
||||||
|
CreditType: "credit_type",
|
||||||
|
CreditGroup: "credit_group",
|
||||||
|
BeforeNum: "before_num",
|
||||||
|
Num: "num",
|
||||||
|
AfterNum: "after_num",
|
||||||
|
Remark: "remark",
|
||||||
|
Ip: "ip",
|
||||||
|
MapId: "map_id",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminCreditsLogDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminCreditsLogDao(handlers ...gdb.ModelHandler) *AdminCreditsLogDao {
|
||||||
|
return &AdminCreditsLogDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_credits_log",
|
||||||
|
columns: adminCreditsLogColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminCreditsLogDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminCreditsLogDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminCreditsLogDao) Columns() AdminCreditsLogColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminCreditsLogDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminCreditsLogDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminCreditsLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+105
@@ -0,0 +1,105 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminDeptDao is the data access object for the table hg_admin_dept.
|
||||||
|
type AdminDeptDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminDeptColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminDeptColumns defines and stores column names for the table hg_admin_dept.
|
||||||
|
type AdminDeptColumns struct {
|
||||||
|
Id string // 部门ID
|
||||||
|
Pid string // 父部门ID
|
||||||
|
Name string // 部门名称
|
||||||
|
Code string // 部门编码
|
||||||
|
Type string // 部门类型
|
||||||
|
Leader string // 负责人
|
||||||
|
Phone string // 联系电话
|
||||||
|
Email string // 邮箱
|
||||||
|
Level string // 关系树等级
|
||||||
|
Tree string // 关系树
|
||||||
|
Sort string // 排序
|
||||||
|
Status string // 部门状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminDeptColumns holds the columns for the table hg_admin_dept.
|
||||||
|
var adminDeptColumns = AdminDeptColumns{
|
||||||
|
Id: "id",
|
||||||
|
Pid: "pid",
|
||||||
|
Name: "name",
|
||||||
|
Code: "code",
|
||||||
|
Type: "type",
|
||||||
|
Leader: "leader",
|
||||||
|
Phone: "phone",
|
||||||
|
Email: "email",
|
||||||
|
Level: "level",
|
||||||
|
Tree: "tree",
|
||||||
|
Sort: "sort",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminDeptDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminDeptDao(handlers ...gdb.ModelHandler) *AdminDeptDao {
|
||||||
|
return &AdminDeptDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_dept",
|
||||||
|
columns: adminDeptColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminDeptDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminDeptDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminDeptDao) Columns() AdminDeptColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminDeptDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminDeptDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminDeptDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+133
@@ -0,0 +1,133 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminMemberDao is the data access object for the table hg_admin_member.
|
||||||
|
type AdminMemberDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminMemberColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminMemberColumns defines and stores column names for the table hg_admin_member.
|
||||||
|
type AdminMemberColumns struct {
|
||||||
|
Id string // 管理员ID
|
||||||
|
DeptId string // 部门ID
|
||||||
|
RoleId string // 角色ID
|
||||||
|
RealName string // 真实姓名
|
||||||
|
Username string // 帐号
|
||||||
|
PasswordHash string // 密码
|
||||||
|
Salt string // 密码盐
|
||||||
|
PasswordResetToken string // 密码重置令牌
|
||||||
|
Integral string // 积分
|
||||||
|
Balance string // 余额
|
||||||
|
Avatar string // 头像
|
||||||
|
Sex string // 性别
|
||||||
|
Qq string // qq
|
||||||
|
Email string // 邮箱
|
||||||
|
Mobile string // 手机号码
|
||||||
|
Birthday string // 生日
|
||||||
|
CityId string // 城市编码
|
||||||
|
Address string // 联系地址
|
||||||
|
Pid string // 上级管理员ID
|
||||||
|
Level string // 关系树等级
|
||||||
|
Tree string // 关系树
|
||||||
|
InviteCode string // 邀请码
|
||||||
|
Cash string // 提现配置
|
||||||
|
LastActiveAt string // 最后活跃时间
|
||||||
|
Remark string // 备注
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminMemberColumns holds the columns for the table hg_admin_member.
|
||||||
|
var adminMemberColumns = AdminMemberColumns{
|
||||||
|
Id: "id",
|
||||||
|
DeptId: "dept_id",
|
||||||
|
RoleId: "role_id",
|
||||||
|
RealName: "real_name",
|
||||||
|
Username: "username",
|
||||||
|
PasswordHash: "password_hash",
|
||||||
|
Salt: "salt",
|
||||||
|
PasswordResetToken: "password_reset_token",
|
||||||
|
Integral: "integral",
|
||||||
|
Balance: "balance",
|
||||||
|
Avatar: "avatar",
|
||||||
|
Sex: "sex",
|
||||||
|
Qq: "qq",
|
||||||
|
Email: "email",
|
||||||
|
Mobile: "mobile",
|
||||||
|
Birthday: "birthday",
|
||||||
|
CityId: "city_id",
|
||||||
|
Address: "address",
|
||||||
|
Pid: "pid",
|
||||||
|
Level: "level",
|
||||||
|
Tree: "tree",
|
||||||
|
InviteCode: "invite_code",
|
||||||
|
Cash: "cash",
|
||||||
|
LastActiveAt: "last_active_at",
|
||||||
|
Remark: "remark",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminMemberDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminMemberDao(handlers ...gdb.ModelHandler) *AdminMemberDao {
|
||||||
|
return &AdminMemberDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_member",
|
||||||
|
columns: adminMemberColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminMemberDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminMemberDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminMemberDao) Columns() AdminMemberColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminMemberDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminMemberDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminMemberDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+81
@@ -0,0 +1,81 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminMemberPostDao is the data access object for the table hg_admin_member_post.
|
||||||
|
type AdminMemberPostDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminMemberPostColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminMemberPostColumns defines and stores column names for the table hg_admin_member_post.
|
||||||
|
type AdminMemberPostColumns struct {
|
||||||
|
MemberId string // 管理员ID
|
||||||
|
PostId string // 岗位ID
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminMemberPostColumns holds the columns for the table hg_admin_member_post.
|
||||||
|
var adminMemberPostColumns = AdminMemberPostColumns{
|
||||||
|
MemberId: "member_id",
|
||||||
|
PostId: "post_id",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminMemberPostDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminMemberPostDao(handlers ...gdb.ModelHandler) *AdminMemberPostDao {
|
||||||
|
return &AdminMemberPostDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_member_post",
|
||||||
|
columns: adminMemberPostColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminMemberPostDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminMemberPostDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminMemberPostDao) Columns() AdminMemberPostColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminMemberPostDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminMemberPostDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminMemberPostDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+81
@@ -0,0 +1,81 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminMemberRoleDao is the data access object for the table hg_admin_member_role.
|
||||||
|
type AdminMemberRoleDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminMemberRoleColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminMemberRoleColumns defines and stores column names for the table hg_admin_member_role.
|
||||||
|
type AdminMemberRoleColumns struct {
|
||||||
|
MemberId string // 管理员ID
|
||||||
|
RoleId string // 角色ID
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminMemberRoleColumns holds the columns for the table hg_admin_member_role.
|
||||||
|
var adminMemberRoleColumns = AdminMemberRoleColumns{
|
||||||
|
MemberId: "member_id",
|
||||||
|
RoleId: "role_id",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminMemberRoleDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminMemberRoleDao(handlers ...gdb.ModelHandler) *AdminMemberRoleDao {
|
||||||
|
return &AdminMemberRoleDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_member_role",
|
||||||
|
columns: adminMemberRoleColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminMemberRoleDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminMemberRoleDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminMemberRoleDao) Columns() AdminMemberRoleColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminMemberRoleDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminMemberRoleDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminMemberRoleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+129
@@ -0,0 +1,129 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminMenuDao is the data access object for the table hg_admin_menu.
|
||||||
|
type AdminMenuDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminMenuColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminMenuColumns defines and stores column names for the table hg_admin_menu.
|
||||||
|
type AdminMenuColumns struct {
|
||||||
|
Id string // 菜单ID
|
||||||
|
Pid string // 父菜单ID
|
||||||
|
Level string // 关系树等级
|
||||||
|
Tree string // 关系树
|
||||||
|
Title string // 菜单名称
|
||||||
|
Name string // 名称编码
|
||||||
|
Path string // 路由地址
|
||||||
|
Icon string // 菜单图标
|
||||||
|
Type string // 菜单类型(1目录 2菜单 3按钮)
|
||||||
|
Redirect string // 重定向地址
|
||||||
|
Permissions string // 菜单包含权限集合
|
||||||
|
PermissionName string // 权限名称
|
||||||
|
Component string // 组件路径
|
||||||
|
AlwaysShow string // 取消自动计算根路由模式
|
||||||
|
ActiveMenu string // 高亮菜单编码
|
||||||
|
IsRoot string // 是否跟路由
|
||||||
|
IsFrame string // 是否内嵌
|
||||||
|
FrameSrc string // 内联外部地址
|
||||||
|
KeepAlive string // 缓存该路由
|
||||||
|
Hidden string // 是否隐藏
|
||||||
|
Affix string // 是否固定
|
||||||
|
Sort string // 排序
|
||||||
|
Remark string // 备注
|
||||||
|
Status string // 菜单状态
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminMenuColumns holds the columns for the table hg_admin_menu.
|
||||||
|
var adminMenuColumns = AdminMenuColumns{
|
||||||
|
Id: "id",
|
||||||
|
Pid: "pid",
|
||||||
|
Level: "level",
|
||||||
|
Tree: "tree",
|
||||||
|
Title: "title",
|
||||||
|
Name: "name",
|
||||||
|
Path: "path",
|
||||||
|
Icon: "icon",
|
||||||
|
Type: "type",
|
||||||
|
Redirect: "redirect",
|
||||||
|
Permissions: "permissions",
|
||||||
|
PermissionName: "permission_name",
|
||||||
|
Component: "component",
|
||||||
|
AlwaysShow: "always_show",
|
||||||
|
ActiveMenu: "active_menu",
|
||||||
|
IsRoot: "is_root",
|
||||||
|
IsFrame: "is_frame",
|
||||||
|
FrameSrc: "frame_src",
|
||||||
|
KeepAlive: "keep_alive",
|
||||||
|
Hidden: "hidden",
|
||||||
|
Affix: "affix",
|
||||||
|
Sort: "sort",
|
||||||
|
Remark: "remark",
|
||||||
|
Status: "status",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminMenuDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminMenuDao(handlers ...gdb.ModelHandler) *AdminMenuDao {
|
||||||
|
return &AdminMenuDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_menu",
|
||||||
|
columns: adminMenuColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminMenuDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminMenuDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminMenuDao) Columns() AdminMenuColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminMenuDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminMenuDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminMenuDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+105
@@ -0,0 +1,105 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminNoticeDao is the data access object for the table hg_admin_notice.
|
||||||
|
type AdminNoticeDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminNoticeColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminNoticeColumns defines and stores column names for the table hg_admin_notice.
|
||||||
|
type AdminNoticeColumns struct {
|
||||||
|
Id string // 公告ID
|
||||||
|
Title string // 公告标题
|
||||||
|
Type string // 公告类型
|
||||||
|
Tag string // 标签
|
||||||
|
Content string // 公告内容
|
||||||
|
Receiver string // 接收者
|
||||||
|
Remark string // 备注
|
||||||
|
Sort string // 排序
|
||||||
|
Status string // 公告状态
|
||||||
|
CreatedBy string // 发送人
|
||||||
|
UpdatedBy string // 修改人
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
DeletedAt string // 删除时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminNoticeColumns holds the columns for the table hg_admin_notice.
|
||||||
|
var adminNoticeColumns = AdminNoticeColumns{
|
||||||
|
Id: "id",
|
||||||
|
Title: "title",
|
||||||
|
Type: "type",
|
||||||
|
Tag: "tag",
|
||||||
|
Content: "content",
|
||||||
|
Receiver: "receiver",
|
||||||
|
Remark: "remark",
|
||||||
|
Sort: "sort",
|
||||||
|
Status: "status",
|
||||||
|
CreatedBy: "created_by",
|
||||||
|
UpdatedBy: "updated_by",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminNoticeDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminNoticeDao(handlers ...gdb.ModelHandler) *AdminNoticeDao {
|
||||||
|
return &AdminNoticeDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_notice",
|
||||||
|
columns: adminNoticeColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminNoticeDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminNoticeDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminNoticeDao) Columns() AdminNoticeColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminNoticeDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminNoticeDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminNoticeDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+89
@@ -0,0 +1,89 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminNoticeReadDao is the data access object for the table hg_admin_notice_read.
|
||||||
|
type AdminNoticeReadDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminNoticeReadColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminNoticeReadColumns defines and stores column names for the table hg_admin_notice_read.
|
||||||
|
type AdminNoticeReadColumns struct {
|
||||||
|
Id string // 记录ID
|
||||||
|
NoticeId string // 公告ID
|
||||||
|
MemberId string // 会员ID
|
||||||
|
Clicks string // 已读次数
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
CreatedAt string // 阅读时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminNoticeReadColumns holds the columns for the table hg_admin_notice_read.
|
||||||
|
var adminNoticeReadColumns = AdminNoticeReadColumns{
|
||||||
|
Id: "id",
|
||||||
|
NoticeId: "notice_id",
|
||||||
|
MemberId: "member_id",
|
||||||
|
Clicks: "clicks",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminNoticeReadDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminNoticeReadDao(handlers ...gdb.ModelHandler) *AdminNoticeReadDao {
|
||||||
|
return &AdminNoticeReadDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_notice_read",
|
||||||
|
columns: adminNoticeReadColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminNoticeReadDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminNoticeReadDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminNoticeReadDao) Columns() AdminNoticeReadColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminNoticeReadDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminNoticeReadDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminNoticeReadDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+107
@@ -0,0 +1,107 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminOauthDao is the data access object for the table hg_admin_oauth.
|
||||||
|
type AdminOauthDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminOauthColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminOauthColumns defines and stores column names for the table hg_admin_oauth.
|
||||||
|
type AdminOauthColumns struct {
|
||||||
|
Id string // 主键
|
||||||
|
MemberId string // 用户ID
|
||||||
|
Unionid string // 唯一ID
|
||||||
|
OauthClient string // 授权组别
|
||||||
|
OauthOpenid string // 授权开放ID
|
||||||
|
Sex string // 性别
|
||||||
|
Nickname string // 昵称
|
||||||
|
HeadPortrait string // 头像
|
||||||
|
Birthday string // 生日
|
||||||
|
Country string // 国家
|
||||||
|
Province string // 省
|
||||||
|
City string // 市
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminOauthColumns holds the columns for the table hg_admin_oauth.
|
||||||
|
var adminOauthColumns = AdminOauthColumns{
|
||||||
|
Id: "id",
|
||||||
|
MemberId: "member_id",
|
||||||
|
Unionid: "unionid",
|
||||||
|
OauthClient: "oauth_client",
|
||||||
|
OauthOpenid: "oauth_openid",
|
||||||
|
Sex: "sex",
|
||||||
|
Nickname: "nickname",
|
||||||
|
HeadPortrait: "head_portrait",
|
||||||
|
Birthday: "birthday",
|
||||||
|
Country: "country",
|
||||||
|
Province: "province",
|
||||||
|
City: "city",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminOauthDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminOauthDao(handlers ...gdb.ModelHandler) *AdminOauthDao {
|
||||||
|
return &AdminOauthDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_oauth",
|
||||||
|
columns: adminOauthColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminOauthDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminOauthDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminOauthDao) Columns() AdminOauthColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminOauthDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminOauthDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminOauthDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+101
@@ -0,0 +1,101 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminOrderDao is the data access object for the table hg_admin_order.
|
||||||
|
type AdminOrderDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminOrderColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminOrderColumns defines and stores column names for the table hg_admin_order.
|
||||||
|
type AdminOrderColumns struct {
|
||||||
|
Id string // 主键
|
||||||
|
MemberId string // 管理员id
|
||||||
|
OrderType string // 订单类型
|
||||||
|
ProductId string // 产品id
|
||||||
|
OrderSn string // 关联订单号
|
||||||
|
Money string // 充值金额
|
||||||
|
Remark string // 备注
|
||||||
|
RefundReason string // 退款原因
|
||||||
|
RejectRefundReason string // 拒绝退款原因
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminOrderColumns holds the columns for the table hg_admin_order.
|
||||||
|
var adminOrderColumns = AdminOrderColumns{
|
||||||
|
Id: "id",
|
||||||
|
MemberId: "member_id",
|
||||||
|
OrderType: "order_type",
|
||||||
|
ProductId: "product_id",
|
||||||
|
OrderSn: "order_sn",
|
||||||
|
Money: "money",
|
||||||
|
Remark: "remark",
|
||||||
|
RefundReason: "refund_reason",
|
||||||
|
RejectRefundReason: "reject_refund_reason",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminOrderDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminOrderDao(handlers ...gdb.ModelHandler) *AdminOrderDao {
|
||||||
|
return &AdminOrderDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_order",
|
||||||
|
columns: adminOrderColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminOrderDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminOrderDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminOrderDao) Columns() AdminOrderColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminOrderDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminOrderDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminOrderDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+93
@@ -0,0 +1,93 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminPostDao is the data access object for the table hg_admin_post.
|
||||||
|
type AdminPostDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminPostColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminPostColumns defines and stores column names for the table hg_admin_post.
|
||||||
|
type AdminPostColumns struct {
|
||||||
|
Id string // 岗位ID
|
||||||
|
Code string // 岗位编码
|
||||||
|
Name string // 岗位名称
|
||||||
|
Remark string // 备注
|
||||||
|
Sort string // 排序
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminPostColumns holds the columns for the table hg_admin_post.
|
||||||
|
var adminPostColumns = AdminPostColumns{
|
||||||
|
Id: "id",
|
||||||
|
Code: "code",
|
||||||
|
Name: "name",
|
||||||
|
Remark: "remark",
|
||||||
|
Sort: "sort",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminPostDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminPostDao(handlers ...gdb.ModelHandler) *AdminPostDao {
|
||||||
|
return &AdminPostDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_post",
|
||||||
|
columns: adminPostColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminPostDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminPostDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminPostDao) Columns() AdminPostColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminPostDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminPostDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminPostDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+103
@@ -0,0 +1,103 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminRoleDao is the data access object for the table hg_admin_role.
|
||||||
|
type AdminRoleDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminRoleColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminRoleColumns defines and stores column names for the table hg_admin_role.
|
||||||
|
type AdminRoleColumns struct {
|
||||||
|
Id string // 角色ID
|
||||||
|
Name string // 角色名称
|
||||||
|
Key string // 角色权限字符串
|
||||||
|
DataScope string // 数据范围
|
||||||
|
CustomDept string // 自定义部门权限
|
||||||
|
Pid string // 上级角色ID
|
||||||
|
Level string // 关系树等级
|
||||||
|
Tree string // 关系树
|
||||||
|
Remark string // 备注
|
||||||
|
Sort string // 排序
|
||||||
|
Status string // 角色状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminRoleColumns holds the columns for the table hg_admin_role.
|
||||||
|
var adminRoleColumns = AdminRoleColumns{
|
||||||
|
Id: "id",
|
||||||
|
Name: "name",
|
||||||
|
Key: "key",
|
||||||
|
DataScope: "data_scope",
|
||||||
|
CustomDept: "custom_dept",
|
||||||
|
Pid: "pid",
|
||||||
|
Level: "level",
|
||||||
|
Tree: "tree",
|
||||||
|
Remark: "remark",
|
||||||
|
Sort: "sort",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminRoleDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminRoleDao(handlers ...gdb.ModelHandler) *AdminRoleDao {
|
||||||
|
return &AdminRoleDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_role",
|
||||||
|
columns: adminRoleColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminRoleDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminRoleDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminRoleDao) Columns() AdminRoleColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminRoleDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminRoleDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminRoleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+93
@@ -0,0 +1,93 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminRoleCasbinDao is the data access object for the table hg_admin_role_casbin.
|
||||||
|
type AdminRoleCasbinDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminRoleCasbinColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminRoleCasbinColumns defines and stores column names for the table hg_admin_role_casbin.
|
||||||
|
type AdminRoleCasbinColumns struct {
|
||||||
|
Id string //
|
||||||
|
PType string //
|
||||||
|
V0 string //
|
||||||
|
V1 string //
|
||||||
|
V2 string //
|
||||||
|
V3 string //
|
||||||
|
V4 string //
|
||||||
|
V5 string //
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminRoleCasbinColumns holds the columns for the table hg_admin_role_casbin.
|
||||||
|
var adminRoleCasbinColumns = AdminRoleCasbinColumns{
|
||||||
|
Id: "id",
|
||||||
|
PType: "p_type",
|
||||||
|
V0: "v0",
|
||||||
|
V1: "v1",
|
||||||
|
V2: "v2",
|
||||||
|
V3: "v3",
|
||||||
|
V4: "v4",
|
||||||
|
V5: "v5",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminRoleCasbinDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminRoleCasbinDao(handlers ...gdb.ModelHandler) *AdminRoleCasbinDao {
|
||||||
|
return &AdminRoleCasbinDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_role_casbin",
|
||||||
|
columns: adminRoleCasbinColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminRoleCasbinDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminRoleCasbinDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminRoleCasbinDao) Columns() AdminRoleCasbinColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminRoleCasbinDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminRoleCasbinDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminRoleCasbinDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+81
@@ -0,0 +1,81 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminRoleMenuDao is the data access object for the table hg_admin_role_menu.
|
||||||
|
type AdminRoleMenuDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminRoleMenuColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminRoleMenuColumns defines and stores column names for the table hg_admin_role_menu.
|
||||||
|
type AdminRoleMenuColumns struct {
|
||||||
|
RoleId string // 角色ID
|
||||||
|
MenuId string // 菜单ID
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminRoleMenuColumns holds the columns for the table hg_admin_role_menu.
|
||||||
|
var adminRoleMenuColumns = AdminRoleMenuColumns{
|
||||||
|
RoleId: "role_id",
|
||||||
|
MenuId: "menu_id",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminRoleMenuDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminRoleMenuDao(handlers ...gdb.ModelHandler) *AdminRoleMenuDao {
|
||||||
|
return &AdminRoleMenuDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_admin_role_menu",
|
||||||
|
columns: adminRoleMenuColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminRoleMenuDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminRoleMenuDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminRoleMenuDao) Columns() AdminRoleMenuColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminRoleMenuDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminRoleMenuDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminRoleMenuDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+137
@@ -0,0 +1,137 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PayLogDao is the data access object for the table hg_pay_log.
|
||||||
|
type PayLogDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns PayLogColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// PayLogColumns defines and stores column names for the table hg_pay_log.
|
||||||
|
type PayLogColumns struct {
|
||||||
|
Id string // 主键
|
||||||
|
MemberId string // 会员ID
|
||||||
|
AppId string // 应用ID
|
||||||
|
AddonsName string // 插件名称
|
||||||
|
OrderSn string // 关联订单号
|
||||||
|
OrderGroup string // 组别[默认统一支付类型]
|
||||||
|
Openid string // openid
|
||||||
|
MchId string // 商户支付账户
|
||||||
|
Subject string // 订单标题
|
||||||
|
Detail string // 支付商品详情
|
||||||
|
AuthCode string // 刷卡码
|
||||||
|
OutTradeNo string // 商户订单号
|
||||||
|
TransactionId string // 交易号
|
||||||
|
PayType string // 支付类型
|
||||||
|
PayAmount string // 支付金额
|
||||||
|
ActualAmount string // 实付金额
|
||||||
|
PayStatus string // 支付状态
|
||||||
|
PayAt string // 支付时间
|
||||||
|
TradeType string // 交易类型
|
||||||
|
RefundSn string // 退款单号
|
||||||
|
IsRefund string // 是否退款
|
||||||
|
Custom string // 自定义参数
|
||||||
|
CreateIp string // 创建者IP
|
||||||
|
PayIp string // 支付者IP
|
||||||
|
NotifyUrl string // 支付通知回调地址
|
||||||
|
ReturnUrl string // 买家付款成功跳转地址
|
||||||
|
TraceIds string // 链路ID集合
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// payLogColumns holds the columns for the table hg_pay_log.
|
||||||
|
var payLogColumns = PayLogColumns{
|
||||||
|
Id: "id",
|
||||||
|
MemberId: "member_id",
|
||||||
|
AppId: "app_id",
|
||||||
|
AddonsName: "addons_name",
|
||||||
|
OrderSn: "order_sn",
|
||||||
|
OrderGroup: "order_group",
|
||||||
|
Openid: "openid",
|
||||||
|
MchId: "mch_id",
|
||||||
|
Subject: "subject",
|
||||||
|
Detail: "detail",
|
||||||
|
AuthCode: "auth_code",
|
||||||
|
OutTradeNo: "out_trade_no",
|
||||||
|
TransactionId: "transaction_id",
|
||||||
|
PayType: "pay_type",
|
||||||
|
PayAmount: "pay_amount",
|
||||||
|
ActualAmount: "actual_amount",
|
||||||
|
PayStatus: "pay_status",
|
||||||
|
PayAt: "pay_at",
|
||||||
|
TradeType: "trade_type",
|
||||||
|
RefundSn: "refund_sn",
|
||||||
|
IsRefund: "is_refund",
|
||||||
|
Custom: "custom",
|
||||||
|
CreateIp: "create_ip",
|
||||||
|
PayIp: "pay_ip",
|
||||||
|
NotifyUrl: "notify_url",
|
||||||
|
ReturnUrl: "return_url",
|
||||||
|
TraceIds: "trace_ids",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewPayLogDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewPayLogDao(handlers ...gdb.ModelHandler) *PayLogDao {
|
||||||
|
return &PayLogDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_pay_log",
|
||||||
|
columns: payLogColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *PayLogDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *PayLogDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *PayLogDao) Columns() PayLogColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *PayLogDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *PayLogDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *PayLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+103
@@ -0,0 +1,103 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PayRefundDao is the data access object for the table hg_pay_refund.
|
||||||
|
type PayRefundDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns PayRefundColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// PayRefundColumns defines and stores column names for the table hg_pay_refund.
|
||||||
|
type PayRefundColumns struct {
|
||||||
|
Id string // 主键ID
|
||||||
|
MemberId string // 会员ID
|
||||||
|
AppId string // 应用ID
|
||||||
|
OrderSn string // 业务订单号
|
||||||
|
RefundTradeNo string // 退款交易号
|
||||||
|
RefundMoney string // 退款金额
|
||||||
|
RefundWay string // 退款方式
|
||||||
|
Ip string // 申请者IP
|
||||||
|
Reason string // 申请退款原因
|
||||||
|
Remark string // 退款备注
|
||||||
|
Status string // 退款状态
|
||||||
|
CreatedAt string // 申请时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// payRefundColumns holds the columns for the table hg_pay_refund.
|
||||||
|
var payRefundColumns = PayRefundColumns{
|
||||||
|
Id: "id",
|
||||||
|
MemberId: "member_id",
|
||||||
|
AppId: "app_id",
|
||||||
|
OrderSn: "order_sn",
|
||||||
|
RefundTradeNo: "refund_trade_no",
|
||||||
|
RefundMoney: "refund_money",
|
||||||
|
RefundWay: "refund_way",
|
||||||
|
Ip: "ip",
|
||||||
|
Reason: "reason",
|
||||||
|
Remark: "remark",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewPayRefundDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewPayRefundDao(handlers ...gdb.ModelHandler) *PayRefundDao {
|
||||||
|
return &PayRefundDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_pay_refund",
|
||||||
|
columns: payRefundColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *PayRefundDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *PayRefundDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *PayRefundDao) Columns() PayRefundColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *PayRefundDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *PayRefundDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *PayRefundDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+105
@@ -0,0 +1,105 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysAddonsConfigDao is the data access object for the table hg_sys_addons_config.
|
||||||
|
type SysAddonsConfigDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysAddonsConfigColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysAddonsConfigColumns defines and stores column names for the table hg_sys_addons_config.
|
||||||
|
type SysAddonsConfigColumns struct {
|
||||||
|
Id string // 配置ID
|
||||||
|
AddonName string // 插件名称
|
||||||
|
Group string // 分组
|
||||||
|
Name string // 参数名称
|
||||||
|
Type string // 键值类型:string,int,uint,bool,TIMESTAMP,date
|
||||||
|
Key string // 参数键名
|
||||||
|
Value string // 参数键值
|
||||||
|
DefaultValue string // 默认值
|
||||||
|
Sort string // 排序
|
||||||
|
Tip string // 变量描述
|
||||||
|
IsDefault string // 是否为系统默认
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysAddonsConfigColumns holds the columns for the table hg_sys_addons_config.
|
||||||
|
var sysAddonsConfigColumns = SysAddonsConfigColumns{
|
||||||
|
Id: "id",
|
||||||
|
AddonName: "addon_name",
|
||||||
|
Group: "group",
|
||||||
|
Name: "name",
|
||||||
|
Type: "type",
|
||||||
|
Key: "key",
|
||||||
|
Value: "value",
|
||||||
|
DefaultValue: "default_value",
|
||||||
|
Sort: "sort",
|
||||||
|
Tip: "tip",
|
||||||
|
IsDefault: "is_default",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysAddonsConfigDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysAddonsConfigDao(handlers ...gdb.ModelHandler) *SysAddonsConfigDao {
|
||||||
|
return &SysAddonsConfigDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_addons_config",
|
||||||
|
columns: sysAddonsConfigColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysAddonsConfigDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysAddonsConfigDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysAddonsConfigDao) Columns() SysAddonsConfigColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysAddonsConfigDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysAddonsConfigDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysAddonsConfigDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysAddonsInstallDao is the data access object for the table hg_sys_addons_install.
|
||||||
|
type SysAddonsInstallDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysAddonsInstallColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysAddonsInstallColumns defines and stores column names for the table hg_sys_addons_install.
|
||||||
|
type SysAddonsInstallColumns struct {
|
||||||
|
Id string // 主键
|
||||||
|
Name string // 插件名称
|
||||||
|
Version string // 版本号
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysAddonsInstallColumns holds the columns for the table hg_sys_addons_install.
|
||||||
|
var sysAddonsInstallColumns = SysAddonsInstallColumns{
|
||||||
|
Id: "id",
|
||||||
|
Name: "name",
|
||||||
|
Version: "version",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysAddonsInstallDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysAddonsInstallDao(handlers ...gdb.ModelHandler) *SysAddonsInstallDao {
|
||||||
|
return &SysAddonsInstallDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_addons_install",
|
||||||
|
columns: sysAddonsInstallColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysAddonsInstallDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysAddonsInstallDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysAddonsInstallDao) Columns() SysAddonsInstallColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysAddonsInstallDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysAddonsInstallDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysAddonsInstallDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+111
@@ -0,0 +1,111 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysAttachmentDao is the data access object for the table hg_sys_attachment.
|
||||||
|
type SysAttachmentDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysAttachmentColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysAttachmentColumns defines and stores column names for the table hg_sys_attachment.
|
||||||
|
type SysAttachmentColumns struct {
|
||||||
|
Id string // 文件ID
|
||||||
|
AppId string // 应用ID
|
||||||
|
MemberId string // 管理员ID
|
||||||
|
CateId string // 上传分类
|
||||||
|
Drive string // 上传驱动
|
||||||
|
Name string // 文件原始名
|
||||||
|
Kind string // 上传类型
|
||||||
|
MimeType string // 扩展类型
|
||||||
|
NaiveType string // NaiveUI类型
|
||||||
|
Path string // 本地路径
|
||||||
|
FileUrl string // url
|
||||||
|
Size string // 文件大小
|
||||||
|
Ext string // 扩展名
|
||||||
|
Md5 string // md5校验码
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysAttachmentColumns holds the columns for the table hg_sys_attachment.
|
||||||
|
var sysAttachmentColumns = SysAttachmentColumns{
|
||||||
|
Id: "id",
|
||||||
|
AppId: "app_id",
|
||||||
|
MemberId: "member_id",
|
||||||
|
CateId: "cate_id",
|
||||||
|
Drive: "drive",
|
||||||
|
Name: "name",
|
||||||
|
Kind: "kind",
|
||||||
|
MimeType: "mime_type",
|
||||||
|
NaiveType: "naive_type",
|
||||||
|
Path: "path",
|
||||||
|
FileUrl: "file_url",
|
||||||
|
Size: "size",
|
||||||
|
Ext: "ext",
|
||||||
|
Md5: "md5",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysAttachmentDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysAttachmentDao(handlers ...gdb.ModelHandler) *SysAttachmentDao {
|
||||||
|
return &SysAttachmentDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_attachment",
|
||||||
|
columns: sysAttachmentColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysAttachmentDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysAttachmentDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysAttachmentDao) Columns() SysAttachmentColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysAttachmentDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysAttachmentDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysAttachmentDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+89
@@ -0,0 +1,89 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysBlacklistDao is the data access object for the table hg_sys_blacklist.
|
||||||
|
type SysBlacklistDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysBlacklistColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysBlacklistColumns defines and stores column names for the table hg_sys_blacklist.
|
||||||
|
type SysBlacklistColumns struct {
|
||||||
|
Id string // 黑名单ID
|
||||||
|
Ip string // IP地址
|
||||||
|
Remark string // 备注
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysBlacklistColumns holds the columns for the table hg_sys_blacklist.
|
||||||
|
var sysBlacklistColumns = SysBlacklistColumns{
|
||||||
|
Id: "id",
|
||||||
|
Ip: "ip",
|
||||||
|
Remark: "remark",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysBlacklistDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysBlacklistDao(handlers ...gdb.ModelHandler) *SysBlacklistDao {
|
||||||
|
return &SysBlacklistDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_blacklist",
|
||||||
|
columns: sysBlacklistColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysBlacklistDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysBlacklistDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysBlacklistDao) Columns() SysBlacklistColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysBlacklistDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysBlacklistDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysBlacklistDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+103
@@ -0,0 +1,103 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysConfigDao is the data access object for the table hg_sys_config.
|
||||||
|
type SysConfigDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysConfigColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysConfigColumns defines and stores column names for the table hg_sys_config.
|
||||||
|
type SysConfigColumns struct {
|
||||||
|
Id string // 配置ID
|
||||||
|
Group string // 配置分组
|
||||||
|
Name string // 参数名称
|
||||||
|
Type string // 键值类型:string,int,uint,bool,TIMESTAMP,date
|
||||||
|
Key string // 参数键名
|
||||||
|
Value string // 参数键值
|
||||||
|
DefaultValue string // 默认值
|
||||||
|
Sort string // 排序
|
||||||
|
Tip string // 变量描述
|
||||||
|
IsDefault string // 是否为系统默认
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysConfigColumns holds the columns for the table hg_sys_config.
|
||||||
|
var sysConfigColumns = SysConfigColumns{
|
||||||
|
Id: "id",
|
||||||
|
Group: "group",
|
||||||
|
Name: "name",
|
||||||
|
Type: "type",
|
||||||
|
Key: "key",
|
||||||
|
Value: "value",
|
||||||
|
DefaultValue: "default_value",
|
||||||
|
Sort: "sort",
|
||||||
|
Tip: "tip",
|
||||||
|
IsDefault: "is_default",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysConfigDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysConfigDao(handlers ...gdb.ModelHandler) *SysConfigDao {
|
||||||
|
return &SysConfigDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_config",
|
||||||
|
columns: sysConfigColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysConfigDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysConfigDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysConfigDao) Columns() SysConfigColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysConfigDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysConfigDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysConfigDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+103
@@ -0,0 +1,103 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysCronDao is the data access object for the table hg_sys_cron.
|
||||||
|
type SysCronDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysCronColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysCronColumns defines and stores column names for the table hg_sys_cron.
|
||||||
|
type SysCronColumns struct {
|
||||||
|
Id string // 任务ID
|
||||||
|
GroupId string // 分组ID
|
||||||
|
Title string // 任务标题
|
||||||
|
Name string // 任务方法
|
||||||
|
Params string // 函数参数
|
||||||
|
Pattern string // 表达式
|
||||||
|
Policy string // 策略
|
||||||
|
Count string // 执行次数
|
||||||
|
Sort string // 排序
|
||||||
|
Remark string // 备注
|
||||||
|
Status string // 任务状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysCronColumns holds the columns for the table hg_sys_cron.
|
||||||
|
var sysCronColumns = SysCronColumns{
|
||||||
|
Id: "id",
|
||||||
|
GroupId: "group_id",
|
||||||
|
Title: "title",
|
||||||
|
Name: "name",
|
||||||
|
Params: "params",
|
||||||
|
Pattern: "pattern",
|
||||||
|
Policy: "policy",
|
||||||
|
Count: "count",
|
||||||
|
Sort: "sort",
|
||||||
|
Remark: "remark",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysCronDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysCronDao(handlers ...gdb.ModelHandler) *SysCronDao {
|
||||||
|
return &SysCronDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_cron",
|
||||||
|
columns: sysCronColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysCronDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysCronDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysCronDao) Columns() SysCronColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysCronDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysCronDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysCronDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+95
@@ -0,0 +1,95 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysCronGroupDao is the data access object for the table hg_sys_cron_group.
|
||||||
|
type SysCronGroupDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysCronGroupColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysCronGroupColumns defines and stores column names for the table hg_sys_cron_group.
|
||||||
|
type SysCronGroupColumns struct {
|
||||||
|
Id string // 任务分组ID
|
||||||
|
Pid string // 父类任务分组ID
|
||||||
|
Name string // 分组名称
|
||||||
|
IsDefault string // 是否默认
|
||||||
|
Sort string // 排序
|
||||||
|
Remark string // 备注
|
||||||
|
Status string // 分组状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysCronGroupColumns holds the columns for the table hg_sys_cron_group.
|
||||||
|
var sysCronGroupColumns = SysCronGroupColumns{
|
||||||
|
Id: "id",
|
||||||
|
Pid: "pid",
|
||||||
|
Name: "name",
|
||||||
|
IsDefault: "is_default",
|
||||||
|
Sort: "sort",
|
||||||
|
Remark: "remark",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysCronGroupDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysCronGroupDao(handlers ...gdb.ModelHandler) *SysCronGroupDao {
|
||||||
|
return &SysCronGroupDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_cron_group",
|
||||||
|
columns: sysCronGroupColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysCronGroupDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysCronGroupDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysCronGroupDao) Columns() SysCronGroupColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysCronGroupDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysCronGroupDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysCronGroupDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+101
@@ -0,0 +1,101 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysDictDataDao is the data access object for the table hg_sys_dict_data.
|
||||||
|
type SysDictDataDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysDictDataColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysDictDataColumns defines and stores column names for the table hg_sys_dict_data.
|
||||||
|
type SysDictDataColumns struct {
|
||||||
|
Id string // 字典数据ID
|
||||||
|
Label string // 字典标签
|
||||||
|
Value string // 字典键值
|
||||||
|
ValueType string // 键值数据类型:string,int,uint,bool,TIMESTAMP,date
|
||||||
|
Type string // 字典类型
|
||||||
|
ListClass string // 表格回显样式
|
||||||
|
IsDefault string // 是否为系统默认
|
||||||
|
Sort string // 字典排序
|
||||||
|
Remark string // 备注
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysDictDataColumns holds the columns for the table hg_sys_dict_data.
|
||||||
|
var sysDictDataColumns = SysDictDataColumns{
|
||||||
|
Id: "id",
|
||||||
|
Label: "label",
|
||||||
|
Value: "value",
|
||||||
|
ValueType: "value_type",
|
||||||
|
Type: "type",
|
||||||
|
ListClass: "list_class",
|
||||||
|
IsDefault: "is_default",
|
||||||
|
Sort: "sort",
|
||||||
|
Remark: "remark",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysDictDataDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysDictDataDao(handlers ...gdb.ModelHandler) *SysDictDataDao {
|
||||||
|
return &SysDictDataDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_dict_data",
|
||||||
|
columns: sysDictDataColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysDictDataDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysDictDataDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysDictDataDao) Columns() SysDictDataColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysDictDataDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysDictDataDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysDictDataDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+95
@@ -0,0 +1,95 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysDictTypeDao is the data access object for the table hg_sys_dict_type.
|
||||||
|
type SysDictTypeDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysDictTypeColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysDictTypeColumns defines and stores column names for the table hg_sys_dict_type.
|
||||||
|
type SysDictTypeColumns struct {
|
||||||
|
Id string // 字典类型ID
|
||||||
|
Pid string // 父类字典类型ID
|
||||||
|
Name string // 字典类型名称
|
||||||
|
Type string // 字典类型
|
||||||
|
Sort string // 排序
|
||||||
|
Remark string // 备注
|
||||||
|
Status string // 字典类型状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysDictTypeColumns holds the columns for the table hg_sys_dict_type.
|
||||||
|
var sysDictTypeColumns = SysDictTypeColumns{
|
||||||
|
Id: "id",
|
||||||
|
Pid: "pid",
|
||||||
|
Name: "name",
|
||||||
|
Type: "type",
|
||||||
|
Sort: "sort",
|
||||||
|
Remark: "remark",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysDictTypeDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysDictTypeDao(handlers ...gdb.ModelHandler) *SysDictTypeDao {
|
||||||
|
return &SysDictTypeDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_dict_type",
|
||||||
|
columns: sysDictTypeColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysDictTypeDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysDictTypeDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysDictTypeDao) Columns() SysDictTypeColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysDictTypeDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysDictTypeDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysDictTypeDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+97
@@ -0,0 +1,97 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysEmsLogDao is the data access object for the table hg_sys_ems_log.
|
||||||
|
type SysEmsLogDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysEmsLogColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysEmsLogColumns defines and stores column names for the table hg_sys_ems_log.
|
||||||
|
type SysEmsLogColumns struct {
|
||||||
|
Id string // 主键
|
||||||
|
Event string // 事件
|
||||||
|
Email string // 邮箱地址,多个用;隔开
|
||||||
|
Code string // 验证码
|
||||||
|
Times string // 验证次数
|
||||||
|
Content string // 邮件内容
|
||||||
|
Ip string // ip地址
|
||||||
|
Status string // 状态(1未验证,2已验证)
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysEmsLogColumns holds the columns for the table hg_sys_ems_log.
|
||||||
|
var sysEmsLogColumns = SysEmsLogColumns{
|
||||||
|
Id: "id",
|
||||||
|
Event: "event",
|
||||||
|
Email: "email",
|
||||||
|
Code: "code",
|
||||||
|
Times: "times",
|
||||||
|
Content: "content",
|
||||||
|
Ip: "ip",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysEmsLogDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysEmsLogDao(handlers ...gdb.ModelHandler) *SysEmsLogDao {
|
||||||
|
return &SysEmsLogDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_ems_log",
|
||||||
|
columns: sysEmsLogColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysEmsLogDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysEmsLogDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysEmsLogDao) Columns() SysEmsLogColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysEmsLogDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysEmsLogDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysEmsLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+105
@@ -0,0 +1,105 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysGenCodesDao is the data access object for the table hg_sys_gen_codes.
|
||||||
|
type SysGenCodesDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysGenCodesColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysGenCodesColumns defines and stores column names for the table hg_sys_gen_codes.
|
||||||
|
type SysGenCodesColumns struct {
|
||||||
|
Id string // 生成ID
|
||||||
|
GenType string // 生成类型
|
||||||
|
GenTemplate string // 生成模板
|
||||||
|
VarName string // 实体命名
|
||||||
|
Options string // 配置选项
|
||||||
|
DbName string // 数据库名称
|
||||||
|
TableName string // 主表名称
|
||||||
|
TableComment string // 主表注释
|
||||||
|
DaoName string // 主表dao模型
|
||||||
|
MasterColumns string // 主表字段
|
||||||
|
AddonName string // 插件名称
|
||||||
|
Status string // 生成状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysGenCodesColumns holds the columns for the table hg_sys_gen_codes.
|
||||||
|
var sysGenCodesColumns = SysGenCodesColumns{
|
||||||
|
Id: "id",
|
||||||
|
GenType: "gen_type",
|
||||||
|
GenTemplate: "gen_template",
|
||||||
|
VarName: "var_name",
|
||||||
|
Options: "options",
|
||||||
|
DbName: "db_name",
|
||||||
|
TableName: "table_name",
|
||||||
|
TableComment: "table_comment",
|
||||||
|
DaoName: "dao_name",
|
||||||
|
MasterColumns: "master_columns",
|
||||||
|
AddonName: "addon_name",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysGenCodesDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysGenCodesDao(handlers ...gdb.ModelHandler) *SysGenCodesDao {
|
||||||
|
return &SysGenCodesDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_gen_codes",
|
||||||
|
columns: sysGenCodesColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysGenCodesDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysGenCodesDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysGenCodesDao) Columns() SysGenCodesColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysGenCodesDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysGenCodesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysGenCodesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+111
@@ -0,0 +1,111 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysGenCurdDemoDao is the data access object for the table hg_sys_gen_curd_demo.
|
||||||
|
type SysGenCurdDemoDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysGenCurdDemoColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysGenCurdDemoColumns defines and stores column names for the table hg_sys_gen_curd_demo.
|
||||||
|
type SysGenCurdDemoColumns struct {
|
||||||
|
Id string // ID
|
||||||
|
CategoryId string // 分类ID
|
||||||
|
Title string // 标题
|
||||||
|
Description string // 描述
|
||||||
|
Content string // 内容
|
||||||
|
Image string // 单图
|
||||||
|
Attachfile string // 附件
|
||||||
|
CityId string // 所在城市
|
||||||
|
Switch string // 显示开关
|
||||||
|
Sort string // 排序
|
||||||
|
Status string // 状态
|
||||||
|
CreatedBy string // 创建者
|
||||||
|
UpdatedBy string // 更新者
|
||||||
|
DeletedBy string // 删除者
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
DeletedAt string // 删除时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysGenCurdDemoColumns holds the columns for the table hg_sys_gen_curd_demo.
|
||||||
|
var sysGenCurdDemoColumns = SysGenCurdDemoColumns{
|
||||||
|
Id: "id",
|
||||||
|
CategoryId: "category_id",
|
||||||
|
Title: "title",
|
||||||
|
Description: "description",
|
||||||
|
Content: "content",
|
||||||
|
Image: "image",
|
||||||
|
Attachfile: "attachfile",
|
||||||
|
CityId: "city_id",
|
||||||
|
Switch: "switch",
|
||||||
|
Sort: "sort",
|
||||||
|
Status: "status",
|
||||||
|
CreatedBy: "created_by",
|
||||||
|
UpdatedBy: "updated_by",
|
||||||
|
DeletedBy: "deleted_by",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysGenCurdDemoDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysGenCurdDemoDao(handlers ...gdb.ModelHandler) *SysGenCurdDemoDao {
|
||||||
|
return &SysGenCurdDemoDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_gen_curd_demo",
|
||||||
|
columns: sysGenCurdDemoColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysGenCurdDemoDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysGenCurdDemoDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysGenCurdDemoDao) Columns() SysGenCurdDemoColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysGenCurdDemoDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysGenCurdDemoDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysGenCurdDemoDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+105
@@ -0,0 +1,105 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysGenTreeDemoDao is the data access object for the table hg_sys_gen_tree_demo.
|
||||||
|
type SysGenTreeDemoDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysGenTreeDemoColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysGenTreeDemoColumns defines and stores column names for the table hg_sys_gen_tree_demo.
|
||||||
|
type SysGenTreeDemoColumns struct {
|
||||||
|
Id string // ID
|
||||||
|
Pid string // 上级ID
|
||||||
|
Level string // 关系树级别
|
||||||
|
Tree string // 关系树
|
||||||
|
CategoryId string // 分类ID
|
||||||
|
Title string // 标题
|
||||||
|
Description string // 描述
|
||||||
|
Sort string // 排序
|
||||||
|
Status string // 状态
|
||||||
|
CreatedBy string // 创建者
|
||||||
|
UpdatedBy string // 更新者
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
DeletedAt string // 删除时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysGenTreeDemoColumns holds the columns for the table hg_sys_gen_tree_demo.
|
||||||
|
var sysGenTreeDemoColumns = SysGenTreeDemoColumns{
|
||||||
|
Id: "id",
|
||||||
|
Pid: "pid",
|
||||||
|
Level: "level",
|
||||||
|
Tree: "tree",
|
||||||
|
CategoryId: "category_id",
|
||||||
|
Title: "title",
|
||||||
|
Description: "description",
|
||||||
|
Sort: "sort",
|
||||||
|
Status: "status",
|
||||||
|
CreatedBy: "created_by",
|
||||||
|
UpdatedBy: "updated_by",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysGenTreeDemoDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysGenTreeDemoDao(handlers ...gdb.ModelHandler) *SysGenTreeDemoDao {
|
||||||
|
return &SysGenTreeDemoDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_gen_tree_demo",
|
||||||
|
columns: sysGenTreeDemoColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysGenTreeDemoDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysGenTreeDemoDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysGenTreeDemoDao) Columns() SysGenTreeDemoColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysGenTreeDemoDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysGenTreeDemoDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysGenTreeDemoDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+123
@@ -0,0 +1,123 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysLogDao is the data access object for the table hg_sys_log.
|
||||||
|
type SysLogDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysLogColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysLogColumns defines and stores column names for the table hg_sys_log.
|
||||||
|
type SysLogColumns struct {
|
||||||
|
Id string // 日志ID
|
||||||
|
ReqId string // 对外ID
|
||||||
|
AppId string // 应用ID
|
||||||
|
MerchantId string // 商户ID
|
||||||
|
MemberId string // 用户ID
|
||||||
|
Method string // 提交类型
|
||||||
|
Module string // 访问模块
|
||||||
|
Url string // 提交url
|
||||||
|
GetData string // get数据
|
||||||
|
PostData string // post数据
|
||||||
|
HeaderData string // header数据
|
||||||
|
Ip string // IP地址
|
||||||
|
ProvinceId string // 省编码
|
||||||
|
CityId string // 市编码
|
||||||
|
ErrorCode string // 报错code
|
||||||
|
ErrorMsg string // 对外错误提示
|
||||||
|
ErrorData string // 报错日志
|
||||||
|
UserAgent string // UA信息
|
||||||
|
TakeUpTime string // 请求耗时
|
||||||
|
Timestamp string // 响应时间
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysLogColumns holds the columns for the table hg_sys_log.
|
||||||
|
var sysLogColumns = SysLogColumns{
|
||||||
|
Id: "id",
|
||||||
|
ReqId: "req_id",
|
||||||
|
AppId: "app_id",
|
||||||
|
MerchantId: "merchant_id",
|
||||||
|
MemberId: "member_id",
|
||||||
|
Method: "method",
|
||||||
|
Module: "module",
|
||||||
|
Url: "url",
|
||||||
|
GetData: "get_data",
|
||||||
|
PostData: "post_data",
|
||||||
|
HeaderData: "header_data",
|
||||||
|
Ip: "ip",
|
||||||
|
ProvinceId: "province_id",
|
||||||
|
CityId: "city_id",
|
||||||
|
ErrorCode: "error_code",
|
||||||
|
ErrorMsg: "error_msg",
|
||||||
|
ErrorData: "error_data",
|
||||||
|
UserAgent: "user_agent",
|
||||||
|
TakeUpTime: "take_up_time",
|
||||||
|
Timestamp: "timestamp",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysLogDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysLogDao(handlers ...gdb.ModelHandler) *SysLogDao {
|
||||||
|
return &SysLogDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_log",
|
||||||
|
columns: sysLogColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysLogDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysLogDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysLogDao) Columns() SysLogColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysLogDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysLogDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+105
@@ -0,0 +1,105 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysLoginLogDao is the data access object for the table hg_sys_login_log.
|
||||||
|
type SysLoginLogDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysLoginLogColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysLoginLogColumns defines and stores column names for the table hg_sys_login_log.
|
||||||
|
type SysLoginLogColumns struct {
|
||||||
|
Id string // 日志ID
|
||||||
|
ReqId string // 请求ID
|
||||||
|
MemberId string // 用户ID
|
||||||
|
Username string // 用户名
|
||||||
|
Response string // 响应数据
|
||||||
|
LoginAt string // 登录时间
|
||||||
|
LoginIp string // 登录IP
|
||||||
|
ProvinceId string // 省编码
|
||||||
|
CityId string // 市编码
|
||||||
|
UserAgent string // UA信息
|
||||||
|
ErrMsg string // 错误提示
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysLoginLogColumns holds the columns for the table hg_sys_login_log.
|
||||||
|
var sysLoginLogColumns = SysLoginLogColumns{
|
||||||
|
Id: "id",
|
||||||
|
ReqId: "req_id",
|
||||||
|
MemberId: "member_id",
|
||||||
|
Username: "username",
|
||||||
|
Response: "response",
|
||||||
|
LoginAt: "login_at",
|
||||||
|
LoginIp: "login_ip",
|
||||||
|
ProvinceId: "province_id",
|
||||||
|
CityId: "city_id",
|
||||||
|
UserAgent: "user_agent",
|
||||||
|
ErrMsg: "err_msg",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysLoginLogDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysLoginLogDao(handlers ...gdb.ModelHandler) *SysLoginLogDao {
|
||||||
|
return &SysLoginLogDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_login_log",
|
||||||
|
columns: sysLoginLogColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysLoginLogDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysLoginLogDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysLoginLogDao) Columns() SysLoginLogColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysLoginLogDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysLoginLogDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysLoginLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+101
@@ -0,0 +1,101 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysProvincesDao is the data access object for the table hg_sys_provinces.
|
||||||
|
type SysProvincesDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysProvincesColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysProvincesColumns defines and stores column names for the table hg_sys_provinces.
|
||||||
|
type SysProvincesColumns struct {
|
||||||
|
Id string // 省市区ID
|
||||||
|
Title string // 栏目名称
|
||||||
|
Pinyin string // 拼音
|
||||||
|
Lng string // 经度
|
||||||
|
Lat string // 纬度
|
||||||
|
Pid string // 父栏目
|
||||||
|
Level string // 关系树等级
|
||||||
|
Tree string // 关系
|
||||||
|
Sort string // 排序
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysProvincesColumns holds the columns for the table hg_sys_provinces.
|
||||||
|
var sysProvincesColumns = SysProvincesColumns{
|
||||||
|
Id: "id",
|
||||||
|
Title: "title",
|
||||||
|
Pinyin: "pinyin",
|
||||||
|
Lng: "lng",
|
||||||
|
Lat: "lat",
|
||||||
|
Pid: "pid",
|
||||||
|
Level: "level",
|
||||||
|
Tree: "tree",
|
||||||
|
Sort: "sort",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysProvincesDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysProvincesDao(handlers ...gdb.ModelHandler) *SysProvincesDao {
|
||||||
|
return &SysProvincesDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_provinces",
|
||||||
|
columns: sysProvincesColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysProvincesDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysProvincesDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysProvincesDao) Columns() SysProvincesColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysProvincesDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysProvincesDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysProvincesDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+111
@@ -0,0 +1,111 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysServeLicenseDao is the data access object for the table hg_sys_serve_license.
|
||||||
|
type SysServeLicenseDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysServeLicenseColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysServeLicenseColumns defines and stores column names for the table hg_sys_serve_license.
|
||||||
|
type SysServeLicenseColumns struct {
|
||||||
|
Id string // 许可ID
|
||||||
|
Group string // 分组
|
||||||
|
Name string // 许可名称
|
||||||
|
Appid string // 应用ID
|
||||||
|
SecretKey string // 应用秘钥
|
||||||
|
RemoteAddr string // 最后连接地址
|
||||||
|
OnlineLimit string // 在线限制
|
||||||
|
LoginTimes string // 登录次数
|
||||||
|
LastLoginAt string // 最后登录时间
|
||||||
|
LastActiveAt string // 最后心跳
|
||||||
|
Routes string // 路由表,空使用默认分组路由
|
||||||
|
AllowedIps string // IP白名单
|
||||||
|
EndAt string // 授权有效期
|
||||||
|
Remark string // 备注
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysServeLicenseColumns holds the columns for the table hg_sys_serve_license.
|
||||||
|
var sysServeLicenseColumns = SysServeLicenseColumns{
|
||||||
|
Id: "id",
|
||||||
|
Group: "group",
|
||||||
|
Name: "name",
|
||||||
|
Appid: "appid",
|
||||||
|
SecretKey: "secret_key",
|
||||||
|
RemoteAddr: "remote_addr",
|
||||||
|
OnlineLimit: "online_limit",
|
||||||
|
LoginTimes: "login_times",
|
||||||
|
LastLoginAt: "last_login_at",
|
||||||
|
LastActiveAt: "last_active_at",
|
||||||
|
Routes: "routes",
|
||||||
|
AllowedIps: "allowed_ips",
|
||||||
|
EndAt: "end_at",
|
||||||
|
Remark: "remark",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysServeLicenseDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysServeLicenseDao(handlers ...gdb.ModelHandler) *SysServeLicenseDao {
|
||||||
|
return &SysServeLicenseDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_serve_license",
|
||||||
|
columns: sysServeLicenseColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysServeLicenseDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysServeLicenseDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysServeLicenseDao) Columns() SysServeLicenseColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysServeLicenseDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysServeLicenseDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysServeLicenseDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+97
@@ -0,0 +1,97 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysServeLogDao is the data access object for the table hg_sys_serve_log.
|
||||||
|
type SysServeLogDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysServeLogColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysServeLogColumns defines and stores column names for the table hg_sys_serve_log.
|
||||||
|
type SysServeLogColumns struct {
|
||||||
|
Id string // 日志ID
|
||||||
|
TraceId string // 链路ID
|
||||||
|
LevelFormat string // 日志级别
|
||||||
|
Content string // 日志内容
|
||||||
|
Stack string // 打印堆栈
|
||||||
|
Line string // 调用行
|
||||||
|
TriggerNs string // 触发时间(ns)
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysServeLogColumns holds the columns for the table hg_sys_serve_log.
|
||||||
|
var sysServeLogColumns = SysServeLogColumns{
|
||||||
|
Id: "id",
|
||||||
|
TraceId: "trace_id",
|
||||||
|
LevelFormat: "level_format",
|
||||||
|
Content: "content",
|
||||||
|
Stack: "stack",
|
||||||
|
Line: "line",
|
||||||
|
TriggerNs: "trigger_ns",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysServeLogDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysServeLogDao(handlers ...gdb.ModelHandler) *SysServeLogDao {
|
||||||
|
return &SysServeLogDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_serve_log",
|
||||||
|
columns: sysServeLogColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysServeLogDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysServeLogDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysServeLogDao) Columns() SysServeLogColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysServeLogDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysServeLogDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysServeLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+95
@@ -0,0 +1,95 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SysSmsLogDao is the data access object for the table hg_sys_sms_log.
|
||||||
|
type SysSmsLogDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns SysSmsLogColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SysSmsLogColumns defines and stores column names for the table hg_sys_sms_log.
|
||||||
|
type SysSmsLogColumns struct {
|
||||||
|
Id string // 主键
|
||||||
|
Event string // 事件
|
||||||
|
Mobile string // 手机号
|
||||||
|
Code string // 验证码或短信内容
|
||||||
|
Times string // 验证次数
|
||||||
|
Ip string // ip地址
|
||||||
|
Status string // 状态(1未验证,2已验证)
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// sysSmsLogColumns holds the columns for the table hg_sys_sms_log.
|
||||||
|
var sysSmsLogColumns = SysSmsLogColumns{
|
||||||
|
Id: "id",
|
||||||
|
Event: "event",
|
||||||
|
Mobile: "mobile",
|
||||||
|
Code: "code",
|
||||||
|
Times: "times",
|
||||||
|
Ip: "ip",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSysSmsLogDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewSysSmsLogDao(handlers ...gdb.ModelHandler) *SysSmsLogDao {
|
||||||
|
return &SysSmsLogDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_sys_sms_log",
|
||||||
|
columns: sysSmsLogColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *SysSmsLogDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *SysSmsLogDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *SysSmsLogDao) Columns() SysSmsLogColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *SysSmsLogDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *SysSmsLogDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *SysSmsLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
+97
@@ -0,0 +1,97 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
package internal
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestCategoryDao is the data access object for the table hg_test_category.
|
||||||
|
type TestCategoryDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns TestCategoryColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestCategoryColumns defines and stores column names for the table hg_test_category.
|
||||||
|
type TestCategoryColumns struct {
|
||||||
|
Id string // 分类ID
|
||||||
|
Name string // 分类名称
|
||||||
|
ShortName string // 简称
|
||||||
|
Description string // 描述
|
||||||
|
Sort string // 排序
|
||||||
|
Remark string // 备注
|
||||||
|
Status string // 状态
|
||||||
|
CreatedAt string // 创建时间
|
||||||
|
UpdatedAt string // 修改时间
|
||||||
|
DeletedAt string // 删除时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// testCategoryColumns holds the columns for the table hg_test_category.
|
||||||
|
var testCategoryColumns = TestCategoryColumns{
|
||||||
|
Id: "id",
|
||||||
|
Name: "name",
|
||||||
|
ShortName: "short_name",
|
||||||
|
Description: "description",
|
||||||
|
Sort: "sort",
|
||||||
|
Remark: "remark",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewTestCategoryDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewTestCategoryDao(handlers ...gdb.ModelHandler) *TestCategoryDao {
|
||||||
|
return &TestCategoryDao{
|
||||||
|
group: "default",
|
||||||
|
table: "hg_test_category",
|
||||||
|
columns: testCategoryColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *TestCategoryDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *TestCategoryDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *TestCategoryDao) Columns() TestCategoryColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *TestCategoryDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *TestCategoryDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *TestCategoryDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// payLogDao is the data access object for the table hg_pay_log.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type payLogDao struct {
|
||||||
|
*internal.PayLogDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// PayLog is a globally accessible object for table hg_pay_log operations.
|
||||||
|
PayLog = payLogDao{internal.NewPayLogDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// payRefundDao is the data access object for the table hg_pay_refund.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type payRefundDao struct {
|
||||||
|
*internal.PayRefundDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// PayRefund is a globally accessible object for table hg_pay_refund operations.
|
||||||
|
PayRefund = payRefundDao{internal.NewPayRefundDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysAddonsConfigDao is the data access object for the table hg_sys_addons_config.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysAddonsConfigDao struct {
|
||||||
|
*internal.SysAddonsConfigDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysAddonsConfig is a globally accessible object for table hg_sys_addons_config operations.
|
||||||
|
SysAddonsConfig = sysAddonsConfigDao{internal.NewSysAddonsConfigDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysAddonsInstallDao is the data access object for the table hg_sys_addons_install.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysAddonsInstallDao struct {
|
||||||
|
*internal.SysAddonsInstallDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysAddonsInstall is a globally accessible object for table hg_sys_addons_install operations.
|
||||||
|
SysAddonsInstall = sysAddonsInstallDao{internal.NewSysAddonsInstallDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysAttachmentDao is the data access object for the table hg_sys_attachment.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysAttachmentDao struct {
|
||||||
|
*internal.SysAttachmentDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysAttachment is a globally accessible object for table hg_sys_attachment operations.
|
||||||
|
SysAttachment = sysAttachmentDao{internal.NewSysAttachmentDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysBlacklistDao is the data access object for the table hg_sys_blacklist.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysBlacklistDao struct {
|
||||||
|
*internal.SysBlacklistDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysBlacklist is a globally accessible object for table hg_sys_blacklist operations.
|
||||||
|
SysBlacklist = sysBlacklistDao{internal.NewSysBlacklistDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysConfigDao is the data access object for the table hg_sys_config.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysConfigDao struct {
|
||||||
|
*internal.SysConfigDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysConfig is a globally accessible object for table hg_sys_config operations.
|
||||||
|
SysConfig = sysConfigDao{internal.NewSysConfigDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysCronDao is the data access object for the table hg_sys_cron.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysCronDao struct {
|
||||||
|
*internal.SysCronDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysCron is a globally accessible object for table hg_sys_cron operations.
|
||||||
|
SysCron = sysCronDao{internal.NewSysCronDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysCronGroupDao is the data access object for the table hg_sys_cron_group.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysCronGroupDao struct {
|
||||||
|
*internal.SysCronGroupDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysCronGroup is a globally accessible object for table hg_sys_cron_group operations.
|
||||||
|
SysCronGroup = sysCronGroupDao{internal.NewSysCronGroupDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysDictDataDao is the data access object for the table hg_sys_dict_data.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysDictDataDao struct {
|
||||||
|
*internal.SysDictDataDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysDictData is a globally accessible object for table hg_sys_dict_data operations.
|
||||||
|
SysDictData = sysDictDataDao{internal.NewSysDictDataDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysDictTypeDao is the data access object for the table hg_sys_dict_type.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysDictTypeDao struct {
|
||||||
|
*internal.SysDictTypeDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysDictType is a globally accessible object for table hg_sys_dict_type operations.
|
||||||
|
SysDictType = sysDictTypeDao{internal.NewSysDictTypeDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysEmsLogDao is the data access object for the table hg_sys_ems_log.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysEmsLogDao struct {
|
||||||
|
*internal.SysEmsLogDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysEmsLog is a globally accessible object for table hg_sys_ems_log operations.
|
||||||
|
SysEmsLog = sysEmsLogDao{internal.NewSysEmsLogDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysGenCodesDao is the data access object for the table hg_sys_gen_codes.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysGenCodesDao struct {
|
||||||
|
*internal.SysGenCodesDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysGenCodes is a globally accessible object for table hg_sys_gen_codes operations.
|
||||||
|
SysGenCodes = sysGenCodesDao{internal.NewSysGenCodesDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysGenCurdDemoDao is the data access object for the table hg_sys_gen_curd_demo.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysGenCurdDemoDao struct {
|
||||||
|
*internal.SysGenCurdDemoDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysGenCurdDemo is a globally accessible object for table hg_sys_gen_curd_demo operations.
|
||||||
|
SysGenCurdDemo = sysGenCurdDemoDao{internal.NewSysGenCurdDemoDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysGenTreeDemoDao is the data access object for the table hg_sys_gen_tree_demo.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysGenTreeDemoDao struct {
|
||||||
|
*internal.SysGenTreeDemoDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysGenTreeDemo is a globally accessible object for table hg_sys_gen_tree_demo operations.
|
||||||
|
SysGenTreeDemo = sysGenTreeDemoDao{internal.NewSysGenTreeDemoDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysLogDao is the data access object for the table hg_sys_log.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysLogDao struct {
|
||||||
|
*internal.SysLogDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysLog is a globally accessible object for table hg_sys_log operations.
|
||||||
|
SysLog = sysLogDao{internal.NewSysLogDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysLoginLogDao is the data access object for the table hg_sys_login_log.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysLoginLogDao struct {
|
||||||
|
*internal.SysLoginLogDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysLoginLog is a globally accessible object for table hg_sys_login_log operations.
|
||||||
|
SysLoginLog = sysLoginLogDao{internal.NewSysLoginLogDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysProvincesDao is the data access object for the table hg_sys_provinces.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysProvincesDao struct {
|
||||||
|
*internal.SysProvincesDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysProvinces is a globally accessible object for table hg_sys_provinces operations.
|
||||||
|
SysProvinces = sysProvincesDao{internal.NewSysProvincesDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysServeLicenseDao is the data access object for the table hg_sys_serve_license.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysServeLicenseDao struct {
|
||||||
|
*internal.SysServeLicenseDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysServeLicense is a globally accessible object for table hg_sys_serve_license operations.
|
||||||
|
SysServeLicense = sysServeLicenseDao{internal.NewSysServeLicenseDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysServeLogDao is the data access object for the table hg_sys_serve_log.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysServeLogDao struct {
|
||||||
|
*internal.SysServeLogDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysServeLog is a globally accessible object for table hg_sys_serve_log operations.
|
||||||
|
SysServeLog = sysServeLogDao{internal.NewSysServeLogDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// sysSmsLogDao is the data access object for the table hg_sys_sms_log.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type sysSmsLogDao struct {
|
||||||
|
*internal.SysSmsLogDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// SysSmsLog is a globally accessible object for table hg_sys_sms_log operations.
|
||||||
|
SysSmsLog = sysSmsLogDao{internal.NewSysSmsLogDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hotgo/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// testCategoryDao is the data access object for the table hg_test_category.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type testCategoryDao struct {
|
||||||
|
*internal.TestCategoryDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// TestCategory is a globally accessible object for table hg_test_category operations.
|
||||||
|
TestCategory = testCategoryDao{internal.NewTestCategoryDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
// Package global
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package global
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"hotgo/internal/consts"
|
||||||
|
"hotgo/internal/library/hgrds/lock"
|
||||||
|
"hotgo/internal/library/hgrds/pubsub"
|
||||||
|
"hotgo/internal/service"
|
||||||
|
"hotgo/utility/simple"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SubscribeClusterSync 订阅集群同步,可以用来集中同步数据、状态等
|
||||||
|
func SubscribeClusterSync(ctx context.Context) {
|
||||||
|
if !simple.IsCluster(ctx) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err := pubsub.SubscribeMap(map[string]pubsub.SubHandler{
|
||||||
|
consts.ClusterSyncSysconfig: service.SysConfig().ClusterSync, // 系统配置
|
||||||
|
consts.ClusterSyncSysBlacklist: service.SysBlacklist().ClusterSync, // 系统黑名单
|
||||||
|
consts.ClusterSyncSysSuperAdmin: service.AdminMember().ClusterSyncSuperAdmin, // 超管
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
g.Log().Fatal(ctx, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PublishClusterSync 推送集群同步消息,如果没有开启集群部署,则不进行推送
|
||||||
|
func PublishClusterSync(ctx context.Context, channel string, message interface{}) {
|
||||||
|
if !simple.IsCluster(ctx) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mutex := lock.Mutex(fmt.Sprintf("%s:%s", "lock", channel))
|
||||||
|
err := mutex.LockFunc(ctx, func() {
|
||||||
|
if _, err := pubsub.Publish(ctx, channel, message); err != nil {
|
||||||
|
g.Log().Warningf(ctx, "PublishClusterSync %v err:%v", channel, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
g.Log().Warningf(ctx, "PublishClusterSync %v LockFunc err:%v", channel, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// Package global
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package global
|
||||||
|
|
||||||
|
// 在这里可以配置一些全局公用的变量
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
// Package global
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package global
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/net/ghttp"
|
||||||
|
"github.com/gogf/gf/v2/util/gmeta"
|
||||||
|
"github.com/gogf/gf/v2/util/gtag"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HTTPRouter http路由
|
||||||
|
type HTTPRouter struct {
|
||||||
|
ghttp.RouterItem
|
||||||
|
Tags string `json:"tags" dc:"接口所属的标签,用于接口分类"`
|
||||||
|
Summary string `json:"summary" dc:"接口/参数概要描述"`
|
||||||
|
Description string `json:"description" dc:"接口/参数详细描述"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
httpRoutes map[string]*HTTPRouter
|
||||||
|
routeMutex sync.Mutex
|
||||||
|
shortTypeMapForTag = map[string]string{
|
||||||
|
gtag.SummaryShort: gtag.Summary,
|
||||||
|
gtag.SummaryShort2: gtag.Summary,
|
||||||
|
gtag.DescriptionShort: gtag.Description,
|
||||||
|
gtag.DescriptionShort2: gtag.Description,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRequestRoute 获取当前请求路由属性
|
||||||
|
func GetRequestRoute(r *ghttp.Request) *HTTPRouter {
|
||||||
|
key := GenFilterRequestKey(r)
|
||||||
|
routes := LoadHTTPRoutes(r)
|
||||||
|
router, ok := routes[key]
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return router
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenFilterRequestKey 根据请求生成唯一key
|
||||||
|
func GenFilterRequestKey(r *ghttp.Request) string {
|
||||||
|
return GenRouteKey(r.Method, r.Request.URL.Path)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenFilterRouteKey 根据路由生成唯一key
|
||||||
|
func GenFilterRouteKey(r *ghttp.Router) string {
|
||||||
|
return GenRouteKey(r.Method, r.Uri)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenRouteKey 生成唯一key
|
||||||
|
func GenRouteKey(method, path string) string {
|
||||||
|
return strings.ToUpper(method) + " " + path
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadHTTPRoutes(r *ghttp.Request) map[string]*HTTPRouter {
|
||||||
|
if httpRoutes == nil {
|
||||||
|
routeMutex.Lock()
|
||||||
|
defer routeMutex.Unlock()
|
||||||
|
|
||||||
|
if httpRoutes != nil {
|
||||||
|
return httpRoutes
|
||||||
|
}
|
||||||
|
|
||||||
|
httpRoutes = make(map[string]*HTTPRouter, len(r.Server.GetRoutes()))
|
||||||
|
for _, v := range r.Server.GetRoutes() {
|
||||||
|
key := GenFilterRouteKey(v.Handler.Router)
|
||||||
|
if _, ok := httpRoutes[key]; !ok {
|
||||||
|
router := new(HTTPRouter)
|
||||||
|
router.RouterItem = v
|
||||||
|
httpRoutes[key] = setRouterMeta(router)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return httpRoutes
|
||||||
|
}
|
||||||
|
|
||||||
|
func setRouterMeta(router *HTTPRouter) *HTTPRouter {
|
||||||
|
if !router.RouterItem.Handler.Info.IsStrictRoute {
|
||||||
|
return router
|
||||||
|
}
|
||||||
|
|
||||||
|
var reflectValue = reflect.ValueOf(router.Handler.Info.Value.Interface())
|
||||||
|
for reflectValue.Kind() == reflect.Ptr {
|
||||||
|
reflectValue = reflectValue.Elem()
|
||||||
|
}
|
||||||
|
|
||||||
|
if reflectValue.Kind() != reflect.Func {
|
||||||
|
return router
|
||||||
|
}
|
||||||
|
|
||||||
|
var reflectType = reflect.TypeOf(router.Handler.Info.Value.Interface())
|
||||||
|
if reflectType.NumIn() != 2 || reflectType.NumOut() != 2 {
|
||||||
|
return router
|
||||||
|
}
|
||||||
|
|
||||||
|
var inputObject reflect.Value
|
||||||
|
if reflectType.In(1).Kind() == reflect.Ptr {
|
||||||
|
inputObject = reflect.New(reflectType.In(1).Elem()).Elem()
|
||||||
|
} else {
|
||||||
|
inputObject = reflect.New(reflectType.In(1)).Elem()
|
||||||
|
}
|
||||||
|
|
||||||
|
inputMetaMap := fillMapWithShortTags(gmeta.Data(inputObject.Interface()))
|
||||||
|
router.Tags = inputMetaMap["tags"]
|
||||||
|
router.Summary = inputMetaMap[gtag.Summary]
|
||||||
|
router.Description = inputMetaMap[gtag.Description]
|
||||||
|
return router
|
||||||
|
}
|
||||||
|
|
||||||
|
func fillMapWithShortTags(m map[string]string) map[string]string {
|
||||||
|
for k, v := range shortTypeMapForTag {
|
||||||
|
if m[v] == "" && m[k] != "" {
|
||||||
|
m[v] = m[k]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
// Package global
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package global
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/gogf/gf/contrib/trace/jaeger/v2"
|
||||||
|
"github.com/gogf/gf/v2"
|
||||||
|
"github.com/gogf/gf/v2/container/gvar"
|
||||||
|
"github.com/gogf/gf/v2/encoding/gjson"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gctx"
|
||||||
|
"github.com/gogf/gf/v2/os/gfile"
|
||||||
|
"github.com/gogf/gf/v2/os/glog"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
"github.com/gogf/gf/v2/text/gstr"
|
||||||
|
"github.com/gogf/gf/v2/util/gmode"
|
||||||
|
"hotgo/internal/consts"
|
||||||
|
"hotgo/internal/library/cache"
|
||||||
|
"hotgo/internal/library/queue"
|
||||||
|
"hotgo/internal/model/entity"
|
||||||
|
"hotgo/internal/service"
|
||||||
|
"hotgo/utility/charset"
|
||||||
|
"hotgo/utility/simple"
|
||||||
|
"hotgo/utility/validate"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init(ctx context.Context) {
|
||||||
|
// 设置gf运行模式
|
||||||
|
SetGFMode(ctx)
|
||||||
|
|
||||||
|
// 设置服务日志处理
|
||||||
|
glog.SetDefaultHandler(LoggingServeLogHandler)
|
||||||
|
|
||||||
|
// 默认上海时区
|
||||||
|
if err := gtime.SetTimeZone("Asia/Shanghai"); err != nil {
|
||||||
|
g.Log().Fatalf(ctx, "时区设置异常 err:%+v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("欢迎使用HotGo!\r\n当前运行环境:%v, 运行根路径为:%v \r\nHotGo版本:v%v, gf版本:%v \n", runtime.GOOS, gfile.Pwd(), consts.VersionApp, gf.VERSION)
|
||||||
|
|
||||||
|
// 初始化链路追踪
|
||||||
|
InitTrace(ctx)
|
||||||
|
|
||||||
|
// 设置缓存适配器
|
||||||
|
cache.SetAdapter(ctx)
|
||||||
|
|
||||||
|
// 初始化功能库配置
|
||||||
|
service.SysConfig().InitConfig(ctx)
|
||||||
|
|
||||||
|
// 加载超管数据
|
||||||
|
service.AdminMember().LoadSuperAdmin(ctx)
|
||||||
|
|
||||||
|
// 订阅集群同步
|
||||||
|
SubscribeClusterSync(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoggingServeLogHandler 服务日志处理
|
||||||
|
// 需要将异常日志保存到服务日志时可以通过SetHandlers设置此方法
|
||||||
|
func LoggingServeLogHandler(ctx context.Context, in *glog.HandlerInput) {
|
||||||
|
in.Next(ctx)
|
||||||
|
|
||||||
|
err := g.Try(ctx, func(ctx context.Context) {
|
||||||
|
var err error
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// web服务日志不做记录,因为会导致重复记录
|
||||||
|
r := g.RequestFromCtx(ctx)
|
||||||
|
if r != nil && r.Server != nil && in.Logger.GetConfig().Path == r.Server.Logger().GetConfig().Path {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
conf, err := service.SysConfig().GetLoadServeLog(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if conf == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !conf.Switch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if in.LevelFormat == "" || !gstr.InArray(conf.LevelFormat, in.LevelFormat) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if in.Stack == "" {
|
||||||
|
in.Stack = in.Logger.GetStack()
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(in.Content) == 0 {
|
||||||
|
in.Content = gstr.StrLimit(gvar.New(in.Values).String(), consts.MaxServeLogContentLen)
|
||||||
|
}
|
||||||
|
|
||||||
|
var data entity.SysServeLog
|
||||||
|
data.TraceId = gctx.CtxId(ctx)
|
||||||
|
data.LevelFormat = in.LevelFormat
|
||||||
|
data.Content = in.Content
|
||||||
|
data.Stack = gjson.New(charset.ParseStack(in.Stack))
|
||||||
|
data.Line = strings.TrimRight(in.CallerPath, ":")
|
||||||
|
data.TriggerNs = in.Time.UnixNano()
|
||||||
|
data.Status = consts.StatusEnabled
|
||||||
|
|
||||||
|
if gstr.Contains(in.Content, `exception recovered`) {
|
||||||
|
data.LevelFormat = "PANI"
|
||||||
|
}
|
||||||
|
|
||||||
|
if data.Stack.IsNil() {
|
||||||
|
data.Stack = gjson.New(consts.NilJsonToString)
|
||||||
|
}
|
||||||
|
|
||||||
|
if conf.Queue {
|
||||||
|
err = queue.Push(consts.QueueServeLogTopic, data)
|
||||||
|
} else {
|
||||||
|
err = service.SysServeLog().RealWrite(ctx, data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
g.Dump("LoggingServeLogHandler err:", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitTrace 初始化链路追踪
|
||||||
|
func InitTrace(ctx context.Context) {
|
||||||
|
if !g.Cfg().MustGet(ctx, "jaeger.switch").Bool() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tp, err := jaeger.Init(simple.AppName(ctx), g.Cfg().MustGet(ctx, "jaeger.endpoint").String())
|
||||||
|
if err != nil {
|
||||||
|
g.Log().Fatal(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
simple.Event().Register(consts.EventServerClose, func(ctx context.Context, args ...interface{}) {
|
||||||
|
_ = tp.Shutdown(ctx)
|
||||||
|
g.Log().Debug(ctx, "jaeger closed ..")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetGFMode 设置gf运行模式
|
||||||
|
func SetGFMode(ctx context.Context) {
|
||||||
|
mode := g.Cfg().MustGet(ctx, "system.mode").String()
|
||||||
|
if len(mode) == 0 {
|
||||||
|
mode = gmode.NOT_SET
|
||||||
|
}
|
||||||
|
|
||||||
|
var modes = []string{gmode.DEVELOP, gmode.TESTING, gmode.STAGING, gmode.PRODUCT}
|
||||||
|
|
||||||
|
// 如果是有效的运行模式,就进行设置
|
||||||
|
if validate.InSlice(modes, mode) {
|
||||||
|
gmode.Set(mode)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
// Package addons
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package addons
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"hotgo/internal/consts"
|
||||||
|
)
|
||||||
|
|
||||||
|
var cacheResourcePath string
|
||||||
|
|
||||||
|
// GetResourcePath 获取插件资源路径
|
||||||
|
func GetResourcePath(ctx context.Context) string {
|
||||||
|
if len(cacheResourcePath) > 0 {
|
||||||
|
return cacheResourcePath
|
||||||
|
}
|
||||||
|
basePath := g.Cfg().MustGet(ctx, "system.addonsResourcePath").String()
|
||||||
|
if basePath == "" {
|
||||||
|
g.Log().Warning(ctx, "addons GetResourcePath not config found:'system.addonsResourcePath', use default values:'resource'")
|
||||||
|
basePath = "resource"
|
||||||
|
}
|
||||||
|
|
||||||
|
cacheResourcePath = basePath
|
||||||
|
return basePath
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetModulePath 获取指定模块相对路径
|
||||||
|
func GetModulePath(name string) string {
|
||||||
|
return "./" + consts.AddonsDir + "/" + name
|
||||||
|
}
|
||||||
|
|
||||||
|
// ViewPath 默认的插件模板路径
|
||||||
|
// 模板路径:resource/addons/插件模块名称/template
|
||||||
|
// 例如:resource/addons/hgexample/template
|
||||||
|
// 如果你不喜欢现在的风格,可以自行调整
|
||||||
|
func ViewPath(name, basePath string) string {
|
||||||
|
return basePath + "/" + consts.AddonsDir + "/" + name + "/template"
|
||||||
|
}
|
||||||
|
|
||||||
|
// StaticPath 默认的插件静态路映射关系
|
||||||
|
// 静态资源路径:resource/public/addons/插件模块名称/public
|
||||||
|
// 例如访问:http://127.0.0.1:8000/addons/hgexample/default 则指向文件-> resource/addons/hgexample/public/default
|
||||||
|
// 如果你不喜欢现在的风格,可以自行调整
|
||||||
|
func StaticPath(name, basePath string) (string, string) {
|
||||||
|
return "/" + consts.AddonsDir + "/" + name, basePath + "/" + consts.AddonsDir + "/" + name + "/public"
|
||||||
|
}
|
||||||
|
|
||||||
|
// RouterPrefix 路由前缀
|
||||||
|
// 最终效果:/应用名称/插件模块名称/xxx/xxx。
|
||||||
|
// 如果你不喜欢现在的风格,可以自行调整
|
||||||
|
func RouterPrefix(ctx context.Context, app, name string) string {
|
||||||
|
var prefix = "/"
|
||||||
|
if app != "" {
|
||||||
|
prefix = g.Cfg().MustGet(ctx, "router."+app+".prefix", "/"+app+"").String()
|
||||||
|
}
|
||||||
|
return prefix + "/" + name
|
||||||
|
}
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
// Package addons
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package addons
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
"github.com/gogf/gf/v2/os/gfile"
|
||||||
|
"github.com/gogf/gf/v2/text/gstr"
|
||||||
|
"hotgo/internal/consts"
|
||||||
|
"hotgo/internal/model"
|
||||||
|
"hotgo/utility/validate"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BuildOption struct {
|
||||||
|
Skeleton Skeleton
|
||||||
|
Config *model.BuildAddonConfig
|
||||||
|
Extend []string `json:"extend" dc:"扩展功能"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build 构建新插件
|
||||||
|
func Build(ctx context.Context, option *BuildOption) (err error) {
|
||||||
|
var (
|
||||||
|
resourcePath = GetResourcePath(ctx)
|
||||||
|
buildPath = "./" + consts.AddonsDir + "/" + option.Skeleton.Name
|
||||||
|
modulesPath = "./" + consts.AddonsDir + "/modules/" + option.Skeleton.Name + ".go"
|
||||||
|
webApiPath = gstr.Replace(option.Config.WebApiPath, "{$name}", option.Skeleton.Name)
|
||||||
|
webViewsPath = gstr.Replace(option.Config.WebViewsPath, "{$name}", option.Skeleton.Name)
|
||||||
|
replaces = map[string]string{
|
||||||
|
"@{.label}": option.Skeleton.Label,
|
||||||
|
"@{.name}": option.Skeleton.Name,
|
||||||
|
"@{.group}": strconv.Itoa(option.Skeleton.Group),
|
||||||
|
"@{.brief}": option.Skeleton.Brief,
|
||||||
|
"@{.description}": option.Skeleton.Description,
|
||||||
|
"@{.author}": option.Skeleton.Author,
|
||||||
|
"@{.version}": option.Skeleton.Version,
|
||||||
|
"@{.hgVersion}": consts.VersionApp, // HG 版本
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if resourcePath == "" {
|
||||||
|
err = gerror.New("请先设置一个有效的插件资源路径,配置名称:'system.addonsResourcePath'")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = checkBuildDir(buildPath, modulesPath, webApiPath, webViewsPath); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// scans directory recursively
|
||||||
|
list, err := gfile.ScanDirFunc(option.Config.SrcPath, "*", true, func(path string) string {
|
||||||
|
return path
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, path := range list {
|
||||||
|
if !gfile.IsReadable(path) {
|
||||||
|
err = gerror.Newf("file:%v is unreadable, please check permissions", path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if gfile.IsDir(path) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
flowFile := gstr.ReplaceByMap(path, map[string]string{
|
||||||
|
gfile.RealPath(option.Config.SrcPath): "",
|
||||||
|
".template": "",
|
||||||
|
})
|
||||||
|
flowFile = buildPath + "/" + flowFile
|
||||||
|
|
||||||
|
content := gstr.ReplaceByMap(gfile.GetContents(path), replaces)
|
||||||
|
|
||||||
|
if err = gfile.PutContents(flowFile, content); err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 隐式注入插件
|
||||||
|
if err = gfile.PutContents(modulesPath, gstr.ReplaceByMap(importModules, replaces)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// webApi
|
||||||
|
if err = gfile.PutContents(webApiPath+"/config/index.ts", gstr.ReplaceByMap(webApiLayout, replaces)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// web插件配置主页面
|
||||||
|
if err = gfile.PutContents(webViewsPath+"/config/BasicSetting.vue", gstr.ReplaceByMap(webConfigBasicSetting, replaces)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// web插件基础配置页面
|
||||||
|
if err = gfile.PutContents(webViewsPath+"/config/system.vue", gstr.ReplaceByMap(webConfigSystem, replaces)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建静态目录
|
||||||
|
if validate.InSlice(option.Extend, consts.AddonsExtendResourcePublic) {
|
||||||
|
_, staticPath := StaticPath(option.Skeleton.Name, resourcePath)
|
||||||
|
content := fmt.Sprintf(resourcePublicDefaultFile, option.Skeleton.Label)
|
||||||
|
if err = gfile.PutContents(staticPath+"/default", content); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建模板目录
|
||||||
|
if validate.InSlice(option.Extend, consts.AddonsExtendResourceTemplate) {
|
||||||
|
viewPath := ViewPath(option.Skeleton.Name, resourcePath)
|
||||||
|
if err = gfile.PutContents(viewPath+"/home/index.html", resourceTemplateHomeFile); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkBuildDir(paths ...string) (err error) {
|
||||||
|
if len(paths) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, path := range paths {
|
||||||
|
if gfile.Exists(path) {
|
||||||
|
return gerror.Newf("插件已存在,请换一个插件名称或者经确认无误后依次删除文件夹: [%v] 后重新生成", strings.Join(paths, "、\t"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,232 @@
|
|||||||
|
// Package addons
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package addons
|
||||||
|
|
||||||
|
const (
|
||||||
|
importModules = `// Package modules
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package modules
|
||||||
|
|
||||||
|
import _ "hotgo/addons/@{.name}"
|
||||||
|
`
|
||||||
|
|
||||||
|
webApiLayout = `import { http } from '@/utils/http/axios';
|
||||||
|
|
||||||
|
export function getConfig(params) {
|
||||||
|
return http.request({
|
||||||
|
url: '/@{.name}/config/get',
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateConfig(params) {
|
||||||
|
return http.request({
|
||||||
|
url: '/@{.name}/config/update',
|
||||||
|
method: 'post',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
webConfigBasicSetting = `<template>
|
||||||
|
<div>
|
||||||
|
<n-spin :show="show" description="请稍候...">
|
||||||
|
<n-form :label-width="80" :model="formValue" :rules="rules" ref="formRef">
|
||||||
|
<n-form-item label="测试参数" path="basicTest">
|
||||||
|
<n-input v-model:value="formValue.basicTest" placeholder="请输入测试参数" />
|
||||||
|
<template #feedback>
|
||||||
|
这是一个测试参数,每个插件都可以有独立的配置项,可以按需添加</template
|
||||||
|
>
|
||||||
|
</n-form-item>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<n-space>
|
||||||
|
<n-button type="primary" @click="formSubmit">保存更新</n-button>
|
||||||
|
</n-space>
|
||||||
|
</div>
|
||||||
|
</n-form>
|
||||||
|
</n-spin>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, onMounted } from 'vue';
|
||||||
|
import { useMessage } from 'naive-ui';
|
||||||
|
import { getConfig, updateConfig } from '@/api/addons/@{.name}/config';
|
||||||
|
|
||||||
|
const group = ref('basic');
|
||||||
|
|
||||||
|
const show = ref(false);
|
||||||
|
const rules = {
|
||||||
|
basicTest: {
|
||||||
|
required: true,
|
||||||
|
message: '请输入测试参数',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const formRef: any = ref(null);
|
||||||
|
const message = useMessage();
|
||||||
|
|
||||||
|
const formValue = ref({
|
||||||
|
basicTest: 'HotGo',
|
||||||
|
});
|
||||||
|
|
||||||
|
function formSubmit() {
|
||||||
|
formRef.value.validate((errors) => {
|
||||||
|
if (!errors) {
|
||||||
|
updateConfig({ group: group.value, list: formValue.value }).then((_res) => {
|
||||||
|
message.success('更新成功');
|
||||||
|
load();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
message.error('验证失败,请填写完整信息');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
load();
|
||||||
|
});
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
show.value = true;
|
||||||
|
new Promise((_resolve, _reject) => {
|
||||||
|
getConfig({ group: group.value })
|
||||||
|
.then((res) => {
|
||||||
|
formValue.value = res.list;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
show.value = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
`
|
||||||
|
|
||||||
|
webConfigSystem = `<template>
|
||||||
|
<div>
|
||||||
|
<n-grid cols="24 300:1 600:24" :x-gap="12">
|
||||||
|
<n-grid-item span="6">
|
||||||
|
<n-card :bordered="false" size="small" class="proCard">
|
||||||
|
<n-thing
|
||||||
|
class="thing-cell"
|
||||||
|
v-for="item in typeTabList"
|
||||||
|
:key="item.key"
|
||||||
|
:class="{ 'thing-cell-on': type === item.key }"
|
||||||
|
@click="switchType(item)"
|
||||||
|
>
|
||||||
|
<template #header>{{ item.name }}</template>
|
||||||
|
<template #description>{{ item.desc }}</template>
|
||||||
|
</n-thing>
|
||||||
|
</n-card>
|
||||||
|
</n-grid-item>
|
||||||
|
<n-grid-item span="18">
|
||||||
|
<n-card :bordered="false" size="small" :title="typeTitle" class="proCard">
|
||||||
|
<BasicSetting v-if="type === 1" />
|
||||||
|
</n-card>
|
||||||
|
</n-grid-item>
|
||||||
|
</n-grid>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent, reactive, toRefs } from 'vue';
|
||||||
|
import BasicSetting from './BasicSetting.vue';
|
||||||
|
const typeTabList = [
|
||||||
|
{
|
||||||
|
name: '基本设置',
|
||||||
|
desc: '系统常规设置',
|
||||||
|
key: 1,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
export default defineComponent({
|
||||||
|
components: {
|
||||||
|
BasicSetting,
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
const state = reactive({
|
||||||
|
type: 1,
|
||||||
|
typeTitle: '基本设置',
|
||||||
|
});
|
||||||
|
|
||||||
|
function switchType(e) {
|
||||||
|
state.type = e.key;
|
||||||
|
state.typeTitle = e.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...toRefs(state),
|
||||||
|
switchType,
|
||||||
|
typeTabList,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.thing-cell {
|
||||||
|
margin: 0 -16px 10px;
|
||||||
|
padding: 5px 16px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #f3f3f3;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.thing-cell-on {
|
||||||
|
background: #f0faff;
|
||||||
|
color: #2d8cf0;
|
||||||
|
|
||||||
|
::v-deep(.n-thing-main .n-thing-header .n-thing-header__title) {
|
||||||
|
color: #2d8cf0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #f0faff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
`
|
||||||
|
|
||||||
|
resourcePublicDefaultFile = "Hello!这是创建插件 [%v] 时默认生成的一个静态目录文件,用于测试,当你看到这个提示时,说明已经联调成功啦!"
|
||||||
|
|
||||||
|
resourceTemplateHomeFile = `<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
|
||||||
|
<meta name="keywords" content="@{.Keywords}"/>
|
||||||
|
<meta name="description" content="@{.Description}"/>
|
||||||
|
<title>@{.Title}</title>
|
||||||
|
<script type="text/javascript" src="/resource/home/js/jquery-3.6.0.min.js"></script>
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: #f6f6f6;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="padding-top: 100px;text-align:center;">
|
||||||
|
<h1><p>Hello,@{.Data.name}!!</p></h1>
|
||||||
|
<h2><p>@{.Data.module}</p></h2>
|
||||||
|
<h2><p>服务器时间:@{.Data.time}</p></h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</html>`
|
||||||
|
)
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
// Package addons
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package addons
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"hotgo/internal/consts"
|
||||||
|
"hotgo/internal/dao"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// InstallRecord 安装记录
|
||||||
|
type InstallRecord struct {
|
||||||
|
Id int64 `json:"id" description:"安装ID"`
|
||||||
|
Version string `json:"version" description:"安装版本"`
|
||||||
|
Status int `json:"status" description:"安装状态"`
|
||||||
|
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
|
||||||
|
UpdatedAt *gtime.Time `json:"updatedAt" description:"更新时间"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetModel(ctx context.Context) *gdb.Model {
|
||||||
|
return dao.SysAddonsInstall.Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ScanInstall(m Module) (record *InstallRecord, err error) {
|
||||||
|
err = GetModel(m.Ctx()).Where(dao.SysAddonsInstall.Columns().Name, m.GetSkeleton().Name).Scan(&record)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsInstall 模块是否已安装
|
||||||
|
func IsInstall(m Module) bool {
|
||||||
|
record, err := ScanInstall(m)
|
||||||
|
if err != nil {
|
||||||
|
g.Log().Debugf(m.Ctx(), "addons.IsInstall err:%+v", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if record == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return record.Status == consts.AddonsInstallStatusOk
|
||||||
|
}
|
||||||
|
|
||||||
|
// Install 安装模块
|
||||||
|
func Install(m Module) (err error) {
|
||||||
|
record, err := ScanInstall(m)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if record != nil && record.Status == consts.AddonsInstallStatusOk {
|
||||||
|
return gerror.New("插件已安装,无需重复操作!")
|
||||||
|
}
|
||||||
|
|
||||||
|
data := g.Map{
|
||||||
|
dao.SysAddonsInstall.Columns().Name: m.GetSkeleton().Name,
|
||||||
|
dao.SysAddonsInstall.Columns().Version: m.GetSkeleton().Version,
|
||||||
|
dao.SysAddonsInstall.Columns().Status: consts.AddonsInstallStatusOk,
|
||||||
|
}
|
||||||
|
return g.DB().Transaction(m.Ctx(), func(ctx context.Context, tx gdb.TX) error {
|
||||||
|
if record != nil {
|
||||||
|
_, _ = GetModel(ctx).Where(dao.SysAddonsInstall.Columns().Id, record.Id).Delete()
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = GetModel(ctx).Data(data).OmitEmptyData().Insert(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return m.Install(ctx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upgrade 更新模块
|
||||||
|
func Upgrade(m Module) (err error) {
|
||||||
|
record, err := ScanInstall(m)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if record == nil || record.Status != consts.AddonsInstallStatusOk {
|
||||||
|
return gerror.New("插件未安装,请安装后操作!")
|
||||||
|
}
|
||||||
|
|
||||||
|
data := g.Map{
|
||||||
|
dao.SysAddonsInstall.Columns().Version: m.GetSkeleton().Version,
|
||||||
|
}
|
||||||
|
return g.DB().Transaction(m.Ctx(), func(ctx context.Context, tx gdb.TX) error {
|
||||||
|
if _, err = GetModel(ctx).Where(dao.SysAddonsInstall.Columns().Id, record.Id).Data(data).Update(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return m.Upgrade(ctx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnInstall 卸载模块
|
||||||
|
func UnInstall(m Module) (err error) {
|
||||||
|
record, err := ScanInstall(m)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if record == nil || record.Status != consts.AddonsInstallStatusOk {
|
||||||
|
return gerror.New("插件未安装,请安装后操作!")
|
||||||
|
}
|
||||||
|
|
||||||
|
data := g.Map{
|
||||||
|
dao.SysAddonsInstall.Columns().Version: m.GetSkeleton().Version,
|
||||||
|
dao.SysAddonsInstall.Columns().Status: consts.AddonsInstallStatusUn,
|
||||||
|
}
|
||||||
|
return g.DB().Transaction(m.Ctx(), func(ctx context.Context, tx gdb.TX) error {
|
||||||
|
if _, err = GetModel(ctx).Where(dao.SysAddonsInstall.Columns().Id, record.Id).Data(data).Update(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return m.UnInstall(ctx)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
// Package addons
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package addons
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/net/ghttp"
|
||||||
|
"github.com/gogf/gf/v2/os/gfile"
|
||||||
|
"github.com/gogf/gf/v2/os/gres"
|
||||||
|
"hotgo/internal/model/input/form"
|
||||||
|
"sort"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Option 模块启动选项
|
||||||
|
type Option struct {
|
||||||
|
Server *ghttp.Server // http服务器
|
||||||
|
// 更多选项参数
|
||||||
|
// ..
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skeleton 模块骨架
|
||||||
|
type Skeleton struct {
|
||||||
|
Label string `json:"label"` // 标识
|
||||||
|
Name string `json:"name"` // 名称
|
||||||
|
Group int `json:"group"` // 分组
|
||||||
|
Logo string `json:"logo"` // logo
|
||||||
|
Brief string `json:"brief"` // 简介
|
||||||
|
Description string `json:"description"` // 详细描述
|
||||||
|
Author string `json:"author"` // 作者
|
||||||
|
Version string `json:"version"` // 版本号
|
||||||
|
RootPath string `json:"rootPath"` // 根路径
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Skeleton) GetModule() Module {
|
||||||
|
return GetModule(s.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Module 插件模块
|
||||||
|
type Module interface {
|
||||||
|
Start(option *Option) (err error) // 启动模块
|
||||||
|
Stop() (err error) // 停止模块
|
||||||
|
Ctx() context.Context // 上下文
|
||||||
|
GetSkeleton() *Skeleton // 获取模块
|
||||||
|
Install(ctx context.Context) (err error) // 安装模块
|
||||||
|
Upgrade(ctx context.Context) (err error) // 更新模块
|
||||||
|
UnInstall(ctx context.Context) (err error) // 卸载模块
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
modules = make(map[string]Module)
|
||||||
|
mLock sync.Mutex
|
||||||
|
)
|
||||||
|
|
||||||
|
// StartModules 启动所有已安装模块
|
||||||
|
func StartModules(ctx context.Context, option *Option) (err error) {
|
||||||
|
for _, module := range filterInstalled() {
|
||||||
|
if err = module.Start(option); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 为所有已安装模块设置静态资源路径
|
||||||
|
AddStaticPath(ctx, option.Server)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// StopModules 停止所有已安装模块
|
||||||
|
func StopModules(ctx context.Context) {
|
||||||
|
for _, module := range filterInstalled() {
|
||||||
|
if err := module.Stop(); err != nil {
|
||||||
|
g.Log().Warningf(ctx, "StopModules err:%v, module:%v", err.Error(), module.GetSkeleton().Name)
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterModule 注册模块
|
||||||
|
func RegisterModule(m Module) Module {
|
||||||
|
mLock.Lock()
|
||||||
|
defer mLock.Unlock()
|
||||||
|
name := m.GetSkeleton().Name
|
||||||
|
_, ok := modules[name]
|
||||||
|
if ok {
|
||||||
|
panic("module repeat registration, name:" + name)
|
||||||
|
}
|
||||||
|
|
||||||
|
sk := m.GetSkeleton()
|
||||||
|
if sk == nil {
|
||||||
|
panic("module skeleton not initialized, name:" + name)
|
||||||
|
}
|
||||||
|
|
||||||
|
sk.RootPath = GetModulePath(name)
|
||||||
|
modules[name] = m
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetModule 获取指定名称模块
|
||||||
|
func GetModule(name string) Module {
|
||||||
|
mLock.Lock()
|
||||||
|
defer mLock.Unlock()
|
||||||
|
m, ok := modules[name]
|
||||||
|
if !ok {
|
||||||
|
panic("implement not found for interface " + name + ", forgot register?")
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSkeletons 获取所有模块骨架
|
||||||
|
func GetSkeletons() (list []*Skeleton) {
|
||||||
|
var keys []string
|
||||||
|
for k := range modules {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Strings(keys)
|
||||||
|
|
||||||
|
for _, v := range keys {
|
||||||
|
list = append(list, GetModule(v).GetSkeleton())
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetModuleRealPath 获取指定模块绝对路径
|
||||||
|
func GetModuleRealPath(name string) string {
|
||||||
|
path := gfile.RealPath(GetModulePath(name))
|
||||||
|
if path == "" {
|
||||||
|
panic("no path is found. please confirm that the path " + GetModulePath(name) + " exists?")
|
||||||
|
}
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddStaticPath 设置插件静态目录映射
|
||||||
|
func AddStaticPath(ctx context.Context, server *ghttp.Server) {
|
||||||
|
basePath := GetResourcePath(ctx)
|
||||||
|
if basePath == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, module := range filterInstalled() {
|
||||||
|
name := module.GetSkeleton().Name
|
||||||
|
prefix, path := StaticPath(name, basePath)
|
||||||
|
if !gres.Contains(path) {
|
||||||
|
if _, err := gfile.Search(path); err != nil {
|
||||||
|
g.Log().Warningf(ctx, `addons AddStaticPath failed: %v`, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.AddStaticPath(prefix, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// filterInstalled 过滤已安装模块
|
||||||
|
func filterInstalled() []Module {
|
||||||
|
var ms []Module
|
||||||
|
for _, module := range modules {
|
||||||
|
if IsInstall(module) {
|
||||||
|
ms = append(ms, module)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModuleSelect 获取插件模块选项
|
||||||
|
func ModuleSelect() form.Selects {
|
||||||
|
sks := GetSkeletons()
|
||||||
|
lst := make(form.Selects, 0)
|
||||||
|
if len(sks) == 0 {
|
||||||
|
return lst
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, skeleton := range sks {
|
||||||
|
lst = append(lst, &form.Select{
|
||||||
|
Value: skeleton.Name,
|
||||||
|
Label: skeleton.Label,
|
||||||
|
Name: skeleton.Label,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return lst
|
||||||
|
}
|
||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
// Package cache
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gcache"
|
||||||
|
"github.com/gogf/gf/v2/os/gfile"
|
||||||
|
"hotgo/internal/library/cache/file"
|
||||||
|
)
|
||||||
|
|
||||||
|
// cache 缓存驱动
|
||||||
|
var cache *gcache.Cache
|
||||||
|
|
||||||
|
// Instance 缓存实例
|
||||||
|
func Instance() *gcache.Cache {
|
||||||
|
if cache == nil {
|
||||||
|
panic("cache uninitialized.")
|
||||||
|
}
|
||||||
|
return cache
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdapter 设置缓存适配器
|
||||||
|
func SetAdapter(ctx context.Context) {
|
||||||
|
var adapter gcache.Adapter
|
||||||
|
|
||||||
|
switch g.Cfg().MustGet(ctx, "cache.adapter").String() {
|
||||||
|
case "redis":
|
||||||
|
adapter = gcache.NewAdapterRedis(g.Redis())
|
||||||
|
case "file":
|
||||||
|
fileDir := g.Cfg().MustGet(ctx, "cache.fileDir").String()
|
||||||
|
if fileDir == "" {
|
||||||
|
g.Log().Fatal(ctx, "file path must be configured for file caching.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !gfile.Exists(fileDir) {
|
||||||
|
if err := gfile.Mkdir(fileDir); err != nil {
|
||||||
|
g.Log().Fatalf(ctx, "failed to create the cache directory. procedure, err:%+v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
adapter = file.NewAdapterFile(fileDir)
|
||||||
|
default:
|
||||||
|
adapter = gcache.NewAdapterMemory()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 数据库缓存,默认和通用缓冲驱动一致,如果你不想使用默认的,可以自行调整
|
||||||
|
g.DB().GetCache().SetAdapter(adapter)
|
||||||
|
|
||||||
|
// 通用缓存
|
||||||
|
cache = gcache.New()
|
||||||
|
cache.SetAdapter(adapter)
|
||||||
|
}
|
||||||
+322
@@ -0,0 +1,322 @@
|
|||||||
|
// Package file
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package file
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"crypto/sha256"
|
||||||
|
"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/gogf/gf/v2/container/gvar"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
"github.com/gogf/gf/v2/os/gcache"
|
||||||
|
"github.com/gogf/gf/v2/os/gfile"
|
||||||
|
"github.com/gogf/gf/v2/util/gconv"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// AdapterFile is the gcache adapter implements using file server.
|
||||||
|
AdapterFile struct {
|
||||||
|
dir string
|
||||||
|
}
|
||||||
|
|
||||||
|
fileContent struct {
|
||||||
|
Duration int64 `json:"duration"`
|
||||||
|
Data interface{} `json:"data,omitempty"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const perm = 0o666
|
||||||
|
|
||||||
|
var (
|
||||||
|
CacheExpiredErr = errors.New("cache expired")
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewAdapterFile creates and returns a new memory cache object.
|
||||||
|
func NewAdapterFile(dir string) gcache.Adapter {
|
||||||
|
return &AdapterFile{
|
||||||
|
dir: dir,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) Set(ctx context.Context, key interface{}, value interface{}, lifeTime time.Duration) (err error) {
|
||||||
|
fileKey := gconv.String(key)
|
||||||
|
if value == nil || lifeTime < 0 {
|
||||||
|
return c.Delete(fileKey)
|
||||||
|
}
|
||||||
|
return c.Save(fileKey, gconv.String(value), lifeTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) SetMap(ctx context.Context, data map[interface{}]interface{}, duration time.Duration) (err error) {
|
||||||
|
return gerror.New("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) SetIfNotExist(ctx context.Context, key interface{}, value interface{}, duration time.Duration) (ok bool, err error) {
|
||||||
|
return false, gerror.New("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) SetIfNotExistFunc(ctx context.Context, key interface{}, f gcache.Func, duration time.Duration) (ok bool, err error) {
|
||||||
|
return false, gerror.New("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) SetIfNotExistFuncLock(ctx context.Context, key interface{}, f gcache.Func, duration time.Duration) (ok bool, err error) {
|
||||||
|
return false, gerror.New("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) Get(ctx context.Context, key interface{}) (*gvar.Var, error) {
|
||||||
|
fetch, err := c.Fetch(gconv.String(key))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return gvar.New(fetch), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) GetOrSet(ctx context.Context, key interface{}, value interface{}, duration time.Duration) (result *gvar.Var, err error) {
|
||||||
|
result, err = c.Get(ctx, key)
|
||||||
|
if err != nil && !errors.Is(err, CacheExpiredErr) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if result.IsNil() {
|
||||||
|
return gvar.New(value), c.Set(ctx, key, value, duration)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) GetOrSetFunc(ctx context.Context, key interface{}, f gcache.Func, duration time.Duration) (result *gvar.Var, err error) {
|
||||||
|
v, err := c.Get(ctx, key)
|
||||||
|
if err != nil && !errors.Is(err, CacheExpiredErr) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if v.IsNil() {
|
||||||
|
value, err := f(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if value == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return gvar.New(value), c.Set(ctx, key, value, duration)
|
||||||
|
} else {
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) GetOrSetFuncLock(ctx context.Context, key interface{}, f gcache.Func, duration time.Duration) (result *gvar.Var, err error) {
|
||||||
|
return c.GetOrSetFunc(ctx, key, f, duration)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) Contains(ctx context.Context, key interface{}) (bool, error) {
|
||||||
|
return c.Has(gconv.String(key)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) Size(ctx context.Context) (size int, err error) {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) Data(ctx context.Context) (data map[interface{}]interface{}, err error) {
|
||||||
|
return nil, gerror.New("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) Keys(ctx context.Context) (keys []interface{}, err error) {
|
||||||
|
return nil, gerror.New("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) Values(ctx context.Context) (values []interface{}, err error) {
|
||||||
|
return nil, gerror.New("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) Update(ctx context.Context, key interface{}, value interface{}) (oldValue *gvar.Var, exist bool, err error) {
|
||||||
|
return nil, false, gerror.New("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) UpdateExpire(ctx context.Context, key interface{}, duration time.Duration) (oldDuration time.Duration, err error) {
|
||||||
|
var (
|
||||||
|
v *gvar.Var
|
||||||
|
oldTTL int64
|
||||||
|
fileKey = gconv.String(key)
|
||||||
|
)
|
||||||
|
// TTL.
|
||||||
|
expire, err := c.GetExpire(ctx, fileKey)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
oldTTL = int64(expire)
|
||||||
|
if oldTTL == -2 {
|
||||||
|
// It does not exist.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
oldDuration = time.Duration(oldTTL) * time.Second
|
||||||
|
// DEL.
|
||||||
|
if duration < 0 {
|
||||||
|
err = c.Delete(fileKey)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
v, err = c.Get(ctx, fileKey)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = c.Set(ctx, fileKey, v.Val(), duration)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) GetExpire(ctx context.Context, key interface{}) (time.Duration, error) {
|
||||||
|
content, err := c.read(gconv.String(key))
|
||||||
|
if err != nil {
|
||||||
|
return -1, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if content.Duration <= time.Now().Unix() {
|
||||||
|
return -1, nil
|
||||||
|
}
|
||||||
|
return time.Duration(time.Now().Unix()-content.Duration) * time.Second, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) Remove(ctx context.Context, keys ...interface{}) (lastValue *gvar.Var, err error) {
|
||||||
|
if len(keys) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
// Retrieves the last key value.
|
||||||
|
if lastValue, err = c.Get(ctx, gconv.String(keys[len(keys)-1])); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// Deletes all given keys.
|
||||||
|
err = c.DeleteMulti(gconv.Strings(keys)...)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) Clear(ctx context.Context) error {
|
||||||
|
return c.Flush()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) Close(ctx context.Context) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) createName(key string) string {
|
||||||
|
h := sha256.New()
|
||||||
|
_, _ = h.Write([]byte(key))
|
||||||
|
hash := hex.EncodeToString(h.Sum(nil))
|
||||||
|
return filepath.Join(c.dir, fmt.Sprintf("%s.cache", hash))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AdapterFile) read(key string) (*fileContent, error) {
|
||||||
|
rp := gfile.RealPath(c.createName(key))
|
||||||
|
if rp == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
value, err := os.ReadFile(rp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
content := &fileContent{}
|
||||||
|
if err := json.Unmarshal(value, content); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if content.Duration == 0 {
|
||||||
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if content.Duration <= time.Now().Unix() {
|
||||||
|
_ = c.Delete(key)
|
||||||
|
return nil, CacheExpiredErr
|
||||||
|
}
|
||||||
|
return content, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Has checks if the cached key exists into the File storage
|
||||||
|
func (c *AdapterFile) Has(key string) bool {
|
||||||
|
fc, err := c.read(key)
|
||||||
|
return err == nil && fc != nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the cached key from File storage
|
||||||
|
func (c *AdapterFile) Delete(key string) error {
|
||||||
|
_, err := os.Stat(c.createName(key))
|
||||||
|
if err != nil && os.IsNotExist(err) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return os.Remove(c.createName(key))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteMulti the cached key from File storage
|
||||||
|
func (c *AdapterFile) DeleteMulti(keys ...string) (err error) {
|
||||||
|
for _, key := range keys {
|
||||||
|
if err = c.Delete(key); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch retrieves the cached value from key of the File storage
|
||||||
|
func (c *AdapterFile) Fetch(key string) (interface{}, error) {
|
||||||
|
content, err := c.read(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if content == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return content.Data, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FetchMulti retrieve multiple cached values from keys of the File storage
|
||||||
|
func (c *AdapterFile) FetchMulti(keys []string) map[string]interface{} {
|
||||||
|
result := make(map[string]interface{})
|
||||||
|
for _, key := range keys {
|
||||||
|
if value, err := c.Fetch(key); err == nil {
|
||||||
|
result[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flush removes all cached keys of the File storage
|
||||||
|
func (c *AdapterFile) Flush() error {
|
||||||
|
dir, err := os.Open(c.dir)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
_ = dir.Close()
|
||||||
|
}()
|
||||||
|
|
||||||
|
names, _ := dir.Readdirnames(-1)
|
||||||
|
|
||||||
|
for _, name := range names {
|
||||||
|
_ = os.Remove(filepath.Join(c.dir, name))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save a value in File storage by key
|
||||||
|
func (c *AdapterFile) Save(key string, value string, lifeTime time.Duration) error {
|
||||||
|
duration := int64(0)
|
||||||
|
|
||||||
|
if lifeTime > 0 {
|
||||||
|
duration = time.Now().Unix() + int64(lifeTime.Seconds())
|
||||||
|
}
|
||||||
|
|
||||||
|
content := &fileContent{duration, value}
|
||||||
|
|
||||||
|
data, err := json.Marshal(content)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = os.WriteFile(c.createName(key), data, perm)
|
||||||
|
return err
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
// Package captcha
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package captcha
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"hotgo/internal/consts"
|
||||||
|
"image/color"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/text/gstr"
|
||||||
|
"github.com/mojocn/base64Captcha"
|
||||||
|
)
|
||||||
|
|
||||||
|
// store 验证码存储方式
|
||||||
|
var store = base64Captcha.DefaultMemStore
|
||||||
|
|
||||||
|
// Generate 生成验证码
|
||||||
|
func Generate(ctx context.Context, captchaType int) (id string, base64 string) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
switch captchaType {
|
||||||
|
// 算数
|
||||||
|
case consts.CaptchaTypeMath:
|
||||||
|
driver := &base64Captcha.DriverMath{
|
||||||
|
Height: 42,
|
||||||
|
Width: 100,
|
||||||
|
NoiseCount: 0,
|
||||||
|
ShowLineOptions: 0,
|
||||||
|
BgColor: &color.RGBA{
|
||||||
|
R: 255,
|
||||||
|
G: 250,
|
||||||
|
B: 250,
|
||||||
|
A: 250,
|
||||||
|
},
|
||||||
|
Fonts: []string{"chromohv.ttf"},
|
||||||
|
}
|
||||||
|
c := base64Captcha.NewCaptcha(driver.ConvertFonts(), store)
|
||||||
|
id, base64, _, err = c.Generate()
|
||||||
|
// 字符
|
||||||
|
default:
|
||||||
|
driver := &base64Captcha.DriverString{
|
||||||
|
Height: 42,
|
||||||
|
Width: 100,
|
||||||
|
//NoiseCount: 50,
|
||||||
|
//ShowLineOptions: 20,
|
||||||
|
Length: 4,
|
||||||
|
BgColor: &color.RGBA{
|
||||||
|
R: 255,
|
||||||
|
G: 250,
|
||||||
|
B: 250,
|
||||||
|
A: 250,
|
||||||
|
},
|
||||||
|
Source: "abcdefghjkmnpqrstuvwxyz23456789", // abcdefghjkmnpqrstuvwxyz23456789
|
||||||
|
Fonts: []string{"chromohv.ttf"},
|
||||||
|
}
|
||||||
|
c := base64Captcha.NewCaptcha(driver.ConvertFonts(), store)
|
||||||
|
id, base64, _, err = c.Generate()
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
g.Log().Errorf(ctx, "captcha.Generate err:%+v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify 验证输入的验证码是否正确
|
||||||
|
func Verify(id, answer string) bool {
|
||||||
|
if id == "" || answer == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return store.Verify(id, gstr.ToLower(answer), true)
|
||||||
|
}
|
||||||
@@ -0,0 +1,333 @@
|
|||||||
|
// Package casbin
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package casbin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"hotgo/internal/consts"
|
||||||
|
"hotgo/internal/dao"
|
||||||
|
"math"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/casbin/casbin/v2/model"
|
||||||
|
"github.com/casbin/casbin/v2/persist"
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
var defaultTableName = dao.AdminRoleCasbin.Table()
|
||||||
|
|
||||||
|
const (
|
||||||
|
dropPolicyTableSql = `DROP TABLE IF EXISTS %s`
|
||||||
|
createPolicyTableSql = `
|
||||||
|
CREATE TABLE IF NOT EXISTS %s (
|
||||||
|
id bigint(20) NOT NULL AUTO_INCREMENT,
|
||||||
|
p_type varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||||
|
v0 varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||||
|
v1 varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||||
|
v2 varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||||
|
v3 varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||||
|
v4 varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||||
|
v5 varchar(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (id) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '管理员_casbin权限表' ROW_FORMAT = Dynamic;
|
||||||
|
`
|
||||||
|
createPolicyTablePgSql = `CREATE TABLE IF NOT EXISTS "public"."%s" (
|
||||||
|
"id" int8 NOT NULL DEFAULT nextval('hg_admin_role_casbin_id_seq'::regclass),
|
||||||
|
"p_type" varchar(64) COLLATE "pg_catalog"."default",
|
||||||
|
"v0" varchar(256) COLLATE "pg_catalog"."default",
|
||||||
|
"v1" varchar(256) COLLATE "pg_catalog"."default",
|
||||||
|
"v2" varchar(256) COLLATE "pg_catalog"."default",
|
||||||
|
"v3" varchar(256) COLLATE "pg_catalog"."default",
|
||||||
|
"v4" varchar(256) COLLATE "pg_catalog"."default",
|
||||||
|
"v5" varchar(256) COLLATE "pg_catalog"."default",
|
||||||
|
CONSTRAINT "hg_admin_role_casbin_pkey" PRIMARY KEY ("id")
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
ALTER TABLE "public"."%s"
|
||||||
|
OWNER TO "postgres";
|
||||||
|
|
||||||
|
COMMENT ON TABLE "public"."%s" IS '管理员_casbin权限表';`
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
adapter struct {
|
||||||
|
db gdb.DB
|
||||||
|
table string
|
||||||
|
}
|
||||||
|
|
||||||
|
policyColumns struct {
|
||||||
|
ID string // ID
|
||||||
|
PType string // PType
|
||||||
|
V0 string // V0
|
||||||
|
V1 string // V1
|
||||||
|
V2 string // V2
|
||||||
|
V3 string // V3
|
||||||
|
V4 string // V4
|
||||||
|
V5 string // V5
|
||||||
|
}
|
||||||
|
|
||||||
|
// policy rule entity
|
||||||
|
policyRule struct {
|
||||||
|
ID int64 `orm:"id" json:"id"`
|
||||||
|
PType string `orm:"p_type" json:"p_type"`
|
||||||
|
V0 string `orm:"v0" json:"v0"`
|
||||||
|
V1 string `orm:"v1" json:"v1"`
|
||||||
|
V2 string `orm:"v2" json:"v2"`
|
||||||
|
V3 string `orm:"v3" json:"v3"`
|
||||||
|
V4 string `orm:"v4" json:"v4"`
|
||||||
|
V5 string `orm:"v5" json:"v5"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errInvalidDatabaseLink = errors.New("invalid database link")
|
||||||
|
policyColumnsName = policyColumns{
|
||||||
|
ID: "id",
|
||||||
|
PType: "p_type",
|
||||||
|
V0: "v0",
|
||||||
|
V1: "v1",
|
||||||
|
V2: "v2",
|
||||||
|
V3: "v3",
|
||||||
|
V4: "v4",
|
||||||
|
V5: "v5",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewAdapter Create a casbin adapter
|
||||||
|
func NewAdapter(link string) (adp *adapter, err error) {
|
||||||
|
adp = &adapter{table: defaultTableName}
|
||||||
|
config := strings.SplitN(link, ":", 2)
|
||||||
|
|
||||||
|
if len(config) != 2 {
|
||||||
|
err = errInvalidDatabaseLink
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if adp.db, err = gdb.New(gdb.ConfigNode{Type: config[0], Link: config[1]}); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = adp.createPolicyTable()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *adapter) model() *gdb.Model {
|
||||||
|
return a.db.Model(a.table).Safe().Ctx(context.TODO())
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a policy table when it's not exists.
|
||||||
|
func (a *adapter) createPolicyTable() (err error) {
|
||||||
|
if a.db.GetConfig().Type == consts.DBPgsql {
|
||||||
|
_, err = a.db.Exec(context.TODO(), fmt.Sprintf(createPolicyTablePgSql, a.table, a.table, a.table))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = a.db.Exec(context.TODO(), fmt.Sprintf(createPolicyTableSql, a.table))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// drop policy table from the storage.
|
||||||
|
func (a *adapter) dropPolicyTable() (err error) {
|
||||||
|
_, err = a.db.Exec(context.TODO(), fmt.Sprintf(dropPolicyTableSql, a.table))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadPolicy loads all policy rules from the storage.
|
||||||
|
func (a *adapter) LoadPolicy(model model.Model) (err error) {
|
||||||
|
var rules []policyRule
|
||||||
|
if err = a.model().Scan(&rules); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, rule := range rules {
|
||||||
|
a.loadPolicyRule(rule, model)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// SavePolicy Saves all policy rules to the storage.
|
||||||
|
func (a *adapter) SavePolicy(model model.Model) (err error) {
|
||||||
|
if err = a.dropPolicyTable(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = a.createPolicyTable(); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
policyRules := make([]policyRule, 0)
|
||||||
|
|
||||||
|
for ptype, ast := range model["p"] {
|
||||||
|
for _, rule := range ast.Policy {
|
||||||
|
policyRules = append(policyRules, a.buildPolicyRule(ptype, rule))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ptype, ast := range model["g"] {
|
||||||
|
for _, rule := range ast.Policy {
|
||||||
|
policyRules = append(policyRules, a.buildPolicyRule(ptype, rule))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if count := len(policyRules); count > 0 {
|
||||||
|
if _, err = a.model().OmitEmptyData().FieldsEx(policyColumnsName.ID).Insert(policyRules); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPolicy adds a policy rule to the storage.
|
||||||
|
func (a *adapter) AddPolicy(sec string, ptype string, rule []string) (err error) {
|
||||||
|
_, err = a.model().OmitEmptyData().FieldsEx(policyColumnsName.ID).Insert(a.buildPolicyRule(ptype, rule))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPolicies adds policy rules to the storage.
|
||||||
|
func (a *adapter) AddPolicies(sec string, ptype string, rules [][]string) (err error) {
|
||||||
|
if len(rules) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
policyRules := make([]policyRule, 0, len(rules))
|
||||||
|
|
||||||
|
for _, rule := range rules {
|
||||||
|
policyRules = append(policyRules, a.buildPolicyRule(ptype, rule))
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = a.model().OmitEmptyData().FieldsEx(policyColumnsName.ID).Insert(policyRules)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemovePolicy removes a policy rule from the storage.
|
||||||
|
func (a *adapter) RemovePolicy(sec string, ptype string, rule []string) (err error) {
|
||||||
|
db := a.model()
|
||||||
|
db = db.Where(policyColumnsName.PType, ptype)
|
||||||
|
for index := 0; index < len(rule); index++ {
|
||||||
|
db = db.Where(fmt.Sprintf("v%d", index), rule[index])
|
||||||
|
}
|
||||||
|
_, err = db.Delete()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveFilteredPolicy removes policy rules that match the filter from the storage.
|
||||||
|
func (a *adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) (err error) {
|
||||||
|
db := a.model()
|
||||||
|
db = db.Where(policyColumnsName.PType, ptype)
|
||||||
|
for index := 0; index <= 5; index++ {
|
||||||
|
if fieldIndex <= index && index < fieldIndex+len(fieldValues) {
|
||||||
|
db = db.Where(fmt.Sprintf("v%d", index), fieldValues[index-fieldIndex])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err = db.Delete()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemovePolicies removes policy rules from the storage (implements the persist.BatchAdapter interface).
|
||||||
|
func (a *adapter) RemovePolicies(sec string, ptype string, rules [][]string) (err error) {
|
||||||
|
db := a.model()
|
||||||
|
|
||||||
|
for _, rule := range rules {
|
||||||
|
where := map[string]interface{}{policyColumnsName.PType: ptype}
|
||||||
|
|
||||||
|
for i := 0; i <= 5; i++ {
|
||||||
|
if len(rule) > i {
|
||||||
|
where[fmt.Sprintf("v%d", i)] = rule[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
db = db.WhereOr(where)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = db.Delete()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePolicy updates a policy rule from storage.
|
||||||
|
func (a *adapter) UpdatePolicy(sec string, ptype string, oldRule, newRule []string) (err error) {
|
||||||
|
_, err = a.model().Update(a.buildPolicyRule(ptype, newRule), a.buildPolicyRule(ptype, oldRule))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePolicies updates some policy rules to storage, like db, redis.
|
||||||
|
func (a *adapter) UpdatePolicies(sec string, ptype string, oldRules, newRules [][]string) (err error) {
|
||||||
|
if len(oldRules) == 0 || len(newRules) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return a.db.Transaction(context.TODO(), func(ctx context.Context, tx gdb.TX) error {
|
||||||
|
for i := 0; i < int(math.Min(float64(len(oldRules)), float64(len(newRules)))); i++ {
|
||||||
|
if _, err = tx.Model(a.table).Update(a.buildPolicyRule(ptype, newRules[i]), a.buildPolicyRule(ptype, oldRules[i])); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载策略规则
|
||||||
|
func (a *adapter) loadPolicyRule(rule policyRule, model model.Model) {
|
||||||
|
ruleText := rule.PType
|
||||||
|
|
||||||
|
if rule.V0 != "" {
|
||||||
|
ruleText += ", " + rule.V0
|
||||||
|
}
|
||||||
|
|
||||||
|
if rule.V1 != "" {
|
||||||
|
ruleText += ", " + rule.V1
|
||||||
|
}
|
||||||
|
|
||||||
|
if rule.V2 != "" {
|
||||||
|
ruleText += ", " + rule.V2
|
||||||
|
}
|
||||||
|
|
||||||
|
if rule.V3 != "" {
|
||||||
|
ruleText += ", " + rule.V3
|
||||||
|
}
|
||||||
|
|
||||||
|
if rule.V4 != "" {
|
||||||
|
ruleText += ", " + rule.V4
|
||||||
|
}
|
||||||
|
|
||||||
|
if rule.V5 != "" {
|
||||||
|
ruleText += ", " + rule.V5
|
||||||
|
}
|
||||||
|
if err := persist.LoadPolicyLine(ruleText, model); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建策略规则
|
||||||
|
func (a *adapter) buildPolicyRule(ptype string, data []string) policyRule {
|
||||||
|
rule := policyRule{PType: ptype}
|
||||||
|
|
||||||
|
if len(data) > 0 {
|
||||||
|
rule.V0 = data[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(data) > 1 {
|
||||||
|
rule.V1 = data[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(data) > 2 {
|
||||||
|
rule.V2 = data[2]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(data) > 3 {
|
||||||
|
rule.V3 = data[3]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(data) > 4 {
|
||||||
|
rule.V4 = data[4]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(data) > 5 {
|
||||||
|
rule.V5 = data[5]
|
||||||
|
}
|
||||||
|
return rule
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
// Package casbin
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package casbin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestNew description
|
||||||
|
func TestNew(t *testing.T) {
|
||||||
|
|
||||||
|
InitEnforcer(context.TODO())
|
||||||
|
|
||||||
|
user := "admin"
|
||||||
|
path := "/"
|
||||||
|
method := http.MethodGet
|
||||||
|
t.Logf("\nuser:%v\npath:%v\nmethod:%v", user, path, method)
|
||||||
|
|
||||||
|
ok, err := Enforcer.DeletePermissionsForUser(user)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
t.Logf("delete user premission:%v", ok)
|
||||||
|
CheckPremission(t, user, path, method)
|
||||||
|
AddPremission(t, user, "*", ActionAll)
|
||||||
|
CheckPremission(t, user, path, method)
|
||||||
|
|
||||||
|
user1 := "user1"
|
||||||
|
path1 := "/api/v1/*"
|
||||||
|
checkPathTrue := "/api/v1/user/list"
|
||||||
|
checkPathFalse := "/api/v2/user/list"
|
||||||
|
AddPremission(t, user1, path1, ActionAll)
|
||||||
|
CheckPremission(t, user1, checkPathTrue, ActionPost)
|
||||||
|
CheckPremission(t, user1, checkPathFalse, http.MethodGet)
|
||||||
|
CheckPremission(t, user1, checkPathTrue, http.MethodGet)
|
||||||
|
CheckPremission(t, user1, "/api/v1/user/list2", http.MethodGet)
|
||||||
|
|
||||||
|
ok, err = Enforcer.DeletePermissionsForUser(user1)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
t.Logf("delete user premission:%v", ok)
|
||||||
|
CheckPremission(t, user1, "/api/v1/user1/list", http.MethodGet)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckPremission description
|
||||||
|
func CheckPremission(t *testing.T, user string, path string, method string) {
|
||||||
|
ok, err := Enforcer.Enforce(user, path, method)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
t.Logf("check \tuser[%s] \tpremission[%s] \tpath[%s] \tallow[%v]", user, method, path, ok)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add description
|
||||||
|
func AddPremission(t *testing.T, user string, path string, method string) {
|
||||||
|
ok, err := Enforcer.AddPolicy(user, path, method)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
t.Logf("add \tuser[%s] \tpremission[%s] \tpath[%s] \tresult[%v]", user, method, path, ok)
|
||||||
|
}
|
||||||
@@ -0,0 +1,164 @@
|
|||||||
|
// Package casbin
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package casbin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"hotgo/internal/consts"
|
||||||
|
"hotgo/internal/dao"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/casbin/casbin/v2"
|
||||||
|
"github.com/casbin/casbin/v2/model"
|
||||||
|
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
||||||
|
"github.com/gogf/gf/v2/container/gvar"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gfile"
|
||||||
|
"github.com/gogf/gf/v2/os/gres"
|
||||||
|
"github.com/gogf/gf/v2/text/gstr"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ActionGet = http.MethodGet
|
||||||
|
ActionPost = http.MethodPost
|
||||||
|
ActionPut = http.MethodPut
|
||||||
|
ActionDelete = http.MethodDelete
|
||||||
|
ActionAll = "GET|POST|PUT|DELETE|PATCH|OPTIONS|HEAD"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Enforcer *casbin.Enforcer
|
||||||
|
|
||||||
|
// InitEnforcer 初始化
|
||||||
|
func InitEnforcer(ctx context.Context) {
|
||||||
|
var (
|
||||||
|
link = getDbLink(ctx)
|
||||||
|
a, err = NewAdapter(link.String())
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
g.Log().Panicf(ctx, "casbin.NewAdapter err . %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
path := "manifest/config/casbin.conf"
|
||||||
|
|
||||||
|
// 优先从本地加载casbin.conf,如果不存在就从资源文件中找
|
||||||
|
modelContent := gfile.GetContents(path)
|
||||||
|
if len(modelContent) == 0 {
|
||||||
|
if !gres.IsEmpty() && gres.Contains(path) {
|
||||||
|
modelContent = string(gres.GetContent(path))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(modelContent) == 0 {
|
||||||
|
g.Log().Panicf(ctx, "casbin model file does not exist:%v", path)
|
||||||
|
}
|
||||||
|
|
||||||
|
m, err := model.NewModelFromString(modelContent)
|
||||||
|
if err != nil {
|
||||||
|
g.Log().Panicf(ctx, "casbin NewModelFromString err:%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
Enforcer, err = casbin.NewEnforcer(m, a)
|
||||||
|
if err != nil {
|
||||||
|
g.Log().Panicf(ctx, "casbin NewEnforcer err:%v", err)
|
||||||
|
}
|
||||||
|
loadPermissions(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDbLink 获取数据库链接
|
||||||
|
func getDbLink(ctx context.Context) *gvar.Var {
|
||||||
|
|
||||||
|
link := g.Cfg().MustGet(ctx, "database.default")
|
||||||
|
//读写分离
|
||||||
|
if !link.IsSlice() {
|
||||||
|
return g.Cfg().MustGet(ctx, "database.default.link")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range link.Array() {
|
||||||
|
// 只获取主库
|
||||||
|
val := v.(map[string]interface{})
|
||||||
|
if val["role"] == "master" {
|
||||||
|
return gvar.New(val["link"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return gvar.New("database.default.0.link")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadPermissions(ctx context.Context) {
|
||||||
|
type Policy struct {
|
||||||
|
Key string `json:"key"`
|
||||||
|
Permissions string `json:"permissions"`
|
||||||
|
}
|
||||||
|
var (
|
||||||
|
rules [][]string
|
||||||
|
polices []*Policy
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
//别名拼接 r.key m.permissions
|
||||||
|
q := func(alias string, column string) string {
|
||||||
|
return fmt.Sprintf("%s.%s", alias, column)
|
||||||
|
}
|
||||||
|
err = g.Model(gstr.Join([]string{dao.AdminRole.Table(), "r"}, " ")).
|
||||||
|
LeftJoin(gstr.Join([]string{dao.AdminRoleMenu.Table(), "rm"}, " "), "r.id=rm.role_id").
|
||||||
|
LeftJoin(gstr.Join([]string{dao.AdminMenu.Table(), "m"}, " "), "rm.menu_id=m.id").
|
||||||
|
Fields(q("r", dao.AdminRole.Columns().Key), q("m", dao.AdminMenu.Columns().Permissions)).
|
||||||
|
Where(q("r", dao.AdminRole.Columns().Status), consts.StatusEnabled).
|
||||||
|
Where(q("m", dao.AdminMenu.Columns().Status), consts.StatusEnabled).
|
||||||
|
WhereNot(q("m", dao.AdminMenu.Columns().Permissions), "").
|
||||||
|
WhereNot(q("r", dao.AdminRole.Columns().Key), consts.SuperRoleKey).
|
||||||
|
Scan(&polices)
|
||||||
|
if err != nil {
|
||||||
|
g.Log().Fatalf(ctx, "loadPermissions Scan err:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, policy := range polices {
|
||||||
|
if strings.Contains(policy.Permissions, ",") {
|
||||||
|
lst := strings.Split(policy.Permissions, ",")
|
||||||
|
for _, permissions := range lst {
|
||||||
|
rules = append(rules, []string{policy.Key, permissions, ActionAll})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rules = append(rules, []string{policy.Key, policy.Permissions, ActionAll})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = Enforcer.AddPolicies(rules); err != nil {
|
||||||
|
g.Log().Fatalf(ctx, "loadPermissions AddPolicies err:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Clear(ctx context.Context) (err error) {
|
||||||
|
policy, err := Enforcer.GetPolicy()
|
||||||
|
if err != nil {
|
||||||
|
g.Log().Warningf(ctx, "Enforcer RemovePolicies err:%+v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err = Enforcer.RemovePolicies(policy)
|
||||||
|
if err != nil {
|
||||||
|
g.Log().Warningf(ctx, "Enforcer RemovePolicies err:%+v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否清理干净
|
||||||
|
if len(policy) > 0 {
|
||||||
|
return Clear(ctx)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Refresh(ctx context.Context) (err error) {
|
||||||
|
if err = Clear(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
loadPermissions(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
// Package contexts
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package contexts
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/net/ghttp"
|
||||||
|
"hotgo/internal/consts"
|
||||||
|
"hotgo/internal/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Init 初始化上下文对象指针到上下文对象中,以便后续的请求流程中可以修改
|
||||||
|
func Init(r *ghttp.Request, customCtx *model.Context) {
|
||||||
|
r.SetCtxVar(consts.ContextHTTPKey, customCtx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get 获得上下文变量,如果没有设置,那么返回nil
|
||||||
|
func Get(ctx context.Context) *model.Context {
|
||||||
|
value := ctx.Value(consts.ContextHTTPKey)
|
||||||
|
if value == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if localCtx, ok := value.(*model.Context); ok {
|
||||||
|
return localCtx
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUser 将上下文信息设置到上下文请求中,注意是完整覆盖
|
||||||
|
func SetUser(ctx context.Context, user *model.Identity) {
|
||||||
|
c := Get(ctx)
|
||||||
|
if c == nil {
|
||||||
|
g.Log().Warning(ctx, "contexts.SetUser, c == nil ")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.User = user
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetResponse 设置组件响应 用于访问日志使用
|
||||||
|
func SetResponse(ctx context.Context, response *model.Response) {
|
||||||
|
c := Get(ctx)
|
||||||
|
if c == nil {
|
||||||
|
g.Log().Warning(ctx, "contexts.SetResponse, c == nil ")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Response = response
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetModule 设置应用模块
|
||||||
|
func SetModule(ctx context.Context, module string) {
|
||||||
|
c := Get(ctx)
|
||||||
|
if c == nil {
|
||||||
|
g.Log().Warning(ctx, "contexts.SetModule, c == nil ")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Module = module
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUser 获取用户信息
|
||||||
|
func GetUser(ctx context.Context) *model.Identity {
|
||||||
|
c := Get(ctx)
|
||||||
|
if c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return c.User
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserId 获取用户ID
|
||||||
|
func GetUserId(ctx context.Context) int64 {
|
||||||
|
user := GetUser(ctx)
|
||||||
|
if user == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return user.Id
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRoleId 获取用户角色ID
|
||||||
|
func GetRoleId(ctx context.Context) int64 {
|
||||||
|
user := GetUser(ctx)
|
||||||
|
if user == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return user.RoleId
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRoleKey 获取用户角色唯一编码
|
||||||
|
func GetRoleKey(ctx context.Context) string {
|
||||||
|
user := GetUser(ctx)
|
||||||
|
if user == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return user.RoleKey
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDeptType 获取用户部门类型
|
||||||
|
func GetDeptType(ctx context.Context) string {
|
||||||
|
user := GetUser(ctx)
|
||||||
|
if user == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return user.DeptType
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCompanyDept 是否为公司部门
|
||||||
|
func IsCompanyDept(ctx context.Context) bool {
|
||||||
|
return GetDeptType(ctx) == consts.DeptTypeCompany
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsTenantDept 是否为租户部门
|
||||||
|
func IsTenantDept(ctx context.Context) bool {
|
||||||
|
return GetDeptType(ctx) == consts.DeptTypeTenant
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsMerchantDept 是否为商户部门
|
||||||
|
func IsMerchantDept(ctx context.Context) bool {
|
||||||
|
return GetDeptType(ctx) == consts.DeptTypeMerchant
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsUserDept 是否为普通用户部门
|
||||||
|
func IsUserDept(ctx context.Context) bool {
|
||||||
|
return GetDeptType(ctx) == consts.DeptTypeUser
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetModule 获取应用模块
|
||||||
|
func GetModule(ctx context.Context) string {
|
||||||
|
c := Get(ctx)
|
||||||
|
if c == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return c.Module
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAddonName 设置插件信息
|
||||||
|
func SetAddonName(ctx context.Context, name string) {
|
||||||
|
c := Get(ctx)
|
||||||
|
if c == nil {
|
||||||
|
g.Log().Warning(ctx, "contexts.SetAddonName, c == nil ")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Get(ctx).AddonName = name
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsAddonRequest 是否为插件模块请求
|
||||||
|
func IsAddonRequest(ctx context.Context) bool {
|
||||||
|
c := Get(ctx)
|
||||||
|
if c == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return GetAddonName(ctx) != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAddonName 获取插件信息
|
||||||
|
func GetAddonName(ctx context.Context) string {
|
||||||
|
c := Get(ctx)
|
||||||
|
if c == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return Get(ctx).AddonName
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetData 设置额外数据
|
||||||
|
func SetData(ctx context.Context, k string, v interface{}) {
|
||||||
|
c := Get(ctx)
|
||||||
|
if c == nil {
|
||||||
|
g.Log().Warning(ctx, "contexts.SetData, c == nil ")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Get(ctx).Data[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDataMap 设置额外数据
|
||||||
|
func SetDataMap(ctx context.Context, vs g.Map) {
|
||||||
|
c := Get(ctx)
|
||||||
|
if c == nil {
|
||||||
|
g.Log().Warning(ctx, "contexts.SetData, c == nil ")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range vs {
|
||||||
|
Get(ctx).Data[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetData 获取额外数据
|
||||||
|
func GetData(ctx context.Context) g.Map {
|
||||||
|
c := Get(ctx)
|
||||||
|
if c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return c.Data
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
// Package contexts
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package contexts
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type detached struct {
|
||||||
|
ctx context.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
func (detached) Deadline() (time.Time, bool) {
|
||||||
|
return time.Time{}, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (detached) Done() <-chan struct{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (detached) Err() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d detached) Value(key interface{}) interface{} {
|
||||||
|
return d.ctx.Value(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Detach(ctx context.Context) context.Context {
|
||||||
|
return detached{ctx: ctx}
|
||||||
|
}
|
||||||
@@ -0,0 +1,313 @@
|
|||||||
|
// Package cron
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package cron
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gcron"
|
||||||
|
"github.com/gogf/gf/v2/os/gctx"
|
||||||
|
"github.com/gogf/gf/v2/os/gfile"
|
||||||
|
"github.com/gogf/gf/v2/os/glog"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
"hotgo/internal/consts"
|
||||||
|
"hotgo/internal/dao"
|
||||||
|
"hotgo/internal/model/entity"
|
||||||
|
"hotgo/utility/simple"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var crons = &cronManager{
|
||||||
|
tasks: make(map[string]*TaskItem),
|
||||||
|
loggers: make(map[string]*glog.Logger),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cron 定时任务接口
|
||||||
|
type Cron interface {
|
||||||
|
// GetName 获取任务名称
|
||||||
|
GetName() string
|
||||||
|
// Execute 执行任务
|
||||||
|
Execute(ctx context.Context, parser *Parser) (err error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parser 任务执行参数
|
||||||
|
type Parser struct {
|
||||||
|
Args []string // 任务参数
|
||||||
|
Logger *glog.Logger // 日志管理实例
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log 任务调度日志
|
||||||
|
type Log struct {
|
||||||
|
FileName string `json:"fileName" dc:"文件名称"`
|
||||||
|
SizeFormat string `json:"sizeFormat" dc:"文件大小"`
|
||||||
|
Contents string `json:"contents" dc:"文件内容"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// consumerManager 任务管理者
|
||||||
|
type cronManager struct {
|
||||||
|
tasks map[string]*TaskItem
|
||||||
|
loggers map[string]*glog.Logger
|
||||||
|
sync.RWMutex
|
||||||
|
}
|
||||||
|
|
||||||
|
type TaskItem struct {
|
||||||
|
Pattern string // 表达式,参考:https://goframe.org/pages/viewpage.action?pageId=30736411
|
||||||
|
Name string // 唯一的任务名称
|
||||||
|
Params string // 函数参数,多个用,隔开
|
||||||
|
Fun gcron.JobFunc // 执行的函数接口
|
||||||
|
Policy int64 // 策略 1:并行 2:单例 3:单次 4:多次
|
||||||
|
Count int // 执行次数,仅Policy=4时有效
|
||||||
|
}
|
||||||
|
|
||||||
|
func Logger() *glog.Logger {
|
||||||
|
return g.Log("cron")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register 注册任务
|
||||||
|
func Register(c Cron) {
|
||||||
|
crons.Lock()
|
||||||
|
defer crons.Unlock()
|
||||||
|
|
||||||
|
name := c.GetName()
|
||||||
|
if _, ok := crons.tasks[name]; ok {
|
||||||
|
Logger().Debugf(gctx.GetInitCtx(), "cron.Register name:%v duplicate registration.", name)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
crons.tasks[name] = &TaskItem{Name: c.GetName(), Fun: GenExecuteFun(c.Execute)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// StopALL 停止所有任务
|
||||||
|
func StopALL() {
|
||||||
|
for _, v := range gcron.Entries() {
|
||||||
|
gcron.Remove(v.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartALL 启动所有任务
|
||||||
|
func StartALL(sysCron []*entity.SysCron) (err error) {
|
||||||
|
crons.Lock()
|
||||||
|
defer crons.Unlock()
|
||||||
|
|
||||||
|
if len(crons.tasks) == 0 {
|
||||||
|
g.Log().Debug(gctx.GetInitCtx(), "no scheduled task is available.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, cron := range sysCron {
|
||||||
|
f, ok := crons.tasks[cron.Name]
|
||||||
|
if !ok {
|
||||||
|
return gerror.Newf("该任务没有加入任务列表:%v", cron.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
sn := GenCronSn(cron)
|
||||||
|
|
||||||
|
// 没有则添加
|
||||||
|
if gcron.Search(sn) == nil {
|
||||||
|
var (
|
||||||
|
t *gcron.Entry
|
||||||
|
ctx = GenCronCtx(cron)
|
||||||
|
)
|
||||||
|
switch cron.Policy {
|
||||||
|
case consts.CronPolicySame:
|
||||||
|
t, err = gcron.Add(ctx, cron.Pattern, f.Fun, sn)
|
||||||
|
|
||||||
|
case consts.CronPolicySingle:
|
||||||
|
t, err = gcron.AddSingleton(ctx, cron.Pattern, f.Fun, sn)
|
||||||
|
|
||||||
|
case consts.CronPolicyOnce:
|
||||||
|
t, err = gcron.AddOnce(ctx, cron.Pattern, f.Fun, sn)
|
||||||
|
|
||||||
|
case consts.CronPolicyTimes:
|
||||||
|
if f.Count <= 0 {
|
||||||
|
f.Count = 1
|
||||||
|
}
|
||||||
|
t, err = gcron.AddTimes(ctx, cron.Pattern, int(cron.Count), f.Fun, sn)
|
||||||
|
|
||||||
|
default:
|
||||||
|
return gerror.Newf("使用无效的策略, cron.Policy=%v", cron.Policy)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if t == nil {
|
||||||
|
return gerror.New("启动任务失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gcron.Start(sn)
|
||||||
|
|
||||||
|
// 执行完毕,单次和多次执行的任务更新状态
|
||||||
|
if cron.Policy == consts.CronPolicyOnce || cron.Policy == consts.CronPolicyTimes {
|
||||||
|
if _, err = dao.SysCron.Ctx(gctx.GetInitCtx()).Where(dao.SysCron.Columns().Id, cron.Id).Data(g.Map{dao.SysCron.Columns().Status: consts.StatusDisable, dao.SysCron.Columns().UpdatedAt: gtime.Now()}).Update(); err != nil {
|
||||||
|
err = gerror.Wrap(err, "定时任务执行失败!")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger().Debug(gctx.GetInitCtx(), "load cron success..")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RefreshStatus 刷新状态
|
||||||
|
func RefreshStatus(sysCron *entity.SysCron) (err error) {
|
||||||
|
if sysCron == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if sysCron.Status == consts.StatusEnabled {
|
||||||
|
return ResetStart(sysCron)
|
||||||
|
}
|
||||||
|
return Stop(sysCron)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop 停止单个任务
|
||||||
|
func Stop(sysCron *entity.SysCron) (err error) {
|
||||||
|
cr := gcron.Search(GenCronSn(sysCron))
|
||||||
|
if cr == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cr.Stop()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetStart 重置任务
|
||||||
|
func ResetStart(sysCron *entity.SysCron) (err error) {
|
||||||
|
if err = Stop(sysCron); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = Delete(sysCron); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return Start(sysCron)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Once 立即执行一次某个任务
|
||||||
|
func Once(ctx context.Context, sysCron *entity.SysCron) error {
|
||||||
|
crons.RLock()
|
||||||
|
defer crons.RUnlock()
|
||||||
|
|
||||||
|
for _, v := range crons.tasks {
|
||||||
|
if v.Name == sysCron.Name {
|
||||||
|
simple.SafeGo(ctx, func(ctx context.Context) {
|
||||||
|
v.Fun(GenCronCtx(sysCron))
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return gerror.Newf("定时任务不存在:%+v", sysCron.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete 删除任务
|
||||||
|
func Delete(sysCron *entity.SysCron) (err error) {
|
||||||
|
if sysCron == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range gcron.Entries() {
|
||||||
|
if v.Name == GenCronSn(sysCron) {
|
||||||
|
gcron.Remove(v.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start 启动单个任务
|
||||||
|
func Start(sysCron *entity.SysCron) (err error) {
|
||||||
|
if sysCron == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c := gcron.Search(GenCronSn(sysCron))
|
||||||
|
if c != nil {
|
||||||
|
c.Start()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return StartALL([]*entity.SysCron{sysCron})
|
||||||
|
}
|
||||||
|
|
||||||
|
// DispatchLog 查看指定任务的调度日志
|
||||||
|
func DispatchLog(sysCron *entity.SysCron) (log *Log, err error) {
|
||||||
|
path := fmt.Sprintf("%v/%v", Logger().GetConfig().Path, GenCronSn(sysCron))
|
||||||
|
file, err := FindLastModifiedFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(file) == 0 || !gfile.IsFile(file) {
|
||||||
|
err = gerror.New("未找到日志!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log = new(Log)
|
||||||
|
log.FileName = file
|
||||||
|
log.SizeFormat = gfile.SizeFormat(file)
|
||||||
|
|
||||||
|
if gfile.Size(file) > 1024*50 {
|
||||||
|
log.Contents, err = ReadLastLines(file, 100)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Contents = gfile.GetContents(file)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReadLastLines(filename string, lineCount int) (string, error) {
|
||||||
|
file, err := os.Open(filename)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
scanner := bufio.NewScanner(file)
|
||||||
|
|
||||||
|
lines := make([]string, 0, lineCount)
|
||||||
|
for scanner.Scan() {
|
||||||
|
lines = append(lines, scanner.Text())
|
||||||
|
if len(lines) > lineCount {
|
||||||
|
lines = lines[1:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := strings.Join(lines, "\n")
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func FindLastModifiedFile(dirPath string) (string, error) {
|
||||||
|
if !gfile.Exists(dirPath) {
|
||||||
|
return "", gerror.New("该任务暂未产生日志!")
|
||||||
|
}
|
||||||
|
|
||||||
|
files, err := gfile.ScanDir(dirPath, "*.log", true)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastModifiedFile string
|
||||||
|
var lastModifiedTime int64 = 0
|
||||||
|
|
||||||
|
for _, file := range files {
|
||||||
|
modTime := gfile.MTimestamp(file)
|
||||||
|
if modTime > lastModifiedTime {
|
||||||
|
lastModifiedTime = modTime
|
||||||
|
lastModifiedFile = file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lastModifiedFile, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
// Package cron
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
package cron
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gctx"
|
||||||
|
"github.com/gogf/gf/v2/os/glog"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
"hotgo/internal/consts"
|
||||||
|
"hotgo/internal/model/entity"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GenCronSn 生成任务序列号
|
||||||
|
func GenCronSn(sysCron *entity.SysCron) string {
|
||||||
|
return fmt.Sprintf("%s@%d", sysCron.Name, sysCron.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenCronCtx 生成任务上下文
|
||||||
|
func GenCronCtx(sysCron *entity.SysCron) (ctx context.Context) {
|
||||||
|
ctx = context.WithValue(gctx.New(), consts.ContextKeyCronArgs, strings.Split(sysCron.Params, consts.CronSplitStr))
|
||||||
|
ctx = context.WithValue(ctx, consts.ContextKeyCronSn, GenCronSn(sysCron))
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func GenLoggerByCtx(ctx context.Context) *glog.Logger {
|
||||||
|
sn, ok := ctx.Value(consts.ContextKeyCronSn).(string)
|
||||||
|
if !ok {
|
||||||
|
Logger().Panic(ctx, "获取定时任务序列号失败!")
|
||||||
|
}
|
||||||
|
|
||||||
|
crons.RLock()
|
||||||
|
logger, ok := crons.loggers[sn]
|
||||||
|
crons.RUnlock()
|
||||||
|
if ok {
|
||||||
|
return logger
|
||||||
|
}
|
||||||
|
|
||||||
|
logger = glog.New()
|
||||||
|
if err := logger.SetConfig(Logger().GetConfig()); err != nil {
|
||||||
|
Logger().Panic(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.SetFlags(glog.F_TIME_STD | glog.F_FILE_SHORT)
|
||||||
|
// 设置子路径
|
||||||
|
if err := logger.SetPath(fmt.Sprintf("%v/%v", logger.GetPath(), sn)); err != nil {
|
||||||
|
Logger().Panic(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
crons.Lock()
|
||||||
|
defer crons.Unlock()
|
||||||
|
crons.loggers[sn] = logger
|
||||||
|
return logger
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenExecuteFun 生成执行过程
|
||||||
|
func GenExecuteFun(fun func(ctx context.Context, parser *Parser) (err error)) func(ctx context.Context) {
|
||||||
|
return func(ctx context.Context) {
|
||||||
|
args, ok := ctx.Value(consts.ContextKeyCronArgs).([]string)
|
||||||
|
if !ok {
|
||||||
|
Logger().Panic(ctx, "执行定时任务时,参数解析失败!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
parser := new(Parser)
|
||||||
|
parser.Args = args
|
||||||
|
parser.Logger = GenLoggerByCtx(ctx)
|
||||||
|
|
||||||
|
st := gtime.Now()
|
||||||
|
err := g.Try(ctx, func(ctx context.Context) {
|
||||||
|
if err := fun(ctx, parser); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
milliseconds := gtime.Now().Sub(st).Milliseconds() // 执行耗时
|
||||||
|
if err != nil {
|
||||||
|
parser.Logger.Errorf(ctx, "execute failed, took %vms, err:%+v", milliseconds, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
parser.Logger.Infof(ctx, "execute success, took %vms.", milliseconds)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// Package debris
|
||||||
|
// @Link https://github.com/bufanyun/hotgo
|
||||||
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||||
|
// @Author Ms <133814250@qq.com>
|
||||||
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||||
|
//
|
||||||
|
package debris
|
||||||
|
|
||||||
|
// 碎片
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user