user.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "hongze/hongze_api/models"
  6. "hongze/hongze_api/services"
  7. "hongze/hongze_api/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. //用户
  13. type UserController struct {
  14. BaseAuthController
  15. }
  16. //用户
  17. type UserCommonController struct {
  18. BaseCommonController
  19. }
  20. //用户不登录
  21. type UserNotAuthController struct {
  22. BaseNotAuthController
  23. }
  24. // @Title 获取用户详情
  25. // @Description 获取用户详情接口
  26. // @Success 200 {object} models.UserDetail
  27. // @router /detail [get]
  28. func (this *UserController) Detail() {
  29. br := new(models.BaseResponse).Init()
  30. defer func() {
  31. this.Data["json"] = br
  32. this.ServeJSON()
  33. }()
  34. user := this.User
  35. if user == nil {
  36. br.Msg = "请登录"
  37. br.ErrMsg = "请登录,用户信息为空"
  38. br.Ret = 408
  39. return
  40. }
  41. item, err := models.GetUserDetailByUserId(user.UserId)
  42. if err != nil {
  43. br.Msg = "获取信息失败"
  44. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  45. return
  46. }
  47. userPermission, err := services.CheckUserPermission(user.UserId)
  48. if err != nil {
  49. br.Msg = "获取信息失败"
  50. br.ErrMsg = "判断用户权限信息失败,Err:" + err.Error()
  51. return
  52. }
  53. if item.Mobile == "" && item.Email == "" {
  54. item.FirstLogin = 1
  55. }
  56. //新增访问日志
  57. {
  58. record := new(models.UserAccessRecord)
  59. record.Uid = user.UserId
  60. record.Token = this.Token
  61. record.CreateTime = time.Now()
  62. go models.AddUserAccessRecord(record)
  63. }
  64. item.UserPermission = userPermission
  65. br.Ret = 200
  66. br.Success = true
  67. br.Msg = "获取成功"
  68. br.Data = item
  69. }
  70. // @Title 获取短信验证码
  71. // @Description 获取短信验证码接口
  72. // @Param Mobile query string true "手机号码"
  73. // @Param AreaNum query string true "地区编码"
  74. // @Success Ret=200 获取成功
  75. // @router /getSmsCode [get]
  76. func (this *UserNotAuthController) GetSmsCode() {
  77. br := new(models.BaseResponse).Init()
  78. defer func() {
  79. this.Data["json"] = br
  80. this.ServeJSON()
  81. }()
  82. mobile := this.GetString("Mobile")
  83. if mobile == "" {
  84. br.Msg = "请输入手机号"
  85. return
  86. }
  87. areaNum := this.GetString("AreaNum")
  88. msgCode := utils.GetRandDigit(4)
  89. var result bool
  90. if areaNum == "86" || areaNum == "" || areaNum == "0" {
  91. result = services.SendSmsCode(mobile, msgCode)
  92. } else {
  93. result = services.SendSmsCodeGj(mobile, msgCode, areaNum)
  94. }
  95. //发送成功
  96. if result {
  97. item := new(models.MsgCode)
  98. item.OpenId = ""
  99. item.Code = msgCode
  100. item.Mobile = mobile
  101. item.ExpiredIn = time.Now().Add(15 * time.Minute).Unix()
  102. item.Enabled = 1
  103. item.CreatedTime = time.Now()
  104. err := models.AddMsgCode(item)
  105. if err != nil {
  106. br.Msg = "发送失败"
  107. br.ErrMsg = "发送失败,Err:" + err.Error()
  108. return
  109. }
  110. br.Msg = "发送成功"
  111. } else {
  112. br.Msg = "发送失败"
  113. }
  114. br.Ret = 200
  115. br.Success = true
  116. }
  117. // @Title 校验短信验证码
  118. // @Description 校验短信验证码接口
  119. // @Param request body models.CheckSmsCodeReq true "type json string"
  120. // @Success Ret=200 校验成功
  121. // @router /checkSmsCode [post]
  122. func (this *UserNotAuthController) CheckSmsCode() {
  123. br := new(models.BaseResponse).Init()
  124. defer func() {
  125. this.Data["json"] = br
  126. this.ServeJSON()
  127. }()
  128. var req models.CheckSmsCodeReq
  129. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  130. if err != nil {
  131. br.Msg = "参数解析异常!"
  132. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  133. return
  134. }
  135. if req.Mobile == "" {
  136. br.Msg = "请输入手机号"
  137. br.ErrMsg = "请输入手机号"
  138. return
  139. }
  140. if req.SmsCode == "" {
  141. br.Msg = "请输入验证码"
  142. br.ErrMsg = "请输入验证码"
  143. return
  144. }
  145. item, err := models.GetMsgCode(req.Mobile, req.SmsCode)
  146. if err != nil {
  147. if err.Error() == utils.ErrNoRow() {
  148. br.Msg = "验证码错误,请重新输入"
  149. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  150. return
  151. } else {
  152. br.Msg = "验证码错误,请重新输入"
  153. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  154. return
  155. }
  156. }
  157. if item == nil {
  158. br.Msg = "验证码错误,请重新输入"
  159. return
  160. }
  161. br.Ret = 200
  162. br.Success = true
  163. br.Msg = "验证码正确"
  164. }
  165. // @Title 获取邮件验证码
  166. // @Description 获取邮件验证码接口
  167. // @Param Email query string true "邮箱"
  168. // @Success Ret=200 获取成功
  169. // @router /getEmailCode [get]
  170. func (this *UserNotAuthController) GetEmailCode() {
  171. br := new(models.BaseResponse).Init()
  172. defer func() {
  173. this.Data["json"] = br
  174. this.ServeJSON()
  175. }()
  176. email := this.GetString("Email")
  177. if email == "" {
  178. br.Msg = "请输入邮箱地址"
  179. return
  180. }
  181. if !utils.ValidateEmailFormatat(email) {
  182. br.Msg = "邮箱格式错误,请重新输入"
  183. return
  184. }
  185. msgCode := utils.GetRandDigit(4)
  186. content := "尊敬的用户:</br>您好,感谢您使用弘则研究,您正在进行邮箱验证,本次请求的验证码为:" + msgCode + "(为了保障您账号的安全性,请在15分钟内完成验证。)</br>弘则研究团队 </br>2019年05月11日"
  187. title := "弘则研究登陆验证"
  188. //发送邮件
  189. result, err := utils.SendEmailByHz(title, content, email)
  190. if err != nil {
  191. br.Msg = "发送失败"
  192. br.ErrMsg = "发送失败,Err:" + err.Error()
  193. return
  194. }
  195. if result {
  196. item := new(models.MsgCode)
  197. item.OpenId = ""
  198. item.Code = msgCode
  199. item.Mobile = email
  200. item.ExpiredIn = time.Now().Add(15 * time.Minute).Unix()
  201. item.Enabled = 1
  202. item.CreatedTime = time.Now()
  203. err := models.AddMsgCode(item)
  204. if err != nil {
  205. br.Msg = "发送失败"
  206. br.ErrMsg = "发送失败,Err:" + err.Error()
  207. return
  208. }
  209. br.Msg = "发送成功"
  210. } else {
  211. br.Msg = "发送失败"
  212. }
  213. br.Ret = 200
  214. br.Success = true
  215. }
  216. // @Title 校验邮箱验证码
  217. // @Description 校验邮箱验证码接口
  218. // @Param request body models.CheckEmailCodeReq true "type json string"
  219. // @Success Ret=200 校验成功
  220. // @router /checkEmailCode [post]
  221. func (this *UserNotAuthController) CheckEmailCode() {
  222. br := new(models.BaseResponse).Init()
  223. defer func() {
  224. this.Data["json"] = br
  225. this.ServeJSON()
  226. }()
  227. var req models.CheckEmailCodeReq
  228. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  229. if err != nil {
  230. br.Msg = "参数解析异常!"
  231. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  232. return
  233. }
  234. if req.Email == "" {
  235. br.Msg = "请输入手机号"
  236. br.ErrMsg = "请输入手机号"
  237. return
  238. }
  239. if req.SmsCode == "" {
  240. br.Msg = "请输入验证码"
  241. br.ErrMsg = "请输入验证码"
  242. return
  243. }
  244. item, err := models.GetMsgCode(req.Email, req.SmsCode)
  245. if err != nil {
  246. if err.Error() == utils.ErrNoRow() {
  247. br.Msg = "验证码错误,请重新输入"
  248. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  249. return
  250. } else {
  251. br.Msg = "验证码错误,请重新输入"
  252. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  253. return
  254. }
  255. }
  256. if item == nil {
  257. br.Msg = "验证码错误,请重新输入"
  258. return
  259. }
  260. br.Ret = 200
  261. br.Success = true
  262. br.Msg = "验证码正确"
  263. }
  264. // @Title 登录
  265. // @Description 登录接口
  266. // @Param request body models.LoginReq true "type json string"
  267. // @Success 200 {object} models.LoginResp
  268. // @router /login [post]
  269. func (this *UserNotAuthController) Login() {
  270. br := new(models.BaseResponse).Init()
  271. defer func() {
  272. this.Data["json"] = br
  273. this.ServeJSON()
  274. }()
  275. var req models.LoginReq
  276. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  277. if err != nil {
  278. br.Msg = "参数解析异常!"
  279. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  280. return
  281. }
  282. user := this.User
  283. if user == nil {
  284. br.Msg = "请登录"
  285. br.ErrMsg = "请登录"
  286. br.Ret = 408
  287. return
  288. }
  289. openId := user.OpenId
  290. if openId == "" {
  291. br.Msg = "参数错误"
  292. br.ErrMsg = "参数错误,openid 为空"
  293. return
  294. }
  295. if req.LoginType == 1 {
  296. //手机登录
  297. if req.Mobile == "" {
  298. br.ErrMsg = "手机号不能为空,请输入手机号"
  299. br.Msg = "手机号不能为空,请输入手机号"
  300. return
  301. }
  302. req.Mobile = strings.Trim(req.Mobile, " ")
  303. } else if req.LoginType == 2 {
  304. //邮箱登录
  305. if req.Email == "" {
  306. br.ErrMsg = "邮箱不能为空,请输入邮箱"
  307. br.Msg = "邮箱不能为空,请输入邮箱"
  308. return
  309. }
  310. if !utils.ValidateEmailFormatat(req.Email) {
  311. br.ErrMsg = "邮箱格式错误,请重新输入"
  312. br.Msg = "邮箱格式错误,请重新输入"
  313. return
  314. }
  315. } else {
  316. br.Msg = "无效的登录方式"
  317. br.ErrMsg = "无效的登录方式,Err:" + err.Error()
  318. return
  319. }
  320. user, errMsg, err := services.BindWxUser(openId, req.Mobile, req.Email, req.AreaNum, 1)
  321. if err != nil && err.Error() != utils.ErrNoRow() {
  322. br.Msg = "登录失败,系统处理中,请稍后重试"
  323. if errMsg != `` {
  324. br.Msg = errMsg
  325. }
  326. br.ErrMsg = "登录失败:" + err.Error()
  327. return
  328. }
  329. userId := user.UserId
  330. var token string
  331. tokenItem, err := models.GetTokenByOpenId(openId)
  332. if err != nil && err.Error() != utils.ErrNoRow() {
  333. br.Msg = "登录失败"
  334. br.ErrMsg = "登录失败,获取token失败:" + err.Error()
  335. return
  336. }
  337. if tokenItem == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
  338. timeUnix := time.Now().Unix()
  339. timeUnixStr := strconv.FormatInt(timeUnix, 10)
  340. token := utils.MD5(openId) + utils.MD5(timeUnixStr)
  341. //新增session
  342. {
  343. session := new(models.Session)
  344. session.OpenId = openId
  345. session.UserId = userId
  346. session.CreatedTime = time.Now()
  347. session.LastUpdatedTime = time.Now()
  348. session.ExpireTime = time.Now().AddDate(0, 1, 0)
  349. session.AccessToken = token
  350. err = models.AddSession(session)
  351. if err != nil {
  352. br.Msg = "登录失败"
  353. br.ErrMsg = "登录失败,新增用户session信息失败:" + err.Error()
  354. return
  355. }
  356. }
  357. } else {
  358. token = tokenItem.AccessToken
  359. _ = models.UpdateSession(tokenItem.SessionId, userId, time.Now().AddDate(0, 1, 0))
  360. }
  361. userPermission, err := services.CheckUserPermission(userId)
  362. if err != nil {
  363. br.Msg = "登录失败"
  364. br.ErrMsg = "登录失败,判断权限失败:" + err.Error()
  365. return
  366. }
  367. err = models.ModifyFirstLogin(user.UserId)
  368. if err != nil {
  369. br.Msg = "登录失败"
  370. br.ErrMsg = "登录失败,判断权限失败:" + err.Error()
  371. return
  372. }
  373. //新增登录日志
  374. {
  375. loginLog := new(models.WxUserLog)
  376. loginLog.UserId = userId
  377. loginLog.OpenId = openId
  378. loginLog.Mobile = req.Mobile
  379. loginLog.Email = req.Email
  380. loginLog.CreateTime = time.Now()
  381. loginLog.Handle = "wechat_user_login"
  382. loginLog.Remark = token
  383. go models.AddWxUserLog(loginLog)
  384. }
  385. resp := new(models.LoginResp)
  386. resp.UserId = userId
  387. resp.UserPermission = userPermission
  388. resp.Authorization = token
  389. br.Ret = 200
  390. br.Success = true
  391. br.Data = resp
  392. br.Msg = "登录成功"
  393. }
  394. //func (this *UserController) Login() {
  395. // br := new(models.BaseResponse).Init()
  396. // defer func() {
  397. // this.Data["json"] = br
  398. // this.ServeJSON()
  399. // }()
  400. // var req models.LoginReq
  401. // err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  402. // if err != nil {
  403. // br.Msg = "参数解析异常!"
  404. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  405. // return
  406. // }
  407. // user := this.User
  408. // if user == nil {
  409. // br.Msg = "请登录"
  410. // br.ErrMsg = "请登录"
  411. // br.Ret = 408
  412. // return
  413. // }
  414. //
  415. // openId := user.OpenId
  416. // if openId == "" {
  417. // br.Msg = "参数错误"
  418. // br.ErrMsg = "参数错误,openid 为空"
  419. // return
  420. // }
  421. // userId := user.UserId
  422. // newUserId := 0
  423. // if req.LoginType == 1 {
  424. // //BindMobile(openId, mobile string, userId, loginType int) (err error) {
  425. // req.Mobile = strings.Trim(req.Mobile, " ")
  426. // newUserId, err = models.BindMobile(openId, req.Mobile, userId, req.LoginType)
  427. // } else if req.LoginType == 2 {
  428. // if req.Email == "" {
  429. // br.ErrMsg = "邮箱不能为空,请输入邮箱"
  430. // br.Msg = "邮箱不能为空,请输入邮箱"
  431. // return
  432. // }
  433. // if !utils.ValidateEmailFormatat(req.Email) {
  434. // br.ErrMsg = "邮箱格式错误,请重新输入"
  435. // br.Msg = "邮箱格式错误,请重新输入"
  436. // return
  437. // }
  438. // newUserId, err = models.BindMobile(openId, req.Email, userId, req.LoginType)
  439. // } else {
  440. // br.Msg = "无效的登录方式"
  441. // br.ErrMsg = "无效的登录方式,Err:" + err.Error()
  442. // return
  443. // }
  444. // var token string
  445. // tokenItem, err := models.GetTokenByUid(newUserId)
  446. // if err != nil && err.Error() != utils.ErrNoRow() {
  447. // br.Msg = "登录失败"
  448. // br.ErrMsg = "登录失败,获取token失败:" + err.Error()
  449. // return
  450. // }
  451. //
  452. // if tokenItem == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
  453. // timeUnix := time.Now().Unix()
  454. // timeUnixStr := strconv.FormatInt(timeUnix, 10)
  455. // token := utils.MD5(strconv.Itoa(userId)) + utils.MD5(timeUnixStr)
  456. // //新增session
  457. // {
  458. // session := new(models.Session)
  459. // session.OpenId = openId
  460. // session.UserId = userId
  461. // session.CreatedTime = time.Now()
  462. // session.LastUpdatedTime = time.Now()
  463. // session.ExpireTime = time.Now().AddDate(0, 1, 0)
  464. // session.AccessToken = token
  465. // err = models.AddSession(session)
  466. // if err != nil {
  467. // br.Msg = "登录失败"
  468. // br.ErrMsg = "登录失败,新增用户session信息失败:" + err.Error()
  469. // return
  470. // }
  471. // }
  472. // } else {
  473. // token = tokenItem.AccessToken
  474. // }
  475. // userPermission, err := services.CheckUserPermission(newUserId)
  476. // if err != nil {
  477. // br.Msg = "登录失败"
  478. // br.ErrMsg = "登录失败,判断权限失败:" + err.Error()
  479. // return
  480. // }
  481. // err = models.ModifyFirstLogin(user.UserId)
  482. // if err != nil {
  483. // br.Msg = "登录失败"
  484. // br.ErrMsg = "登录失败,判断权限失败:" + err.Error()
  485. // return
  486. // }
  487. //
  488. // //新增登录日志
  489. // {
  490. // loginLog := new(models.WxUserLog)
  491. // loginLog.UserId = userId
  492. // loginLog.OpenId = openId
  493. // loginLog.Mobile=req.Mobile
  494. // loginLog.Email=req.Email
  495. // loginLog.CreateTime = time.Now()
  496. // loginLog.Handle="wechat_user_login"
  497. // loginLog.Remark=token
  498. // go models.AddWxUserLog(loginLog)
  499. // }
  500. //
  501. // resp := new(models.LoginResp)
  502. // resp.UserId = newUserId
  503. // resp.UserPermission = userPermission
  504. // resp.Authorization = token
  505. // br.Ret = 200
  506. // br.Success = true
  507. // br.Data = resp
  508. // br.Msg = "登录成功"
  509. //}
  510. // @Title 申请试用
  511. // @Description 申请试用接口
  512. // @Param request body models.ApplyReq true "type json string"
  513. // @Success Ret=200 申请成功
  514. // @router /apply [post]
  515. func (this *UserController) Apply() {
  516. br := new(models.BaseResponse).Init()
  517. defer func() {
  518. this.Data["json"] = br
  519. this.ServeJSON()
  520. }()
  521. user := this.User
  522. if user == nil {
  523. br.Msg = "请登录"
  524. br.ErrMsg = "请登录"
  525. br.Ret = 408
  526. return
  527. }
  528. var req models.ApplyReq
  529. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  530. if err != nil {
  531. br.Msg = "参数解析异常!"
  532. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  533. return
  534. }
  535. realName := req.RealName
  536. userId := user.UserId
  537. if req.ApplyMethod == 2 {
  538. if realName == "" {
  539. br.Msg = "姓名不能为空!"
  540. return
  541. }
  542. }
  543. if realName == "" {
  544. realName = user.RealName
  545. }
  546. err = models.Apply(userId, req.ApplyMethod, user.Mobile, user.Email, req.CompanyName, realName, user.OpenId)
  547. if err != nil {
  548. br.Msg = "申请失败!"
  549. br.ErrMsg = "申请失败,Err:" + err.Error()
  550. return
  551. }
  552. br.Ret = 200
  553. br.Success = true
  554. br.Msg = "申请成功"
  555. }
  556. // @Title 是否小套餐客户
  557. // @Description 是否小套餐客户接口
  558. // @Success 200 {object} models.SmallLimitResp
  559. // @router /smallLimit [get]
  560. func (this *UserController) SmallLimit() {
  561. br := new(models.BaseResponse).Init()
  562. defer func() {
  563. this.Data["json"] = br
  564. this.ServeJSON()
  565. }()
  566. user := this.User
  567. if user == nil {
  568. br.Msg = "请登录"
  569. br.ErrMsg = "请登录"
  570. br.Ret = 408
  571. return
  572. }
  573. userItem, err := models.GetWxUserItemByUserId(user.UserId)
  574. if err != nil {
  575. br.Msg = "获取用户信息失败"
  576. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  577. return
  578. }
  579. if userItem == nil {
  580. br.Msg = "获取用户信息失败"
  581. br.ErrMsg = "用户信息不存在,UserId:" + strconv.Itoa(user.UserId)
  582. return
  583. }
  584. maxCount, err := models.GetUserIsMaxPermission(userItem.CompanyId)
  585. if err != nil {
  586. br.Msg = "获取用户信息失败"
  587. br.ErrMsg = "判断是否最大客户权限失败,Err:" + err.Error()
  588. return
  589. }
  590. resp := new(models.SmallLimitResp)
  591. maxPermissionCount, err := models.GetDefaultChartPermissionCountByCache(1)
  592. if err != nil {
  593. br.Msg = "获取失败"
  594. br.ErrMsg = "获取产品默认最大权限数量失败,Err:" + err.Error()
  595. return
  596. }
  597. if maxCount >= maxPermissionCount {
  598. resp.IsMaxPermission = 1
  599. } else {
  600. resp.IsMaxPermission = 0
  601. }
  602. br.Ret = 200
  603. br.Success = true
  604. br.Data = resp
  605. }
  606. // @Title test
  607. // @Description test接口
  608. // @Param request body models.CheckEmailCodeReq true "type json string"
  609. // @Success Ret=200 校验成功
  610. // @router /test [get]
  611. func (this *UserNotAuthController) Test() {
  612. br := new(models.BaseResponse).Init()
  613. defer func() {
  614. this.Data["json"] = br
  615. this.ServeJSON()
  616. }()
  617. openid := "oN0jD1S3P-FVosLhq-YiVOXldtRo"
  618. wxUser, err := services.GetWxUserItemByOpenId(openid)
  619. fmt.Println(err)
  620. fmt.Println(wxUser)
  621. fmt.Println("-----------")
  622. //wxUser,err = models.GetWxUserItemByOpenId(openid)
  623. //fmt.Println(err)
  624. //fmt.Println(wxUser)
  625. //fmt.Println("-----------")
  626. userId := 12274
  627. userId = 12018
  628. platform := 2
  629. wxUser, err = services.GetWxUserItemByUserId(userId, platform)
  630. fmt.Println(err)
  631. fmt.Println(wxUser)
  632. fmt.Println("根据用户id获取结束-----------")
  633. mobile := "18170239278"
  634. wxUser, err = services.GetWxUserItemByMobile(mobile, platform)
  635. fmt.Println(err)
  636. fmt.Println(wxUser)
  637. fmt.Println("根据手机号获取结束-----------")
  638. email := "984198890@qq.com"
  639. wxUser, err = services.GetWxUserItemByEmail(email, platform)
  640. fmt.Println(err)
  641. fmt.Println(wxUser)
  642. fmt.Println("根据邮箱获取结束-----------")
  643. unionId := "o1q5cwOzXXA9Hy9PTEIwxP81Casg"
  644. wxUser, err = services.GetWxUserItemByUnionId(unionId, platform)
  645. fmt.Println(err)
  646. fmt.Println(wxUser)
  647. fmt.Println("根据unionid获取结束-----------")
  648. br.Ret = 200
  649. br.Success = true
  650. br.Msg = "验证码正确"
  651. }