user_pc.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/mojocn/base64Captcha"
  6. "hongze/hongze_api/services"
  7. "hongze/hongze_api/utils"
  8. "strconv"
  9. "hongze/hongze_api/models"
  10. "image/color"
  11. "time"
  12. )
  13. // @Title 获取图形验证码
  14. // @Description 获取图形验证码
  15. // @Success 200 {object} models.GraphicVerifyCodeResp
  16. // @router /pc/getGraphicVerifyCode [get]
  17. func (this *UserCommonController) GetGraphicVerifyCode() {
  18. br := new(models.BaseResponse).Init()
  19. defer func() {
  20. this.Data["json"] = br
  21. this.ServeJSON()
  22. }()
  23. var configC = base64Captcha.ConfigCharacter{
  24. Height: 26,
  25. Width: 67,
  26. Mode: base64Captcha.CaptchaModeNumber,
  27. ComplexOfNoiseText: base64Captcha.CaptchaComplexLower,
  28. ComplexOfNoiseDot: base64Captcha.CaptchaComplexLower,
  29. IsUseSimpleFont: true,
  30. IsShowHollowLine: false,
  31. IsShowNoiseDot: true,
  32. IsShowNoiseText: true,
  33. IsShowSlimeLine: false,
  34. IsShowSineLine: false,
  35. CaptchaLen: 4,
  36. BgColor: &color.RGBA{255, 255, 255, 1},
  37. }
  38. char := base64Captcha.EngineCharCreate(configC)
  39. base64stringC := base64Captcha.CaptchaWriteToBase64Encoding(char)
  40. verifyId := fmt.Sprintf("%d", time.Now().UnixNano())
  41. item := new(models.GraphicVerifyCode)
  42. item.VerifyId = verifyId
  43. item.VerifyCode = char.CaptchaItem.VerifyValue
  44. item.CreateTime = time.Now()
  45. err := models.AddGraphicVerifyCode(item)
  46. if err != nil {
  47. br.Msg = "获取失败"
  48. br.ErrMsg = "获取失败,Err:" + err.Error()
  49. return
  50. }
  51. resp := new(models.GraphicVerifyCodeResp)
  52. resp.VerifyId = verifyId
  53. resp.VerifyCode = base64stringC
  54. br.Ret = 200
  55. br.Data = resp
  56. br.Msg = "获取成功"
  57. br.Success = true
  58. }
  59. // @Title pc端获取短信验证码
  60. // @Description pc端获取短信验证码接口
  61. // @Param Mobile query string true "手机号码"
  62. // @Param AreaNum query string true "地区编码"
  63. // @Param VerifyId query string true "图形验证码id"
  64. // @Param VerifyCode query string true "图形验证码code"
  65. // @Success Ret=200 获取成功
  66. // @router /pc/getSmsCode [get]
  67. func (this *UserCommonController) PcGetSmsCode() {
  68. br := new(models.BaseResponse).Init()
  69. defer func() {
  70. this.Data["json"] = br
  71. this.ServeJSON()
  72. }()
  73. mobile := this.GetString("Mobile")
  74. if mobile == "" {
  75. br.Msg = "请输入手机号"
  76. return
  77. }
  78. areaNum := this.GetString("AreaNum")
  79. msgCode := utils.GetRandDigit(4)
  80. verifyId := this.GetString("VerifyId")
  81. verifyCode := this.GetString("VerifyCode")
  82. item, err := models.GetGraphicVerifyById(verifyId)
  83. if err != nil {
  84. if err.Error() == utils.ErrNoRow() {
  85. br.Msg = "验证码不存在,请刷新页面!"
  86. return
  87. }
  88. br.Msg = "校验验证码失败!"
  89. return
  90. }
  91. if item.VerifyCode != verifyCode {
  92. br.Msg = "验证码错误,请重新输入!"
  93. return
  94. }
  95. checkoutTime := time.Now().Add(15 * time.Minute)
  96. if item.CreateTime.After(checkoutTime) {
  97. br.Msg = "验证码过期,请重新输入!"
  98. return
  99. }
  100. var result bool
  101. if areaNum == "86" || areaNum == "" || areaNum == "0" {
  102. result = services.SendSmsCode(mobile, msgCode)
  103. } else {
  104. result = services.SendSmsCodeGj(mobile, msgCode, areaNum)
  105. }
  106. //发送成功
  107. if result {
  108. item := new(models.MsgCode)
  109. item.OpenId = ""
  110. item.Code = msgCode
  111. item.Mobile = mobile
  112. item.ExpiredIn = time.Now().Add(15 * time.Minute).Unix()
  113. item.Enabled = 1
  114. item.CreatedTime = time.Now()
  115. err := models.AddMsgCode(item)
  116. if err != nil {
  117. br.Msg = "发送失败"
  118. br.ErrMsg = "发送失败,Err:" + err.Error()
  119. return
  120. }
  121. br.Msg = "发送成功"
  122. } else {
  123. br.Msg = "发送失败"
  124. }
  125. br.Ret = 200
  126. br.Success = true
  127. }
  128. // @Title 登录
  129. // @Description 登录接口
  130. // @Param request body models.LoginReq true "type json string"
  131. // @Success 200 {object} models.LoginResp
  132. // @router /pc/login [post]
  133. func (this *UserCommonController) PcLogin() {
  134. br := new(models.BaseResponse).Init()
  135. defer func() {
  136. this.Data["json"] = br
  137. this.ServeJSON()
  138. }()
  139. var req models.PcLoginReq
  140. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  141. if err != nil {
  142. br.Msg = "参数解析异常!"
  143. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  144. return
  145. }
  146. userId := 0
  147. var isAdd bool
  148. if req.LoginType == 1 {
  149. if req.Mobile == "" {
  150. br.Msg = "请输入手机号"
  151. br.ErrMsg = "请输入手机号"
  152. return
  153. }
  154. if req.SmsCode == "" {
  155. br.Msg = "请输入有效手机验证码"
  156. br.ErrMsg = "请输入有效手机验证码"
  157. return
  158. }
  159. item, err := models.GetMsgCode(req.Mobile, req.SmsCode)
  160. if err != nil {
  161. if err.Error() == utils.ErrNoRow() {
  162. br.Msg = "验证码错误,请重新输入"
  163. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  164. return
  165. } else {
  166. br.Msg = "验证码错误,请重新输入"
  167. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  168. return
  169. }
  170. }
  171. if item == nil {
  172. br.Msg = "手机验证码错误,请重新输入"
  173. return
  174. }
  175. wxUser, err := models.GetWxUserItemByMobile(req.Mobile)
  176. if err != nil {
  177. if err.Error() == utils.ErrNoRow() {
  178. isAdd = true
  179. } else {
  180. br.Msg = "登陆失败"
  181. br.ErrMsg = "根据手机号获取用户信息失败,Err:" + err.Error()
  182. return
  183. }
  184. }
  185. if wxUser == nil {
  186. isAdd = true
  187. } else {
  188. userId = wxUser.UserId
  189. }
  190. //BindMobile(openId, mobile string, userId, loginType int) (err error) {
  191. //newUserId, err = models.BindMobile(openId, req.Mobile, userId, req.LoginType)
  192. } else if req.LoginType == 2 {
  193. if req.Email == "" {
  194. br.ErrMsg = "邮箱不能为空,请输入邮箱"
  195. br.Msg = "邮箱不能为空,请输入邮箱"
  196. return
  197. }
  198. if !utils.ValidateEmailFormatat(req.Email) {
  199. br.ErrMsg = "邮箱格式错误,请重新输入"
  200. br.Msg = "邮箱格式错误,请重新输入"
  201. return
  202. }
  203. if req.SmsCode == "" {
  204. br.Msg = "请输入有效验证码"
  205. br.ErrMsg = "请输入有效验证码"
  206. return
  207. }
  208. item, err := models.GetMsgCode(req.Email, req.SmsCode)
  209. if err != nil {
  210. if err.Error() == utils.ErrNoRow() {
  211. br.Msg = "验证码错误,请重新输入"
  212. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  213. return
  214. } else {
  215. br.Msg = "验证码错误,请重新输入"
  216. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  217. return
  218. }
  219. }
  220. if item == nil {
  221. br.Msg = "邮箱证码错误,请重新输入"
  222. return
  223. }
  224. wxUser, err := models.GetWxUserItemByEmail(req.Email)
  225. if err != nil {
  226. if err.Error() == utils.ErrNoRow() {
  227. isAdd = true
  228. } else {
  229. br.Msg = "登陆失败"
  230. br.ErrMsg = "根据邮箱获取用户信息失败,Err:" + err.Error()
  231. return
  232. }
  233. }
  234. if wxUser == nil {
  235. isAdd = true
  236. } else {
  237. userId = wxUser.UserId
  238. }
  239. } else {
  240. br.Msg = "无效的登录方式"
  241. br.ErrMsg = "无效的登录方式,loginType:" + strconv.Itoa(req.LoginType)
  242. }
  243. if isAdd {
  244. user := new(models.WxUser)
  245. user.CompanyId = 1
  246. user.CreatedTime = time.Now()
  247. user.FirstLogin = 1
  248. user.Enabled = 1
  249. user.Email = req.Email
  250. user.Mobile = req.Mobile
  251. if req.LoginType == 1 {
  252. user.BindAccount = user.Mobile
  253. } else {
  254. user.BindAccount = user.Email
  255. }
  256. user.RegisterTime = time.Now()
  257. user.LoginTime = time.Now()
  258. user.IsFreeLogin = req.IsFreeLogin
  259. user.RegisterPlatform=2
  260. lastId, err := models.AddWxUser(user)
  261. if err != nil {
  262. br.Msg = "登录失败"
  263. br.ErrMsg = "登录失败,新增客户信息失败,Err:" + err.Error()
  264. return
  265. }
  266. userId = int(lastId)
  267. timeUnix := time.Now().Unix()
  268. timeUnixStr := strconv.FormatInt(timeUnix, 10)
  269. token := utils.MD5(strconv.Itoa(userId)) + utils.MD5(timeUnixStr)
  270. //新增session
  271. {
  272. session := new(models.Session)
  273. session.UserId = userId
  274. session.CreatedTime = time.Now()
  275. session.LastUpdatedTime = time.Now()
  276. session.ExpireTime = time.Now().AddDate(0, 1, 0)
  277. session.AccessToken = token
  278. err = models.AddSession(session)
  279. if err != nil {
  280. br.Msg = "登录失败"
  281. br.ErrMsg = "登录失败,新增用户session信息失败:" + err.Error()
  282. return
  283. }
  284. }
  285. } else {
  286. err = models.ModifyLoginTime(userId, req.IsFreeLogin)
  287. if err != nil {
  288. br.Msg = "登录失败"
  289. br.ErrMsg = "登录失败,修改登录信息失败,Err:" + err.Error()
  290. return
  291. }
  292. }
  293. if userId == 0 {
  294. br.Msg = "登录失败"
  295. br.ErrMsg = "登录失败,id为 0"
  296. return
  297. }
  298. userPermission, err := services.CheckUserPermission(userId)
  299. if err != nil {
  300. br.Msg = "登录失败"
  301. br.ErrMsg = "登录失败,判断权限失败:" + err.Error()
  302. return
  303. }
  304. err = models.ModifyFirstLogin(userId)
  305. if err != nil {
  306. br.Msg = "登录失败"
  307. br.ErrMsg = "登录失败,判断权限失败:" + err.Error()
  308. return
  309. }
  310. var token string
  311. tokenItem, err := models.GetTokenByUid(userId)
  312. if err != nil && err.Error() != utils.ErrNoRow() {
  313. br.Msg = "登录失败"
  314. br.ErrMsg = "登录失败,获取token失败:" + err.Error()
  315. return
  316. }
  317. if tokenItem == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
  318. timeUnix := time.Now().Unix()
  319. timeUnixStr := strconv.FormatInt(timeUnix, 10)
  320. token = utils.MD5(strconv.Itoa(userId)) + utils.MD5(timeUnixStr)
  321. //新增session
  322. {
  323. session := new(models.Session)
  324. session.UserId = userId
  325. session.CreatedTime = time.Now()
  326. session.LastUpdatedTime = time.Now()
  327. session.ExpireTime = time.Now().AddDate(0, 1, 0)
  328. session.AccessToken = token
  329. err = models.AddSession(session)
  330. if err != nil {
  331. br.Msg = "登录失败"
  332. br.ErrMsg = "登录失败,新增用户session信息失败:" + err.Error()
  333. return
  334. }
  335. }
  336. } else {
  337. token = tokenItem.AccessToken
  338. }
  339. cp, err := models.GetCompanyProductsByUserId(userId)
  340. if err != nil {
  341. br.Msg = "登录失败"
  342. br.ErrMsg = "登录失败,获取客户信息失败:" + err.Error()
  343. return
  344. }
  345. var companyName, status, endDate, productName string
  346. for _, v := range cp {
  347. companyName = v.CompanyName
  348. if status != "" {
  349. status = status + "/" + v.Status
  350. endDate = endDate + "/" + v.EndDate
  351. productName = productName + "/" + v.ProductName
  352. } else {
  353. status = v.Status
  354. endDate = v.EndDate
  355. productName = v.ProductName
  356. }
  357. }
  358. newUser, _ := models.GetWxUserItemByUserId(userId)
  359. resp := new(models.LoginResp)
  360. resp.UserId = newUser.UserId
  361. resp.UserPermission = userPermission
  362. resp.Authorization = token
  363. resp.Headimgurl = newUser.Headimgurl
  364. resp.Mobile = newUser.Mobile
  365. resp.Email = newUser.Email
  366. resp.CompanyName = companyName
  367. resp.EndDate = endDate
  368. resp.Status = status
  369. resp.ProductName = productName
  370. br.Ret = 200
  371. br.Success = true
  372. br.Data = resp
  373. br.Msg = "登录成功"
  374. }
  375. // @Title 绑定手机号或邮箱
  376. // @Description 绑定手机号或邮箱
  377. // @Param request body models.BindReq true "type json string"
  378. // @Success Ret=200 绑定成功
  379. // @router /pc/bind [post]
  380. func (this *UserController) PcBind() {
  381. br := new(models.BaseResponse).Init()
  382. defer func() {
  383. this.Data["json"] = br
  384. this.ServeJSON()
  385. }()
  386. var req models.BindReq
  387. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  388. if err != nil {
  389. br.Msg = "参数解析异常!"
  390. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  391. return
  392. }
  393. unionId := this.User.UnionId
  394. userId := this.User.UserId
  395. utils.FileLog.Info("绑定unionId:%s", unionId)
  396. utils.FileLog.Info("userId:%d", userId)
  397. var newUserId int
  398. if req.BindType == 1 { //手机号
  399. if req.Mobile == "" {
  400. br.Msg = "请输入手机号"
  401. br.ErrMsg = "请输入手机号"
  402. return
  403. }
  404. if req.VerifyCode == "" {
  405. br.Msg = "请输入有效手机验证码"
  406. br.ErrMsg = "请输入有效手机验证码"
  407. return
  408. }
  409. item, err := models.GetMsgCode(req.Mobile, req.VerifyCode)
  410. if err != nil {
  411. if err.Error() == utils.ErrNoRow() {
  412. br.Msg = "验证码错误,请重新输入"
  413. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  414. return
  415. } else {
  416. br.Msg = "验证码错误,请重新输入"
  417. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  418. return
  419. }
  420. }
  421. if item == nil {
  422. br.Msg = "手机验证码错误,请重新输入"
  423. return
  424. }
  425. fmt.Println("bind")
  426. fmt.Println(unionId, req.Mobile, userId, req.BindType)
  427. newUserId, err = models.PcBindMobile(unionId, req.Mobile, userId, req.BindType)
  428. if err != nil {
  429. br.ErrMsg = "绑定失败"
  430. br.Msg = "绑定失败,Err:" + err.Error()
  431. return
  432. }
  433. } else if req.BindType == 2 {
  434. if req.Email == "" {
  435. br.ErrMsg = "邮箱不能为空,请输入邮箱"
  436. br.Msg = "邮箱不能为空,请输入邮箱"
  437. return
  438. }
  439. if req.VerifyCode == "" {
  440. br.Msg = "请填写有效的邮箱验证码"
  441. br.ErrMsg = "请填写有效的邮箱验证码"
  442. return
  443. }
  444. if !utils.ValidateEmailFormatat(req.Email) {
  445. br.ErrMsg = "邮箱格式错误,请重新输入"
  446. br.Msg = "邮箱格式错误,请重新输入"
  447. return
  448. }
  449. item, err := models.GetMsgCode(req.Email, req.VerifyCode)
  450. if err != nil {
  451. if err.Error() == utils.ErrNoRow() {
  452. br.Msg = "验证码错误,请重新输入"
  453. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  454. return
  455. } else {
  456. br.Msg = "验证码错误,请重新输入"
  457. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  458. return
  459. }
  460. }
  461. if item == nil {
  462. br.Msg = "邮箱证码错误,请重新输入"
  463. return
  464. }
  465. newUserId, err = models.PcBindMobile(unionId, req.Email, userId, req.BindType)
  466. if err != nil {
  467. br.ErrMsg = "绑定失败"
  468. br.Msg = "绑定失败,Err:" + err.Error()
  469. return
  470. }
  471. } else {
  472. br.Msg = "无效的绑定方式"
  473. br.ErrMsg = "无效的绑定方式,bindType:" + strconv.Itoa(req.BindType)
  474. return
  475. }
  476. var token string
  477. tokenItem, err := models.GetTokenByUid(newUserId)
  478. if err != nil && err.Error() != utils.ErrNoRow() {
  479. br.Msg = "登录失败"
  480. br.ErrMsg = "登录失败,获取token失败:" + err.Error()
  481. return
  482. }
  483. if tokenItem == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
  484. timeUnix := time.Now().Unix()
  485. timeUnixStr := strconv.FormatInt(timeUnix, 10)
  486. token = utils.MD5(strconv.Itoa(newUserId)) + utils.MD5(timeUnixStr)
  487. //新增session
  488. {
  489. session := new(models.Session)
  490. session.UserId = newUserId
  491. session.CreatedTime = time.Now()
  492. session.LastUpdatedTime = time.Now()
  493. session.ExpireTime = time.Now().AddDate(0, 1, 0)
  494. session.AccessToken = token
  495. err = models.AddSession(session)
  496. if err != nil {
  497. br.Msg = "登录失败"
  498. br.ErrMsg = "登录失败,新增用户session信息失败:" + err.Error()
  499. return
  500. }
  501. }
  502. } else {
  503. token = tokenItem.AccessToken
  504. }
  505. userPermission, err := services.CheckUserPermission(newUserId)
  506. if err != nil {
  507. br.Msg = "绑定失败"
  508. br.ErrMsg = "绑定失败,判断权限失败:" + err.Error()
  509. return
  510. }
  511. err = models.ModifyFirstLogin(newUserId)
  512. if err != nil {
  513. br.Msg = "绑定失败"
  514. br.ErrMsg = "绑定失败,判断权限失败:" + err.Error()
  515. return
  516. }
  517. cp, err := models.GetCompanyProductsByUserId(newUserId)
  518. if err != nil {
  519. br.Msg = "登录失败"
  520. br.ErrMsg = "登录失败,获取客户信息失败:" + err.Error()
  521. return
  522. }
  523. var companyName, status, endDate, productName string
  524. for _, v := range cp {
  525. companyName = v.CompanyName
  526. if status != "" {
  527. status = status + "/" + v.Status
  528. endDate = endDate + "/" + v.EndDate
  529. productName = productName + "/" + v.ProductName
  530. } else {
  531. status = v.Status
  532. endDate = v.EndDate
  533. productName = v.ProductName
  534. }
  535. }
  536. newUser, err := models.GetWxUserItemByUserId(newUserId)
  537. if err != nil {
  538. br.Msg = "登录失败"
  539. br.ErrMsg = "获取客户信息失败 GetWxUserItemByUserId:" + err.Error()
  540. return
  541. }
  542. resp := new(models.LoginResp)
  543. resp.UserId = newUserId
  544. resp.UserPermission = userPermission
  545. resp.Authorization = token
  546. resp.Email = newUser.Email
  547. resp.Headimgurl = newUser.Headimgurl
  548. resp.Mobile = newUser.Mobile
  549. resp.CompanyName = companyName
  550. resp.EndDate = endDate
  551. resp.Status = status
  552. resp.ProductName = productName
  553. br.Ret = 200
  554. br.Success = true
  555. br.Data = resp
  556. br.Msg = "绑定成功"
  557. }
  558. // @Title 校验免登陆
  559. // @Description 校验免登陆
  560. // @Success 200 {object} models.CheckLoginResp
  561. // @router /pc/check/login [get]
  562. func (this *UserController) CheckLogin() {
  563. br := new(models.BaseResponse).Init()
  564. defer func() {
  565. this.Data["json"] = br
  566. this.ServeJSON()
  567. }()
  568. if this.User.IsFreeLogin == 1 {
  569. if this.User.LoginTime.AddDate(0, 0, 30).After(time.Now()) {
  570. br.Ret = 600
  571. } else {
  572. br.Ret = 408
  573. }
  574. } else {
  575. if this.User.LoginTime.AddDate(0, 0, 1).After(time.Now()) {
  576. br.Ret = 600 //正常状态,不需要登录
  577. } else {
  578. br.Ret = 408
  579. }
  580. }
  581. authorization := this.Ctx.Input.Header("Authorization")
  582. if authorization == "" {
  583. cookie := this.Ctx.GetCookie("rddp_access_token")
  584. utils.FileLog.Info("authorization:%s,cookie:%s", authorization, cookie)
  585. authorization = cookie
  586. }
  587. br.IsSendEmail = false
  588. //判断token是否过期
  589. if br.Ret == 408 {
  590. tokenCount, err := models.GetSessionCountByToken(authorization)
  591. if err != nil {
  592. if err.Error() == utils.ErrNoRow() {
  593. br.Ret = 408
  594. } else {
  595. br.ErrMsg = "登录失败,Err:" + err.Error()
  596. br.ErrMsg = "登录失败"
  597. br.IsSendEmail = true
  598. return
  599. }
  600. }
  601. if tokenCount > 0 {
  602. br.Ret = 600
  603. }
  604. }
  605. resp := new(models.CheckLoginResp)
  606. if br.Ret == 600 {
  607. checkPermissionCount, err := models.GetCustomPermission(this.User.CompanyId)
  608. if err != nil && err.Error() != utils.ErrNoRow() {
  609. br.Msg = "登录失败"
  610. br.ErrMsg = "校验提示权限信息失败 Err:" + err.Error()
  611. return
  612. }
  613. if checkPermissionCount <= 0 && this.User.CompanyId > 1 {
  614. resp.IsTips = true
  615. }
  616. if this.User.Mobile == "" && this.User.Email == "" {
  617. resp.IsBind = true
  618. }
  619. }
  620. br.Success = true
  621. br.Msg = "获取成功"
  622. br.Data = resp
  623. }
  624. //
  625. //var (
  626. // searcher = riot.New("zh")
  627. //)
  628. //
  629. //func init() {
  630. // fmt.Sprintf("start")
  631. // data := types.DocData{Content: `I wonder how, I wonder why
  632. // , I wonder where they are`}
  633. // data1 := types.DocData{Content: "所以, 你好, 再见"}
  634. // data2 := types.DocData{Content: "没有理由"}
  635. // data3 := types.DocData{Content: "你好,中国"}
  636. // data4 := types.DocData{Content: "晚上好"}
  637. // data5 := types.DocData{Content: "中国人民,你好啊,2020年"}
  638. // data6 := types.DocData{Content: "中国的新冠疫情算基本得到了有效的控制,随着各地的纷纷复工,甚至有些省市已经开始了复学,大量的外籍华人、旅居的、留学的平时召唤都召唤不来的那些人纷纷回国,这都说明了我们伟大的中国,伟大的中国人民战胜了这次肆虐全球的瘟疫。\n\n  在这这次的抗击新冠疫情中,我们的白衣天使们,我们的专家、学者、科学家们,纷纷的冲在了抗疫第一线。看着84岁高龄的钟南山院士坐在高铁座位上睡着的照片,看着73岁的第一个提出武汉封城的李兰娟院士数次往返于武汉,脸上那一道道的长时间佩戴口罩和护目镜留下的压痕,看着一个个的花季少女剪掉秀发只是为了更好的穿戴防护装备,看着一车车的物资涌向武汉,看着一张张按着手印的奔赴疫区申请书,听着一句句熟悉而又温暖的入党誓词,感动无不充盈心腔,眼泪也从未吝啬。对最美逆行者的赞美是多么的诚挚!"}
  639. // data7 := types.DocData{Content: "在此,我除了表达对他们由衷的感动,还想说:我们中国千万万的普普通通的老百姓也是最伟大、最可爱的人。从来没有一个朝代,从来没有一个国家,像我们中国的老百姓这样如此的对待疫情。平凡的老百姓节衣缩食,也要将物资援助最需要的地方,宁愿几个月不出门,也不给国家增加一分的负担。试问世界上有哪个国家的人民有我们中国的人民对国家如母亲般的感情呢?\n\n  近期看到的最多的新闻就是国外疫情的泛滥,不说在抗疫中每个国家的责任和力量,就说普通的百姓不戴口罩到处跑的,一只狗被遛了三十二次的,最硬核的就是用棍棒打腿的,这些都说明了他们的意识,他们面对疫情的态度和我们的同胞不是一个层次,他们对待国家的情感是不能和我们比拟的!当然,我们国家也不排除有个别的另类出现,但一定会收到最严厉的惩戒。\n\n  中国人民在这次的抗击新冠疫情的战役中表现出来的智慧、勇气、精神,都使我感到作为一个中国人是多么幸运。"}
  640. //
  641. // searcher.Index("1", data)
  642. // searcher.Index("2", data1)
  643. // searcher.IndexDoc("3", data2)
  644. // searcher.IndexDoc("4", data3)
  645. // searcher.IndexDoc("5", data4)
  646. // searcher.IndexDoc("6", data5)
  647. // searcher.IndexDoc("7", data6)
  648. // searcher.IndexDoc("8", data7)
  649. // searcher.Flush()
  650. //
  651. // req := types.SearchReq{Text: "中国人民",Orderless: false,CountDocsOnly: false}
  652. // search := searcher.Search(req)
  653. // jsonStr,_:=json.Marshal(search)
  654. // fmt.Println(string(jsonStr))
  655. // utils.FileLog.Info("%s",string(jsonStr))
  656. // fmt.Sprintf("end")
  657. //}
  658. //