database

package
v0.0.0-...-66c88e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2019 License: MIT Imports: 9 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DrDatabase *gorm.DB
)

Functions

func AddFoodRecs

func AddFoodRecs(diseaseID int, foodNames []string)

func AddQuestion

func AddQuestion(question QuestionInfo) (id int, err error)

func AddUserAndDiseaseScore

func AddUserAndDiseaseScore(userID int, diseaseID int, score int) (err error)

func AddUserAndFoodScore

func AddUserAndFoodScore(userID int, foodID int, score int) (err error)

func AddUserScore

func AddUserScore(userID int, score int) (err error)

func CreateCollectDiseaseInfo

func CreateCollectDiseaseInfo(userID int, diseaseID int) (err error)

func CreateCollectFoodInfo

func CreateCollectFoodInfo(userID int, foodID int) (err error)

func CreateDiseaseAdmin

func CreateDiseaseAdmin(request DiseaseInfo) (int, error)

func CreateDiseaseComment

func CreateDiseaseComment(diseaseID int, userID int, content string) (err error)

func CreateDiseaseVoice

func CreateDiseaseVoice()

func CreateFoodAdmin

func CreateFoodAdmin(request FoodInfo) (int, error)

func CreateFoodComment

func CreateFoodComment(foodID int, userID int, content string) (err error)

func CreateFoodKindAdmin

func CreateFoodKindAdmin(request FoodKindInfo) (int, error)

func CreateFoodVoice

func CreateFoodVoice()

func CreateQuestionSheet

func CreateQuestionSheet(request AnswerSheet) (err error)

func CreateUserAdmin

func CreateUserAdmin(request UserInfo) (int, error)

func CreateUserAndDiseaseScore

func CreateUserAndDiseaseScore(userID int, diseaseID int)

func CreateUserAndFoodScore

func CreateUserAndFoodScore(userID int, foodID int)

func DecreaseDiseaseCollectCount

func DecreaseDiseaseCollectCount(diseaseID int)

func DecreaseFoodCollectCount

func DecreaseFoodCollectCount(foodID int)

func DeleteCollectedDisease

func DeleteCollectedDisease(userID int, disease_id int) bool

func DeleteCollectedFood

func DeleteCollectedFood(userID int, foodID int) bool

func GetDiseaseNameByDiseaseID

func GetDiseaseNameByDiseaseID(diseaseID int) string

func GetFoodIDByFoodName

func GetFoodIDByFoodName(foodName string) int

func GetFoodNameByFoodID

func GetFoodNameByFoodID(foodID int) string

func GetUserImagePath

func GetUserImagePath(userID int) (path string, err error)

func GetUserNameByID

func GetUserNameByID(userID int) (name string, err error)

func InitMysql

func InitMysql(dsn string) error

func IsUserCollectedDisease

func IsUserCollectedDisease(userID int, diseaseID int) bool

func IsUserCollectedFood

func IsUserCollectedFood(userID int, foodID int) bool

func UpdateDiseaseCollectCount

func UpdateDiseaseCollectCount(diseaseID int)

func UpdateDiseaseField

func UpdateDiseaseField(diseaseID int, path string, field string) (err error)

func UpdateDiseaseInfo

func UpdateDiseaseInfo(request DiseaseInfo) (err error)

func UpdateDiseaseView

func UpdateDiseaseView(diseaseID int)

func UpdateFoodCollect

func UpdateFoodCollect(foodID int)

func UpdateFoodField

func UpdateFoodField(foodID int, value string, field string) (err error)

func UpdateFoodInfo

func UpdateFoodInfo(request FoodInfo) (err error)

func UpdateFoodKindInfo

func UpdateFoodKindInfo(request FoodKindInfo) (err error)

func UpdateFoodKindPath

func UpdateFoodKindPath(kindID int, path string) (err error)

func UpdateFoodView

func UpdateFoodView(foodID int)

func UpdateUserInfo

