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,7 +13,7 @@ import ( | ||
13 | // @Accept json | 13 | // @Accept json |
14 | // @Produce json | 14 | // @Produce json |
15 | // @Param id 5dfb03070a9ac17ac7a82054 string true "景区id" | 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 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | 17 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" |
18 | // @Router /ScenicInfo? [get] | 18 | // @Router /ScenicInfo? [get] |
19 | func ScenicInfo(c *gin.Context) { | 19 | func ScenicInfo(c *gin.Context) { |
@@ -43,7 +43,7 @@ func ScenicInfo(c *gin.Context) { | @@ -43,7 +43,7 @@ func ScenicInfo(c *gin.Context) { | ||
43 | // @Accept json | 43 | // @Accept json |
44 | // @Produce json | 44 | // @Produce json |
45 | // @Param id 5dfb03070a9ac17ac7a82054 string true "景区id" | 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 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | 47 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" |
48 | // @Router /UpdateScenic? [post] | 48 | // @Router /UpdateScenic? [post] |
49 | func UpdateScenic(c *gin.Context) { | 49 | func UpdateScenic(c *gin.Context) { |
@@ -65,7 +65,7 @@ func UpdateScenic(c *gin.Context) { | @@ -65,7 +65,7 @@ func UpdateScenic(c *gin.Context) { | ||
65 | var ActivityPicture []DB.SPicture | 65 | var ActivityPicture []DB.SPicture |
66 | json.Unmarshal([]byte(c.PostForm("ActivityPicture")), &ActivityPicture) | 66 | json.Unmarshal([]byte(c.PostForm("ActivityPicture")), &ActivityPicture) |
67 | 67 | ||
68 | - var VideoList []DB.SPicture | 68 | + var VideoList []DB.SVideo |
69 | json.Unmarshal([]byte(c.PostForm("VideoList")), &VideoList) | 69 | json.Unmarshal([]byte(c.PostForm("VideoList")), &VideoList) |
70 | 70 | ||
71 | 71 |
API/User.go
@@ -12,74 +12,6 @@ import ( | @@ -12,74 +12,6 @@ import ( | ||
12 | "time" | 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 | 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}$" | 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,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 | // @Accept json | 20 | // @Accept json |
89 | // @Produce json | 21 | // @Produce json |
90 | // @Param Mobile aaron string true "手机号" | 22 | // @Param Mobile aaron string true "手机号" |
91 | -// @Param Password 1 string true "密码或验证码(使用验证码的新手机号自动注册)" | 23 | +// @Param Code 1 string true "验证码(使用验证码的新手机号自动注册)" |
92 | // @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":{"Id":"5e09c64c1c09c6f0f7ca2fa9","Token":"640bf934e425aba5d3c90998b2641f2f0ca07261d334d9615d1cd4790b5f34e7"}} 调用其它需要登陆的接口时携带token,有过期时间" | 24 | // @Success 200 {object} tools.ResponseSeccess "{"errcode":0,"result":{"Id":"5e09c64c1c09c6f0f7ca2fa9","Token":"640bf934e425aba5d3c90998b2641f2f0ca07261d334d9615d1cd4790b5f34e7"}} 调用其它需要登陆的接口时携带token,有过期时间" |
93 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" | 25 | // @Failure 500 {object} tools.ResponseError "{"errcode":1,"errmsg":"错误原因"}" |
94 | // @Router /LoginUser? [post] | 26 | // @Router /LoginUser? [post] |
@@ -106,23 +38,23 @@ func LoginUser(c *gin.Context) { | @@ -106,23 +38,23 @@ func LoginUser(c *gin.Context) { | ||
106 | return | 38 | return |
107 | } | 39 | } |
108 | 40 | ||
109 | - if c.PostForm("Mobile") == "" || c.PostForm("Password") == "" { | 41 | + if c.PostForm("Mobile") == "" || c.PostForm("Code") == "" { |
110 | c.JSON(200, tools.ResponseError{ | 42 | c.JSON(200, tools.ResponseError{ |
111 | 1, | 43 | 1, |
112 | - "空", | 44 | + "手机号和验证码不能空", |
113 | }) | 45 | }) |
114 | return | 46 | return |
115 | } | 47 | } |
116 | 48 | ||
117 | // 生成token | 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 | token := hex.EncodeToString(tokenunit8[:32]) | 51 | token := hex.EncodeToString(tokenunit8[:32]) |
120 | 52 | ||
121 | // 检查验证码 | 53 | // 检查验证码 |
122 | cacheCode := DB.Redis.Get(c.PostForm("Mobile")) | 54 | cacheCode := DB.Redis.Get(c.PostForm("Mobile")) |
123 | selected := bson.M{} | 55 | selected := bson.M{} |
124 | var User *DB.SMember | 56 | var User *DB.SMember |
125 | - if cacheCode == c.PostForm("Password") { | 57 | + if cacheCode == c.PostForm("Code") { |
126 | selected["Mobile"] = c.PostForm("Mobile") | 58 | selected["Mobile"] = c.PostForm("Mobile") |
127 | DB.CMember.Find(selected).One(&User) | 59 | DB.CMember.Find(selected).One(&User) |
128 | 60 | ||
@@ -151,7 +83,7 @@ func LoginUser(c *gin.Context) { | @@ -151,7 +83,7 @@ func LoginUser(c *gin.Context) { | ||
151 | 83 | ||
152 | } else { | 84 | } else { |
153 | selected["Mobile"] = c.PostForm("Mobile") | 85 | selected["Mobile"] = c.PostForm("Mobile") |
154 | - selected["Password"] = c.PostForm("Password") | 86 | + selected["Code"] = c.PostForm("Code") |
155 | DB.CMember.Find(selected).One(&User) | 87 | DB.CMember.Find(selected).One(&User) |
156 | if User == nil { | 88 | if User == nil { |
157 | c.JSON(200, tools.ResponseError{ | 89 | c.JSON(200, tools.ResponseError{ |
@@ -210,10 +142,8 @@ func UserInfo(c *gin.Context) { | @@ -210,10 +142,8 @@ func UserInfo(c *gin.Context) { | ||
210 | // @Description 用户管理 - 修改用户信息 | 142 | // @Description 用户管理 - 修改用户信息 |
211 | // @Accept json | 143 | // @Accept json |
212 | // @Produce json | 144 | // @Produce json |
213 | -// @Param Password 1 string true "密码" | ||
214 | -// @Param ConfirmPassword 1 string true "确认密码" | ||
215 | // @Param Birthday 2010.10.10 string true "生日" | 145 | // @Param Birthday 2010.10.10 string true "生日" |
216 | -// @Param Fullname aarongao string true "全名" | 146 | +// @Param FullName aarongao string true "全名" |
217 | // @Param Code 12345678 string true "6位验证码" | 147 | // @Param Code 12345678 string true "6位验证码" |
218 | // @Param Mobile 18616619599 string true "手机,同用户名" | 148 | // @Param Mobile 18616619599 string true "手机,同用户名" |
219 | // @Param Sex 男 string true "性别" | 149 | // @Param Sex 男 string true "性别" |
@@ -235,21 +165,21 @@ func UpdateUser(c *gin.Context) { | @@ -235,21 +165,21 @@ func UpdateUser(c *gin.Context) { | ||
235 | return | 165 | return |
236 | } | 166 | } |
237 | 167 | ||
238 | - if c.PostForm("Mobile") == "" || c.PostForm("Password") == "" { | 168 | + if c.PostForm("Mobile") == "" || c.PostForm("Code") == "" { |
239 | c.JSON(200, tools.ResponseError{ | 169 | c.JSON(200, tools.ResponseError{ |
240 | 1, | 170 | 1, |
241 | - "手机号或密码为空", | 171 | + "手机号或验证码不能为空", |
242 | }) | 172 | }) |
243 | return | 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 | code := DB.Redis.Get(c.PostForm("Mobile")) | 185 | code := DB.Redis.Get(c.PostForm("Mobile")) |
@@ -264,9 +194,8 @@ func UpdateUser(c *gin.Context) { | @@ -264,9 +194,8 @@ func UpdateUser(c *gin.Context) { | ||
264 | err := DB.CMember.Update( | 194 | err := DB.CMember.Update( |
265 | bson.M{"Mobile": c.PostForm("Mobile")}, | 195 | bson.M{"Mobile": c.PostForm("Mobile")}, |
266 | bson.M{"$set": bson.M{ | 196 | bson.M{"$set": bson.M{ |
267 | - "Password": c.PostForm("Password"), | ||
268 | "Birthday": c.PostForm("Birthday"), | 197 | "Birthday": c.PostForm("Birthday"), |
269 | - "FullName": c.PostForm("Fullname"), | 198 | + "FullName": c.PostForm("FullName"), |
270 | "Mobile": c.PostForm("Mobile"), | 199 | "Mobile": c.PostForm("Mobile"), |
271 | "Sex": c.PostForm("Sex"), | 200 | "Sex": c.PostForm("Sex"), |
272 | }}, | 201 | }}, |
DB/db.go
@@ -122,8 +122,14 @@ type STag struct { | @@ -122,8 +122,14 @@ type STag struct { | ||
122 | } | 122 | } |
123 | 123 | ||
124 | type SPicture struct { | 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 | type SScenic struct { | 134 | type SScenic struct { |
129 | Id *bson.ObjectId `bson:"_id" json:"Id" valid:"required"` | 135 | Id *bson.ObjectId `bson:"_id" json:"Id" valid:"required"` |
@@ -137,5 +143,5 @@ type SScenic struct { | @@ -137,5 +143,5 @@ type SScenic struct { | ||
137 | ShopAdPicture []SPicture `bson:"ShopAdPicture" json:"ShopAdPicture"` //商城列表页图片 | 143 | ShopAdPicture []SPicture `bson:"ShopAdPicture" json:"ShopAdPicture"` //商城列表页图片 |
138 | ItemScenicPicture []SPicture `bson:"ItemScenicPicture" json:"ItemScenicPicture"` //项目场次照片 | 144 | ItemScenicPicture []SPicture `bson:"ItemScenicPicture" json:"ItemScenicPicture"` //项目场次照片 |
139 | ActivityPicture []SPicture `bson:"ActivityPicture" json:"ActivityPicture"` //活动照片 | 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,7 +306,7 @@ | ||
306 | | Param Name | Example | Data Type | Description | Required? | | 306 | | Param Name | Example | Data Type | Description | Required? | |
307 | |-----|-----|-----|-----|-----| | 307 | |-----|-----|-----|-----|-----| |
308 | | Mobile | aaron | string | 手机号 | Yes | | 308 | | Mobile | aaron | string | 手机号 | Yes | |
309 | -| Password | 1 | string | 密码或验证码(使用验证码的新手机号自动注册) | Yes | | 309 | +| Code | 1 | string | 验证码(使用验证码的新手机号自动注册) | Yes | |
310 | 310 | ||
311 | 311 | ||
312 | | Code | Type | Model | Message | | 312 | | Code | Type | Model | Message | |
@@ -330,7 +330,7 @@ | @@ -330,7 +330,7 @@ | ||
330 | 330 | ||
331 | | Code | Type | Model | Message | | 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 | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | | 334 | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | |
335 | 335 | ||
336 | 336 | ||
@@ -464,7 +464,7 @@ | @@ -464,7 +464,7 @@ | ||
464 | 464 | ||
465 | | Code | Type | Model | Message | | 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 | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | | 468 | | 500 | object | [ResponseError](#github.com.aarongao.tools.ResponseError) | {"errcode":1,"errmsg":"错误原因"} | |
469 | 469 | ||
470 | 470 | ||
@@ -478,10 +478,8 @@ | @@ -478,10 +478,8 @@ | ||
478 | 478 | ||
479 | | Param Name | Example | Data Type | Description | Required? | | 479 | | Param Name | Example | Data Type | Description | Required? | |
480 | |-----|-----|-----|-----|-----| | 480 | |-----|-----|-----|-----|-----| |
481 | -| Password | 1 | string | 密码 | Yes | | ||
482 | -| ConfirmPassword | 1 | string | 确认密码 | Yes | | ||
483 | | Birthday | 2010.10.10 | string | 生日 | Yes | | 481 | | Birthday | 2010.10.10 | string | 生日 | Yes | |
484 | -| Fullname | aarongao | string | 全名 | Yes | | 482 | +| FullName | aarongao | string | 全名 | Yes | |
485 | | Code | 12345678 | string | 6位验证码 | Yes | | 483 | | Code | 12345678 | string | 6位验证码 | Yes | |
486 | | Mobile | 18616619599 | string | 手机,同用户名 | Yes | | 484 | | Mobile | 18616619599 | string | 手机,同用户名 | Yes | |
487 | | Sex | 男 | string | 性别 | Yes | | 485 | | Sex | 男 | string | 性别 | Yes | |