Documentation ¶
Index ¶
- Constants
- func Connect(driver string, dsn string)
- func Default() *sqlx.DB
- func Disconnect()
- func DriverName() string
- func Exec(ql string, params ...any) error
- func ExecOne(ql string, params ...any) error
- func From(table ...any) *goqu.SelectDataset
- func Get(ql string, dest any, params ...any) error
- func In(ql string, args ...any) (string, []any, error)
- func MustAffected1Row(res sql.Result, ql string) error
- func ParseDate(date string) (time.Time, error)
- func Rebind(ql string) string
- func Select(ql string, dest any, params ...any) error
- func SelectOne(ql string, dest any, params ...any) error
- func Serial() (uint64, error)
- func TimeRange(s time.Time, e time.Time) exp.RangeVal
- func TimeSerial() string
- type ACL
- type ACLAllow
- type Account
- type Bulletin
- type Debug
- type Event
- type GeoIP
- type Image
- type ImageStore
- type MTA
- type Notification
- type OAuth
- type Ops
- type Pagination
- func (p *Pagination) Col(col any) exp.IdentifierExpression
- func (p *Pagination) Exec(count *uint, records any) error
- func (p *Pagination) Join(t exp.Expression, on exp.JoinCondition) *Pagination
- func (p *Pagination) OrderBy(order ...exp.OrderedExpression) *Pagination
- func (p *Pagination) Select(columns ...any) *Pagination
- func (p *Pagination) Where(conds ...exp.Expression) *Pagination
- type SMS
- type SigninHistory
- type Task
- type Tree
- type TreeBind
- type User
- type UserOAuth
Constants ¶
const ( DriverSqlite = "sqlite" DriverPgx = "pgx" DriverMySQL = "mysql" )
Variables ¶
This section is empty.
Functions ¶
func MustAffected1Row ¶
对于 update/insert/delete,检查结果是否只影响了 1 行
func TimeRange ¶
如果是在时间之间进行比较,sqlite 貌似不能正确处理 UTC 格式,例如: BETWEEN '2022-05-07T16:00:00Z' AND '2022-05-08T15:59:59.999Z' 与 BETWEEN '2022-05-07 16:00:00' AND '2022-05-08 15:59:59.999' 的查询结果不同,后者才是正确的结果
func TimeSerial ¶
func TimeSerial() string
Types ¶
type ACL ¶
type ACL struct { UUID string `db:"uuid" json:"uuid"` // uuid CreateAt time.Time `db:"create_at" json:"create_at"` // 创建时间 UpdateAt time.Time `db:"update_at" json:"update_at"` // 更新时间 Code int `db:"code" json:"code"` // 代码 Name string `db:"name" json:"name"` // 名称 Summary string `db:"summary" json:"summary"` // 描述 Features string `db:"features" json:"features"` // 特征 }
访问控制角色
type ACLAllow ¶
type ACLAllow struct { UUID string `db:"uuid" json:"uuid"` // uuid ACL string `db:"acl" json:"acl"` // acl uuid Code int `db:"code" json:"code"` // 菜单代码 Title string `db:"title" json:"title"` // 菜单标题 URL string `db:"url" json:"url"` // url IRead bool `db:"iread" json:"iread"` // 访问权限 IWrite bool `db:"iwrite" json:"iwrite"` // 修改权限 IAdmin bool `db:"iadmin" json:"iadmin"` // 管理权限 }
访问控制权限
type Account ¶
type Account struct { Signupable bool `db:"signupable" json:"signupable"` // 开放用户注册 SignupACL string `db:"signupacl" json:"signupacl"` // 用户注册角色 LookUserid bool `db:"lookuserid" json:"lookuserid"` // 允许找回登录名 ResetPass bool `db:"resetpass" json:"resetpass"` // 允许找回密码 SessDuration int `db:"sessduration" json:"sessduration"` // 会话持续时间 JWTSignKey string `db:"jwtsignkey" json:"jwtsignkey"` // JWT 签名密钥 JWTSignKey2 string `db:"jwtsignkey2" json:"jwtsignkey2"` // JWT 签名密钥(旧) }
账号设置
type Bulletin ¶
type Bulletin struct { UUID string `db:"uuid" json:"uuid"` // uuid CreateAt time.Time `db:"create_at" json:"create_at"` // 创建时间 UserUUID string `db:"user_uuid" json:"user_uuid"` // 用户 Title string `db:"title" json:"title"` // 标题 Content string `db:"content" json:"content"` // 内容 SendTime time.Time `db:"send_time" json:"send_time"` // 发布时间 IsPublic bool `db:"is_public" json:"is_public"` // 公开访问 IsNotify bool `db:"is_notify" json:"is_notify"` // 通知用户 Status int `db:"status" json:"status"` // 状态 NRead int `db:"nread" json:"nread"` // 阅读次数 NStar int `db:"nstar" json:"nstar"` // 点赞次数 }
系统公告
type Event ¶
type Event struct { UUID string `db:"uuid" json:"uuid"` // uuid CreateAt time.Time `db:"create_at" json:"create_at"` // 创建时间 Level int `db:"level" json:"level"` // 级别 Title string `db:"title" json:"title"` // 标题 Message string `db:"message" json:"message"` // 消息 Fresh bool `db:"fresh" json:"fresh"` // 未读 }
系统事件
type GeoIP ¶
type GeoIP struct { AMapWebKey string `db:"amap_webkey" json:"amap_webkey"` // 高德开放平台 web 服务 key AMapEnable bool `db:"amap_enable" json:"amap_enable"` // 是否允许高德开放平台 AMapApiVer string `db:"amap_apiver" json:"amap_apiver"` // 高德开放平台 IP 定位接口版本 TencentWebKey string `db:"tencent_webkey" json:"tencent_webkey"` // 腾讯位置服务 web 服务 key TencentEnable bool `db:"tencent_enable" json:"tencent_enable"` // 是否允许腾讯位置服务 }
IP 定位
type Image ¶
type Image struct { UUID string `db:"uuid" json:"uuid"` // unique id CreateAt time.Time `db:"create_at" json:"create_at"` // create time UpdateAt time.Time `db:"update_at" json:"update_at"` // update time Place int `db:"place" json:"place"` // 位置 Data []byte `db:"data" json:"data"` // image 数据 Path string `db:"path" json:"path"` // 文件系统路径(相对路径) Mime string `db:"mime" json:"mime"` // image mime 类型 ETag string `db:"etag" json:"etag"` // image 数据哈希 }
图片
type ImageStore ¶
type MTA ¶
type MTA struct { UUID string `db:"uuid" json:"uuid"` // uuid CreateAt time.Time `db:"create_at" json:"create_at"` // 创建时间 UpdateAt time.Time `db:"update_at" json:"update_at"` // 更新时间 Name string `db:"name" json:"name"` // 名称 Host string `db:"host" json:"host"` // 主机 Port int `db:"port" json:"port"` // 端口 SSLMode bool `db:"sslmode" json:"sslmode"` // SSL 模式 Sender string `db:"sender" json:"sender"` // 发送地址 Prefix string `db:"prefix" json:"prefix"` // 标题前缀 ReplyTo string `db:"replyto" json:"replyto"` // 回复地址 Username string `db:"username" json:"username"` // 认证用户名 Passwd string `db:"passwd" json:"passwd"` // 密码 CC string `db:"cc" json:"cc"` // 抄送 BCC string `db:"bcc" json:"bcc"` // 密送 SortNo int `db:"sortno" json:"sortno"` // 排序序号 NSent int `db:"nsent" json:"nsent"` // 发送量 Disabled bool `db:"disabled" json:"disabled"` // 是否停用 }
邮件服务
type Notification ¶
type Notification struct { UUID string `db:"uuid" json:"uuid"` // uuid CreateAt time.Time `db:"create_at" json:"create_at"` // 创建时间 UserUUID string `db:"user_uuid" json:"user_uuid"` // 用户 Type int `db:"type" json:"type"` // 类型 Title string `db:"title" json:"title"` // 标题 Content string `db:"content" json:"content"` // 内容 Status int `db:"status" json:"status"` // 状态 Refer string `db:"refer" json:"refer"` // 引用 }
通知
type OAuth ¶
type OAuth struct { Provider string `db:"provider" json:"provider"` // 身份提供方 SortNo string `db:"sortno" json:"sortno"` // 排序序号 ClientId string `db:"clientid" json:"clientid"` // 客户端id Secret string `db:"secret" json:"secret"` // 客户端密钥 Enabled bool `db:"enabled" json:"enabled"` // 启用 }
身份授权设置
type Ops ¶
type Ops struct { UUID string `db:"uuid" json:"uuid"` // uuid CreateAt time.Time `db:"create_at" json:"create_at"` // 创建时间 UserUUID string `db:"user_uuid" json:"user_uuid"` // 用户 Method string `db:"method" json:"method"` // 方法 URL string `db:"url" json:"url"` // URL Body string `db:"body" json:"body"` // 请求内容 Audit string `db:"audit" json:"audit"` // 审计消息 }
操作记录
type Pagination ¶
type Pagination struct { Table exp.IdentifierExpression // contains filtered or unexported fields }
func NewPagination ¶
func NewPagination(table string, offset, limit uint) *Pagination
func (*Pagination) Col ¶
func (p *Pagination) Col(col any) exp.IdentifierExpression
返回 "table.column" 而不是 "column",在连表查询时,应该用这个指定表名, 单表查询无所谓,用 goqu.C() 就可以
func (*Pagination) Exec ¶
func (p *Pagination) Exec(count *uint, records any) error
这个函数执行 2 个 SQL 查询,第一次查询表的总数,第二次查询当前的分页数据 这个函数应该在上面的条件都准备好之后调用
func (*Pagination) Join ¶
func (p *Pagination) Join(t exp.Expression, on exp.JoinCondition) *Pagination
添加 left join,大致用法如下(on 有多种方式): p.Join(goqu.T('t2'), goqu.On(t1.col.eq(t2.col)))
可以多次调用该函数联合多个表
func (*Pagination) OrderBy ¶
func (p *Pagination) OrderBy(order ...exp.OrderedExpression) *Pagination
添加 order by 子句,可以指定多个,例如: OrderBy(goqu.Col("serial").Desc(), goqu.Col("create_at").Asc()) 注意使用 Desc() 和 Asc()
可以多次调用该函数添加多个 order by 子句
func (*Pagination) Select ¶
func (p *Pagination) Select(columns ...any) *Pagination
用这个函数指定查询列,例如 * 或者 goqu.C("name") 或者 p.Col("name"),分别是: select * from select name from select table.name from
可以指定多列,也可以多次调用该函数来添加列
func (*Pagination) Where ¶
func (p *Pagination) Where(conds ...exp.Expression) *Pagination
添加 where 子句,多个条件以 and 结合,和使用 goqu.And() 的效果一样
可以多次调用该函数增加查询条件(and 组合)
type SMS ¶
type SMS struct { UUID string `db:"uuid" json:"uuid"` // uuid CreateAt time.Time `db:"create_at" json:"create_at"` // 创建时间 UpdateAt time.Time `db:"update_at" json:"update_at"` // 更新时间 ISP string `db:"isp" json:"isp"` // 运营商 ISPName string `db:"isp_name" json:"isp_name"` // 运营商名称 AppId string `db:"appid" json:"appid"` // appid SecretId string `db:"secret_id" json:"secret_id"` // secret id SecretKey string `db:"secret_key" json:"secret_key"` // secret key Prefix string `db:"prefix" json:"prefix"` // 签名 TextNo1 string `db:"textno1" json:"textno1"` // 验证码模板 SortNo int `db:"sortno" json:"sortno"` // 排序序号 NSent int `db:"nsent" json:"nsent"` // 发送量 Disabled bool `db:"disabled" json:"disabled"` // 是否停用 }
短信服务
type SigninHistory ¶
type SigninHistory struct { UUID string `db:"uuid" json:"uuid"` // uuid CreateAt time.Time `db:"create_at" json:"create_at"` // 创建时间 User string `db:"user_uuid" json:"user_uuid"` // 用户 uuid UserId string `db:"userid" json:"userid"` // 用户 userid Name string `db:"name" json:"name"` // 姓名 IP string `db:"ip" json:"ip"` // IP 地址 Country string `db:"country" json:"country"` // 国家 Province string `db:"province" json:"province"` // 省 City string `db:"city" json:"city"` // 市 District string `db:"district" json:"district"` // 区 Longitude float64 `db:"longitude" json:"longitude"` // 精度 Latitude float64 `db:"latitude" json:"latitude"` // 纬度 UA string `db:"ua" json:"ua"` // 客户端 userAgent ClientId string `db:"clientid" json:"clientid"` // 客户端id Trust bool `db:"trust" json:"trust"` // 信任设备 TFA int `db:"tfa" json:"tfa"` // 两因素认证方式 ActType int `db:"act_type" json:"act_type"` // 登录方法 OAuthP string `db:"oauthp" json:"oauthp"` // 三方账号提供方 }
登录历史
type Task ¶
type Task struct { UUID string `db:"uuid" json:"uuid"` // uuid CreateAt time.Time `db:"create_at" json:"create_at"` // 创建时间 UpdateAt time.Time `db:"update_at" json:"update_at"` // 更新时间 Name string `db:"name" json:"name"` // 名称 Summary string `db:"summary" json:"summary"` // 描述 Cron string `db:"cron" json:"cron"` // CRON 表达式 Type int `db:"type" json:"type"` // 类型 Path string `db:"path" json:"path"` // 文件路径 LastFire time.Time `db:"last_fire" json:"last_fire"` // 最后执行时间 NFire int `db:"nfire" json:"nfire"` // 执行次数 Disabled bool `db:"disabled" json:"disabled"` // 是否停用 Note sql.NullString `db:"note" json:"note"` // 备注 }
定时任务
type Tree ¶
type Tree struct { UUID string `db:"uuid" json:"uuid"` // uuid CreateAt time.Time `db:"create_at" json:"create_at"` // 创建时间 UpdateAt time.Time `db:"update_at" json:"update_at"` // 更新时间 Name string `db:"name" json:"name"` // 名称 Summary string `db:"summary" json:"summary"` // 描述 Up string `db:"up" json:"up"` // 上级 TPath string `db:"tpath" json:"tpath"` // 路径 TPathHash string `db:"tpath_hash" json:"tpath_hash"` // 路径 md5 hash 值 NLevel int `db:"nlevel" json:"nlevel"` // 级别 Disabled bool `db:"disabled" json:"disabled"` // 禁用 SortNo int `db:"sortno" json:"sortno"` // 排序 }
层次结构
type User ¶
type User struct { UUID string `db:"uuid" json:"uuid"` // uuid CreateAt time.Time `db:"create_at" json:"create_at"` // 创建时间 UpdateAt time.Time `db:"update_at" json:"update_at"` // 更新时间 SigninAt time.Time `db:"signin_at" json:"signin_at"` // 最后登录时间 Disabled bool `db:"disabled" json:"disabled"` // 已禁用 Deleted bool `db:"deleted" json:"deleted"` // 已删除 UserId string `db:"userid" json:"userid"` // 登录名 Passwd string `db:"passwd" json:"passwd"` // 密码 Name string `db:"name" json:"name"` // 姓名 Avatar string `db:"avatar" json:"avatar"` // 头像 Email string `db:"email" json:"email"` // 邮箱地址 Mobile string `db:"mobile" json:"mobile"` // 手机号 IdNo string `db:"idno" json:"idno"` // 身份证号 Address string `db:"address" json:"address"` // 联系地址 AcctName string `db:"acct_name" json:"acct_name"` // 银行账号开户人 AcctNo string `db:"acct_no" json:"acct_no"` // 银行账号 AcctIdno string `db:"acct_idno" json:"acct_idno"` // 银行账号身份证 AcctMobile string `db:"acct_mobile" json:"acct_mobile"` // 银行账号手机号 AcctBankName string `db:"acct_bank_name" json:"acct_bank_name"` // 银行账号开户行 TFA bool `db:"tfa" json:"tfa"` // 短信认证 ACL string `db:"acl" json:"acl"` // 访问控制 SecretCode string `db:"secretcode" json:"secretcode"` // 安全操作码 TOTPSecret string `db:"totp_secret" json:"totp_secret"` // TOTP 密钥 NSignin int `db:"n_signin" json:"n_signin"` // 总登录次数 NotiPopup bool `db:"noti_popup" json:"noti_popup"` // 弹出通知消息 NotiBrowser bool `db:"noti_browser" json:"noti_browser"` // 弹出浏览器通知 NotiMail bool `db:"noti_mail" json:"noti_mail"` // 通知发送邮件 }
用户
type UserOAuth ¶
type UserOAuth struct { UUID string `db:"uuid" json:"uuid"` // uuid CreateAt time.Time `db:"create_at" json:"create_at"` // 创建时间 UserUUID string `db:"user_uuid" json:"user_uuid"` // 用户 Provider string `db:"provider" json:"provider"` // 身份提供方 UserId string `db:"userid" json:"userid"` // 用户编号 Email string `db:"email" json:"email"` // 邮箱地址 Login string `db:"login" json:"login"` // 登录名 Name string `db:"name" json:"name"` // 用户名 Avatar string `db:"avatar" json:"avatar"` // 头像 Profile string `db:"profile" json:"profile"` // 用户信息 Status int `db:"status" json:"status"` // 状态 Usage int `db:"usage" json:"usage"` // 用途 }
用户授权账号