func UpdateUserInfo(userInfo UserInfo) (err error)

func UpdateUserPath

func UpdateUserPath(userID int, path string) (err error)

func VerifyAdmin

func VerifyAdmin(token string) bool

Types

type AdminInfo

type AdminInfo struct {
	ID    int    `json:"id"`
	Token string `json:"token"`
}

type AnswerSheet

type AnswerSheet struct {
	ID         int    `json:"id" gorm:"column:id;primary_key"`
	QuestionID int    `json:"question_id"`
	UserID     int    `json:"user_id"`
	Answer     string `json:"answer"`
	RecordTime string `json:"record_time"`
}

type DiseaseCommentInfo

type DiseaseCommentInfo struct {
	ID         int    `json:"id"`
	DiseaseID  int    `json:"disease_id"`
	UserID     int    `json:"user_id"`
	UserName   string `json:"user_name"`
	Comment    string `json:"comment"`
	RecordTime string `json:"record_time"`
}

func GetCommentByDiseaseID

func GetCommentByDiseaseID(diseaseID int) (diseaseComments []DiseaseCommentInfo, err error)

type DiseaseFoodRec

type DiseaseFoodRec struct {
	DiseaseID int    `json:"disease_id"`
	FoodID    int    `json:"food_id"`
	FoodName  string `json:"food_name"`
}

type DiseaseInfo

type DiseaseInfo struct {
	DiseaseID     int    `json:"disease_id"  gorm:"column:disease_id;primary_key"`
	Name          string `json:"name"`
	DiseaseKind   string `json:"disease_kind"`
	Info          string `json:"info"`
	Taboo         string `json:"taboo"`
	RecommendFood string `json:"recommend_food"`
	PhotoPath     string `json:"photo_path"`
	VoicePath     string `json:"voice_path"`
	ViewCount     int    `json:"view_count"`
	CollectCount  int    `json:"collect_count"`
}

func GetDiseaseInfoByID

func GetDiseaseInfoByID(diseaseID int) (diseaseInfo DiseaseInfo, err error)

func GetDiseaseLists

func GetDiseaseLists(keyword string) (diseaseList []DiseaseInfo, err error)

func GetRecDiseaseByUserID

func GetRecDiseaseByUserID(userID int) (diseaseInfo []DiseaseInfo, err error)

type FoodCommentInfo

type FoodCommentInfo struct {
	ID         int    `json:"id"`
	FoodID     int    `json:"food_id"`
	UserID     int    `json:"user_id"`
	UserName   string `json:"user_name"`
	Comment    string `json:"comment"`
	RecordTime string `json:"record_time"`
}

func GetCommentByFoodID

func GetCommentByFoodID(foodID int) (foodComments []FoodCommentInfo, err error)

type FoodInfo

type FoodInfo struct {
	FoodID       int    `json:"food_id" gorm:"column:food_id;primary_key"`
	Name         string `json:"name"`
	FoodKindID   int    `json:"food_kind_id"`
	FoodKind     string `json:"food_kind"`
	Info         string `json:"info"`
	Effect       string `json:"effect"`
	Keyword      string `json:"keyword"`
	ViewCount    int    `json:"view_count"`
	CollectCount int    `json:"collect_count"`
	PhotoPath    string `json:"photo_path"`
	VoicePath    string `json:"voice_path"`
}

func GetFoodInfoByID

func GetFoodInfoByID(foodID int) (foodInfo FoodInfo, err error)

func GetRecFoodByUserID

func GetRecFoodByUserID(userID int) (foodInfo []FoodInfo, err error)

func SearchByFoodKindID

func SearchByFoodKindID(foodKindID int) (foodList []FoodInfo, err error)

func SearchByFoodKindIDAndKey

func SearchByFoodKindIDAndKey(keyword string, foodKindID int) (foodList []FoodInfo, err error)

func SearchByKeyWord

func SearchByKeyWord(keyword string) (foodList []FoodInfo, err error)

