home_api_controller.go 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. package new_mobile_api_controllers
  2. import (
  3. "XT_New/controllers/mobile_api_controllers"
  4. "XT_New/enums"
  5. "XT_New/models"
  6. "XT_New/service"
  7. "XT_New/utils"
  8. "encoding/json"
  9. "github.com/astaxie/beego"
  10. "io/ioutil"
  11. "net/http"
  12. "net/url"
  13. "strconv"
  14. "strings"
  15. "time"
  16. )
  17. type HomeController struct {
  18. NewMobileBaseAPIAuthController
  19. }
  20. func (this *HomeController) GetHomeData() {
  21. adminUserInfo := this.GetMobileAdminUserInfo()
  22. if adminUserInfo.Org != nil && adminUserInfo.Org.Id != 0 {
  23. //获取该管理员所有机构列表
  24. var orgs []*models.Org
  25. adminUser, err := service.GetHomeData(adminUserInfo.AdminUser.Id)
  26. if err != nil {
  27. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28. return
  29. }
  30. for _, item := range adminUser.Org {
  31. orgs = append(orgs, item)
  32. }
  33. for _, item := range adminUser.VMApp_Role {
  34. for _, subItem := range item.Org {
  35. orgs = append(orgs, subItem)
  36. }
  37. }
  38. orgs = RemoveRepeatedOrgElement(orgs)
  39. var isSubSuperAdmin bool = false
  40. app_role, _ := service.GetAppRoleById(adminUserInfo.AppRole.Id)
  41. role_ids := strings.Split(app_role.RoleIds, ",")
  42. if adminUserInfo.AdminUser.Id != adminUserInfo.Org.Creator {
  43. for _, item := range role_ids {
  44. id, _ := strconv.ParseInt(item, 10, 64)
  45. role, _ := service.GetRoleByRoleID(id)
  46. if role.IsSystem == 1 && role.RoleName == "子管理员" {
  47. isSubSuperAdmin = true
  48. }
  49. }
  50. }
  51. apps, err := service.GetAllApp(adminUserInfo.Org.Id)
  52. if err != nil {
  53. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  54. return
  55. }
  56. banners, err := service.GetSystemBanner()
  57. if err != nil {
  58. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  59. return
  60. }
  61. this.ServeSuccessJSON(map[string]interface{}{
  62. "orgs": orgs,
  63. "apps": apps,
  64. "banners": banners,
  65. "isCreateOrg": true,
  66. "isSubSuperAdmin": isSubSuperAdmin,
  67. })
  68. } else {
  69. apps, err := service.GetAllApp(0)
  70. if err != nil {
  71. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  72. return
  73. }
  74. banners, err := service.GetSystemBanner()
  75. if err != nil {
  76. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  77. return
  78. }
  79. this.ServeSuccessJSON(map[string]interface{}{
  80. "isCreateOrg": false,
  81. "apps": apps,
  82. "banners": banners,
  83. "isSubSuperAdmin": false,
  84. })
  85. }
  86. }
  87. func RemoveRepeatedOrgElement(orgs []*models.Org) (newOrgs []*models.Org) {
  88. newOrgs = make([]*models.Org, 0)
  89. for i := 0; i < len(orgs); i++ {
  90. repeat := false
  91. for j := i + 1; j < len(orgs); j++ {
  92. if orgs[i].Id == orgs[j].Id {
  93. repeat = true
  94. break
  95. }
  96. }
  97. if !repeat {
  98. newOrgs = append(newOrgs, orgs[i])
  99. }
  100. }
  101. return
  102. }
  103. func (this *HomeController) ChangeOrg() {
  104. org_id, _ := this.GetInt64("org_id")
  105. adminUserInfo := this.GetMobileAdminUserInfo()
  106. tempOrg, err := service.GetOrgById(org_id)
  107. if err != nil {
  108. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  109. return
  110. }
  111. if tempOrg == nil {
  112. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoExist)
  113. return
  114. }
  115. mobile := adminUserInfo.AdminUser.Mobile
  116. // 只取最近被创建的 admin_role
  117. adminUser, getAdminErr := service.GetValidAdminUserByMobileReturnErr(mobile) //账号信息唯一值
  118. if getAdminErr != nil {
  119. utils.ErrorLog("获取管理员失败:%v", getAdminErr)
  120. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  121. this.ServeJSON()
  122. return
  123. } else if adminUser == nil {
  124. utils.ErrorLog("查找不到 mobile = %v 的用户", mobile)
  125. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
  126. this.ServeJSON()
  127. return
  128. } else {
  129. var appRole *models.App_Role
  130. var org *models.Org
  131. var subscibe *models.ServeSubscibe
  132. var app *models.OrgApp
  133. //根据登录信息的机构和用户id,去获取对应用户信息和机构信息
  134. tempApp, _ := service.GetOrgApp(tempOrg.Id, 3)
  135. tempRole, _ := service.GetAppRole(tempOrg.Id, tempApp.Id, adminUser.Id)
  136. tempSubscibe, getSubscibeErr := service.GetOrgServeSubscibe(tempOrg.Id)
  137. if getSubscibeErr != nil {
  138. utils.ErrorLog("获取机构订阅信息失败:%v", getSubscibeErr)
  139. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  140. this.ServeJSON()
  141. return
  142. }
  143. subscibe = tempSubscibe
  144. org = tempOrg
  145. appRole = tempRole
  146. app = tempApp
  147. templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
  148. mobileAdminUserInfo := &mobile_api_controllers.MobileAdminUserInfo{
  149. AdminUser: adminUser,
  150. Org: org,
  151. App: app,
  152. AppRole: appRole,
  153. Subscibe: subscibe,
  154. TemplateInfo: &templateInfo,
  155. }
  156. if org != nil && appRole != nil {
  157. // 插入一条登录记录
  158. ip := this.GetString("ip")
  159. loginLog := &models.AdminUserLoginLog{
  160. AdminUserId: adminUser.Id,
  161. OrgId: org.Id,
  162. AppId: appRole.AppId,
  163. IP: ip,
  164. OperateType: 3,
  165. AppType: 3,
  166. CreateTime: time.Now().Unix(),
  167. }
  168. if insertErr := service.InsertLoginLog(loginLog); insertErr != nil {
  169. utils.ErrorLog("为手机号为%v的用户插入一条登录记录失败:%v", mobile, insertErr)
  170. }
  171. }
  172. //删除session和cookie
  173. this.DelSession("mobile_admin_user_info")
  174. this.Ctx.SetCookie("token_cookie", "")
  175. //设置new seesion
  176. this.SetSession("mobile_admin_user_info", mobileAdminUserInfo)
  177. //设置new cookie
  178. mobile := adminUser.Mobile + "-" + strconv.FormatInt(org.Id, 10) + "-" + strconv.FormatInt(appRole.Id, 10)
  179. token := utils.GenerateLoginToken(mobile)
  180. expiration, _ := beego.AppConfig.Int64("mobile_token_expiration_second")
  181. this.Ctx.SetCookie("token_cookie", token, expiration, "/")
  182. var configList interface{}
  183. var FiledList []*models.FiledConfig
  184. if org.Id > 0 {
  185. configList, _ = service.GetConfigList(org.Id)
  186. FiledList, _ = service.FindFiledByOrgId(org.Id)
  187. }
  188. if len(FiledList) == 0 {
  189. var err error
  190. if org.Id > 0 {
  191. err = service.BatchInsertFiledConfig(org.Id)
  192. if err == nil {
  193. FiledList, _ = service.FindFiledByOrgId(org.Id)
  194. } else {
  195. utils.ErrorLog("字段批量插入失败:%v", err)
  196. }
  197. } else {
  198. FiledList = make([]*models.FiledConfig, 0)
  199. }
  200. }
  201. this.ServeSuccessJSON(map[string]interface{}{
  202. "admin": adminUser,
  203. "user": appRole,
  204. "org": org,
  205. "template_info": map[string]interface{}{
  206. "id": templateInfo.ID,
  207. "org_id": templateInfo.OrgId,
  208. "template_id": templateInfo.TemplateId,
  209. },
  210. "config_list": configList,
  211. "filed_list": FiledList,
  212. })
  213. }
  214. }
  215. func (this *HomeController) CreateOrg() {
  216. adminUserInfo := this.GetMobileAdminUserInfo()
  217. adminUser := adminUserInfo.AdminUser
  218. //if didCreateOrg, checkCreateOrgErr := service.DidAdminUserCreateOrg(adminUser.Id); checkCreateOrgErr != nil {
  219. // this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. // this.ServeJSON()
  221. // return
  222. //} else if didCreateOrg {
  223. // this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeRepeatCreateOrg)
  224. // this.ServeJSON()
  225. // return
  226. //}
  227. name := this.GetString("org_name")
  228. shortName := name
  229. provinceName := this.GetString("provinces_name")
  230. cityName := this.GetString("city_name")
  231. districtName := this.GetString("district_name")
  232. address := this.GetString("address")
  233. org_type := this.GetString("org_type")
  234. contactName := this.GetString("contact_name")
  235. openXT := true
  236. openCDM := false
  237. openSCRM := false
  238. openMall := false
  239. if len(name) == 0 || len(shortName) == 0 || len(contactName) == 0 || len(address) == 0 || len(provinceName) <= 0 || len(cityName) <= 0 || len(districtName) <= 0 || len(org_type) <= 0 {
  240. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  241. this.ServeJSON()
  242. return
  243. }
  244. orgPhone := this.GetString("telephone")
  245. if len(orgPhone) > 0 {
  246. if utils.PhoneRegexp().MatchString(orgPhone) == false {
  247. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  248. this.ServeJSON()
  249. return
  250. }
  251. }
  252. provinceID := 0
  253. cityID := 0
  254. districtID := 0
  255. province, getProvinceErr := service.GetProvinceWithName(provinceName)
  256. if getProvinceErr != nil {
  257. utils.ErrorLog("查询省名失败:%v", getProvinceErr)
  258. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  259. this.ServeJSON()
  260. return
  261. } else if province != nil {
  262. provinceID = int(province.ID)
  263. city, getCityErr := service.GetCityWithName(province.ID, cityName)
  264. if getCityErr != nil {
  265. utils.ErrorLog("查询城市名失败:%v", getCityErr)
  266. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  267. this.ServeJSON()
  268. return
  269. } else if city != nil {
  270. cityID = int(city.ID)
  271. district, getDistrictErr := service.GetDistrictWithName(city.ID, districtName)
  272. if getDistrictErr != nil {
  273. utils.ErrorLog("查询区县名失败:%v", getDistrictErr)
  274. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  275. this.ServeJSON()
  276. return
  277. } else if district != nil {
  278. districtID = int(district.ID)
  279. }
  280. }
  281. }
  282. var orgs []*models.Org
  283. vmAdminUser, err := service.GetHomeData(adminUser.Id)
  284. if err != nil {
  285. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  286. return
  287. }
  288. for _, item := range vmAdminUser.Org {
  289. orgs = append(orgs, item)
  290. }
  291. for _, item := range vmAdminUser.VMApp_Role {
  292. for _, subItem := range item.Org {
  293. orgs = append(orgs, subItem)
  294. }
  295. }
  296. orgs = RemoveRepeatedOrgElement(orgs)
  297. orgType := service.GetOrgTypeByName(org_type)
  298. org := &models.Org{
  299. Creator: adminUser.Id,
  300. OrgName: name,
  301. OrgShortName: shortName,
  302. Province: int64(provinceID),
  303. City: int64(cityID),
  304. District: int64(districtID),
  305. Address: address,
  306. OrgType: orgType.ID,
  307. Telephone: orgPhone,
  308. ContactName: contactName,
  309. Claim: 1,
  310. Evaluate: 5,
  311. Status: 1,
  312. CreateTime: time.Now().Unix(),
  313. ModifyTime: time.Now().Unix(),
  314. }
  315. createErr := service.CreateOrg(org, adminUser.Name, openXT, openCDM, openSCRM, openMall) // 创建机构以及所有类型的 app,如果有新类型的平台,则需要在这个方法里面把创建这一新类型的 app 的代码加上
  316. if createErr != nil {
  317. utils.ErrorLog("mobile=%v的超级管理员创建机构失败:%v", adminUser.Mobile, createErr)
  318. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
  319. this.ServeJSON()
  320. } else {
  321. //初始化病人和排班相关数据
  322. InitPatientAndSchedule(org)
  323. //初始化透析方案
  324. InitSystemPrescrption(org)
  325. //初始化医嘱模版
  326. //InitAdviceTemplate(org)
  327. //初始化角色和权限
  328. InitRoleAndPurviews(org)
  329. //初始化设备管理
  330. InitEquitMentInformation(org)
  331. //初始化显示配置
  332. if len(orgs) == 0 {
  333. ip := utils.GetIP(this.Ctx.Request)
  334. ssoDomain := beego.AppConfig.String("sso_domain")
  335. api := ssoDomain + "/m/login/pwd"
  336. values := make(url.Values)
  337. values.Set("mobile", adminUser.Mobile)
  338. values.Set("password", adminUser.Password)
  339. values.Set("app_type", "3")
  340. values.Set("ip", ip)
  341. resp, requestErr := http.PostForm(api, values)
  342. if requestErr != nil {
  343. utils.ErrorLog("请求SSO登录接口失败: %v", requestErr)
  344. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  345. return
  346. }
  347. defer resp.Body.Close()
  348. body, ioErr := ioutil.ReadAll(resp.Body)
  349. if ioErr != nil {
  350. utils.ErrorLog("SSO登录接口返回数据读取失败: %v", ioErr)
  351. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  352. return
  353. }
  354. var respJSON map[string]interface{}
  355. utils.InfoLog(string(body))
  356. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  357. utils.ErrorLog("SSO登录接口返回数据解析JSON失败: %v", err)
  358. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  359. return
  360. }
  361. if respJSON["state"].(float64) != 1 {
  362. msg := respJSON["msg"].(string)
  363. utils.ErrorLog("SSO登录接口请求失败: %v", msg)
  364. if int(respJSON["code"].(float64)) == 609 {
  365. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
  366. return
  367. }
  368. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  369. return
  370. } else {
  371. utils.SuccessLog("SSO登录成功")
  372. // 下面这几段 Map=>JSON=>Struct 的流程可能会造成速度很慢
  373. userJSON := respJSON["data"].(map[string]interface{})["admin"].(map[string]interface{})
  374. userJSONBytes, _ := json.Marshal(userJSON)
  375. var adminUser models.AdminUser
  376. if err := json.Unmarshal(userJSONBytes, &adminUser); err != nil {
  377. utils.ErrorLog("解析管理员失败:%v", err)
  378. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  379. return
  380. }
  381. var org models.Org
  382. if respJSON["data"].(map[string]interface{})["org"] != nil {
  383. orgJSON := respJSON["data"].(map[string]interface{})["org"].(map[string]interface{})
  384. orgJSONBytes, _ := json.Marshal(orgJSON)
  385. if err := json.Unmarshal(orgJSONBytes, &org); err != nil {
  386. utils.ErrorLog("解析机构失败:%v", err)
  387. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  388. return
  389. }
  390. }
  391. var app models.OrgApp
  392. if respJSON["data"].(map[string]interface{})["app"] != nil {
  393. appJSON := respJSON["data"].(map[string]interface{})["app"].(map[string]interface{})
  394. appJSONBytes, _ := json.Marshal(appJSON)
  395. if err := json.Unmarshal(appJSONBytes, &app); err != nil {
  396. utils.ErrorLog("解析应用失败:%v", err)
  397. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  398. return
  399. }
  400. }
  401. var appRole models.App_Role
  402. if respJSON["data"].(map[string]interface{})["app_role"] != nil {
  403. appRoleJSON := respJSON["data"].(map[string]interface{})["app_role"].(map[string]interface{})
  404. appRoleJSONBytes, _ := json.Marshal(appRoleJSON)
  405. if err := json.Unmarshal(appRoleJSONBytes, &appRole); err != nil {
  406. utils.ErrorLog("解析AppRole失败:%v", err)
  407. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  408. return
  409. }
  410. }
  411. var subscibe models.ServeSubscibe
  412. if respJSON["data"].(map[string]interface{})["subscibe"] != nil {
  413. subscibeJSON := respJSON["data"].(map[string]interface{})["subscibe"].(map[string]interface{})
  414. subscibeJSONBytes, _ := json.Marshal(subscibeJSON)
  415. if err := json.Unmarshal(subscibeJSONBytes, &subscibe); err != nil {
  416. utils.ErrorLog("解析Subscibe失败:%v", err)
  417. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  418. return
  419. }
  420. }
  421. //service.GetOrgSubscibeState(&subscibe)
  422. templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
  423. mobileAdminUserInfo := &mobile_api_controllers.MobileAdminUserInfo{
  424. AdminUser: &adminUser,
  425. Org: &org,
  426. App: &app,
  427. AppRole: &appRole,
  428. Subscibe: &subscibe,
  429. TemplateInfo: &templateInfo,
  430. }
  431. this.Ctx.SetCookie("token_cookie", "")
  432. //设置seesion
  433. this.SetSession("mobile_admin_user_info", mobileAdminUserInfo)
  434. //设置cookie
  435. mobile := adminUser.Mobile + "-" + strconv.FormatInt(org.Id, 10) + "-" + strconv.FormatInt(appRole.Id, 10)
  436. token := utils.GenerateLoginToken(mobile)
  437. expiration, _ := beego.AppConfig.Int64("mobile_token_expiration_second")
  438. this.Ctx.SetCookie("token_cookie", token, expiration, "/")
  439. var configList interface{}
  440. var FiledList []*models.FiledConfig
  441. if org.Id > 0 {
  442. configList, _ = service.GetConfigList(org.Id)
  443. FiledList, _ = service.FindFiledByOrgId(org.Id)
  444. }
  445. if len(FiledList) == 0 {
  446. var err error
  447. if org.Id > 0 {
  448. err = service.BatchInsertFiledConfig(org.Id)
  449. if err == nil {
  450. FiledList, _ = service.FindFiledByOrgId(org.Id)
  451. } else {
  452. utils.ErrorLog("字段批量插入失败:%v", err)
  453. }
  454. } else {
  455. FiledList = make([]*models.FiledConfig, 0)
  456. }
  457. }
  458. this.ServeSuccessJSON(map[string]interface{}{
  459. "admin": adminUser,
  460. "user": appRole,
  461. "org": org,
  462. "template_info": map[string]interface{}{
  463. "id": templateInfo.ID,
  464. "org_id": templateInfo.OrgId,
  465. "template_id": templateInfo.TemplateId,
  466. },
  467. "config_list": configList,
  468. "filed_list": FiledList,
  469. "status": 1,
  470. })
  471. }
  472. } else {
  473. this.ServeSuccessJSON(map[string]interface{}{
  474. "org": org,
  475. "status": 2,
  476. })
  477. }
  478. }
  479. }
  480. func (this *HomeController) ModifyPsw() {
  481. mobile := this.GetString("mobile")
  482. code := this.GetString("code")
  483. password := this.GetString("password")
  484. checkErr := this.checkParam(mobile, code, password)
  485. if checkErr != nil {
  486. this.ServeFailJSONWithSGJErrorCode(checkErr.Code)
  487. return
  488. }
  489. adminUser, _ := service.GetValidAdminUserByMobileReturnErr(mobile)
  490. modifyErr := service.ModifyPassword(adminUser.Id, password)
  491. if modifyErr != nil {
  492. utils.ErrorLog("修改mobile=%v的用户的密码时失败: %v", mobile, modifyErr)
  493. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
  494. return
  495. } else {
  496. // 修改成功后验证码就要使其失效
  497. redisClient := service.RedisClient()
  498. defer redisClient.Close()
  499. redisClient.Del("code_msg_" + mobile)
  500. this.ServeSuccessJSON(map[string]interface{}{
  501. "admin": adminUser,
  502. })
  503. return
  504. }
  505. }
  506. func (this *HomeController) checkParam(mobile string, code string, password string) *enums.SGJError {
  507. if utils.CellPhoneRegexp().MatchString(mobile) == false {
  508. return &enums.SGJError{Code: enums.ErrorCodeMobileFormat}
  509. }
  510. if len(code) == 0 {
  511. return &enums.SGJError{Code: enums.ErrorCodeVerificationCodeWrong}
  512. }
  513. if len(password) == 0 {
  514. return &enums.SGJError{Code: enums.ErrorCodePasswordEmpty}
  515. }
  516. if service.IsMobileRegister(mobile) == false {
  517. return &enums.SGJError{Code: enums.ErrorCodeMobileNotExit}
  518. }
  519. redisClient := service.RedisClient()
  520. defer redisClient.Close()
  521. cache_code, _ := redisClient.Get("code_msg_" + mobile).Result()
  522. if cache_code != code {
  523. return &enums.SGJError{Code: enums.ErrorCodeVerificationCodeWrong}
  524. }
  525. return nil
  526. }