You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.4 KiB
66 lines
2.4 KiB
package repository
|
|
|
|
import "health-ai/internal/model"
|
|
|
|
// UserRepository 用户数据访问接口
|
|
type UserRepository interface {
|
|
Create(user *model.User) error
|
|
GetByID(id uint) (*model.User, error)
|
|
GetByPhone(phone string) (*model.User, error)
|
|
GetByEmail(email string) (*model.User, error)
|
|
Update(user *model.User) error
|
|
UpdateSurveyStatus(userID uint, completed bool) error
|
|
}
|
|
|
|
// HealthProfileRepository 健康档案数据访问接口
|
|
type HealthProfileRepository interface {
|
|
Create(profile *model.HealthProfile) error
|
|
GetByUserID(userID uint) (*model.HealthProfile, error)
|
|
Update(profile *model.HealthProfile) error
|
|
Upsert(profile *model.HealthProfile) error
|
|
}
|
|
|
|
// LifestyleRepository 生活习惯数据访问接口
|
|
type LifestyleRepository interface {
|
|
Create(lifestyle *model.LifestyleInfo) error
|
|
GetByUserID(userID uint) (*model.LifestyleInfo, error)
|
|
Update(lifestyle *model.LifestyleInfo) error
|
|
Upsert(lifestyle *model.LifestyleInfo) error
|
|
}
|
|
|
|
// MedicalHistoryRepository 病史数据访问接口
|
|
type MedicalHistoryRepository interface {
|
|
Create(history *model.MedicalHistory) error
|
|
GetByHealthProfileID(healthProfileID uint) ([]model.MedicalHistory, error)
|
|
Update(history *model.MedicalHistory) error
|
|
Delete(id uint) error
|
|
BatchCreate(histories []model.MedicalHistory) error
|
|
}
|
|
|
|
// ConstitutionRepository 体质测评数据访问接口
|
|
type ConstitutionRepository interface {
|
|
CreateAssessment(assessment *model.ConstitutionAssessment) error
|
|
GetLatestByUserID(userID uint) (*model.ConstitutionAssessment, error)
|
|
GetHistoryByUserID(userID uint, limit int) ([]model.ConstitutionAssessment, error)
|
|
GetQuestions() ([]model.QuestionBank, error)
|
|
CreateAnswers(answers []model.AssessmentAnswer) error
|
|
}
|
|
|
|
// ConversationRepository 对话数据访问接口
|
|
type ConversationRepository interface {
|
|
Create(conversation *model.Conversation) error
|
|
GetByID(id uint) (*model.Conversation, error)
|
|
GetByUserID(userID uint) ([]model.Conversation, error)
|
|
Delete(id uint) error
|
|
AddMessage(message *model.Message) error
|
|
GetMessages(conversationID uint, limit int) ([]model.Message, error)
|
|
}
|
|
|
|
// ProductRepository 产品数据访问接口
|
|
type ProductRepository interface {
|
|
GetByID(id uint) (*model.Product, error)
|
|
GetByCategory(category string) ([]model.Product, error)
|
|
GetByConstitution(constitutionType string) ([]model.Product, error)
|
|
SearchByKeyword(keyword string) ([]model.Product, error)
|
|
GetAll(page, pageSize int) ([]model.Product, int64, error)
|
|
}
|
|
|