Commit e4cd450a42e1538d63e154164cee0bbbf0a035b1
1 parent
57d9acaf
Exists in
v1.2
and in
2 other branches
..
Showing
4 changed files
with
33 additions
and
100 deletions
Show diff stats
API/Scenic.go
... | ... | @@ -13,7 +13,7 @@ import ( |
13 | 13 | // @Accept json |
14 | 14 | // @Produce json |
15 | 15 | // @Param id 5dfb03070a9ac17ac7a82054 string true "景区id" |
16 | -// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频" | |
16 | +// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片)" | |
17 | 17 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" |
18 | 18 | // @Router /ScenicInfo? [get] |
19 | 19 | func ScenicInfo(c *gin.Context) { |
... | ... | @@ -43,7 +43,7 @@ func ScenicInfo(c *gin.Context) { |
43 | 43 | // @Accept json |
44 | 44 | // @Produce json |
45 | 45 | // @Param id 5dfb03070a9ac17ac7a82054 string true "景区id" |
46 | -// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频" | |
46 | +// @Success 200 {object} tools.ResponseSeccess "Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片)" | |
47 | 47 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" |
48 | 48 | // @Router /UpdateScenic? [post] |
49 | 49 | func UpdateScenic(c *gin.Context) { |
... | ... | @@ -65,7 +65,7 @@ func UpdateScenic(c *gin.Context) { |
65 | 65 | var ActivityPicture []DB.SPicture |
66 | 66 | json.Unmarshal([]byte(c.PostForm("ActivityPicture")), &ActivityPicture) |
67 | 67 | |
68 | - var VideoList []DB.SPicture | |
68 | + var VideoList []DB.SVideo | |
69 | 69 | json.Unmarshal([]byte(c.PostForm("VideoList")), &VideoList) |
70 | 70 | |
71 | 71 | ... | ... |
API/User.go
... | ... | @@ -12,74 +12,6 @@ import ( |
12 | 12 | "time" |
13 | 13 | ) |
14 | 14 | |
15 | -// | |
16 | -//// @Title 创建用户 | |
17 | -//// @Description 用户注册 | |
18 | -//// @Accept json | |
19 | -//// @Produce json | |
20 | -//// @Param password 1 string true "密码" | |
21 | -//// @Param confirmpassword 1 string true "确认密码" | |
22 | -//// @Param birthday 2010.10.10 string true "生日" | |
23 | -//// @Param fullname aarongao string true "全名" | |
24 | -//// @Param code 12345678 string true "6位验证码" | |
25 | -//// @Param mobile 18616619599 string true "手机,同用户名" | |
26 | -//// @Param openid 12345 string true "微信id" | |
27 | -//// @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":"ok"}" | |
28 | -//// @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | |
29 | -//// @Router /CreateUser? [post] | |
30 | -//func CreateUser(c *gin.Context) { | |
31 | -// c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("Origin")) | |
32 | -// c.Header("Access-Control-Allow-Credentials", "true") | |
33 | -// | |
34 | -// if c.PostForm("mobile") == "" { | |
35 | -// c.JSON(200, tools.ResponseError{ | |
36 | -// 1, | |
37 | -// "必须有手机号", | |
38 | -// }) | |
39 | -// return | |
40 | -// } | |
41 | -// if c.PostForm("password") != c.PostForm("confirmpassword") { | |
42 | -// c.JSON(200, tools.ResponseError{ | |
43 | -// 1, | |
44 | -// "密码错误", | |
45 | -// }) | |
46 | -// return | |
47 | -// } | |
48 | -// | |
49 | -// // 检查验证码 | |
50 | -// code := DB.Redis.Get(c.PostForm("mobile")) | |
51 | -// if code == "" || code != c.PostForm("code") { | |
52 | -// c.JSON(200, tools.ResponseError{ | |
53 | -// 1, | |
54 | -// "验证码错误", | |
55 | -// }) | |
56 | -// return | |
57 | -// } | |
58 | -// | |
59 | -// objectID := bson.NewObjectId() | |
60 | -// err := DB.CMember.Insert(DB.SMember{ | |
61 | -// &objectID, | |
62 | -// c.PostForm("password"), | |
63 | -// c.PostForm("birthday"), | |
64 | -// c.PostForm("fullname"), | |
65 | -// c.PostForm("mobile"), | |
66 | -// c.PostForm("openid"), | |
67 | -// "", | |
68 | -// }) | |
69 | -// if err == nil{ | |
70 | -// c.JSON(200, tools.ResponseSeccess{ | |
71 | -// 0, | |
72 | -// "ok", | |
73 | -// }) | |
74 | -// }else{ | |
75 | -// c.JSON(200, tools.ResponseError{ | |
76 | -// 0, | |
77 | -// "此手机号已经注册", | |
78 | -// }) | |
79 | -// } | |
80 | -// | |
81 | -// | |
82 | -//} | |
83 | 15 | |
84 | 16 | 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}$" |
85 | 17 | |
... | ... | @@ -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 |
88 | 20 | // @Accept json |
89 | 21 | // @Produce json |
90 | 22 | // @Param Mobile aaron string true "手机号" |
91 | -// @Param Password 1 string true "密码或验证码(使用验证码的新手机号自动注册)" | |
23 | +// @Param Code 1 string true "验证码(使用验证码的新手机号自动注册)" | |
92 | 24 | // @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":{"Id":"5e09c64c1c09c6f0f7ca2fa9","Token":"640bf934e425aba5d3c90998b2641f2f0ca07261d334d9615d1cd4790b5f34e7"}} 调用其它需要登陆的接口时携带token,有过期时间" |
93 | 25 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" |
94 | 26 | // @Router /LoginUser? [post] |
... | ... | @@ -106,23 +38,23 @@ func LoginUser(c *gin.Context) { |
106 | 38 | return |
107 | 39 | } |
108 | 40 | |
109 | - if c.PostForm("Mobile") == "" || c.PostForm("Password") == "" { | |
41 | + if c.PostForm("Mobile") == "" || c.PostForm("Code") == "" { | |
110 | 42 | c.JSON(200, tools.ResponseError{ |
111 | 43 | 1, |
112 | - "空", | |
44 | + "手机号和验证码不能空", | |
113 | 45 | }) |
114 | 46 | return |
115 | 47 | } |
116 | 48 | |
117 | 49 | // 生成token |
118 | - tokenunit8 := sha256.Sum256([]byte(c.PostForm("Mobile") + c.PostForm("Password") + strconv.FormatInt(time.Now().UnixNano(), 10))) | |
50 | + tokenunit8 := sha256.Sum256([]byte(c.PostForm("Mobile") + c.PostForm("Code") + strconv.FormatInt(time.Now().UnixNano(), 10))) | |
119 | 51 | token := hex.EncodeToString(tokenunit8[:32]) |
120 | 52 | |
121 | 53 | // 检查验证码 |
122 | 54 | cacheCode := DB.Redis.Get(c.PostForm("Mobile")) |
123 | 55 | selected := bson.M{} |
124 | 56 | var User *DB.SMember |
125 | - if cacheCode == c.PostForm("Password") { | |
57 | + if cacheCode == c.PostForm("Code") { | |
126 | 58 | selected["Mobile"] = c.PostForm("Mobile") |
127 | 59 | DB.CMember.Find(selected).One(&User) |
128 | 60 | |
... | ... | @@ -151,7 +83,7 @@ func LoginUser(c *gin.Context) { |
151 | 83 | |
152 | 84 | } else { |
153 | 85 | selected["Mobile"] = c.PostForm("Mobile") |
154 | - selected["Password"] = c.PostForm("Password") | |
86 | + selected["Code"] = c.PostForm("Code") | |
155 | 87 | DB.CMember.Find(selected).One(&User) |
156 | 88 | if User == nil { |
157 | 89 | c.JSON(200, tools.ResponseError{ |
... | ... | @@ -210,10 +142,8 @@ func UserInfo(c *gin.Context) { |
210 | 142 | // @Description 用户管理 - 修改用户信息 |
211 | 143 | // @Accept json |
212 | 144 | // @Produce json |
213 | -// @Param Password 1 string true "密码" | |
214 | -// @Param ConfirmPassword 1 string true "确认密码" | |
215 | 145 | // @Param Birthday 2010.10.10 string true "生日" |
216 | -// @Param Fullname aarongao string true "全名" | |
146 | +// @Param FullName aarongao string true "全名" | |
217 | 147 | // @Param Code 12345678 string true "6位验证码" |
218 | 148 | // @Param Mobile 18616619599 string true "手机,同用户名" |
219 | 149 | // @Param Sex 男 string true "性别" |
... | ... | @@ -235,21 +165,21 @@ func UpdateUser(c *gin.Context) { |
235 | 165 | return |
236 | 166 | } |
237 | 167 | |
238 | - if c.PostForm("Mobile") == "" || c.PostForm("Password") == "" { | |
168 | + if c.PostForm("Mobile") == "" || c.PostForm("Code") == "" { | |
239 | 169 | c.JSON(200, tools.ResponseError{ |
240 | 170 | 1, |
241 | - "手机号或密码为空", | |
171 | + "手机号或验证码不能为空", | |
242 | 172 | }) |
243 | 173 | return |
244 | 174 | } |
245 | 175 | |
246 | - if c.PostForm("Password") != c.PostForm("ConfirmPassword") { | |
247 | - c.JSON(200, tools.ResponseError{ | |
248 | - 1, | |
249 | - "2次密码不一致", | |
250 | - }) | |
251 | - return | |
252 | - } | |
176 | + //if c.PostForm("Password") != c.PostForm("ConfirmPassword") { | |
177 | + // c.JSON(200, tools.ResponseError{ | |
178 | + // 1, | |
179 | + // "2次密码不一致", | |
180 | + // }) | |
181 | + // return | |
182 | + //} | |
253 | 183 | |
254 | 184 | // 检查验证码 |
255 | 185 | code := DB.Redis.Get(c.PostForm("Mobile")) |
... | ... | @@ -264,9 +194,8 @@ func UpdateUser(c *gin.Context) { |
264 | 194 | err := DB.CMember.Update( |
265 | 195 | bson.M{"Mobile": c.PostForm("Mobile")}, |
266 | 196 | bson.M{"$set": bson.M{ |
267 | - "Password": c.PostForm("Password"), | |
268 | 197 | "Birthday": c.PostForm("Birthday"), |
269 | - "FullName": c.PostForm("Fullname"), | |
198 | + "FullName": c.PostForm("FullName"), | |
270 | 199 | "Mobile": c.PostForm("Mobile"), |
271 | 200 | "Sex": c.PostForm("Sex"), |
272 | 201 | }}, | ... | ... |
DB/db.go
... | ... | @@ -122,8 +122,14 @@ type STag struct { |
122 | 122 | } |
123 | 123 | |
124 | 124 | type SPicture struct { |
125 | - Src string `bson:"Src" json:"Src"` | |
126 | - Link string `bson:"Link" json:"Link"` | |
125 | + Src string `bson:"Src" json:"Src"` // 地址,也可能是视频地址 | |
126 | + Link string `bson:"Link" json:"Link"` // 链接地址 | |
127 | +} | |
128 | +type SVideo struct { | |
129 | + Src string `bson:"Src" json:"Src"` // 地址,也可能是视频地址 | |
130 | + Link string `bson:"Link" json:"Link"` // 链接地址 | |
131 | + VideoPicture string `bson:"VideoPicture" json:"VideoPicture"` // 用于视频的首桢图 | |
132 | + Title string `bson:"Title" json:"Title"` // 标题 | |
127 | 133 | } |
128 | 134 | type SScenic struct { |
129 | 135 | Id *bson.ObjectId `bson:"_id" json:"Id" valid:"required"` |
... | ... | @@ -137,5 +143,5 @@ type SScenic struct { |
137 | 143 | ShopAdPicture []SPicture `bson:"ShopAdPicture" json:"ShopAdPicture"` //商城列表页图片 |
138 | 144 | ItemScenicPicture []SPicture `bson:"ItemScenicPicture" json:"ItemScenicPicture"` //项目场次照片 |
139 | 145 | ActivityPicture []SPicture `bson:"ActivityPicture" json:"ActivityPicture"` //活动照片 |
140 | - VideoList []SPicture `bson:"VideoList" json:"VideoList"` | |
146 | + VideoList []SVideo `bson:"VideoList" json:"VideoList"` | |
141 | 147 | } | ... | ... |
README.md
... | ... | @@ -306,7 +306,7 @@ |
306 | 306 | | Param Name | Example | Data Type | Description | Required? | |
307 | 307 | |-----|-----|-----|-----|-----| |
308 | 308 | | Mobile | aaron | string | 手机号 | Yes | |
309 | -| Password | 1 | string | 密码或验证码(使用验证码的新手机号自动注册) | Yes | | |
309 | +| Code | 1 | string | 验证码(使用验证码的新手机号自动注册) | Yes | | |
310 | 310 | |
311 | 311 | |
312 | 312 | | Code | Type | Model | Message | |
... | ... | @@ -330,7 +330,7 @@ |
330 | 330 | |
331 | 331 | | Code | Type | Model | Message | |
332 | 332 | |-----|-----|-----|-----| |
333 | -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频 | | |
333 | +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片) | | |
334 | 334 | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | |
335 | 335 | |
336 | 336 | |
... | ... | @@ -464,7 +464,7 @@ |
464 | 464 | |
465 | 465 | | Code | Type | Model | Message | |
466 | 466 | |-----|-----|-----|-----| |
467 | -| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频 | | |
467 | +| 200 | object | [ResponseSeccess](#github.com.aarongao.tools.ResponseSeccess) | Name名称;Describe介绍;OpenHours营业时间;Picture最上面图片;ShopAdPicture商城列表页图片;ItemScenicPicture项目场次照片;ActivityPicture活动照片;VideoList视频(VideoPicture=首桢图片) | | |
468 | 468 | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | |
469 | 469 | |
470 | 470 | |
... | ... | @@ -478,10 +478,8 @@ |
478 | 478 | |
479 | 479 | | Param Name | Example | Data Type | Description | Required? | |
480 | 480 | |-----|-----|-----|-----|-----| |
481 | -| Password | 1 | string | 密码 | Yes | | |
482 | -| ConfirmPassword | 1 | string | 确认密码 | Yes | | |
483 | 481 | | Birthday | 2010.10.10 | string | 生日 | Yes | |
484 | -| Fullname | aarongao | string | 全名 | Yes | | |
482 | +| FullName | aarongao | string | 全名 | Yes | | |
485 | 483 | | Code | 12345678 | string | 6位验证码 | Yes | |
486 | 484 | | Mobile | 18616619599 | string | 手机,同用户名 | Yes | |
487 | 485 | | Sex | 男 | string | 性别 | Yes | | ... | ... |