type FoodKindInfo

type FoodKindInfo struct {
	KindID    int    `json:"kind_id" gorm:"column:kind_id;primary_key"`
	KindName  string `json:"kind_name"`
	KindInfo  string `json:"kind_info"`
	PhotoPath string `json:"photo_path"`
	ViewCount int    `json:"view_count"`
}

func GetFoodKind

func GetFoodKind() (foodKinds []FoodKindInfo, err error)

func GetFoodKindByID

func GetFoodKindByID(kindID int) (foodKind FoodKindInfo, err error)

type QuestionInfo

type QuestionInfo struct {
	QuestionID int    `json:"question_id" gorm:"column:question_id;primary_key"`
	Info       string `json:"info"`
	AnswerA    string `json:"answer_a"`
	ResponseA  string `json:"response_a"`
	AnswerB    string `json:"answer_b"`
	ResponseB  string `json:"response_b"`
	AnswerC    string `json:"answer_c"`
	ResponseC  string `json:"response_c"`
}

func SelectQuestionInfo

func SelectQuestionInfo(userID int) (questionLists []QuestionInfo, err error)

type UserCollectDiseaseInfo

type UserCollectDiseaseInfo struct {
	ID         int    `json:"id"`
	UserID     int    `json:"user_id"`
	DiseaseID  int    `json:"disease_id"`
	RecordTime string `json:"record_time"`
}

func GetCollectDiseaseByUserID

func GetCollectDiseaseByUserID(userID int) (collectDisease []UserCollectDiseaseInfo, err error)

type UserCollectFoodInfo

type UserCollectFoodInfo struct {
	ID         int    `json:"id"`
	UserID     int    `json:"user_id"`
	FoodID     int    `json:"food_id"`
	RecordTime string `json:"record_time"`
}

func GetCollectFoodByID

func GetCollectFoodByID(userID int) (collectFood []UserCollectFoodInfo, err error)

type UserDiseaseRelation

type UserDiseaseRelation struct {
	UserID      int    `json:"user_id"`
	DiseaseID   int    `json:"disease_id"`
	DiseaseName string `json:"disease_name"`
	Score       int    `json:"score"`
}

type UserFoodRelation

type UserFoodRelation struct {
	UserID   int    `json:"user_id"`
	FoodID   int    `json:"food_id"`
	FoodName string `json:"food_name"`
	Score    int    `json:"score"`
}

type UserInfo

type UserInfo struct {
	UserID        int    `json:"user_id" gorm:"column:user_id;primary_key"`
	Name          string `json:"name"`
	Age           int    `json:"age"`
	Gender        string `json:"gender" gorm:"default:'male'"`
	UserImagePath string `json:"user_image_path"`
	DiseasesFocus string `json:"diseases_focus"`
	Keywords      string `json:"keywords"`
	OpenID        string `json:"open_id"`
	UserScore     int    `json:"user_score"`
	NoAttention   int    `json:"no_attention" gorm:"default:0"`
	UpdateTime    string `json:"update_time"`
}

func CreateUserByOpenID

func CreateUserByOpenID(openID string, name string, gender string, userImagePath string) (newUserInfo UserInfo, err error)

创建用户,性别默认为男性,默认60岁

func GetOrCreateUserInfoByOpenID

func GetOrCreateUserInfoByOpenID(openID string, request WechatLoginRequestBody) (userInfo UserInfo, err error)

暂时userID就是openID

func GetUserInfoByOpenID

func GetUserInfoByOpenID(openID string) (userInfo UserInfo, err error)

func GetUserInfoByUserID

func GetUserInfoByUserID(userID int) (userInfo UserInfo, err error)

type WechatLoginRequestBody

type WechatLoginRequestBody struct {
	Code      string `json:"code"`
	NickName  string `json:"nick_name"`
	AvatarUrl string `json:"avatar_url"`
	Gender    string `json:"gender"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL