This commit is contained in:
2023-05-14 07:00:24 +08:00
parent 2423213e9a
commit ee3b60eccc
18 changed files with 273 additions and 1221 deletions

View File

@@ -17,28 +17,24 @@ import (
var manager = models.NewWebSocketManager()
// 獲取模型列表
func ModelsGet(w http.ResponseWriter, r *http.Request) {
// 初始化基本參數
var listview models.ListView
listview.Page = utils.ParamInt(r.URL.Query().Get("page"), 1)
listview.PageSize = utils.ParamInt(r.URL.Query().Get("pageSize"), 10)
// 獲取模型列表
var model_list []models.Model
db := configs.ORMDB()
db.Offset((listview.Page - 1) * listview.PageSize).Limit(listview.PageSize).Find(&model_list)
for _, model := range model_list {
listview.List = append(listview.List, model)
}
// 獲取總數
var total int64
db.Model(&models.Model{}).Count(&total)
listview.Total = int(total)
listview.Next = listview.Page*listview.PageSize < listview.Total
db.Model(&models.Model{}).Count(&listview.Total)
listview.Next = listview.Page*listview.PageSize < int(listview.Total)
listview.WriteJSON(w)
}
// 創建模型
func ModelsPost(w http.ResponseWriter, r *http.Request) {
// 取得用戶
models.AccountRead(w, r, func(account *models.Account) {
fmt.Println(account)
// TODO: 判斷權限(是否可以創建)
@@ -138,7 +134,7 @@ func ModelItemPatch(w http.ResponseWriter, r *http.Request) {
model.Status = model_new.Status
// 如果狀態被改變爲 ready, 將模型發送到訓練隊列
if model.Status == "ready" {
model.SendToTrain()
//model.SendToTrain()
}
}
if model_new.Image != "" && model_new.Image != model.Image {