package pet import ( "context" "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/pet" petReq "github.com/flipped-aurora/gin-vue-admin/server/model/pet/request" ) type PetAiAssistantConversationsService struct{} // CreatePetAiAssistantConversations 创建petAiAssistantConversations表记录 // Author [yourname](https://github.com/yourname) func (petAiAssistantConversationsService *PetAiAssistantConversationsService) CreatePetAiAssistantConversations(ctx context.Context, petAiAssistantConversations *pet.PetAiAssistantConversations) (err error) { err = global.GVA_DB.Create(petAiAssistantConversations).Error return err } // DeletePetAiAssistantConversations 删除petAiAssistantConversations表记录 // Author [yourname](https://github.com/yourname) func (petAiAssistantConversationsService *PetAiAssistantConversationsService) DeletePetAiAssistantConversations(ctx context.Context, ID string) (err error) { err = global.GVA_DB.Delete(&pet.PetAiAssistantConversations{}, "id = ?", ID).Error return err } // DeletePetAiAssistantConversationsByIds 批量删除petAiAssistantConversations表记录 // Author [yourname](https://github.com/yourname) func (petAiAssistantConversationsService *PetAiAssistantConversationsService) DeletePetAiAssistantConversationsByIds(ctx context.Context, IDs []string) (err error) { err = global.GVA_DB.Delete(&[]pet.PetAiAssistantConversations{}, "id in ?", IDs).Error return err } // UpdatePetAiAssistantConversations 更新petAiAssistantConversations表记录 // Author [yourname](https://github.com/yourname) func (petAiAssistantConversationsService *PetAiAssistantConversationsService) UpdatePetAiAssistantConversations(ctx context.Context, petAiAssistantConversations pet.PetAiAssistantConversations) (err error) { err = global.GVA_DB.Model(&pet.PetAiAssistantConversations{}).Where("id = ?", petAiAssistantConversations.ID).Updates(&petAiAssistantConversations).Error return err } // GetPetAiAssistantConversations 根据ID获取petAiAssistantConversations表记录 // Author [yourname](https://github.com/yourname) func (petAiAssistantConversationsService *PetAiAssistantConversationsService) GetPetAiAssistantConversations(ctx context.Context, ID string) (petAiAssistantConversations pet.PetAiAssistantConversations, err error) { err = global.GVA_DB.Where("id = ?", ID).First(&petAiAssistantConversations).Error return } // GetPetAiAssistantConversationsInfoList 分页获取petAiAssistantConversations表记录 // Author [yourname](https://github.com/yourname) func (petAiAssistantConversationsService *PetAiAssistantConversationsService) GetPetAiAssistantConversationsInfoList(ctx context.Context, info petReq.PetAiAssistantConversationsSearch) (list []pet.PetAiAssistantConversations, total int64, err error) { limit := info.PageSize offset := info.PageSize * (info.Page - 1) // 创建db db := global.GVA_DB.Model(&pet.PetAiAssistantConversations{}) var petAiAssistantConversationss []pet.PetAiAssistantConversations // 如果有条件搜索 下方会自动创建搜索语句 if len(info.CreatedAtRange) == 2 { db = db.Where("created_at BETWEEN ? AND ?", info.CreatedAtRange[0], info.CreatedAtRange[1]) } err = db.Count(&total).Error if err != nil { return } if limit != 0 { db = db.Limit(limit).Offset(offset) } err = db.Find(&petAiAssistantConversationss).Error return petAiAssistantConversationss, total, err } func (petAiAssistantConversationsService *PetAiAssistantConversationsService) GetPetAiAssistantConversationsPublic(ctx context.Context) { // 此方法为获取数据源定义的数据 // 请自行实现 }