重新初始化项目

This commit is contained in:
2023-04-27 15:56:12 +08:00
parent 10546eb629
commit d6e256ef9e
50 changed files with 1255 additions and 308 deletions

View File

@@ -1,8 +0,0 @@
package entity
import "Lee-WineList/common/types"
type Category struct {
types.BaseDbModel
Name string `gorm:"column:name;type:varchar(255);comment:分类名;NOT NULL" json:"name"`
}

14
model/entity/material.go Normal file
View File

@@ -0,0 +1,14 @@
package entity
import "Lee-WineList/common/types"
type Material struct {
types.BaseDbModel
Name string `gorm:"column:name;type:varchar(255);comment:材料名;NOT NULL" json:"name"`
ML string `gorm:"column:ml;type:int(11) unsigned;comment:毫升;NOT NULL" json:"ml"`
WindId int `gorm:"column:wine_id;type:int(11) unsigned;comment:酒ID;NOT NULL" json:"wine_id"`
}
func (Material) TableName() string {
return "materials"
}

View File

@@ -1,17 +1,20 @@
package entity
import (
"Lee-WineList/common/constant"
"Lee-WineList/common/types"
)
// User 普通用户表
type User struct {
types.BaseDbModel
Phone string `json:"phone" gorm:"index:deleted,unique;type:varchar(255) not null comment '手机号'"`
UnionId string `json:"union_id" gorm:"type:varchar(255) comment '微信UnionId'"`
OpenId string `json:"open_id" gorm:"type:varchar(255) comment '微信OpenId'"`
Nickname string `json:"nickname" gorm:"type:varchar(255) comment '昵称'"`
Avatar string `json:"avatar" gorm:"type:varchar(255) comment '头像'"`
Phone string `json:"phone" gorm:"index:deleted,unique;type:varchar(255) not null comment '手机号'"`
WechatUnionId *string `json:"wechat_union_id" gorm:"type:varchar(255) comment '微信UnionId'"`
WechatOpenId *string `json:"wechat_open_id" gorm:"type:varchar(255) comment '微信OpenId'"`
Nickname string `json:"nickname" gorm:"type:varchar(255) comment '昵称'"`
Avatar string `json:"avatar" gorm:"type:varchar(255) comment '头像'"`
Sex constant.UserSex `json:"sex" gorm:"type:int; default 0; not null comment 性别"` // 1男2女
Status constant.UserStatus `json:"status" gorm:"type:enum('NORMAL','DISABLE'); default:'NORMAL'; not null; comment:'状态 NORMAL-正常DISABLE-禁用'"`
}
func (User) TableName() string {

View File

@@ -4,12 +4,19 @@ import "Lee-WineList/common/types"
// Wine 酒
type Wine struct {
types.BaseDbModel
Name string `gorm:"column:name;type:varchar(255);comment:酒;NOT NULL" json:"name"`
ChineseName string `gorm:"column:chinese_name;type:varchar(255);comment:中文酒名;NOT NULL" json:"chinese_name"`
Ingredients string `gorm:"column:ingredients;type:varchar(255);comment:配料;NOT NULL" json:"ingredients"`
Quote string `gorm:"column:quote;type:varchar(255);comment:引用;NOT NULL" json:"quote"`
CategoryId uint `gorm:"column:category_id;type:int(11) unsigned;comment:分类ID;NOT NULL" json:"category_id"`
Steps string `gorm:"column:steps;type:varchar(255);comment:步骤;NOT NULL" json:"steps"`
Context string `gorm:"column:context;type:varchar(255);comment:酒文;NOT NULL" json:"context"`
types.Model
WineId int `gorm:"column:wine_id;type:int(11) unsigned;primarykey;comment:酒ID;NOT NULL" json:"wine_id"`
Name string `gorm:"column:name;type:varchar(255);comment:酒名;NOT NULL" json:"name"`
ChineseName string `gorm:"column:chinese_name;type:varchar(255);comment:中文酒名;NOT NULL" json:"chinese_name"`
Quote string `gorm:"column:quote;type:varchar(255);comment:引用;NOT NULL" json:"quote"`
Category string `gorm:"column:category;type:varchar(255);comment:分类;NOT NULL" json:"category"`
Steps string `gorm:"column:steps;type:varchar(255);comment:步骤;NOT NULL" json:"steps"`
Context string `gorm:"column:context;type:varchar(255);comment:酒文;NOT NULL" json:"context"`
Materials []Material `gorm:"many2many:wine_materials"`
UserId int `gorm:"column:user_id;type:int(11) unsigned;comment:用户ID;NOT NULL" json:"user_id"`
}
// TableName 设置表名
func (Wine) TableName() string {
return "wines"
}