mirror of
https://github.com/gmsec/gmsec.git
synced 2025-09-26 20:01:21 +08:00
new
This commit is contained in:
2
.coveralls.yml
Normal file
2
.coveralls.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
service_name:travis-pro
|
||||
repo_token:0LTKdJPyx19srGcw0Ef8URUlG8fE4K2sa
|
2
.github/FUNDING.yml
vendored
Normal file
2
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
github: xxjwxc
|
||||
patreon: xxjwxcsource
|
28
.github/workflows/go.yml
vendored
Normal file
28
.github/workflows/go.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
name: Go
|
||||
on: [push]
|
||||
jobs:
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Set up Go 1.13
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.13
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Get dependencies
|
||||
run: |
|
||||
go get -v -t -d ./...
|
||||
if [ -f Gopkg.toml ]; then
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
dep ensure
|
||||
fi
|
||||
|
||||
- name: Build
|
||||
run: go build -v .
|
15
.travis.yml
Normal file
15
.travis.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
language: go
|
||||
go:
|
||||
- 1.13.x
|
||||
- master
|
||||
|
||||
go_import_path: github.com/xxjwxc/gmsec
|
||||
|
||||
before_install:
|
||||
- go get -t -v ./...
|
||||
|
||||
script:
|
||||
- go test -race -coverprofile=coverage.txt -covermode=atomic
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
@@ -1,3 +1,7 @@
|
||||
[](https://travis-ci.org/xxjwxc/gmsec)
|
||||
[](https://goreportcard.com/report/github.com/xxjwxc/gmsec)
|
||||
[](https://godoc.org/github.com/xxjwxc/gmsec)
|
||||
|
||||
# gmsec 基于[ginprc](https://github.com/xxjwxc/ginrpc) 实现微服务架构集
|
||||
|
||||
## 目标
|
||||
|
@@ -1,201 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
type _Oauth2AccessTokenMgr struct {
|
||||
*_BaseMgr
|
||||
}
|
||||
|
||||
// Oauth2AccessTokenMgr open func
|
||||
func Oauth2AccessTokenMgr(db *gorm.DB) *_Oauth2AccessTokenMgr {
|
||||
if db == nil {
|
||||
panic(fmt.Errorf("Oauth2AccessTokenMgr need init by db"))
|
||||
}
|
||||
return &_Oauth2AccessTokenMgr{_BaseMgr: &_BaseMgr{DB: db, isRelated: gloabIsRelated}}
|
||||
}
|
||||
|
||||
// GetTableName get sql table name.获取数据库名字
|
||||
func (obj *_Oauth2AccessTokenMgr) GetTableName() string {
|
||||
return "oauth2_access_token"
|
||||
}
|
||||
|
||||
// Get 获取
|
||||
func (obj *_Oauth2AccessTokenMgr) Get() (result Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Gets 获取批量结果
|
||||
func (obj *_Oauth2AccessTokenMgr) Gets() (results []*Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////option case ////////////////////////////////////////////
|
||||
|
||||
// WithID id获取
|
||||
func (obj *_Oauth2AccessTokenMgr) WithID(ID int) Option {
|
||||
return optionFunc(func(o *options) { o.query["id"] = ID })
|
||||
}
|
||||
|
||||
// WithAccessToken access_token获取
|
||||
func (obj *_Oauth2AccessTokenMgr) WithAccessToken(AccessToken string) Option {
|
||||
return optionFunc(func(o *options) { o.query["access_token"] = AccessToken })
|
||||
}
|
||||
|
||||
// WithTokenType token_type获取
|
||||
func (obj *_Oauth2AccessTokenMgr) WithTokenType(TokenType string) Option {
|
||||
return optionFunc(func(o *options) { o.query["token_type"] = TokenType })
|
||||
}
|
||||
|
||||
// WithAppKey app_key获取 key
|
||||
func (obj *_Oauth2AccessTokenMgr) WithAppKey(AppKey string) Option {
|
||||
return optionFunc(func(o *options) { o.query["app_key"] = AppKey })
|
||||
}
|
||||
|
||||
// WithUsername username获取 用户名
|
||||
func (obj *_Oauth2AccessTokenMgr) WithUsername(Username string) Option {
|
||||
return optionFunc(func(o *options) { o.query["username"] = Username })
|
||||
}
|
||||
|
||||
// WithExpires expires获取 过期时间
|
||||
func (obj *_Oauth2AccessTokenMgr) WithExpires(Expires time.Time) Option {
|
||||
return optionFunc(func(o *options) { o.query["expires"] = Expires })
|
||||
}
|
||||
|
||||
// GetByOption 功能选项模式获取
|
||||
func (obj *_Oauth2AccessTokenMgr) GetByOption(opts ...Option) (result Oauth2AccessToken, err error) {
|
||||
options := options{
|
||||
query: make(map[string]interface{}, len(opts)),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(&options)
|
||||
}
|
||||
|
||||
err = obj.DB.Table(obj.GetTableName()).Where(options.query).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetByOptions 批量功能选项模式获取
|
||||
func (obj *_Oauth2AccessTokenMgr) GetByOptions(opts ...Option) (results []*Oauth2AccessToken, err error) {
|
||||
options := options{
|
||||
query: make(map[string]interface{}, len(opts)),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(&options)
|
||||
}
|
||||
|
||||
err = obj.DB.Table(obj.GetTableName()).Where(options.query).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////enume case ////////////////////////////////////////////
|
||||
|
||||
// GetFromID 通过id获取内容
|
||||
func (obj *_Oauth2AccessTokenMgr) GetFromID(ID int) (result Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromID 批量唯一主键查找
|
||||
func (obj *_Oauth2AccessTokenMgr) GetBatchFromID(IDs []int) (results []*Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id IN (?)", IDs).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromAccessToken 通过access_token获取内容
|
||||
func (obj *_Oauth2AccessTokenMgr) GetFromAccessToken(AccessToken string) (result Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("access_token = ?", AccessToken).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromAccessToken 批量唯一主键查找
|
||||
func (obj *_Oauth2AccessTokenMgr) GetBatchFromAccessToken(AccessTokens []string) (results []*Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("access_token IN (?)", AccessTokens).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromTokenType 通过token_type获取内容
|
||||
func (obj *_Oauth2AccessTokenMgr) GetFromTokenType(TokenType string) (results []*Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("token_type = ?", TokenType).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromTokenType 批量唯一主键查找
|
||||
func (obj *_Oauth2AccessTokenMgr) GetBatchFromTokenType(TokenTypes []string) (results []*Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("token_type IN (?)", TokenTypes).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromAppKey 通过app_key获取内容 key
|
||||
func (obj *_Oauth2AccessTokenMgr) GetFromAppKey(AppKey string) (results []*Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_key = ?", AppKey).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromAppKey 批量唯一主键查找 key
|
||||
func (obj *_Oauth2AccessTokenMgr) GetBatchFromAppKey(AppKeys []string) (results []*Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_key IN (?)", AppKeys).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromUsername 通过username获取内容 用户名
|
||||
func (obj *_Oauth2AccessTokenMgr) GetFromUsername(Username string) (results []*Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("username = ?", Username).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromUsername 批量唯一主键查找 用户名
|
||||
func (obj *_Oauth2AccessTokenMgr) GetBatchFromUsername(Usernames []string) (results []*Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("username IN (?)", Usernames).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromExpires 通过expires获取内容 过期时间
|
||||
func (obj *_Oauth2AccessTokenMgr) GetFromExpires(Expires time.Time) (results []*Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("expires = ?", Expires).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromExpires 批量唯一主键查找 过期时间
|
||||
func (obj *_Oauth2AccessTokenMgr) GetBatchFromExpires(Expiress []time.Time) (results []*Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("expires IN (?)", Expiress).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////primary index case ////////////////////////////////////////////
|
||||
|
||||
// FetchByPrimaryKey primay or index 获取唯一内容
|
||||
func (obj *_Oauth2AccessTokenMgr) FetchByPrimaryKey(ID int) (result Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FetchByUnique primay or index 获取唯一内容
|
||||
func (obj *_Oauth2AccessTokenMgr) FetchByUnique(AccessToken string) (result Oauth2AccessToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("access_token = ?", AccessToken).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
@@ -1,232 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
type _Oauth2ClientTblMgr struct {
|
||||
*_BaseMgr
|
||||
}
|
||||
|
||||
// Oauth2ClientTblMgr open func
|
||||
func Oauth2ClientTblMgr(db *gorm.DB) *_Oauth2ClientTblMgr {
|
||||
if db == nil {
|
||||
panic(fmt.Errorf("Oauth2ClientTblMgr need init by db"))
|
||||
}
|
||||
return &_Oauth2ClientTblMgr{_BaseMgr: &_BaseMgr{DB: db, isRelated: gloabIsRelated}}
|
||||
}
|
||||
|
||||
// GetTableName get sql table name.获取数据库名字
|
||||
func (obj *_Oauth2ClientTblMgr) GetTableName() string {
|
||||
return "oauth2_client_tbl"
|
||||
}
|
||||
|
||||
// Get 获取
|
||||
func (obj *_Oauth2ClientTblMgr) Get() (result Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Gets 获取批量结果
|
||||
func (obj *_Oauth2ClientTblMgr) Gets() (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////option case ////////////////////////////////////////////
|
||||
|
||||
// WithID id获取
|
||||
func (obj *_Oauth2ClientTblMgr) WithID(ID int) Option {
|
||||
return optionFunc(func(o *options) { o.query["id"] = ID })
|
||||
}
|
||||
|
||||
// WithAppKey app_key获取
|
||||
func (obj *_Oauth2ClientTblMgr) WithAppKey(AppKey string) Option {
|
||||
return optionFunc(func(o *options) { o.query["app_key"] = AppKey })
|
||||
}
|
||||
|
||||
// WithAppSecret app_secret获取
|
||||
func (obj *_Oauth2ClientTblMgr) WithAppSecret(AppSecret string) Option {
|
||||
return optionFunc(func(o *options) { o.query["app_secret"] = AppSecret })
|
||||
}
|
||||
|
||||
// WithExpireTime expire_time获取 超时时间
|
||||
func (obj *_Oauth2ClientTblMgr) WithExpireTime(ExpireTime time.Time) Option {
|
||||
return optionFunc(func(o *options) { o.query["expire_time"] = ExpireTime })
|
||||
}
|
||||
|
||||
// WithStrictSign strict_sign获取 是否强制验签:0:用户自定义,1:强制
|
||||
func (obj *_Oauth2ClientTblMgr) WithStrictSign(StrictSign int) Option {
|
||||
return optionFunc(func(o *options) { o.query["strict_sign"] = StrictSign })
|
||||
}
|
||||
|
||||
// WithStrictVerify strict_verify获取 是否强制验证码:0:用户自定义,1:强制
|
||||
func (obj *_Oauth2ClientTblMgr) WithStrictVerify(StrictVerify int) Option {
|
||||
return optionFunc(func(o *options) { o.query["strict_verify"] = StrictVerify })
|
||||
}
|
||||
|
||||
// WithTokenExpireTime token_expire_time获取 token过期时间
|
||||
func (obj *_Oauth2ClientTblMgr) WithTokenExpireTime(TokenExpireTime int) Option {
|
||||
return optionFunc(func(o *options) { o.query["token_expire_time"] = TokenExpireTime })
|
||||
}
|
||||
|
||||
// WithAaa aaa获取
|
||||
func (obj *_Oauth2ClientTblMgr) WithAaa(Aaa string) Option {
|
||||
return optionFunc(func(o *options) { o.query["aaa"] = Aaa })
|
||||
}
|
||||
|
||||
// GetByOption 功能选项模式获取
|
||||
func (obj *_Oauth2ClientTblMgr) GetByOption(opts ...Option) (result Oauth2ClientTbl, err error) {
|
||||
options := options{
|
||||
query: make(map[string]interface{}, len(opts)),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(&options)
|
||||
}
|
||||
|
||||
err = obj.DB.Table(obj.GetTableName()).Where(options.query).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetByOptions 批量功能选项模式获取
|
||||
func (obj *_Oauth2ClientTblMgr) GetByOptions(opts ...Option) (results []*Oauth2ClientTbl, err error) {
|
||||
options := options{
|
||||
query: make(map[string]interface{}, len(opts)),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(&options)
|
||||
}
|
||||
|
||||
err = obj.DB.Table(obj.GetTableName()).Where(options.query).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////enume case ////////////////////////////////////////////
|
||||
|
||||
// GetFromID 通过id获取内容
|
||||
func (obj *_Oauth2ClientTblMgr) GetFromID(ID int) (result Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromID 批量唯一主键查找
|
||||
func (obj *_Oauth2ClientTblMgr) GetBatchFromID(IDs []int) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id IN (?)", IDs).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromAppKey 通过app_key获取内容
|
||||
func (obj *_Oauth2ClientTblMgr) GetFromAppKey(AppKey string) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_key = ?", AppKey).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromAppKey 批量唯一主键查找
|
||||
func (obj *_Oauth2ClientTblMgr) GetBatchFromAppKey(AppKeys []string) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_key IN (?)", AppKeys).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromAppSecret 通过app_secret获取内容
|
||||
func (obj *_Oauth2ClientTblMgr) GetFromAppSecret(AppSecret string) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_secret = ?", AppSecret).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromAppSecret 批量唯一主键查找
|
||||
func (obj *_Oauth2ClientTblMgr) GetBatchFromAppSecret(AppSecrets []string) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_secret IN (?)", AppSecrets).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromExpireTime 通过expire_time获取内容 超时时间
|
||||
func (obj *_Oauth2ClientTblMgr) GetFromExpireTime(ExpireTime time.Time) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("expire_time = ?", ExpireTime).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromExpireTime 批量唯一主键查找 超时时间
|
||||
func (obj *_Oauth2ClientTblMgr) GetBatchFromExpireTime(ExpireTimes []time.Time) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("expire_time IN (?)", ExpireTimes).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromStrictSign 通过strict_sign获取内容 是否强制验签:0:用户自定义,1:强制
|
||||
func (obj *_Oauth2ClientTblMgr) GetFromStrictSign(StrictSign int) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("strict_sign = ?", StrictSign).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromStrictSign 批量唯一主键查找 是否强制验签:0:用户自定义,1:强制
|
||||
func (obj *_Oauth2ClientTblMgr) GetBatchFromStrictSign(StrictSigns []int) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("strict_sign IN (?)", StrictSigns).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromStrictVerify 通过strict_verify获取内容 是否强制验证码:0:用户自定义,1:强制
|
||||
func (obj *_Oauth2ClientTblMgr) GetFromStrictVerify(StrictVerify int) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("strict_verify = ?", StrictVerify).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromStrictVerify 批量唯一主键查找 是否强制验证码:0:用户自定义,1:强制
|
||||
func (obj *_Oauth2ClientTblMgr) GetBatchFromStrictVerify(StrictVerifys []int) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("strict_verify IN (?)", StrictVerifys).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromTokenExpireTime 通过token_expire_time获取内容 token过期时间
|
||||
func (obj *_Oauth2ClientTblMgr) GetFromTokenExpireTime(TokenExpireTime int) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("token_expire_time = ?", TokenExpireTime).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromTokenExpireTime 批量唯一主键查找 token过期时间
|
||||
func (obj *_Oauth2ClientTblMgr) GetBatchFromTokenExpireTime(TokenExpireTimes []int) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("token_expire_time IN (?)", TokenExpireTimes).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromAaa 通过aaa获取内容
|
||||
func (obj *_Oauth2ClientTblMgr) GetFromAaa(Aaa string) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("aaa = ?", Aaa).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromAaa 批量唯一主键查找
|
||||
func (obj *_Oauth2ClientTblMgr) GetBatchFromAaa(Aaas []string) (results []*Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("aaa IN (?)", Aaas).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////primary index case ////////////////////////////////////////////
|
||||
|
||||
// FetchByPrimaryKey primay or index 获取唯一内容
|
||||
func (obj *_Oauth2ClientTblMgr) FetchByPrimaryKey(ID int) (result Oauth2ClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
@@ -1,220 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
type _Oauth2RefreshTokenMgr struct {
|
||||
*_BaseMgr
|
||||
}
|
||||
|
||||
// Oauth2RefreshTokenMgr open func
|
||||
func Oauth2RefreshTokenMgr(db *gorm.DB) *_Oauth2RefreshTokenMgr {
|
||||
if db == nil {
|
||||
panic(fmt.Errorf("Oauth2RefreshTokenMgr need init by db"))
|
||||
}
|
||||
return &_Oauth2RefreshTokenMgr{_BaseMgr: &_BaseMgr{DB: db, isRelated: gloabIsRelated}}
|
||||
}
|
||||
|
||||
// GetTableName get sql table name.获取数据库名字
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetTableName() string {
|
||||
return "oauth2_refresh_token"
|
||||
}
|
||||
|
||||
// Get 获取
|
||||
func (obj *_Oauth2RefreshTokenMgr) Get() (result Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Gets 获取批量结果
|
||||
func (obj *_Oauth2RefreshTokenMgr) Gets() (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////option case ////////////////////////////////////////////
|
||||
|
||||
// WithID id获取
|
||||
func (obj *_Oauth2RefreshTokenMgr) WithID(ID int) Option {
|
||||
return optionFunc(func(o *options) { o.query["id"] = ID })
|
||||
}
|
||||
|
||||
// WithRefreshToken refresh_token获取
|
||||
func (obj *_Oauth2RefreshTokenMgr) WithRefreshToken(RefreshToken string) Option {
|
||||
return optionFunc(func(o *options) { o.query["refresh_token"] = RefreshToken })
|
||||
}
|
||||
|
||||
// WithTokenType token_type获取
|
||||
func (obj *_Oauth2RefreshTokenMgr) WithTokenType(TokenType string) Option {
|
||||
return optionFunc(func(o *options) { o.query["token_type"] = TokenType })
|
||||
}
|
||||
|
||||
// WithAppKey app_key获取
|
||||
func (obj *_Oauth2RefreshTokenMgr) WithAppKey(AppKey string) Option {
|
||||
return optionFunc(func(o *options) { o.query["app_key"] = AppKey })
|
||||
}
|
||||
|
||||
// WithUsername username获取
|
||||
func (obj *_Oauth2RefreshTokenMgr) WithUsername(Username string) Option {
|
||||
return optionFunc(func(o *options) { o.query["username"] = Username })
|
||||
}
|
||||
|
||||
// WithExpires expires获取
|
||||
func (obj *_Oauth2RefreshTokenMgr) WithExpires(Expires time.Time) Option {
|
||||
return optionFunc(func(o *options) { o.query["expires"] = Expires })
|
||||
}
|
||||
|
||||
// WithTokenExpireTime token_expire_time获取
|
||||
func (obj *_Oauth2RefreshTokenMgr) WithTokenExpireTime(TokenExpireTime int) Option {
|
||||
return optionFunc(func(o *options) { o.query["token_expire_time"] = TokenExpireTime })
|
||||
}
|
||||
|
||||
// GetByOption 功能选项模式获取
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetByOption(opts ...Option) (result Oauth2RefreshToken, err error) {
|
||||
options := options{
|
||||
query: make(map[string]interface{}, len(opts)),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(&options)
|
||||
}
|
||||
|
||||
err = obj.DB.Table(obj.GetTableName()).Where(options.query).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetByOptions 批量功能选项模式获取
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetByOptions(opts ...Option) (results []*Oauth2RefreshToken, err error) {
|
||||
options := options{
|
||||
query: make(map[string]interface{}, len(opts)),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(&options)
|
||||
}
|
||||
|
||||
err = obj.DB.Table(obj.GetTableName()).Where(options.query).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////enume case ////////////////////////////////////////////
|
||||
|
||||
// GetFromID 通过id获取内容
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetFromID(ID int) (result Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromID 批量唯一主键查找
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetBatchFromID(IDs []int) (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id IN (?)", IDs).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromRefreshToken 通过refresh_token获取内容
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetFromRefreshToken(RefreshToken string) (result Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("refresh_token = ?", RefreshToken).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromRefreshToken 批量唯一主键查找
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetBatchFromRefreshToken(RefreshTokens []string) (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("refresh_token IN (?)", RefreshTokens).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromTokenType 通过token_type获取内容
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetFromTokenType(TokenType string) (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("token_type = ?", TokenType).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromTokenType 批量唯一主键查找
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetBatchFromTokenType(TokenTypes []string) (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("token_type IN (?)", TokenTypes).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromAppKey 通过app_key获取内容
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetFromAppKey(AppKey string) (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_key = ?", AppKey).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromAppKey 批量唯一主键查找
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetBatchFromAppKey(AppKeys []string) (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_key IN (?)", AppKeys).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromUsername 通过username获取内容
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetFromUsername(Username string) (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("username = ?", Username).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromUsername 批量唯一主键查找
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetBatchFromUsername(Usernames []string) (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("username IN (?)", Usernames).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromExpires 通过expires获取内容
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetFromExpires(Expires time.Time) (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("expires = ?", Expires).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromExpires 批量唯一主键查找
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetBatchFromExpires(Expiress []time.Time) (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("expires IN (?)", Expiress).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromTokenExpireTime 通过token_expire_time获取内容
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetFromTokenExpireTime(TokenExpireTime int) (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("token_expire_time = ?", TokenExpireTime).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromTokenExpireTime 批量唯一主键查找
|
||||
func (obj *_Oauth2RefreshTokenMgr) GetBatchFromTokenExpireTime(TokenExpireTimes []int) (results []*Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("token_expire_time IN (?)", TokenExpireTimes).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////primary index case ////////////////////////////////////////////
|
||||
|
||||
// FetchByPrimaryKey primay or index 获取唯一内容
|
||||
func (obj *_Oauth2RefreshTokenMgr) FetchByPrimaryKey(ID int) (result Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FetchByUnique primay or index 获取唯一内容
|
||||
func (obj *_Oauth2RefreshTokenMgr) FetchByUnique(RefreshToken string) (result Oauth2RefreshToken, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("refresh_token = ?", RefreshToken).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
@@ -1,213 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
type _SignClientTblMgr struct {
|
||||
*_BaseMgr
|
||||
}
|
||||
|
||||
// SignClientTblMgr open func
|
||||
func SignClientTblMgr(db *gorm.DB) *_SignClientTblMgr {
|
||||
if db == nil {
|
||||
panic(fmt.Errorf("SignClientTblMgr need init by db"))
|
||||
}
|
||||
return &_SignClientTblMgr{_BaseMgr: &_BaseMgr{DB: db, isRelated: gloabIsRelated}}
|
||||
}
|
||||
|
||||
// GetTableName get sql table name.获取数据库名字
|
||||
func (obj *_SignClientTblMgr) GetTableName() string {
|
||||
return "sign_client_tbl"
|
||||
}
|
||||
|
||||
// Get 获取
|
||||
func (obj *_SignClientTblMgr) Get() (result SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Gets 获取批量结果
|
||||
func (obj *_SignClientTblMgr) Gets() (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////option case ////////////////////////////////////////////
|
||||
|
||||
// WithID id获取
|
||||
func (obj *_SignClientTblMgr) WithID(ID int) Option {
|
||||
return optionFunc(func(o *options) { o.query["id"] = ID })
|
||||
}
|
||||
|
||||
// WithAppKey app_key获取
|
||||
func (obj *_SignClientTblMgr) WithAppKey(AppKey string) Option {
|
||||
return optionFunc(func(o *options) { o.query["app_key"] = AppKey })
|
||||
}
|
||||
|
||||
// WithAppSecret app_secret获取
|
||||
func (obj *_SignClientTblMgr) WithAppSecret(AppSecret string) Option {
|
||||
return optionFunc(func(o *options) { o.query["app_secret"] = AppSecret })
|
||||
}
|
||||
|
||||
// WithExpireTime expire_time获取 超时时间
|
||||
func (obj *_SignClientTblMgr) WithExpireTime(ExpireTime time.Time) Option {
|
||||
return optionFunc(func(o *options) { o.query["expire_time"] = ExpireTime })
|
||||
}
|
||||
|
||||
// WithStrictSign strict_sign获取 是否强制验签:0:用户自定义,1:强制
|
||||
func (obj *_SignClientTblMgr) WithStrictSign(StrictSign int) Option {
|
||||
return optionFunc(func(o *options) { o.query["strict_sign"] = StrictSign })
|
||||
}
|
||||
|
||||
// WithStrictVerify strict_verify获取 是否强制验证码:0:用户自定义,1:强制
|
||||
func (obj *_SignClientTblMgr) WithStrictVerify(StrictVerify int) Option {
|
||||
return optionFunc(func(o *options) { o.query["strict_verify"] = StrictVerify })
|
||||
}
|
||||
|
||||
// WithTokenExpireTime token_expire_time获取 token过期时间
|
||||
func (obj *_SignClientTblMgr) WithTokenExpireTime(TokenExpireTime int) Option {
|
||||
return optionFunc(func(o *options) { o.query["token_expire_time"] = TokenExpireTime })
|
||||
}
|
||||
|
||||
// GetByOption 功能选项模式获取
|
||||
func (obj *_SignClientTblMgr) GetByOption(opts ...Option) (result SignClientTbl, err error) {
|
||||
options := options{
|
||||
query: make(map[string]interface{}, len(opts)),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(&options)
|
||||
}
|
||||
|
||||
err = obj.DB.Table(obj.GetTableName()).Where(options.query).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetByOptions 批量功能选项模式获取
|
||||
func (obj *_SignClientTblMgr) GetByOptions(opts ...Option) (results []*SignClientTbl, err error) {
|
||||
options := options{
|
||||
query: make(map[string]interface{}, len(opts)),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(&options)
|
||||
}
|
||||
|
||||
err = obj.DB.Table(obj.GetTableName()).Where(options.query).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////enume case ////////////////////////////////////////////
|
||||
|
||||
// GetFromID 通过id获取内容
|
||||
func (obj *_SignClientTblMgr) GetFromID(ID int) (result SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromID 批量唯一主键查找
|
||||
func (obj *_SignClientTblMgr) GetBatchFromID(IDs []int) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id IN (?)", IDs).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromAppKey 通过app_key获取内容
|
||||
func (obj *_SignClientTblMgr) GetFromAppKey(AppKey string) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_key = ?", AppKey).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromAppKey 批量唯一主键查找
|
||||
func (obj *_SignClientTblMgr) GetBatchFromAppKey(AppKeys []string) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_key IN (?)", AppKeys).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromAppSecret 通过app_secret获取内容
|
||||
func (obj *_SignClientTblMgr) GetFromAppSecret(AppSecret string) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_secret = ?", AppSecret).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromAppSecret 批量唯一主键查找
|
||||
func (obj *_SignClientTblMgr) GetBatchFromAppSecret(AppSecrets []string) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_secret IN (?)", AppSecrets).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromExpireTime 通过expire_time获取内容 超时时间
|
||||
func (obj *_SignClientTblMgr) GetFromExpireTime(ExpireTime time.Time) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("expire_time = ?", ExpireTime).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromExpireTime 批量唯一主键查找 超时时间
|
||||
func (obj *_SignClientTblMgr) GetBatchFromExpireTime(ExpireTimes []time.Time) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("expire_time IN (?)", ExpireTimes).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromStrictSign 通过strict_sign获取内容 是否强制验签:0:用户自定义,1:强制
|
||||
func (obj *_SignClientTblMgr) GetFromStrictSign(StrictSign int) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("strict_sign = ?", StrictSign).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromStrictSign 批量唯一主键查找 是否强制验签:0:用户自定义,1:强制
|
||||
func (obj *_SignClientTblMgr) GetBatchFromStrictSign(StrictSigns []int) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("strict_sign IN (?)", StrictSigns).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromStrictVerify 通过strict_verify获取内容 是否强制验证码:0:用户自定义,1:强制
|
||||
func (obj *_SignClientTblMgr) GetFromStrictVerify(StrictVerify int) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("strict_verify = ?", StrictVerify).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromStrictVerify 批量唯一主键查找 是否强制验证码:0:用户自定义,1:强制
|
||||
func (obj *_SignClientTblMgr) GetBatchFromStrictVerify(StrictVerifys []int) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("strict_verify IN (?)", StrictVerifys).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromTokenExpireTime 通过token_expire_time获取内容 token过期时间
|
||||
func (obj *_SignClientTblMgr) GetFromTokenExpireTime(TokenExpireTime int) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("token_expire_time = ?", TokenExpireTime).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromTokenExpireTime 批量唯一主键查找 token过期时间
|
||||
func (obj *_SignClientTblMgr) GetBatchFromTokenExpireTime(TokenExpireTimes []int) (results []*SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("token_expire_time IN (?)", TokenExpireTimes).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////primary index case ////////////////////////////////////////////
|
||||
|
||||
// FetchByPrimaryKey primay or index 获取唯一内容
|
||||
func (obj *_SignClientTblMgr) FetchByPrimaryKey(ID int) (result SignClientTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
@@ -1,591 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
type _UserAccountTblMgr struct {
|
||||
*_BaseMgr
|
||||
}
|
||||
|
||||
// UserAccountTblMgr open func
|
||||
func UserAccountTblMgr(db *gorm.DB) *_UserAccountTblMgr {
|
||||
if db == nil {
|
||||
panic(fmt.Errorf("UserAccountTblMgr need init by db"))
|
||||
}
|
||||
return &_UserAccountTblMgr{_BaseMgr: &_BaseMgr{DB: db, isRelated: gloabIsRelated}}
|
||||
}
|
||||
|
||||
// GetTableName get sql table name.获取数据库名字
|
||||
func (obj *_UserAccountTblMgr) GetTableName() string {
|
||||
return "user_account_tbl"
|
||||
}
|
||||
|
||||
// Get 获取
|
||||
func (obj *_UserAccountTblMgr) Get() (result UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Find(&result).Error
|
||||
if err == nil && obj.isRelated {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", result.UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result.UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Gets 获取批量结果
|
||||
func (obj *_UserAccountTblMgr) Gets() (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////option case ////////////////////////////////////////////
|
||||
|
||||
// WithID id获取
|
||||
func (obj *_UserAccountTblMgr) WithID(ID int) Option {
|
||||
return optionFunc(func(o *options) { o.query["id"] = ID })
|
||||
}
|
||||
|
||||
// WithAccount account获取
|
||||
func (obj *_UserAccountTblMgr) WithAccount(Account string) Option {
|
||||
return optionFunc(func(o *options) { o.query["account"] = Account })
|
||||
}
|
||||
|
||||
// WithPassword password获取
|
||||
func (obj *_UserAccountTblMgr) WithPassword(Password string) Option {
|
||||
return optionFunc(func(o *options) { o.query["password"] = Password })
|
||||
}
|
||||
|
||||
// WithAccountType account_type获取 帐号类型:0手机号,1邮件
|
||||
func (obj *_UserAccountTblMgr) WithAccountType(AccountType int) Option {
|
||||
return optionFunc(func(o *options) { o.query["account_type"] = AccountType })
|
||||
}
|
||||
|
||||
// WithAppKey app_key获取 authbucket_oauth2_client表的id
|
||||
func (obj *_UserAccountTblMgr) WithAppKey(AppKey string) Option {
|
||||
return optionFunc(func(o *options) { o.query["app_key"] = AppKey })
|
||||
}
|
||||
|
||||
// WithUserInfoID user_info_id获取
|
||||
func (obj *_UserAccountTblMgr) WithUserInfoID(UserInfoID int) Option {
|
||||
return optionFunc(func(o *options) { o.query["user_info_id"] = UserInfoID })
|
||||
}
|
||||
|
||||
// WithRegTime reg_time获取
|
||||
func (obj *_UserAccountTblMgr) WithRegTime(RegTime time.Time) Option {
|
||||
return optionFunc(func(o *options) { o.query["reg_time"] = RegTime })
|
||||
}
|
||||
|
||||
// WithRegIP reg_ip获取
|
||||
func (obj *_UserAccountTblMgr) WithRegIP(RegIP string) Option {
|
||||
return optionFunc(func(o *options) { o.query["reg_ip"] = RegIP })
|
||||
}
|
||||
|
||||
// WithBundleID bundle_id获取
|
||||
func (obj *_UserAccountTblMgr) WithBundleID(BundleID string) Option {
|
||||
return optionFunc(func(o *options) { o.query["bundle_id"] = BundleID })
|
||||
}
|
||||
|
||||
// WithDescrib describ获取
|
||||
func (obj *_UserAccountTblMgr) WithDescrib(Describ string) Option {
|
||||
return optionFunc(func(o *options) { o.query["describ"] = Describ })
|
||||
}
|
||||
|
||||
// GetByOption 功能选项模式获取
|
||||
func (obj *_UserAccountTblMgr) GetByOption(opts ...Option) (result UserAccountTbl, err error) {
|
||||
options := options{
|
||||
query: make(map[string]interface{}, len(opts)),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(&options)
|
||||
}
|
||||
|
||||
err = obj.DB.Table(obj.GetTableName()).Where(options.query).Find(&result).Error
|
||||
if err == nil && obj.isRelated {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", result.UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result.UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetByOptions 批量功能选项模式获取
|
||||
func (obj *_UserAccountTblMgr) GetByOptions(opts ...Option) (results []*UserAccountTbl, err error) {
|
||||
options := options{
|
||||
query: make(map[string]interface{}, len(opts)),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(&options)
|
||||
}
|
||||
|
||||
err = obj.DB.Table(obj.GetTableName()).Where(options.query).Find(&results).Error
|
||||
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////enume case ////////////////////////////////////////////
|
||||
|
||||
// GetFromID 通过id获取内容
|
||||
func (obj *_UserAccountTblMgr) GetFromID(ID int) (result UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
if err == nil && obj.isRelated {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", result.UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result.UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromID 批量唯一主键查找
|
||||
func (obj *_UserAccountTblMgr) GetBatchFromID(IDs []int) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id IN (?)", IDs).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromAccount 通过account获取内容
|
||||
func (obj *_UserAccountTblMgr) GetFromAccount(Account string) (result UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("account = ?", Account).Find(&result).Error
|
||||
if err == nil && obj.isRelated {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", result.UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result.UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromAccount 批量唯一主键查找
|
||||
func (obj *_UserAccountTblMgr) GetBatchFromAccount(Accounts []string) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("account IN (?)", Accounts).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromPassword 通过password获取内容
|
||||
func (obj *_UserAccountTblMgr) GetFromPassword(Password string) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("password = ?", Password).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromPassword 批量唯一主键查找
|
||||
func (obj *_UserAccountTblMgr) GetBatchFromPassword(Passwords []string) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("password IN (?)", Passwords).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromAccountType 通过account_type获取内容 帐号类型:0手机号,1邮件
|
||||
func (obj *_UserAccountTblMgr) GetFromAccountType(AccountType int) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("account_type = ?", AccountType).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromAccountType 批量唯一主键查找 帐号类型:0手机号,1邮件
|
||||
func (obj *_UserAccountTblMgr) GetBatchFromAccountType(AccountTypes []int) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("account_type IN (?)", AccountTypes).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromAppKey 通过app_key获取内容 authbucket_oauth2_client表的id
|
||||
func (obj *_UserAccountTblMgr) GetFromAppKey(AppKey string) (result UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_key = ?", AppKey).Find(&result).Error
|
||||
if err == nil && obj.isRelated {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", result.UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result.UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromAppKey 批量唯一主键查找 authbucket_oauth2_client表的id
|
||||
func (obj *_UserAccountTblMgr) GetBatchFromAppKey(AppKeys []string) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_key IN (?)", AppKeys).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromUserInfoID 通过user_info_id获取内容
|
||||
func (obj *_UserAccountTblMgr) GetFromUserInfoID(UserInfoID int) (result UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("user_info_id = ?", UserInfoID).Find(&result).Error
|
||||
if err == nil && obj.isRelated {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", result.UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result.UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromUserInfoID 批量唯一主键查找
|
||||
func (obj *_UserAccountTblMgr) GetBatchFromUserInfoID(UserInfoIDs []int) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("user_info_id IN (?)", UserInfoIDs).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromRegTime 通过reg_time获取内容
|
||||
func (obj *_UserAccountTblMgr) GetFromRegTime(RegTime time.Time) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("reg_time = ?", RegTime).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromRegTime 批量唯一主键查找
|
||||
func (obj *_UserAccountTblMgr) GetBatchFromRegTime(RegTimes []time.Time) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("reg_time IN (?)", RegTimes).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromRegIP 通过reg_ip获取内容
|
||||
func (obj *_UserAccountTblMgr) GetFromRegIP(RegIP string) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("reg_ip = ?", RegIP).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromRegIP 批量唯一主键查找
|
||||
func (obj *_UserAccountTblMgr) GetBatchFromRegIP(RegIPs []string) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("reg_ip IN (?)", RegIPs).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromBundleID 通过bundle_id获取内容
|
||||
func (obj *_UserAccountTblMgr) GetFromBundleID(BundleID string) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("bundle_id = ?", BundleID).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromBundleID 批量唯一主键查找
|
||||
func (obj *_UserAccountTblMgr) GetBatchFromBundleID(BundleIDs []string) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("bundle_id IN (?)", BundleIDs).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromDescrib 通过describ获取内容
|
||||
func (obj *_UserAccountTblMgr) GetFromDescrib(Describ string) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("describ = ?", Describ).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromDescrib 批量唯一主键查找
|
||||
func (obj *_UserAccountTblMgr) GetBatchFromDescrib(Describs []string) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("describ IN (?)", Describs).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////primary index case ////////////////////////////////////////////
|
||||
|
||||
// FetchByPrimaryKey primay or index 获取唯一内容
|
||||
func (obj *_UserAccountTblMgr) FetchByPrimaryKey(ID int) (result UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
if err == nil && obj.isRelated {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", result.UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result.UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FetchByUnique primay or index 获取唯一内容
|
||||
func (obj *_UserAccountTblMgr) FetchByUnique(Account string) (result UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("account = ?", Account).Find(&result).Error
|
||||
if err == nil && obj.isRelated {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", result.UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result.UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FetchByUNIQ5696AD037D3656A4UniqueIndex primay or index 获取唯一内容
|
||||
func (obj *_UserAccountTblMgr) FetchByUNIQ5696AD037D3656A4UniqueIndex(AppKey string, UserInfoID int) (result UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("app_key = ? AND user_info_id = ?", AppKey, UserInfoID).Find(&result).Error
|
||||
if err == nil && obj.isRelated {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", result.UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result.UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FetchByIndex 获取多个内容
|
||||
func (obj *_UserAccountTblMgr) FetchByIndex(UserInfoID int) (results []*UserAccountTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("user_info_id = ?", UserInfoID).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
{
|
||||
var info UserInfoTbl // 用户信息
|
||||
err = obj.DB.New().Table("user_info_tbl").Where("id = ?", results[i].UserInfoID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
results[i].UserInfoTbl = info
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
@@ -1,194 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
type _UserInfoTblMgr struct {
|
||||
*_BaseMgr
|
||||
}
|
||||
|
||||
// UserInfoTblMgr open func
|
||||
func UserInfoTblMgr(db *gorm.DB) *_UserInfoTblMgr {
|
||||
if db == nil {
|
||||
panic(fmt.Errorf("UserInfoTblMgr need init by db"))
|
||||
}
|
||||
return &_UserInfoTblMgr{_BaseMgr: &_BaseMgr{DB: db, isRelated: gloabIsRelated}}
|
||||
}
|
||||
|
||||
// GetTableName get sql table name.获取数据库名字
|
||||
func (obj *_UserInfoTblMgr) GetTableName() string {
|
||||
return "user_info_tbl"
|
||||
}
|
||||
|
||||
// Get 获取
|
||||
func (obj *_UserInfoTblMgr) Get() (result UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Gets 获取批量结果
|
||||
func (obj *_UserInfoTblMgr) Gets() (results []*UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////option case ////////////////////////////////////////////
|
||||
|
||||
// WithID id获取 Primary key
|
||||
func (obj *_UserInfoTblMgr) WithID(ID int64) Option {
|
||||
return optionFunc(func(o *options) { o.query["id"] = ID })
|
||||
}
|
||||
|
||||
// WithCreatedAt created_at获取 created time
|
||||
func (obj *_UserInfoTblMgr) WithCreatedAt(CreatedAt time.Time) Option {
|
||||
return optionFunc(func(o *options) { o.query["created_at"] = CreatedAt })
|
||||
}
|
||||
|
||||
// WithUpdatedAt updated_at获取 updated at
|
||||
func (obj *_UserInfoTblMgr) WithUpdatedAt(UpdatedAt time.Time) Option {
|
||||
return optionFunc(func(o *options) { o.query["updated_at"] = UpdatedAt })
|
||||
}
|
||||
|
||||
// WithDeletedAt deleted_at获取 deleted time
|
||||
func (obj *_UserInfoTblMgr) WithDeletedAt(DeletedAt time.Time) Option {
|
||||
return optionFunc(func(o *options) { o.query["deleted_at"] = DeletedAt })
|
||||
}
|
||||
|
||||
// WithNickname nickname获取
|
||||
func (obj *_UserInfoTblMgr) WithNickname(Nickname string) Option {
|
||||
return optionFunc(func(o *options) { o.query["nickname"] = Nickname })
|
||||
}
|
||||
|
||||
// WithHeadurl headurl获取
|
||||
func (obj *_UserInfoTblMgr) WithHeadurl(Headurl string) Option {
|
||||
return optionFunc(func(o *options) { o.query["headurl"] = Headurl })
|
||||
}
|
||||
|
||||
// GetByOption 功能选项模式获取
|
||||
func (obj *_UserInfoTblMgr) GetByOption(opts ...Option) (result UserInfoTbl, err error) {
|
||||
options := options{
|
||||
query: make(map[string]interface{}, len(opts)),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(&options)
|
||||
}
|
||||
|
||||
err = obj.DB.Table(obj.GetTableName()).Where(options.query).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetByOptions 批量功能选项模式获取
|
||||
func (obj *_UserInfoTblMgr) GetByOptions(opts ...Option) (results []*UserInfoTbl, err error) {
|
||||
options := options{
|
||||
query: make(map[string]interface{}, len(opts)),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(&options)
|
||||
}
|
||||
|
||||
err = obj.DB.Table(obj.GetTableName()).Where(options.query).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////enume case ////////////////////////////////////////////
|
||||
|
||||
// GetFromID 通过id获取内容 Primary key
|
||||
func (obj *_UserInfoTblMgr) GetFromID(ID int64) (result UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromID 批量唯一主键查找 Primary key
|
||||
func (obj *_UserInfoTblMgr) GetBatchFromID(IDs []int64) (results []*UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id IN (?)", IDs).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromCreatedAt 通过created_at获取内容 created time
|
||||
func (obj *_UserInfoTblMgr) GetFromCreatedAt(CreatedAt time.Time) (result UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("created_at = ?", CreatedAt).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromCreatedAt 批量唯一主键查找 created time
|
||||
func (obj *_UserInfoTblMgr) GetBatchFromCreatedAt(CreatedAts []time.Time) (results []*UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("created_at IN (?)", CreatedAts).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromUpdatedAt 通过updated_at获取内容 updated at
|
||||
func (obj *_UserInfoTblMgr) GetFromUpdatedAt(UpdatedAt time.Time) (result UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("updated_at = ?", UpdatedAt).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromUpdatedAt 批量唯一主键查找 updated at
|
||||
func (obj *_UserInfoTblMgr) GetBatchFromUpdatedAt(UpdatedAts []time.Time) (results []*UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("updated_at IN (?)", UpdatedAts).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromDeletedAt 通过deleted_at获取内容 deleted time
|
||||
func (obj *_UserInfoTblMgr) GetFromDeletedAt(DeletedAt time.Time) (result UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("deleted_at = ?", DeletedAt).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromDeletedAt 批量唯一主键查找 deleted time
|
||||
func (obj *_UserInfoTblMgr) GetBatchFromDeletedAt(DeletedAts []time.Time) (results []*UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("deleted_at IN (?)", DeletedAts).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromNickname 通过nickname获取内容
|
||||
func (obj *_UserInfoTblMgr) GetFromNickname(Nickname string) (results []*UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("nickname = ?", Nickname).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromNickname 批量唯一主键查找
|
||||
func (obj *_UserInfoTblMgr) GetBatchFromNickname(Nicknames []string) (results []*UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("nickname IN (?)", Nicknames).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFromHeadurl 通过headurl获取内容
|
||||
func (obj *_UserInfoTblMgr) GetFromHeadurl(Headurl string) (results []*UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("headurl = ?", Headurl).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetBatchFromHeadurl 批量唯一主键查找
|
||||
func (obj *_UserInfoTblMgr) GetBatchFromHeadurl(Headurls []string) (results []*UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("headurl IN (?)", Headurls).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////primary index case ////////////////////////////////////////////
|
||||
|
||||
// FetchByPrimaryKey primay or index 获取唯一内容
|
||||
func (obj *_UserInfoTblMgr) FetchByPrimaryKey(ID int64) (result UserInfoTbl, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
@@ -1,73 +1 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
// UserInfoTbl 用户信息
|
||||
type UserInfoTbl struct {
|
||||
gorm.Model
|
||||
Nickname string
|
||||
Headurl string
|
||||
}
|
||||
|
||||
// Oauth2AccessToken token认证
|
||||
type Oauth2AccessToken struct {
|
||||
ID int `gorm:"primary_key"`
|
||||
AccessToken string `gorm:"unique"`
|
||||
TokenType string
|
||||
AppKey string // key
|
||||
Username string // 用户名
|
||||
Expires time.Time // 过期时间
|
||||
}
|
||||
|
||||
// Oauth2ClientTbl client key 信息
|
||||
type Oauth2ClientTbl struct {
|
||||
ID int `gorm:"primary_key"`
|
||||
AppKey string
|
||||
AppSecret string
|
||||
ExpireTime time.Time // 超时时间
|
||||
StrictSign int // 是否强制验签:0:用户自定义,1:强制
|
||||
StrictVerify int // 是否强制验证码:0:用户自定义,1:强制
|
||||
TokenExpireTime int // token过期时间
|
||||
Aaa string
|
||||
}
|
||||
|
||||
// Oauth2RefreshToken 刷新token
|
||||
type Oauth2RefreshToken struct {
|
||||
ID int `gorm:"primary_key"`
|
||||
RefreshToken string `gorm:"unique"`
|
||||
TokenType string
|
||||
AppKey string
|
||||
Username string
|
||||
Expires time.Time
|
||||
TokenExpireTime int
|
||||
}
|
||||
|
||||
// SignClientTbl client secret info
|
||||
type SignClientTbl struct {
|
||||
ID int `gorm:"primary_key"`
|
||||
AppKey string
|
||||
AppSecret string
|
||||
ExpireTime time.Time // 超时时间
|
||||
StrictSign int // 是否强制验签:0:用户自定义,1:强制
|
||||
StrictVerify int // 是否强制验证码:0:用户自定义,1:强制
|
||||
TokenExpireTime int // token过期时间
|
||||
}
|
||||
|
||||
// UserAccountTbl 用户信息
|
||||
type UserAccountTbl struct {
|
||||
ID int `gorm:"primary_key"`
|
||||
Account string `gorm:"unique"`
|
||||
Password string
|
||||
AccountType int // 帐号类型:0手机号,1邮件
|
||||
AppKey string `gorm:"unique_index:UNIQ_5696AD037D3656A4"` // authbucket_oauth2_client表的id
|
||||
UserInfoID int `gorm:"unique_index:UNIQ_5696AD037D3656A4;index"`
|
||||
UserInfoTbl UserInfoTbl `gorm:"association_foreignkey:user_info_id;foreignkey:id"` // 用户信息
|
||||
RegTime time.Time
|
||||
RegIP string
|
||||
BundleID string
|
||||
Describ string
|
||||
}
|
||||
|
37
main.go
37
main.go
@@ -4,16 +4,11 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/xxjwxc/public/tools"
|
||||
|
||||
"gmsec/internal/core"
|
||||
"gmsec/internal/model"
|
||||
_ "gmsec/routers" // debug模式需要添加[mod]/routers 注册注解路由
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/xxjwxc/ginrpc"
|
||||
"github.com/xxjwxc/ginrpc/api"
|
||||
"github.com/xxjwxc/gowp/workpool"
|
||||
)
|
||||
|
||||
// ReqTest demo struct
|
||||
@@ -60,23 +55,23 @@ func TestFun6(c *gin.Context, req ReqTest) (*ReqTest, error) {
|
||||
func main() {
|
||||
|
||||
// debug test
|
||||
wp := workpool.New(1000) // Set the maximum number of threads
|
||||
for i := 0; i < 2000; i++ { // Open 20 requests
|
||||
wp.Do(func() error {
|
||||
orm := core.Dao.GetDBr()
|
||||
var ut []model.UserInfoTbl
|
||||
err := orm.Table("user_info_tbl").Find(&ut).Error
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return err
|
||||
}
|
||||
fmt.Println(tools.GetJSONStr(ut, true))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
// wp := workpool.New(1000) // Set the maximum number of threads
|
||||
// for i := 0; i < 2000; i++ { // Open 20 requests
|
||||
// wp.Do(func() error {
|
||||
// orm := core.Dao.GetDBr()
|
||||
// var ut []model.UserInfoTbl
|
||||
// err := orm.Table("user_info_tbl").Find(&ut).Error
|
||||
// if err != nil {
|
||||
// fmt.Println(err.Error())
|
||||
// return err
|
||||
// }
|
||||
// fmt.Println(tools.GetJSONStr(ut, true))
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
|
||||
wp.Wait()
|
||||
fmt.Println("down")
|
||||
// wp.Wait()
|
||||
// fmt.Println("down")
|
||||
|
||||
// swagger
|
||||
// -----end --
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
ginrpc.SetVersion(1583423174)
|
||||
ginrpc.SetVersion(1583426190)
|
||||
ginrpc.AddGenOne("Hello.Hello", "/block", []string{"post", "get"})
|
||||
ginrpc.AddGenOne("Hello.Hello2", "hello.hello2", []string{"post"})
|
||||
ginrpc.AddGenOne("Hello.Hello3", "hello.hello3", []string{"post"})
|
||||
|
Reference in New Issue
Block a user