refactor: V3 版本重构已基本完成

This commit is contained in:
RockYang
2023-06-15 09:41:30 +08:00
parent b4569d7fe2
commit 01d61ab19b
99 changed files with 5209 additions and 5752 deletions

View File

@@ -0,0 +1,35 @@
package service
import (
"chatplus/store/model"
"chatplus/store/vo"
"chatplus/utils"
"gorm.io/gorm"
)
type ChatRoleService struct {
DB *gorm.DB
Model interface{}
}
func NewChatRoleService(db *gorm.DB) *ChatRoleService {
return &ChatRoleService{DB: db, Model: &model.ChatRole{}}
}
func (s *ChatRoleService) Create(value interface{}) error {
r, ok := value.(vo.ChatRole)
if ok {
var role model.ChatRole
err := utils.CopyObject(r, &role)
if err != nil {
return err
}
result := s.DB.Create(&role)
return result.Error
} else {
result := s.DB.Create(value)
return result.Error
}
}