Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4371717c
authored
Jun 14, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Resolving conflicts caused by mixing multiple databases
parent
d26ae9aa
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
129 additions
and
88 deletions
+129
-88
common/database.go
+7
-0
model/ability.go
+6
-6
model/channel.go
+10
-10
model/log.go
+19
-9
model/main.go
+82
-58
model/token.go
+2
-2
model/user.go
+3
-3
No files found.
common/database.go
View file @
4371717c
package
common
const
(
DatabaseTypeMySQL
=
"mysql"
DatabaseTypeSQLite
=
"sqlite"
DatabaseTypePostgreSQL
=
"postgres"
)
var
UsingSQLite
=
false
var
UsingPostgreSQL
=
false
var
LogSqlType
=
DatabaseTypeSQLite
// Default to SQLite for logging SQL queries
var
UsingMySQL
=
false
var
UsingClickHouse
=
false
...
...
model/ability.go
View file @
4371717c
...
...
@@ -24,7 +24,7 @@ type Ability struct {
func
GetGroupModels
(
group
string
)
[]
string
{
var
models
[]
string
// Find distinct models
DB
.
Table
(
"abilities"
)
.
Where
(
g
roupCol
+
" = ? and enabled = ?"
,
group
,
true
)
.
Distinct
(
"model"
)
.
Pluck
(
"model"
,
&
models
)
DB
.
Table
(
"abilities"
)
.
Where
(
commonG
roupCol
+
" = ? and enabled = ?"
,
group
,
true
)
.
Distinct
(
"model"
)
.
Pluck
(
"model"
,
&
models
)
return
models
}
...
...
@@ -50,8 +50,8 @@ func getPriority(group string, model string, retry int) (int, error) {
var
priorities
[]
int
err
:=
DB
.
Model
(
&
Ability
{})
.
Select
(
"DISTINCT(priority)"
)
.
Where
(
g
roupCol
+
" = ? and model = ? and enabled = "
+
trueVal
,
group
,
model
)
.
Order
(
"priority DESC"
)
.
// 按优先级降序排序
Where
(
commonG
roupCol
+
" = ? and model = ? and enabled = "
+
trueVal
,
group
,
model
)
.
Order
(
"priority DESC"
)
.
// 按优先级降序排序
Pluck
(
"priority"
,
&
priorities
)
.
Error
// Pluck用于将查询的结果直接扫描到一个切片中
if
err
!=
nil
{
...
...
@@ -80,14 +80,14 @@ func getChannelQuery(group string, model string, retry int) *gorm.DB {
if
common
.
UsingPostgreSQL
{
trueVal
=
"true"
}
maxPrioritySubQuery
:=
DB
.
Model
(
&
Ability
{})
.
Select
(
"MAX(priority)"
)
.
Where
(
g
roupCol
+
" = ? and model = ? and enabled = "
+
trueVal
,
group
,
model
)
channelQuery
:=
DB
.
Where
(
g
roupCol
+
" = ? and model = ? and enabled = "
+
trueVal
+
" and priority = (?)"
,
group
,
model
,
maxPrioritySubQuery
)
maxPrioritySubQuery
:=
DB
.
Model
(
&
Ability
{})
.
Select
(
"MAX(priority)"
)
.
Where
(
commonG
roupCol
+
" = ? and model = ? and enabled = "
+
trueVal
,
group
,
model
)
channelQuery
:=
DB
.
Where
(
commonG
roupCol
+
" = ? and model = ? and enabled = "
+
trueVal
+
" and priority = (?)"
,
group
,
model
,
maxPrioritySubQuery
)
if
retry
!=
0
{
priority
,
err
:=
getPriority
(
group
,
model
,
retry
)
if
err
!=
nil
{
common
.
SysError
(
fmt
.
Sprintf
(
"Get priority failed: %s"
,
err
.
Error
()))
}
else
{
channelQuery
=
DB
.
Where
(
g
roupCol
+
" = ? and model = ? and enabled = "
+
trueVal
+
" and priority = ?"
,
group
,
model
,
priority
)
channelQuery
=
DB
.
Where
(
commonG
roupCol
+
" = ? and model = ? and enabled = "
+
trueVal
+
" and priority = ?"
,
group
,
model
,
priority
)
}
}
...
...
model/channel.go
View file @
4371717c
...
...
@@ -145,7 +145,7 @@ func SearchChannels(keyword string, group string, model string, idSort bool) ([]
}
// 构造基础查询
baseQuery
:=
DB
.
Model
(
&
Channel
{})
.
Omit
(
k
eyCol
)
baseQuery
:=
DB
.
Model
(
&
Channel
{})
.
Omit
(
commonK
eyCol
)
// 构造WHERE子句
var
whereClause
string
...
...
@@ -153,15 +153,15 @@ func SearchChannels(keyword string, group string, model string, idSort bool) ([]
if
group
!=
""
&&
group
!=
"null"
{
var
groupCondition
string
if
common
.
UsingMySQL
{
groupCondition
=
`CONCAT(',', `
+
g
roupCol
+
`, ',') LIKE ?`
groupCondition
=
`CONCAT(',', `
+
commonG
roupCol
+
`, ',') LIKE ?`
}
else
{
// sqlite, PostgreSQL
groupCondition
=
`(',' || `
+
g
roupCol
+
` || ',') LIKE ?`
groupCondition
=
`(',' || `
+
commonG
roupCol
+
` || ',') LIKE ?`
}
whereClause
=
"(id = ? OR name LIKE ? OR "
+
k
eyCol
+
" = ? OR "
+
baseURLCol
+
" LIKE ?) AND "
+
modelsCol
+
` LIKE ? AND `
+
groupCondition
whereClause
=
"(id = ? OR name LIKE ? OR "
+
commonK
eyCol
+
" = ? OR "
+
baseURLCol
+
" LIKE ?) AND "
+
modelsCol
+
` LIKE ? AND `
+
groupCondition
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
"%"
+
keyword
+
"%"
,
"%"
+
model
+
"%"
,
"%,"
+
group
+
",%"
)
}
else
{
whereClause
=
"(id = ? OR name LIKE ? OR "
+
k
eyCol
+
" = ? OR "
+
baseURLCol
+
" LIKE ?) AND "
+
modelsCol
+
" LIKE ?"
whereClause
=
"(id = ? OR name LIKE ? OR "
+
commonK
eyCol
+
" = ? OR "
+
baseURLCol
+
" LIKE ?) AND "
+
modelsCol
+
" LIKE ?"
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
"%"
+
keyword
+
"%"
,
"%"
+
model
+
"%"
)
}
...
...
@@ -478,7 +478,7 @@ func SearchTags(keyword string, group string, model string, idSort bool) ([]*str
}
// 构造基础查询
baseQuery
:=
DB
.
Model
(
&
Channel
{})
.
Omit
(
k
eyCol
)
baseQuery
:=
DB
.
Model
(
&
Channel
{})
.
Omit
(
commonK
eyCol
)
// 构造WHERE子句
var
whereClause
string
...
...
@@ -486,15 +486,15 @@ func SearchTags(keyword string, group string, model string, idSort bool) ([]*str
if
group
!=
""
&&
group
!=
"null"
{
var
groupCondition
string
if
common
.
UsingMySQL
{
groupCondition
=
`CONCAT(',', `
+
g
roupCol
+
`, ',') LIKE ?`
groupCondition
=
`CONCAT(',', `
+
commonG
roupCol
+
`, ',') LIKE ?`
}
else
{
// sqlite, PostgreSQL
groupCondition
=
`(',' || `
+
g
roupCol
+
` || ',') LIKE ?`
groupCondition
=
`(',' || `
+
commonG
roupCol
+
` || ',') LIKE ?`
}
whereClause
=
"(id = ? OR name LIKE ? OR "
+
k
eyCol
+
" = ? OR "
+
baseURLCol
+
" LIKE ?) AND "
+
modelsCol
+
` LIKE ? AND `
+
groupCondition
whereClause
=
"(id = ? OR name LIKE ? OR "
+
commonK
eyCol
+
" = ? OR "
+
baseURLCol
+
" LIKE ?) AND "
+
modelsCol
+
` LIKE ? AND `
+
groupCondition
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
"%"
+
keyword
+
"%"
,
"%"
+
model
+
"%"
,
"%,"
+
group
+
",%"
)
}
else
{
whereClause
=
"(id = ? OR name LIKE ? OR "
+
k
eyCol
+
" = ? OR "
+
baseURLCol
+
" LIKE ?) AND "
+
modelsCol
+
" LIKE ?"
whereClause
=
"(id = ? OR name LIKE ? OR "
+
commonK
eyCol
+
" = ? OR "
+
baseURLCol
+
" LIKE ?) AND "
+
modelsCol
+
" LIKE ?"
args
=
append
(
args
,
common
.
String2Int
(
keyword
),
"%"
+
keyword
+
"%"
,
keyword
,
"%"
+
keyword
+
"%"
,
"%"
+
model
+
"%"
)
}
...
...
model/log.go
View file @
4371717c
...
...
@@ -63,7 +63,7 @@ func formatUserLogs(logs []*Log) {
func
GetLogByKey
(
key
string
)
(
logs
[]
*
Log
,
err
error
)
{
if
os
.
Getenv
(
"LOG_SQL_DSN"
)
!=
""
{
var
tk
Token
if
err
=
DB
.
Model
(
&
Token
{})
.
Where
(
k
eyCol
+
"=?"
,
strings
.
TrimPrefix
(
key
,
"sk-"
))
.
First
(
&
tk
)
.
Error
;
err
!=
nil
{
if
err
=
DB
.
Model
(
&
Token
{})
.
Where
(
logK
eyCol
+
"=?"
,
strings
.
TrimPrefix
(
key
,
"sk-"
))
.
First
(
&
tk
)
.
Error
;
err
!=
nil
{
return
nil
,
err
}
err
=
LOG_DB
.
Model
(
&
Log
{})
.
Where
(
"token_id=?"
,
tk
.
Id
)
.
Find
(
&
logs
)
.
Error
...
...
@@ -122,8 +122,13 @@ func RecordErrorLog(c *gin.Context, userId int, channelId int, modelName string,
UseTime
:
useTimeSeconds
,
IsStream
:
isStream
,
Group
:
group
,
Ip
:
func
()
string
{
if
needRecordIp
{
return
c
.
ClientIP
()
};
return
""
}(),
Other
:
otherStr
,
Ip
:
func
()
string
{
if
needRecordIp
{
return
c
.
ClientIP
()
}
return
""
}(),
Other
:
otherStr
,
}
err
:=
LOG_DB
.
Create
(
log
)
.
Error
if
err
!=
nil
{
...
...
@@ -165,8 +170,13 @@ func RecordConsumeLog(c *gin.Context, userId int, channelId int, promptTokens in
UseTime
:
useTimeSeconds
,
IsStream
:
isStream
,
Group
:
group
,
Ip
:
func
()
string
{
if
needRecordIp
{
return
c
.
ClientIP
()
};
return
""
}(),
Other
:
otherStr
,
Ip
:
func
()
string
{
if
needRecordIp
{
return
c
.
ClientIP
()
}
return
""
}(),
Other
:
otherStr
,
}
err
:=
LOG_DB
.
Create
(
log
)
.
Error
if
err
!=
nil
{
...
...
@@ -206,7 +216,7 @@ func GetAllLogs(logType int, startTimestamp int64, endTimestamp int64, modelName
tx
=
tx
.
Where
(
"logs.channel_id = ?"
,
channel
)
}
if
group
!=
""
{
tx
=
tx
.
Where
(
"logs."
+
g
roupCol
+
" = ?"
,
group
)
tx
=
tx
.
Where
(
"logs."
+
logG
roupCol
+
" = ?"
,
group
)
}
err
=
tx
.
Model
(
&
Log
{})
.
Count
(
&
total
)
.
Error
if
err
!=
nil
{
...
...
@@ -264,7 +274,7 @@ func GetUserLogs(userId int, logType int, startTimestamp int64, endTimestamp int
tx
=
tx
.
Where
(
"logs.created_at <= ?"
,
endTimestamp
)
}
if
group
!=
""
{
tx
=
tx
.
Where
(
"logs."
+
g
roupCol
+
" = ?"
,
group
)
tx
=
tx
.
Where
(
"logs."
+
logG
roupCol
+
" = ?"
,
group
)
}
err
=
tx
.
Model
(
&
Log
{})
.
Count
(
&
total
)
.
Error
if
err
!=
nil
{
...
...
@@ -325,8 +335,8 @@ func SumUsedQuota(logType int, startTimestamp int64, endTimestamp int64, modelNa
rpmTpmQuery
=
rpmTpmQuery
.
Where
(
"channel_id = ?"
,
channel
)
}
if
group
!=
""
{
tx
=
tx
.
Where
(
g
roupCol
+
" = ?"
,
group
)
rpmTpmQuery
=
rpmTpmQuery
.
Where
(
g
roupCol
+
" = ?"
,
group
)
tx
=
tx
.
Where
(
logG
roupCol
+
" = ?"
,
group
)
rpmTpmQuery
=
rpmTpmQuery
.
Where
(
logG
roupCol
+
" = ?"
,
group
)
}
tx
=
tx
.
Where
(
"type = ?"
,
LogTypeConsume
)
...
...
model/main.go
View file @
4371717c
package
model
import
(
"fmt"
"log"
"one-api/common"
"one-api/constant"
...
...
@@ -15,18 +16,33 @@ import (
"gorm.io/gorm"
)
var
groupCol
string
var
keyCol
string
var
commonGroupCol
string
var
commonKeyCol
string
var
logKeyCol
string
var
logGroupCol
string
func
initCol
()
{
// init common column names
if
common
.
UsingPostgreSQL
{
groupCol
=
`"group"`
keyCol
=
`"key"`
commonGroupCol
=
`"group"`
commonKeyCol
=
`"key"`
}
else
{
groupCol
=
"`group`"
keyCol
=
"`key`"
commonGroupCol
=
"`group`"
commonKeyCol
=
"`key`"
}
if
DB
!=
LOG_DB
{
switch
common
.
LogSqlType
{
case
common
.
DatabaseTypePostgreSQL
:
logGroupCol
=
`"group"`
logKeyCol
=
`"key"`
default
:
logGroupCol
=
commonGroupCol
logKeyCol
=
commonKeyCol
}
}
// log sql type and database type
common
.
SysLog
(
"Using Log SQL Type: "
+
common
.
LogSqlType
)
}
var
DB
*
gorm
.
DB
...
...
@@ -83,7 +99,7 @@ func CheckSetup() {
}
}
func
chooseDB
(
envName
string
)
(
*
gorm
.
DB
,
error
)
{
func
chooseDB
(
envName
string
,
isLog
bool
)
(
*
gorm
.
DB
,
error
)
{
defer
func
()
{
initCol
()
}()
...
...
@@ -92,7 +108,11 @@ func chooseDB(envName string) (*gorm.DB, error) {
if
strings
.
HasPrefix
(
dsn
,
"postgres://"
)
||
strings
.
HasPrefix
(
dsn
,
"postgresql://"
)
{
// Use PostgreSQL
common
.
SysLog
(
"using PostgreSQL as database"
)
common
.
UsingPostgreSQL
=
true
if
!
isLog
{
common
.
UsingPostgreSQL
=
true
}
else
{
common
.
LogSqlType
=
common
.
DatabaseTypePostgreSQL
}
return
gorm
.
Open
(
postgres
.
New
(
postgres
.
Config
{
DSN
:
dsn
,
PreferSimpleProtocol
:
true
,
// disables implicit prepared statement usage
...
...
@@ -102,7 +122,11 @@ func chooseDB(envName string) (*gorm.DB, error) {
}
if
strings
.
HasPrefix
(
dsn
,
"local"
)
{
common
.
SysLog
(
"SQL_DSN not set, using SQLite as database"
)
common
.
UsingSQLite
=
true
if
!
isLog
{
common
.
UsingSQLite
=
true
}
else
{
common
.
LogSqlType
=
common
.
DatabaseTypeSQLite
}
return
gorm
.
Open
(
sqlite
.
Open
(
common
.
SQLitePath
),
&
gorm
.
Config
{
PrepareStmt
:
true
,
// precompile SQL
})
...
...
@@ -117,7 +141,11 @@ func chooseDB(envName string) (*gorm.DB, error) {
dsn
+=
"?parseTime=true"
}
}
common
.
UsingMySQL
=
true
if
!
isLog
{
common
.
UsingMySQL
=
true
}
else
{
common
.
LogSqlType
=
common
.
DatabaseTypeMySQL
}
return
gorm
.
Open
(
mysql
.
Open
(
dsn
),
&
gorm
.
Config
{
PrepareStmt
:
true
,
// precompile SQL
})
...
...
@@ -131,7 +159,7 @@ func chooseDB(envName string) (*gorm.DB, error) {
}
func
InitDB
()
(
err
error
)
{
db
,
err
:=
chooseDB
(
"SQL_DSN"
)
db
,
err
:=
chooseDB
(
"SQL_DSN"
,
false
)
if
err
==
nil
{
if
common
.
DebugEnabled
{
db
=
db
.
Debug
()
...
...
@@ -149,7 +177,7 @@ func InitDB() (err error) {
return
nil
}
if
common
.
UsingMySQL
{
_
,
_
=
sqlDB
.
Exec
(
"ALTER TABLE channels MODIFY model_mapping TEXT;"
)
// TODO: delete this line when most users have upgraded
//
_, _ = sqlDB.Exec("ALTER TABLE channels MODIFY model_mapping TEXT;") // TODO: delete this line when most users have upgraded
}
common
.
SysLog
(
"database migration started"
)
err
=
migrateDB
()
...
...
@@ -165,7 +193,7 @@ func InitLogDB() (err error) {
LOG_DB
=
DB
return
}
db
,
err
:=
chooseDB
(
"LOG_SQL_DSN"
)
db
,
err
:=
chooseDB
(
"LOG_SQL_DSN"
,
true
)
if
err
==
nil
{
if
common
.
DebugEnabled
{
db
=
db
.
Debug
()
...
...
@@ -198,54 +226,50 @@ func InitLogDB() (err error) {
}
func
migrateDB
()
error
{
err
:=
DB
.
AutoMigrate
(
&
Channel
{})
if
err
!=
nil
{
return
err
}
err
=
DB
.
AutoMigrate
(
&
Token
{})
if
err
!=
nil
{
return
err
}
err
=
DB
.
AutoMigrate
(
&
User
{})
if
err
!=
nil
{
return
err
}
err
=
DB
.
AutoMigrate
(
&
Option
{})
if
err
!=
nil
{
return
err
}
err
=
DB
.
AutoMigrate
(
&
Redemption
{})
if
err
!=
nil
{
return
err
}
err
=
DB
.
AutoMigrate
(
&
Ability
{})
if
err
!=
nil
{
return
err
}
err
=
DB
.
AutoMigrate
(
&
Log
{})
if
err
!=
nil
{
return
err
}
err
=
DB
.
AutoMigrate
(
&
Midjourney
{})
if
err
!=
nil
{
return
err
}
err
=
DB
.
AutoMigrate
(
&
TopUp
{})
if
err
!=
nil
{
return
err
var
wg
sync
.
WaitGroup
errChan
:=
make
(
chan
error
,
12
)
// Buffer size matches number of migrations
migrations
:=
[]
struct
{
model
interface
{}
name
string
}{
{
&
Channel
{},
"Channel"
},
{
&
Token
{},
"Token"
},
{
&
User
{},
"User"
},
{
&
Option
{},
"Option"
},
{
&
Redemption
{},
"Redemption"
},
{
&
Ability
{},
"Ability"
},
{
&
Log
{},
"Log"
},
{
&
Midjourney
{},
"Midjourney"
},
{
&
TopUp
{},
"TopUp"
},
{
&
QuotaData
{},
"QuotaData"
},
{
&
Task
{},
"Task"
},
{
&
Setup
{},
"Setup"
},
}
err
=
DB
.
AutoMigrate
(
&
QuotaData
{})
if
err
!=
nil
{
return
err
for
_
,
m
:=
range
migrations
{
wg
.
Add
(
1
)
go
func
(
model
interface
{},
name
string
)
{
defer
wg
.
Done
()
if
err
:=
DB
.
AutoMigrate
(
model
);
err
!=
nil
{
errChan
<-
fmt
.
Errorf
(
"failed to migrate %s: %v"
,
name
,
err
)
}
}(
m
.
model
,
m
.
name
)
}
err
=
DB
.
AutoMigrate
(
&
Task
{})
if
err
!=
nil
{
return
err
// Wait for all migrations to complete
wg
.
Wait
()
close
(
errChan
)
// Check for any errors
for
err
:=
range
errChan
{
if
err
!=
nil
{
return
err
}
}
err
=
DB
.
AutoMigrate
(
&
Setup
{})
common
.
SysLog
(
"database migrated"
)
//err = createRootAccountIfNeed()
return
err
return
nil
}
func
migrateLOGDB
()
error
{
...
...
model/token.go
View file @
4371717c
...
...
@@ -66,7 +66,7 @@ func SearchUserTokens(userId int, keyword string, token string) (tokens []*Token
if
token
!=
""
{
token
=
strings
.
Trim
(
token
,
"sk-"
)
}
err
=
DB
.
Where
(
"user_id = ?"
,
userId
)
.
Where
(
"name LIKE ?"
,
"%"
+
keyword
+
"%"
)
.
Where
(
k
eyCol
+
" LIKE ?"
,
"%"
+
token
+
"%"
)
.
Find
(
&
tokens
)
.
Error
err
=
DB
.
Where
(
"user_id = ?"
,
userId
)
.
Where
(
"name LIKE ?"
,
"%"
+
keyword
+
"%"
)
.
Where
(
commonK
eyCol
+
" LIKE ?"
,
"%"
+
token
+
"%"
)
.
Find
(
&
tokens
)
.
Error
return
tokens
,
err
}
...
...
@@ -161,7 +161,7 @@ func GetTokenByKey(key string, fromDB bool) (token *Token, err error) {
// Don't return error - fall through to DB
}
fromDB
=
true
err
=
DB
.
Where
(
k
eyCol
+
" = ?"
,
key
)
.
First
(
&
token
)
.
Error
err
=
DB
.
Where
(
commonK
eyCol
+
" = ?"
,
key
)
.
First
(
&
token
)
.
Error
return
token
,
err
}
...
...
model/user.go
View file @
4371717c
...
...
@@ -175,7 +175,7 @@ func SearchUsers(keyword string, group string, startIdx int, num int) ([]*User,
// 如果是数字,同时搜索ID和其他字段
likeCondition
=
"id = ? OR "
+
likeCondition
if
group
!=
""
{
query
=
query
.
Where
(
"("
+
likeCondition
+
") AND "
+
g
roupCol
+
" = ?"
,
query
=
query
.
Where
(
"("
+
likeCondition
+
") AND "
+
commonG
roupCol
+
" = ?"
,
keywordInt
,
"%"
+
keyword
+
"%"
,
"%"
+
keyword
+
"%"
,
"%"
+
keyword
+
"%"
,
group
)
}
else
{
query
=
query
.
Where
(
likeCondition
,
...
...
@@ -184,7 +184,7 @@ func SearchUsers(keyword string, group string, startIdx int, num int) ([]*User,
}
else
{
// 非数字关键字,只搜索字符串字段
if
group
!=
""
{
query
=
query
.
Where
(
"("
+
likeCondition
+
") AND "
+
g
roupCol
+
" = ?"
,
query
=
query
.
Where
(
"("
+
likeCondition
+
") AND "
+
commonG
roupCol
+
" = ?"
,
"%"
+
keyword
+
"%"
,
"%"
+
keyword
+
"%"
,
"%"
+
keyword
+
"%"
,
group
)
}
else
{
query
=
query
.
Where
(
likeCondition
,
...
...
@@ -615,7 +615,7 @@ func GetUserGroup(id int, fromDB bool) (group string, err error) {
// Don't return error - fall through to DB
}
fromDB
=
true
err
=
DB
.
Model
(
&
User
{})
.
Where
(
"id = ?"
,
id
)
.
Select
(
g
roupCol
)
.
Find
(
&
group
)
.
Error
err
=
DB
.
Model
(
&
User
{})
.
Where
(
"id = ?"
,
id
)
.
Select
(
commonG
roupCol
)
.
Find
(
&
group
)
.
Error
if
err
!=
nil
{
return
""
,
err
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment