├── models ├── goodsItemAttr.go ├── roleAccess.go ├── role.go ├── goodsType.go ├── goodsColor.go ├── user.go ├── focus.go ├── captcha.go ├── core.go ├── nav.go ├── manager.go ├── goodsImage.go ├── goodsAttr.go ├── orderItem.go ├── address.go ├── goodsTypeAttribute.go ├── goodsCate.go ├── access.go ├── order.go ├── cart.go ├── cookie.go ├── setting.go ├── cache.go ├── goods.go └── tools.go ├── static └── look me.txt ├── middleware ├── defaultAuth.go └── adminAuth.go ├── views ├── mindex │ ├── public │ │ ├── user_left.html │ │ ├── page_footer.html │ │ ├── page_header.html │ │ └── banner.html │ ├── cart │ │ ├── addcart_success.html │ │ └── cart.html │ ├── index │ │ ├── login.html │ │ └── pass.html │ ├── product │ │ ├── list.html │ │ └── item.html │ └── buy │ │ └── confirm.html └── admin │ ├── main │ ├── welcome.html │ └── index.html │ ├── public │ ├── page_header.html │ ├── page_nav.html │ ├── email.html │ ├── success.html │ ├── error.html │ ├── page_aside.html │ └── privilege.html │ ├── role │ ├── add.html │ ├── edit.html │ ├── index.html │ └── auth.html │ ├── login.html │ ├── manager │ ├── add.html │ ├── edit.html │ └── index.html │ ├── goodsType │ ├── add.html │ ├── edit.html │ └── index.html │ ├── focus │ ├── add.html │ ├── edit.html │ └── index.html │ ├── nav │ ├── add.html │ ├── edit.html │ └── index.html │ ├── goodsCate │ ├── add.html │ ├── edit.html │ └── index.html │ ├── access │ ├── add.html │ ├── index.html │ └── edit.html │ ├── goodsTypeAttribute │ ├── add.html │ ├── edit.html │ └── index.html │ ├── setting │ └── index.html │ └── goods │ └── index.html ├── conf └── app.conf ├── main.go ├── go.mod ├── controllers ├── admin │ ├── setting.go │ ├── login.go │ ├── goodsType.go │ ├── focus.go │ ├── nav.go │ ├── main.go │ ├── manager.go │ ├── access.go │ ├── base.go │ ├── goodsTypeAttr.go │ ├── role.go │ └── goodsCate.go └── mindex │ ├── index.go │ ├── user.go │ ├── base.go │ ├── buy.go │ ├── address.go │ └── product.go ├── tests └── default_test.go ├── routers ├── defaultRouter.go └── adminRouter.go └── README.md /models/goodsItemAttr.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | type GoodsItemAttr struct { 4 | Cate string 5 | List []string 6 | } -------------------------------------------------------------------------------- /static/look me.txt: -------------------------------------------------------------------------------- 1 | 由于项目中的static文件内容较多,而且代码放在GitHub上面,有的同学可能下载速度会很慢,我就将这里面的内容放在了蓝奏云,下载完成后,解压到此目录即可 2 | 3 | https://wwx.lanzoui.com/i3wlPlxmt9e 4 | https://wwx.lanzoui.com/i3wlPlxmt9e 5 | https://wwx.lanzoui.com/i3wlPlxmt9e 6 | 7 | 个人博客网站:https://syjun.vip -------------------------------------------------------------------------------- /models/roleAccess.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | _ "github.com/jinzhu/gorm" 5 | ) 6 | 7 | type RoleAccess struct { 8 | AccessId int 9 | RoleId int 10 | } 11 | 12 | func (RoleAccess) TableName() string { 13 | return "role_access" 14 | } 15 | -------------------------------------------------------------------------------- /models/role.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | _ "github.com/jinzhu/gorm" 5 | ) 6 | 7 | type Role struct { 8 | Id int 9 | Title string 10 | Description string 11 | Status int 12 | AddTime int 13 | } 14 | 15 | func (Role) TableName() string { 16 | return "role" 17 | } 18 | -------------------------------------------------------------------------------- /models/goodsType.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | _ "github.com/jinzhu/gorm" 5 | ) 6 | 7 | type GoodsType struct { 8 | Id int 9 | Title string 10 | Description string 11 | Status int 12 | AddTime int 13 | } 14 | 15 | func (GoodsType) TableName() string { 16 | return "goods_type" 17 | } 18 | -------------------------------------------------------------------------------- /models/goodsColor.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | _ "github.com/jinzhu/gorm" 5 | ) 6 | 7 | type GoodsColor struct { 8 | Id int 9 | ColorName string 10 | ColorValue string 11 | Status int 12 | Checked bool `gorm:"-"` 13 | } 14 | 15 | func (GoodsColor) TableName() string { 16 | return "goods_color" 17 | } 18 | 19 | -------------------------------------------------------------------------------- /models/user.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | _ "github.com/jinzhu/gorm" 5 | ) 6 | 7 | type User struct { 8 | Id int 9 | Phone string 10 | Password string 11 | AddTime int 12 | LastIp string 13 | Email string 14 | Status int 15 | } 16 | 17 | func (User) TableName() string { 18 | return "user" 19 | } 20 | 21 | -------------------------------------------------------------------------------- /middleware/defaultAuth.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import ( 4 | "github.com/astaxie/beego/context" 5 | "mi.com/models" 6 | ) 7 | 8 | func DefaultAuth(ctx *context.Context) { 9 | // 判断前端用户是否登录 10 | user := models.User{} 11 | models.Cookie.Get(ctx, "userinfo", &user) 12 | if len(user.Phone) != 11 { 13 | ctx.Redirect(302,"/login") 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /models/focus.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | _ "github.com/jinzhu/gorm" 5 | ) 6 | 7 | type Focus struct { 8 | Id int 9 | Title string 10 | FocusType int 11 | FocusImg string 12 | Link string 13 | Sort int 14 | Status int 15 | AddTime int 16 | } 17 | 18 | func (Focus) TableName() string { 19 | return "focus" 20 | } 21 | -------------------------------------------------------------------------------- /views/mindex/public/user_left.html: -------------------------------------------------------------------------------- 1 |
-------------------------------------------------------------------------------- /views/mindex/public/page_footer.html: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /models/captcha.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "github.com/astaxie/beego/cache" 5 | "github.com/astaxie/beego/utils/captcha" 6 | ) 7 | 8 | var Cpt *captcha.Captcha 9 | // verify生成验证码 10 | func init() { 11 | store := cache.NewMemoryCache() 12 | Cpt = captcha.NewWithFilter("/captcha/",store) 13 | Cpt.ChallengeNums = 4 14 | Cpt.StdHeight = 41 15 | Cpt.StdWidth = 250 16 | } -------------------------------------------------------------------------------- /models/core.go: -------------------------------------------------------------------------------- 1 | package models 2 | import ( 3 | "github.com/astaxie/beego" 4 | "github.com/jinzhu/gorm" 5 | _ "github.com/jinzhu/gorm/dialects/mysql" 6 | ) 7 | 8 | var DB *gorm.DB 9 | var err error 10 | 11 | func init() { 12 | DB,err = gorm.Open("mysql", "root:123456@/micom?charset=utf8&parseTime=True&loc=Local") 13 | if err != nil { 14 | beego.Error(err) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /conf/app.conf: -------------------------------------------------------------------------------- 1 | appname = mi.com 2 | httpport = 8080 3 | runmode = dev 4 | sessionon = true 5 | sessiongcmaxlifetime = 3600 6 | SessionName = "micom" 7 | adminPath = admin 8 | excludeAuthPath = "/,/welcome,/login/loginOut,/privilege" 9 | ossDomain = "http://bee.sunyj.xyz" 10 | ossStatus = false 11 | resizeImageSize = 200,400 12 | enableRedis=true 13 | redisKey="micom" 14 | redisConn=":6379" 15 | redisDbNum="0" 16 | redisPwd="" 17 | redisTime=3600 -------------------------------------------------------------------------------- /models/nav.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | _ "github.com/jinzhu/gorm" 5 | ) 6 | 7 | type Nav struct { 8 | Id int 9 | Title string 10 | Link string 11 | Position int 12 | IsOpennew int 13 | Relation string 14 | Sort int 15 | Status int 16 | AddTime int 17 | GoodsItem []Goods `gorm:"-"` 18 | GoodsNil string `gorm:"-"` 19 | } 20 | 21 | func (Nav) TableName() string { 22 | return "nav" 23 | } 24 | -------------------------------------------------------------------------------- /models/manager.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | _ "github.com/jinzhu/gorm" 5 | ) 6 | 7 | type Manager struct { 8 | Id int 9 | Username string 10 | Password string 11 | Mobile string 12 | Email string 13 | Status int 14 | RoleId int 15 | AddTime int 16 | IsSuper int 17 | Role Role `gorm:"foreignkey:Id;association_foreignkey:RoleId"` 18 | } 19 | 20 | func (Manager) TableName() string { 21 | return "manager" 22 | } 23 | -------------------------------------------------------------------------------- /models/goodsImage.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | _ "github.com/jinzhu/gorm" 5 | ) 6 | 7 | type GoodsImage struct { 8 | Id int `json:"id"` 9 | GoodsId int `json:"goods_id"` 10 | ImgUrl string `json:"img_url"` 11 | ColorId int `json:"color_id"` 12 | Sort int `json:"sort"` 13 | AddTime int `json:"add_time"` 14 | Status int `json:"status"` 15 | } 16 | 17 | func (GoodsImage) TableName() string { 18 | return "goods_image" 19 | } 20 | -------------------------------------------------------------------------------- /models/goodsAttr.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | _ "github.com/jinzhu/gorm" 5 | ) 6 | 7 | type GoodsAttr struct { 8 | Id int 9 | GoodsId int 10 | AttributeCateId int 11 | AttributeId int 12 | AttributeTitle string 13 | AttributeType int 14 | AttributeValue string 15 | Sort int 16 | AddTime int 17 | Status int 18 | } 19 | 20 | func (GoodsAttr) TableName() string { 21 | return "goods_attr" 22 | } 23 | -------------------------------------------------------------------------------- /models/orderItem.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | _ "github.com/jinzhu/gorm" 5 | ) 6 | 7 | type OrderItem struct { 8 | Id int 9 | OrderId int 10 | Uid int 11 | ProductTitle string 12 | ProductId int 13 | ProductImg string 14 | ProductPrice float64 15 | ProductNum int 16 | GoodsVersion string 17 | GoodsColor string 18 | AddTime int 19 | } 20 | 21 | func (OrderItem) TableName() string { 22 | return "order_item" 23 | } 24 | -------------------------------------------------------------------------------- /views/admin/main/welcome.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
17 |