From 248adced010768aa7bd5088599dfa5da4ef7af39 Mon Sep 17 00:00:00 2001 From: aarongao Date: Tue, 4 Feb 2020 10:05:32 +0800 Subject: [PATCH] 大小写 --- API/Complaint.go | 38 +++++++++++++++++++------------------- API/User.go | 62 +++++++++++++++++++++++++++++++------------------------------- README.md | 36 ++++++++++++++++++------------------ 3 files changed, 68 insertions(+), 68 deletions(-) diff --git a/API/Complaint.go b/API/Complaint.go index abee3a1..965f7fd 100644 --- a/API/Complaint.go +++ b/API/Complaint.go @@ -12,14 +12,14 @@ import ( // @Description 增加投诉 // @Accept json // @Produce json -// @Param mobile 18616619599 string true "联系电话" -// @Param name 高先生 string true "姓名" -// @Param code 123456 string true "验证码" -// @Param sex 男 string true "性别" -// @Param scenicid 5e1ed07524e03431008b4572 string true "景区id" -// @Param type 1 string true "类型" -// @Param content 卫生不干净 string true "投诉内容" -// @Param image ["http://www.xx.com/123.jpg","http://www.xx.com/123.jpg"] string true "照片数组" +// @Param Mobile 18616619599 string true "联系电话" +// @Param Name 高先生 string true "姓名" +// @Param Code 123456 string true "验证码" +// @Param Sex 男 string true "性别" +// @Param ScenicId 5e1ed07524e03431008b4572 string true "景区id" +// @Param Type 1 string true "类型" +// @Param Content 卫生不干净 string true "投诉内容" +// @Param Image ["http://www.xx.com/123.jpg","http://www.xx.com/123.jpg"] string true "照片数组" // @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}" // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" // @Router /CreateComplaint? [post] @@ -30,7 +30,7 @@ func CreateComplaint(c *gin.Context) { reg := regexp.MustCompile(Regular) - if !reg.MatchString(c.PostForm("mobile")) { + if !reg.MatchString(c.PostForm("Mobile")) { c.JSON(200, tools.ResponseError{ 1, @@ -39,7 +39,7 @@ func CreateComplaint(c *gin.Context) { return } - if c.PostForm("mobile") == ""{ + if c.PostForm("Mobile") == ""{ c.JSON(200, tools.ResponseError{ 1, "手机号为空", @@ -49,8 +49,8 @@ func CreateComplaint(c *gin.Context) { // 检查验证码 - cacheCode := DB.Redis.Get(c.PostForm("mobile")) - if cacheCode != c.PostForm("code") { + cacheCode := DB.Redis.Get(c.PostForm("Mobile")) + if cacheCode != c.PostForm("Code") { c.JSON(200, tools.ResponseError{ 1, @@ -67,15 +67,15 @@ func CreateComplaint(c *gin.Context) { var images []string - json.Unmarshal([]byte(c.PostForm("image")), &images) + json.Unmarshal([]byte(c.PostForm("Image")), &images) DB.CComplaint.Insert(DB.SComplaint{ - c.PostForm("type"), - c.PostForm("scenicid"), - c.PostForm("mobile"), - c.PostForm("name"), - c.PostForm("sex"), - c.PostForm("content"), + c.PostForm("Type"), + c.PostForm("ScenicId"), + c.PostForm("Mobile"), + c.PostForm("Name"), + c.PostForm("Sex"), + c.PostForm("Content"), images, }) diff --git a/API/User.go b/API/User.go index a1ed1d8..bbb3134 100644 --- a/API/User.go +++ b/API/User.go @@ -87,8 +87,8 @@ var Regular = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|1 // @Description 用户登录&注册 // @Accept json // @Produce json -// @Param mobile aaron string true "手机号" -// @Param password 1 string true "密码或验证码(使用验证码的新手机号自动注册)" +// @Param Mobile aaron string true "手机号" +// @Param Password 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] @@ -97,7 +97,7 @@ func LoginUser(c *gin.Context) { c.Header("Access-Control-Allow-Credentials", "true") reg := regexp.MustCompile(Regular) - if !reg.MatchString(c.PostForm("mobile")) { + if !reg.MatchString(c.PostForm("Mobile")) { c.JSON(200, tools.ResponseError{ 1, @@ -106,7 +106,7 @@ func LoginUser(c *gin.Context) { return } - if c.PostForm("mobile") == "" || c.PostForm("password") == "" { + if c.PostForm("Mobile") == "" || c.PostForm("Password") == "" { c.JSON(200, tools.ResponseError{ 1, "空", @@ -115,15 +115,15 @@ func LoginUser(c *gin.Context) { } // 生成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("Password") + strconv.FormatInt(time.Now().UnixNano(), 10))) token := hex.EncodeToString(tokenunit8[:32]) // 检查验证码 - cacheCode := DB.Redis.Get(c.PostForm("mobile")) + cacheCode := DB.Redis.Get(c.PostForm("Mobile")) selected := bson.M{} var User *DB.SMember - if cacheCode == c.PostForm("password") { - selected["Mobile"] = c.PostForm("mobile") + if cacheCode == c.PostForm("Password") { + selected["Mobile"] = c.PostForm("Mobile") DB.CMember.Find(selected).One(&User) // 验证码匹配,但手机号不存在 @@ -134,7 +134,7 @@ func LoginUser(c *gin.Context) { "", "", "", - c.PostForm("mobile"), + c.PostForm("Mobile"), "", token, "", @@ -150,8 +150,8 @@ func LoginUser(c *gin.Context) { } } else { - selected["Mobile"] = c.PostForm("mobile") - selected["Password"] = c.PostForm("password") + selected["Mobile"] = c.PostForm("Mobile") + selected["Password"] = c.PostForm("Password") DB.CMember.Find(selected).One(&User) if User == nil { c.JSON(200, tools.ResponseError{ @@ -210,14 +210,14 @@ 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 code 12345678 string true "6位验证码" -// @Param mobile 18616619599 string true "手机,同用户名" -// @Param sex 男 string true "性别" -// @Param openid 12345 string true "微信id" +// @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 Sex 男 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 /UpdateUser? [post] @@ -226,7 +226,7 @@ func UpdateUser(c *gin.Context) { c.Header("Access-Control-Allow-Credentials", "true") reg := regexp.MustCompile(Regular) - if !reg.MatchString(c.PostForm("mobile")) { + if !reg.MatchString(c.PostForm("Mobile")) { c.JSON(200, tools.ResponseError{ 1, @@ -235,7 +235,7 @@ func UpdateUser(c *gin.Context) { return } - if c.PostForm("mobile") == "" || c.PostForm("password") == "" { + if c.PostForm("Mobile") == "" || c.PostForm("Password") == "" { c.JSON(200, tools.ResponseError{ 1, "手机号或密码为空", @@ -243,7 +243,7 @@ func UpdateUser(c *gin.Context) { return } - if c.PostForm("password") != c.PostForm("confirmpassword") { + if c.PostForm("Password") != c.PostForm("ConfirmPassword") { c.JSON(200, tools.ResponseError{ 1, "2次密码不一致", @@ -252,8 +252,8 @@ func UpdateUser(c *gin.Context) { } // 检查验证码 - code := DB.Redis.Get(c.PostForm("mobile")) - if code == "" || code != c.PostForm("code") { + code := DB.Redis.Get(c.PostForm("Mobile")) + if code == "" || code != c.PostForm("Code") { c.JSON(200, tools.ResponseError{ 1, "验证码错误", @@ -262,20 +262,20 @@ func UpdateUser(c *gin.Context) { } err := DB.CMember.Update( - bson.M{"Mobile": c.PostForm("mobile")}, + bson.M{"Mobile": c.PostForm("Mobile")}, bson.M{"$set": bson.M{ - "Password": c.PostForm("password"), - "Birthday": c.PostForm("birthday"), - "FullName": c.PostForm("fullname"), - "Mobile": c.PostForm("mobile"), - "Sex": c.PostForm("sex"), + "Password": c.PostForm("Password"), + "Birthday": c.PostForm("Birthday"), + "FullName": c.PostForm("Fullname"), + "Mobile": c.PostForm("Mobile"), + "Sex": c.PostForm("Sex"), }}, ) if err == nil { var User *DB.SMember - DB.CMember.Find(bson.M{"Mobile": c.PostForm("mobile")}).One(&User) + DB.CMember.Find(bson.M{"Mobile": c.PostForm("Mobile")}).One(&User) c.JSON(200, tools.ResponseSeccess{ 0, diff --git a/README.md b/README.md index 19713f3..a2e0cd0 100644 --- a/README.md +++ b/README.md @@ -120,14 +120,14 @@ | Param Name | Example | Data Type | Description | Required? | |-----|-----|-----|-----|-----| -| mobile | 18616619599 | string | 联系电话 | Yes | -| name | 高先生 | string | 姓名 | Yes | -| code | 123456 | string | 验证码 | Yes | -| sex | 男 | string | 性别 | Yes | -| scenicid | 5e1ed07524e03431008b4572 | string | 景区id | Yes | -| type | 1 | string | 类型 | Yes | -| content | 卫生不干净 | string | 投诉内容 | Yes | -| image | ["http://www.xx.com/123.jpg","http://www.xx.com/123.jpg"] | string | 照片数组 | Yes | +| Mobile | 18616619599 | string | 联系电话 | Yes | +| Name | 高先生 | string | 姓名 | Yes | +| Code | 123456 | string | 验证码 | Yes | +| Sex | 男 | string | 性别 | Yes | +| ScenicId | 5e1ed07524e03431008b4572 | string | 景区id | Yes | +| Type | 1 | string | 类型 | Yes | +| Content | 卫生不干净 | string | 投诉内容 | Yes | +| Image | ["http://www.xx.com/123.jpg","http://www.xx.com/123.jpg"] | string | 照片数组 | Yes | | Code | Type | Model | Message | @@ -271,8 +271,8 @@ | Param Name | Example | Data Type | Description | Required? | |-----|-----|-----|-----|-----| -| mobile | aaron | string | 手机号 | Yes | -| password | 1 | string | 密码或验证码(使用验证码的新手机号自动注册) | Yes | +| Mobile | aaron | string | 手机号 | Yes | +| Password | 1 | string | 密码或验证码(使用验证码的新手机号自动注册) | Yes | | Code | Type | Model | Message | @@ -444,14 +444,14 @@ | 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 | -| code | 12345678 | string | 6位验证码 | Yes | -| mobile | 18616619599 | string | 手机,同用户名 | Yes | -| sex | 男 | string | 性别 | Yes | -| openid | 12345 | string | 微信id | Yes | +| Password | 1 | string | 密码 | Yes | +| ConfirmPassword | 1 | string | 确认密码 | Yes | +| Birthday | 2010.10.10 | string | 生日 | Yes | +| Fullname | aarongao | string | 全名 | Yes | +| Code | 12345678 | string | 6位验证码 | Yes | +| Mobile | 18616619599 | string | 手机,同用户名 | Yes | +| Sex | 男 | string | 性别 | Yes | +| Openid | 12345 | string | 微信id | Yes | | Code | Type | Model | Message | -- libgit2 0.21.0