Some checks failed
Build and Deploy (service.xpcool.com) / build-and-deploy (push) Failing after 14s
64 lines
2.1 KiB
Go
64 lines
2.1 KiB
Go
// Package dao 招聘考试聚合模块数据访问层(手写,未跑 gf gen)。
|
||
// 仅暴露 Ctx(ctx) *gdb.Model,供 service 层链式调用,形态与生成产物一致。
|
||
// 全部表落在独立数据库 recruitment(由 database.recruitment.link 配置)。
|
||
package dao
|
||
|
||
import (
|
||
"context"
|
||
|
||
"github.com/gogf/gf/v2/database/gdb"
|
||
"github.com/gogf/gf/v2/frame/g"
|
||
)
|
||
|
||
// dbGroup 招聘模块独立数据库分组名,对应 config 中 database.recruitment.link。
|
||
const dbGroup = "recruitment"
|
||
|
||
// model 返回指向指定表的安全 Model。
|
||
func model(table string) func(ctx context.Context) *gdb.Model {
|
||
return func(ctx context.Context) *gdb.Model {
|
||
return g.DB(dbGroup).Model(table).Safe()
|
||
}
|
||
}
|
||
|
||
type recruitmentInfoDao struct{ table string }
|
||
|
||
// RecruitmentInfo 公告主表全局访问对象。
|
||
var RecruitmentInfo = recruitmentInfoDao{table: "recruitment_info"}
|
||
|
||
func (d recruitmentInfoDao) Ctx(ctx context.Context) *gdb.Model { return model(d.table)(ctx) }
|
||
|
||
type organizationDao struct{ table string }
|
||
|
||
// Organization 发布主体表全局访问对象。
|
||
var Organization = organizationDao{table: "organization"}
|
||
|
||
func (d organizationDao) Ctx(ctx context.Context) *gdb.Model { return model(d.table)(ctx) }
|
||
|
||
type crawlSourceDao struct{ table string }
|
||
|
||
// CrawlSource 数据源表全局访问对象。
|
||
var CrawlSource = crawlSourceDao{table: "crawl_source"}
|
||
|
||
func (d crawlSourceDao) Ctx(ctx context.Context) *gdb.Model { return model(d.table)(ctx) }
|
||
|
||
type crawlLogDao struct{ table string }
|
||
|
||
// CrawlLog 抓取日志表全局访问对象。
|
||
var CrawlLog = crawlLogDao{table: "crawl_log"}
|
||
|
||
func (d crawlLogDao) Ctx(ctx context.Context) *gdb.Model { return model(d.table)(ctx) }
|
||
|
||
type pushSubscriptionDao struct{ table string }
|
||
|
||
// PushSubscription 推送订阅表全局访问对象。
|
||
var PushSubscription = pushSubscriptionDao{table: "push_subscription"}
|
||
|
||
func (d pushSubscriptionDao) Ctx(ctx context.Context) *gdb.Model { return model(d.table)(ctx) }
|
||
|
||
type pushLogDao struct{ table string }
|
||
|
||
// PushLog 推送记录表全局访问对象。
|
||
var PushLog = pushLogDao{table: "push_log"}
|
||
|
||
func (d pushLogDao) Ctx(ctx context.Context) *gdb.Model { return model(d.table)(ctx) }
|