Commit 248adced010768aa7bd5088599dfa5da4ef7af39
1 parent
9ecec7d4
Exists in
v1.2
and in
2 other branches
大小写
Showing
3 changed files
with
68 additions
and
68 deletions
Show diff stats
API/Complaint.go
| @@ -12,14 +12,14 @@ import ( | @@ -12,14 +12,14 @@ import ( | ||
| 12 | // @Description 增加投诉 | 12 | // @Description 增加投诉 |
| 13 | // @Accept json | 13 | // @Accept json |
| 14 | // @Produce json | 14 | // @Produce json |
| 15 | -// @Param mobile 18616619599 string true "联系电话" | ||
| 16 | -// @Param name 高先生 string true "姓名" | ||
| 17 | -// @Param code 123456 string true "验证码" | ||
| 18 | -// @Param sex 男 string true "性别" | ||
| 19 | -// @Param scenicid 5e1ed07524e03431008b4572 string true "景区id" | ||
| 20 | -// @Param type 1 string true "类型" | ||
| 21 | -// @Param content 卫生不干净 string true "投诉内容" | ||
| 22 | -// @Param image ["http://www.xx.com/123.jpg","http://www.xx.com/123.jpg"] string true "照片数组" | 15 | +// @Param Mobile 18616619599 string true "联系电话" |
| 16 | +// @Param Name 高先生 string true "姓名" | ||
| 17 | +// @Param Code 123456 string true "验证码" | ||
| 18 | +// @Param Sex 男 string true "性别" | ||
| 19 | +// @Param ScenicId 5e1ed07524e03431008b4572 string true "景区id" | ||
| 20 | +// @Param Type 1 string true "类型" | ||
| 21 | +// @Param Content 卫生不干净 string true "投诉内容" | ||
| 22 | +// @Param Image ["http://www.xx.com/123.jpg","http://www.xx.com/123.jpg"] string true "照片数组" | ||
| 23 | // @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}" | 23 | // @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}" |
| 24 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | 24 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" |
| 25 | // @Router /CreateComplaint? [post] | 25 | // @Router /CreateComplaint? [post] |
| @@ -30,7 +30,7 @@ func CreateComplaint(c *gin.Context) { | @@ -30,7 +30,7 @@ func CreateComplaint(c *gin.Context) { | ||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | reg := regexp.MustCompile(Regular) | 32 | reg := regexp.MustCompile(Regular) |
| 33 | - if !reg.MatchString(c.PostForm("mobile")) { | 33 | + if !reg.MatchString(c.PostForm("Mobile")) { |
| 34 | 34 | ||
| 35 | c.JSON(200, tools.ResponseError{ | 35 | c.JSON(200, tools.ResponseError{ |
| 36 | 1, | 36 | 1, |
| @@ -39,7 +39,7 @@ func CreateComplaint(c *gin.Context) { | @@ -39,7 +39,7 @@ func CreateComplaint(c *gin.Context) { | ||
| 39 | return | 39 | return |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | - if c.PostForm("mobile") == ""{ | 42 | + if c.PostForm("Mobile") == ""{ |
| 43 | c.JSON(200, tools.ResponseError{ | 43 | c.JSON(200, tools.ResponseError{ |
| 44 | 1, | 44 | 1, |
| 45 | "手机号为空", | 45 | "手机号为空", |
| @@ -49,8 +49,8 @@ func CreateComplaint(c *gin.Context) { | @@ -49,8 +49,8 @@ func CreateComplaint(c *gin.Context) { | ||
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | // 检查验证码 | 51 | // 检查验证码 |
| 52 | - cacheCode := DB.Redis.Get(c.PostForm("mobile")) | ||
| 53 | - if cacheCode != c.PostForm("code") { | 52 | + cacheCode := DB.Redis.Get(c.PostForm("Mobile")) |
| 53 | + if cacheCode != c.PostForm("Code") { | ||
| 54 | 54 | ||
| 55 | c.JSON(200, tools.ResponseError{ | 55 | c.JSON(200, tools.ResponseError{ |
| 56 | 1, | 56 | 1, |
| @@ -67,15 +67,15 @@ func CreateComplaint(c *gin.Context) { | @@ -67,15 +67,15 @@ func CreateComplaint(c *gin.Context) { | ||
| 67 | 67 | ||
| 68 | var images []string | 68 | var images []string |
| 69 | 69 | ||
| 70 | - json.Unmarshal([]byte(c.PostForm("image")), &images) | 70 | + json.Unmarshal([]byte(c.PostForm("Image")), &images) |
| 71 | 71 | ||
| 72 | DB.CComplaint.Insert(DB.SComplaint{ | 72 | DB.CComplaint.Insert(DB.SComplaint{ |
| 73 | - c.PostForm("type"), | ||
| 74 | - c.PostForm("scenicid"), | ||
| 75 | - c.PostForm("mobile"), | ||
| 76 | - c.PostForm("name"), | ||
| 77 | - c.PostForm("sex"), | ||
| 78 | - c.PostForm("content"), | 73 | + c.PostForm("Type"), |
| 74 | + c.PostForm("ScenicId"), | ||
| 75 | + c.PostForm("Mobile"), | ||
| 76 | + c.PostForm("Name"), | ||
| 77 | + c.PostForm("Sex"), | ||
| 78 | + c.PostForm("Content"), | ||
| 79 | images, | 79 | images, |
| 80 | }) | 80 | }) |
| 81 | 81 |
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 | @@ -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 | ||
| 87 | // @Description 用户登录&注册 | 87 | // @Description 用户登录&注册 |
| 88 | // @Accept json | 88 | // @Accept json |
| 89 | // @Produce json | 89 | // @Produce json |
| 90 | -// @Param mobile aaron string true "手机号" | ||
| 91 | -// @Param password 1 string true "密码或验证码(使用验证码的新手机号自动注册)" | 90 | +// @Param Mobile aaron string true "手机号" |
| 91 | +// @Param Password 1 string true "密码或验证码(使用验证码的新手机号自动注册)" | ||
| 92 | // @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":{"Id":"5e09c64c1c09c6f0f7ca2fa9","Token":"640bf934e425aba5d3c90998b2641f2f0ca07261d334d9615d1cd4790b5f34e7"}} 调用其它需要登陆的接口时携带token,有过期时间" | 92 | // @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":{"Id":"5e09c64c1c09c6f0f7ca2fa9","Token":"640bf934e425aba5d3c90998b2641f2f0ca07261d334d9615d1cd4790b5f34e7"}} 调用其它需要登陆的接口时携带token,有过期时间" |
| 93 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | 93 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" |
| 94 | // @Router /LoginUser? [post] | 94 | // @Router /LoginUser? [post] |
| @@ -97,7 +97,7 @@ func LoginUser(c *gin.Context) { | @@ -97,7 +97,7 @@ func LoginUser(c *gin.Context) { | ||
| 97 | c.Header("Access-Control-Allow-Credentials", "true") | 97 | c.Header("Access-Control-Allow-Credentials", "true") |
| 98 | 98 | ||
| 99 | reg := regexp.MustCompile(Regular) | 99 | reg := regexp.MustCompile(Regular) |
| 100 | - if !reg.MatchString(c.PostForm("mobile")) { | 100 | + if !reg.MatchString(c.PostForm("Mobile")) { |
| 101 | 101 | ||
| 102 | c.JSON(200, tools.ResponseError{ | 102 | c.JSON(200, tools.ResponseError{ |
| 103 | 1, | 103 | 1, |
| @@ -106,7 +106,7 @@ func LoginUser(c *gin.Context) { | @@ -106,7 +106,7 @@ func LoginUser(c *gin.Context) { | ||
| 106 | return | 106 | return |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | - if c.PostForm("mobile") == "" || c.PostForm("password") == "" { | 109 | + if c.PostForm("Mobile") == "" || c.PostForm("Password") == "" { |
| 110 | c.JSON(200, tools.ResponseError{ | 110 | c.JSON(200, tools.ResponseError{ |
| 111 | 1, | 111 | 1, |
| 112 | "空", | 112 | "空", |
| @@ -115,15 +115,15 @@ func LoginUser(c *gin.Context) { | @@ -115,15 +115,15 @@ func LoginUser(c *gin.Context) { | ||
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | // 生成token | 117 | // 生成token |
| 118 | - tokenunit8 := sha256.Sum256([]byte(c.PostForm("mobile") + c.PostForm("password") + strconv.FormatInt(time.Now().UnixNano(), 10))) | 118 | + tokenunit8 := sha256.Sum256([]byte(c.PostForm("Mobile") + c.PostForm("Password") + strconv.FormatInt(time.Now().UnixNano(), 10))) |
| 119 | token := hex.EncodeToString(tokenunit8[:32]) | 119 | token := hex.EncodeToString(tokenunit8[:32]) |
| 120 | 120 | ||
| 121 | // 检查验证码 | 121 | // 检查验证码 |
| 122 | - cacheCode := DB.Redis.Get(c.PostForm("mobile")) | 122 | + cacheCode := DB.Redis.Get(c.PostForm("Mobile")) |
| 123 | selected := bson.M{} | 123 | selected := bson.M{} |
| 124 | var User *DB.SMember | 124 | var User *DB.SMember |
| 125 | - if cacheCode == c.PostForm("password") { | ||
| 126 | - selected["Mobile"] = c.PostForm("mobile") | 125 | + if cacheCode == c.PostForm("Password") { |
| 126 | + selected["Mobile"] = c.PostForm("Mobile") | ||
| 127 | DB.CMember.Find(selected).One(&User) | 127 | DB.CMember.Find(selected).One(&User) |
| 128 | 128 | ||
| 129 | // 验证码匹配,但手机号不存在 | 129 | // 验证码匹配,但手机号不存在 |
| @@ -134,7 +134,7 @@ func LoginUser(c *gin.Context) { | @@ -134,7 +134,7 @@ func LoginUser(c *gin.Context) { | ||
| 134 | "", | 134 | "", |
| 135 | "", | 135 | "", |
| 136 | "", | 136 | "", |
| 137 | - c.PostForm("mobile"), | 137 | + c.PostForm("Mobile"), |
| 138 | "", | 138 | "", |
| 139 | token, | 139 | token, |
| 140 | "", | 140 | "", |
| @@ -150,8 +150,8 @@ func LoginUser(c *gin.Context) { | @@ -150,8 +150,8 @@ func LoginUser(c *gin.Context) { | ||
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | } else { | 152 | } else { |
| 153 | - selected["Mobile"] = c.PostForm("mobile") | ||
| 154 | - selected["Password"] = c.PostForm("password") | 153 | + selected["Mobile"] = c.PostForm("Mobile") |
| 154 | + selected["Password"] = c.PostForm("Password") | ||
| 155 | DB.CMember.Find(selected).One(&User) | 155 | DB.CMember.Find(selected).One(&User) |
| 156 | if User == nil { | 156 | if User == nil { |
| 157 | c.JSON(200, tools.ResponseError{ | 157 | c.JSON(200, tools.ResponseError{ |
| @@ -210,14 +210,14 @@ func UserInfo(c *gin.Context) { | @@ -210,14 +210,14 @@ func UserInfo(c *gin.Context) { | ||
| 210 | // @Description 修改用户信息 | 210 | // @Description 修改用户信息 |
| 211 | // @Accept json | 211 | // @Accept json |
| 212 | // @Produce json | 212 | // @Produce json |
| 213 | -// @Param password 1 string true "密码" | ||
| 214 | -// @Param confirmpassword 1 string true "确认密码" | ||
| 215 | -// @Param birthday 2010.10.10 string true "生日" | ||
| 216 | -// @Param fullname aarongao string true "全名" | ||
| 217 | -// @Param code 12345678 string true "6位验证码" | ||
| 218 | -// @Param mobile 18616619599 string true "手机,同用户名" | ||
| 219 | -// @Param sex 男 string true "性别" | ||
| 220 | -// @Param openid 12345 string true "微信id" | 213 | +// @Param Password 1 string true "密码" |
| 214 | +// @Param ConfirmPassword 1 string true "确认密码" | ||
| 215 | +// @Param Birthday 2010.10.10 string true "生日" | ||
| 216 | +// @Param Fullname aarongao string true "全名" | ||
| 217 | +// @Param Code 12345678 string true "6位验证码" | ||
| 218 | +// @Param Mobile 18616619599 string true "手机,同用户名" | ||
| 219 | +// @Param Sex 男 string true "性别" | ||
| 220 | +// @Param Openid 12345 string true "微信id" | ||
| 221 | // @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}" | 221 | // @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}" |
| 222 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | 222 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" |
| 223 | // @Router /UpdateUser? [post] | 223 | // @Router /UpdateUser? [post] |
| @@ -226,7 +226,7 @@ func UpdateUser(c *gin.Context) { | @@ -226,7 +226,7 @@ func UpdateUser(c *gin.Context) { | ||
| 226 | c.Header("Access-Control-Allow-Credentials", "true") | 226 | c.Header("Access-Control-Allow-Credentials", "true") |
| 227 | 227 | ||
| 228 | reg := regexp.MustCompile(Regular) | 228 | reg := regexp.MustCompile(Regular) |
| 229 | - if !reg.MatchString(c.PostForm("mobile")) { | 229 | + if !reg.MatchString(c.PostForm("Mobile")) { |
| 230 | 230 | ||
| 231 | c.JSON(200, tools.ResponseError{ | 231 | c.JSON(200, tools.ResponseError{ |
| 232 | 1, | 232 | 1, |
| @@ -235,7 +235,7 @@ func UpdateUser(c *gin.Context) { | @@ -235,7 +235,7 @@ func UpdateUser(c *gin.Context) { | ||
| 235 | return | 235 | return |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | - if c.PostForm("mobile") == "" || c.PostForm("password") == "" { | 238 | + if c.PostForm("Mobile") == "" || c.PostForm("Password") == "" { |
| 239 | c.JSON(200, tools.ResponseError{ | 239 | c.JSON(200, tools.ResponseError{ |
| 240 | 1, | 240 | 1, |
| 241 | "手机号或密码为空", | 241 | "手机号或密码为空", |
| @@ -243,7 +243,7 @@ func UpdateUser(c *gin.Context) { | @@ -243,7 +243,7 @@ func UpdateUser(c *gin.Context) { | ||
| 243 | return | 243 | return |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | - if c.PostForm("password") != c.PostForm("confirmpassword") { | 246 | + if c.PostForm("Password") != c.PostForm("ConfirmPassword") { |
| 247 | c.JSON(200, tools.ResponseError{ | 247 | c.JSON(200, tools.ResponseError{ |
| 248 | 1, | 248 | 1, |
| 249 | "2次密码不一致", | 249 | "2次密码不一致", |
| @@ -252,8 +252,8 @@ func UpdateUser(c *gin.Context) { | @@ -252,8 +252,8 @@ func UpdateUser(c *gin.Context) { | ||
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | // 检查验证码 | 254 | // 检查验证码 |
| 255 | - code := DB.Redis.Get(c.PostForm("mobile")) | ||
| 256 | - if code == "" || code != c.PostForm("code") { | 255 | + code := DB.Redis.Get(c.PostForm("Mobile")) |
| 256 | + if code == "" || code != c.PostForm("Code") { | ||
| 257 | c.JSON(200, tools.ResponseError{ | 257 | c.JSON(200, tools.ResponseError{ |
| 258 | 1, | 258 | 1, |
| 259 | "验证码错误", | 259 | "验证码错误", |
| @@ -262,20 +262,20 @@ func UpdateUser(c *gin.Context) { | @@ -262,20 +262,20 @@ func UpdateUser(c *gin.Context) { | ||
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | err := DB.CMember.Update( | 264 | err := DB.CMember.Update( |
| 265 | - bson.M{"Mobile": c.PostForm("mobile")}, | 265 | + bson.M{"Mobile": c.PostForm("Mobile")}, |
| 266 | bson.M{"$set": bson.M{ | 266 | bson.M{"$set": bson.M{ |
| 267 | - "Password": c.PostForm("password"), | ||
| 268 | - "Birthday": c.PostForm("birthday"), | ||
| 269 | - "FullName": c.PostForm("fullname"), | ||
| 270 | - "Mobile": c.PostForm("mobile"), | ||
| 271 | - "Sex": c.PostForm("sex"), | 267 | + "Password": c.PostForm("Password"), |
| 268 | + "Birthday": c.PostForm("Birthday"), | ||
| 269 | + "FullName": c.PostForm("Fullname"), | ||
| 270 | + "Mobile": c.PostForm("Mobile"), | ||
| 271 | + "Sex": c.PostForm("Sex"), | ||
| 272 | }}, | 272 | }}, |
| 273 | ) | 273 | ) |
| 274 | 274 | ||
| 275 | if err == nil { | 275 | if err == nil { |
| 276 | 276 | ||
| 277 | var User *DB.SMember | 277 | var User *DB.SMember |
| 278 | - DB.CMember.Find(bson.M{"Mobile": c.PostForm("mobile")}).One(&User) | 278 | + DB.CMember.Find(bson.M{"Mobile": c.PostForm("Mobile")}).One(&User) |
| 279 | 279 | ||
| 280 | c.JSON(200, tools.ResponseSeccess{ | 280 | c.JSON(200, tools.ResponseSeccess{ |
| 281 | 0, | 281 | 0, |
README.md
| @@ -120,14 +120,14 @@ | @@ -120,14 +120,14 @@ | ||
| 120 | 120 | ||
| 121 | | Param Name | Example | Data Type | Description | Required? | | 121 | | Param Name | Example | Data Type | Description | Required? | |
| 122 | |-----|-----|-----|-----|-----| | 122 | |-----|-----|-----|-----|-----| |
| 123 | -| mobile | 18616619599 | string | 联系电话 | Yes | | ||
| 124 | -| name | 高先生 | string | 姓名 | Yes | | ||
| 125 | -| code | 123456 | string | 验证码 | Yes | | ||
| 126 | -| sex | 男 | string | 性别 | Yes | | ||
| 127 | -| scenicid | 5e1ed07524e03431008b4572 | string | 景区id | Yes | | ||
| 128 | -| type | 1 | string | 类型 | Yes | | ||
| 129 | -| content | 卫生不干净 | string | 投诉内容 | Yes | | ||
| 130 | -| image | ["http://www.xx.com/123.jpg","http://www.xx.com/123.jpg"] | string | 照片数组 | Yes | | 123 | +| Mobile | 18616619599 | string | 联系电话 | Yes | |
| 124 | +| Name | 高先生 | string | 姓名 | Yes | | ||
| 125 | +| Code | 123456 | string | 验证码 | Yes | | ||
| 126 | +| Sex | 男 | string | 性别 | Yes | | ||
| 127 | +| ScenicId | 5e1ed07524e03431008b4572 | string | 景区id | Yes | | ||
| 128 | +| Type | 1 | string | 类型 | Yes | | ||
| 129 | +| Content | 卫生不干净 | string | 投诉内容 | Yes | | ||
| 130 | +| Image | ["http://www.xx.com/123.jpg","http://www.xx.com/123.jpg"] | string | 照片数组 | Yes | | ||
| 131 | 131 | ||
| 132 | 132 | ||
| 133 | | Code | Type | Model | Message | | 133 | | Code | Type | Model | Message | |
| @@ -271,8 +271,8 @@ | @@ -271,8 +271,8 @@ | ||
| 271 | 271 | ||
| 272 | | Param Name | Example | Data Type | Description | Required? | | 272 | | Param Name | Example | Data Type | Description | Required? | |
| 273 | |-----|-----|-----|-----|-----| | 273 | |-----|-----|-----|-----|-----| |
| 274 | -| mobile | aaron | string | 手机号 | Yes | | ||
| 275 | -| password | 1 | string | 密码或验证码(使用验证码的新手机号自动注册) | Yes | | 274 | +| Mobile | aaron | string | 手机号 | Yes | |
| 275 | +| Password | 1 | string | 密码或验证码(使用验证码的新手机号自动注册) | Yes | | ||
| 276 | 276 | ||
| 277 | 277 | ||
| 278 | | Code | Type | Model | Message | | 278 | | Code | Type | Model | Message | |
| @@ -444,14 +444,14 @@ | @@ -444,14 +444,14 @@ | ||
| 444 | 444 | ||
| 445 | | Param Name | Example | Data Type | Description | Required? | | 445 | | Param Name | Example | Data Type | Description | Required? | |
| 446 | |-----|-----|-----|-----|-----| | 446 | |-----|-----|-----|-----|-----| |
| 447 | -| password | 1 | string | 密码 | Yes | | ||
| 448 | -| confirmpassword | 1 | string | 确认密码 | Yes | | ||
| 449 | -| birthday | 2010.10.10 | string | 生日 | Yes | | ||
| 450 | -| fullname | aarongao | string | 全名 | Yes | | ||
| 451 | -| code | 12345678 | string | 6位验证码 | Yes | | ||
| 452 | -| mobile | 18616619599 | string | 手机,同用户名 | Yes | | ||
| 453 | -| sex | 男 | string | 性别 | Yes | | ||
| 454 | -| openid | 12345 | string | 微信id | Yes | | 447 | +| Password | 1 | string | 密码 | Yes | |
| 448 | +| ConfirmPassword | 1 | string | 确认密码 | Yes | | ||
| 449 | +| Birthday | 2010.10.10 | string | 生日 | Yes | | ||
| 450 | +| Fullname | aarongao | string | 全名 | Yes | | ||
| 451 | +| Code | 12345678 | string | 6位验证码 | Yes | | ||
| 452 | +| Mobile | 18616619599 | string | 手机,同用户名 | Yes | | ||
| 453 | +| Sex | 男 | string | 性别 | Yes | | ||
| 454 | +| Openid | 12345 | string | 微信id | Yes | | ||
| 455 | 455 | ||
| 456 | 456 | ||
| 457 | | Code | Type | Model | Message | | 457 | | Code | Type | Model | Message | |