mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-18 06:33:53 +08:00
Merge pull request #52 from yokowu/fix-model-create
fix(model): 添加首个模型自动激活
This commit is contained in:
@@ -30,6 +30,16 @@ func (r *ModelRepo) Create(ctx context.Context, m *domain.CreateModelReq) (*db.M
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
n, err := r.db.Model.Query().Where(model.ModelType(m.ModelType)).Count(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
status := consts.ModelStatusInactive
|
||||
if n == 0 {
|
||||
status = consts.ModelStatusActive
|
||||
}
|
||||
|
||||
return r.db.Model.Create().
|
||||
SetUserID(uid).
|
||||
SetModelName(m.ModelName).
|
||||
@@ -37,7 +47,7 @@ func (r *ModelRepo) Create(ctx context.Context, m *domain.CreateModelReq) (*db.M
|
||||
SetAPIBase(m.APIBase).
|
||||
SetAPIKey(m.APIKey).
|
||||
SetModelType(m.ModelType).
|
||||
SetStatus(consts.ModelStatusInactive).
|
||||
SetStatus(status).
|
||||
Save(ctx)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user