From e4cd450a42e1538d63e154164cee0bbbf0a035b1 Mon Sep 17 00:00:00 2001 From: aarongao Date: Fri, 7 Feb 2020 12:59:40 +0800 Subject: [PATCH] .. --- API/Scenic.go | 6 +++--- API/User.go | 105 +++++++++++++++++---------------------------------------------------------------------------------------- DB/db.go | 12 +++++++++--- README.md | 10 ++++------ 4 files changed, 33 insertions(+), 100 deletions(-) diff --git a/API/Scenic.go b/API/Scenic.go index 610579e..ea203e3 100644 --- a/API/Scenic.go +++ b/API/Scenic.go @@ -13,7 +13,7 @@ import ( // @Accept json // @Produce json // @Param id 5dfb03070a9ac17ac7a82054 string true "景区id" -// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频" +// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片)" // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" // @Router /ScenicInfo? [get] func ScenicInfo(c *gin.Context) { @@ -43,7 +43,7 @@ func ScenicInfo(c *gin.Context) { // @Accept json // @Produce json // @Param id 5dfb03070a9ac17ac7a82054 string true "景区id" -// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频" +// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片)" // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" // @Router /UpdateScenic? [post] func UpdateScenic(c *gin.Context) { @@ -65,7 +65,7 @@ func UpdateScenic(c *gin.Context) { var ActivityPicture []DB.SPicture json.Unmarshal([]byte(c.PostForm("ActivityPicture")), &ActivityPicture) - var VideoList []DB.SPicture + var VideoList []DB.SVideo json.Unmarshal([]byte(c.PostForm("VideoList")), &VideoList) diff --git a/API/User.go b/API/User.go index da8fb56..46709d9 100644 --- a/API/User.go +++ b/API/User.go @@ -12,74 +12,6 @@ import ( "time" ) -// -//// @Title 创建用户 -//// @Description 用户注册 -//// @Accept json -//// @Produce json -//// @Param password 1 string true "密码" -//// @Param confirmpassword 1 string true "确认密码" -//// @Param birthday 2010.10.10 string true "生日" -//// @Param fullname aarongao string true "全名" -//// @Param code 12345678 string true "6位验证码" -//// @Param mobile 18616619599 string true "手机,同用户名" -//// @Param openid 12345 string true "微信id" -//// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}" -//// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" -//// @Router /CreateUser? [post] -//func CreateUser(c *gin.Context) { -// c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) -// c.Header("Access-Control-Allow-Credentials", "true") -// -// if c.PostForm("mobile") == "" { -// c.JSON(200, tools.ResponseError{ -// 1, -// "必须有手机号", -// }) -// return -// } -// if c.PostForm("password") != c.PostForm("confirmpassword") { -// c.JSON(200, tools.ResponseError{ -// 1, -// "密码错误", -// }) -// return -// } -// -// // 检查验证码 -// code := DB.Redis.Get(c.PostForm("mobile")) -// if code == "" || code != c.PostForm("code") { -// c.JSON(200, tools.ResponseError{ -// 1, -// "验证码错误", -// }) -// return -// } -// -// objectID := bson.NewObjectId() -// err := DB.CMember.Insert(DB.SMember{ -// &objectID, -// c.PostForm("password"), -// c.PostForm("birthday"), -// c.PostForm("fullname"), -// c.PostForm("mobile"), -// c.PostForm("openid"), -// "", -// }) -// if err == nil{ -// c.JSON(200, tools.ResponseSeccess{ -// 0, -// "ok", -// }) -// }else{ -// c.JSON(200, tools.ResponseError{ -// 0, -// "此手机号已经注册", -// }) -// } -// -// -//} var Regular = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$" @@ -88,7 +20,7 @@ var Regular = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|1 // @Accept json // @Produce json // @Param Mobile aaron string true "手机号" -// @Param Password 1 string true "密码或验证码(使用验证码的新手机号自动注册)" +// @Param Code 1 string true "验证码(使用验证码的新手机号自动注册)" // @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":{"Id":"5e09c64c1c09c6f0f7ca2fa9","Token":"640bf934e425aba5d3c90998b2641f2f0ca07261d334d9615d1cd4790b5f34e7"}} 调用其它需要登陆的接口时携带token,有过期时间" // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" // @Router /LoginUser? [post] @@ -106,23 +38,23 @@ func LoginUser(c *gin.Context) { return } - if c.PostForm("Mobile") == "" || c.PostForm("Password") == "" { + if c.PostForm("Mobile") == "" || c.PostForm("Code") == "" { c.JSON(200, tools.ResponseError{ 1, - "空", + "手机号和验证码不能空", }) return } // 生成token - tokenunit8 := sha256.Sum256([]byte(c.PostForm("Mobile") + c.PostForm("Password") + strconv.FormatInt(time.Now().UnixNano(), 10))) + tokenunit8 := sha256.Sum256([]byte(c.PostForm("Mobile") + c.PostForm("Code") + strconv.FormatInt(time.Now().UnixNano(), 10))) token := hex.EncodeToString(tokenunit8[:32]) // 检查验证码 cacheCode := DB.Redis.Get(c.PostForm("Mobile")) selected := bson.M{} var User *DB.SMember - if cacheCode == c.PostForm("Password") { + if cacheCode == c.PostForm("Code") { selected["Mobile"] = c.PostForm("Mobile") DB.CMember.Find(selected).One(&User) @@ -151,7 +83,7 @@ func LoginUser(c *gin.Context) { } else { selected["Mobile"] = c.PostForm("Mobile") - selected["Password"] = c.PostForm("Password") + selected["Code"] = c.PostForm("Code") DB.CMember.Find(selected).One(&User) if User == nil { c.JSON(200, tools.ResponseError{ @@ -210,10 +142,8 @@ func UserInfo(c *gin.Context) { // @Description 用户管理 - 修改用户信息 // @Accept json // @Produce json -// @Param Password 1 string true "密码" -// @Param ConfirmPassword 1 string true "确认密码" // @Param Birthday 2010.10.10 string true "生日" -// @Param Fullname aarongao string true "全名" +// @Param FullName aarongao string true "全名" // @Param Code 12345678 string true "6位验证码" // @Param Mobile 18616619599 string true "手机,同用户名" // @Param Sex 男 string true "性别" @@ -235,21 +165,21 @@ func UpdateUser(c *gin.Context) { return } - if c.PostForm("Mobile") == "" || c.PostForm("Password") == "" { + if c.PostForm("Mobile") == "" || c.PostForm("Code") == "" { c.JSON(200, tools.ResponseError{ 1, - "手机号或密码为空", + "手机号或验证码不能为空", }) return } - if c.PostForm("Password") != c.PostForm("ConfirmPassword") { - c.JSON(200, tools.ResponseError{ - 1, - "2次密码不一致", - }) - return - } + //if c.PostForm("Password") != c.PostForm("ConfirmPassword") { + // c.JSON(200, tools.ResponseError{ + // 1, + // "2次密码不一致", + // }) + // return + //} // 检查验证码 code := DB.Redis.Get(c.PostForm("Mobile")) @@ -264,9 +194,8 @@ func UpdateUser(c *gin.Context) { err := DB.CMember.Update( bson.M{"Mobile": c.PostForm("Mobile")}, bson.M{"$set": bson.M{ - "Password": c.PostForm("Password"), "Birthday": c.PostForm("Birthday"), - "FullName": c.PostForm("Fullname"), + "FullName": c.PostForm("FullName"), "Mobile": c.PostForm("Mobile"), "Sex": c.PostForm("Sex"), }}, diff --git a/DB/db.go b/DB/db.go index e06b8ec..d3987eb 100644 --- a/DB/db.go +++ b/DB/db.go @@ -122,8 +122,14 @@ type STag struct { } type SPicture struct { - Src string `bson:"Src" json:"Src"` - Link string `bson:"Link" json:"Link"` + Src string `bson:"Src" json:"Src"` // 地址,也可能是视频地址 + Link string `bson:"Link" json:"Link"` // 链接地址 +} +type SVideo struct { + Src string `bson:"Src" json:"Src"` // 地址,也可能是视频地址 + Link string `bson:"Link" json:"Link"` // 链接地址 + VideoPicture string `bson:"VideoPicture" json:"VideoPicture"` // 用于视频的首桢图 + Title string `bson:"Title" json:"Title"` // 标题 } type SScenic struct { Id *bson.ObjectId `bson:"_id" json:"Id" valid:"required"` @@ -137,5 +143,5 @@ type SScenic struct { ShopAdPicture []SPicture `bson:"ShopAdPicture" json:"ShopAdPicture"` //商城列表页图片 ItemScenicPicture []SPicture `bson:"ItemScenicPicture" json:"ItemScenicPicture"` //项目场次照片 ActivityPicture []SPicture `bson:"ActivityPicture" json:"ActivityPicture"` //活动照片 - VideoList []SPicture `bson:"VideoList" json:"VideoList"` + VideoList []SVideo `bson:"VideoList" json:"VideoList"` } diff --git a/README.md b/README.md index ede794e..08f2f8b 100644 --- a/README.md +++ b/README.md @@ -306,7 +306,7 @@ | Param Name | Example | Data Type | Description | Required? | |-----|-----|-----|-----|-----| | Mobile | aaron | string | 手机号 | Yes | -| Password | 1 | string | 密码或验证码(使用验证码的新手机号自动注册) | Yes | +| Code | 1 | string | 验证码(使用验证码的新手机号自动注册) | Yes | | Code | Type | Model | Message | @@ -330,7 +330,7 @@ | Code | Type | Model | Message | |-----|-----|-----|-----| -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频 | +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片) | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | @@ -464,7 +464,7 @@ | Code | Type | Model | Message | |-----|-----|-----|-----| -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频 | +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片) | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | @@ -478,10 +478,8 @@ | Param Name | Example | Data Type | Description | Required? | |-----|-----|-----|-----|-----| -| Password | 1 | string | 密码 | Yes | -| ConfirmPassword | 1 | string | 确认密码 | Yes | | Birthday | 2010.10.10 | string | 生日 | Yes | -| Fullname | aarongao | string | 全名 | Yes | +| FullName | aarongao | string | 全名 | Yes | | Code | 12345678 | string | 6位验证码 | Yes | | Mobile | 18616619599 | string | 手机,同用户名 | Yes | | Sex | 男 | string | 性别 | Yes | -- libgit2 0.21.0