拓展类型
This commit is contained in:
+22
-4
@@ -2,8 +2,10 @@ package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"gorm.io/gorm"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
"work_cation/cfg"
|
||||
"work_cation/global"
|
||||
"work_cation/models"
|
||||
@@ -31,11 +33,27 @@ func (*erlangCardService) Create(erlangCard *models.ErlangCards) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = repo.ErlangCardRepo.Create(global.DB, erlangCard)
|
||||
if err != nil {
|
||||
|
||||
return global.DB.Transaction(func(tx *gorm.DB) error {
|
||||
err = repo.ErlangCardRepo.Create(global.DB, erlangCard)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var baseCard = models.BaseCard{
|
||||
UUID: erlangCard.UUID,
|
||||
UserID: erlangCard.UserID,
|
||||
Title: erlangCard.Title,
|
||||
Text: erlangCard.Text,
|
||||
Covers: erlangCard.Covers,
|
||||
ToolType: models.ToolTypeErlang,
|
||||
UpdateTx: time.Now(),
|
||||
Number: 0,
|
||||
Goods: 0,
|
||||
Collection: 0,
|
||||
}
|
||||
err = repo.BaseCard.Create(global.DB, &baseCard)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (*erlangCardService) GetInfoPath(erlangCard *models.ErlangCards) string {
|
||||
|
||||
Reference in New Issue
Block a user