sys_admin.go 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  1. package controllers
  2. import (
  3. "encoding/base64"
  4. "encoding/json"
  5. "eta_gn/eta_api/models"
  6. "eta_gn/eta_api/models/company"
  7. "eta_gn/eta_api/models/data_manage"
  8. "eta_gn/eta_api/models/system"
  9. "eta_gn/eta_api/services/eta_forum"
  10. "eta_gn/eta_api/utils"
  11. "fmt"
  12. "strconv"
  13. "strings"
  14. "time"
  15. "github.com/rdlucklib/rdluck_tools/paging"
  16. )
  17. // 系统用户
  18. type SysAdminController struct {
  19. BaseAuthController
  20. }
  21. // @Title 根据分组或者部门获取系统用户列表
  22. // @Description 根据分组或者部门获取系统用户列表接口
  23. // @Param PageSize query int true "每页数据条数"
  24. // @Param CurrentIndex query int true "当前页页码,从1开始"
  25. // @Param DepartmentId query int true "部门ID"
  26. // @Param GroupId query int true "分组ID"
  27. // @Param TeamId query int true "小组ID"
  28. // @Param RoleId query int true "角色ID"
  29. // @Param KeyWord query string true "搜索关键词"
  30. // @Success 200 {object} system.SysuserListResp
  31. // @router /sysuser/list [get]
  32. func (this *SysAdminController) ListSysuser() {
  33. br := new(models.BaseResponse).Init()
  34. defer func() {
  35. this.Data["json"] = br
  36. this.ServeJSON()
  37. }()
  38. sysUser := this.SysUser
  39. if sysUser == nil {
  40. br.Msg = "请登录"
  41. br.ErrMsg = "请登录,SysUser Is Empty"
  42. return
  43. }
  44. pageSize, _ := this.GetInt("PageSize")
  45. currentIndex, _ := this.GetInt("CurrentIndex")
  46. departmentId, _ := this.GetInt("DepartmentId")
  47. groupId, _ := this.GetInt("GroupId")
  48. teamId, _ := this.GetInt("TeamId")
  49. roleId, _ := this.GetInt("RoleId")
  50. keyWord := this.GetString("KeyWord")
  51. var startSize int
  52. if pageSize <= 0 {
  53. pageSize = utils.PageSize20
  54. }
  55. if currentIndex <= 0 {
  56. currentIndex = 1
  57. }
  58. startSize = utils.StartIndex(currentIndex, pageSize)
  59. var condition string
  60. var pars []interface{}
  61. if departmentId > 0 {
  62. condition += ` AND department_id=? `
  63. pars = append(pars, departmentId)
  64. }
  65. if roleId > 0 {
  66. condition += ` AND role_id=? `
  67. pars = append(pars, roleId)
  68. }
  69. if keyWord != "" {
  70. condition += ` AND (real_name LIKE ? OR admin_name LIKE ? OR mobile LIKE ? ) `
  71. pars = utils.GetLikeKeywordPars(pars, keyWord, 3)
  72. }
  73. var total int
  74. var err error
  75. if teamId <= 0 {
  76. if groupId > 0 {
  77. ids, err := system.GetGroupIdByParentId(groupId)
  78. if err != nil {
  79. br.Msg = "获取失败"
  80. br.ErrMsg = "获取失败,Err:" + err.Error()
  81. return
  82. }
  83. sGroupId := strconv.Itoa(groupId)
  84. ids = append(ids, &sGroupId)
  85. var idList []string
  86. for _, id := range ids {
  87. idList = append(idList, *id)
  88. }
  89. sid := strings.Join(idList, ",")
  90. condition += ` AND group_id IN (` + sid + `) `
  91. }
  92. total, err = system.GetSysuserListCount(condition, pars)
  93. if err != nil {
  94. br.Msg = "获取失败"
  95. br.ErrMsg = "获取失败,Err:" + err.Error()
  96. return
  97. }
  98. } else {
  99. nCondition := condition + ` AND group_id=? `
  100. nPars := append(pars, teamId)
  101. total, err = system.GetSysuserListCount(nCondition, nPars)
  102. if err != nil {
  103. br.Msg = "获取失败"
  104. br.ErrMsg = "获取失败,Err:" + err.Error()
  105. return
  106. }
  107. }
  108. var list []*system.AdminItem
  109. adminIdArr := make([]int, 0)
  110. if teamId <= 0 {
  111. //if groupId > 0 {
  112. // ids, err := system.GetGroupIdByParentId(groupId, startSize, pageSize)
  113. // if err != nil {
  114. // br.Msg = "获取失败"
  115. // br.ErrMsg = "获取失败,Err:" + err.Error()
  116. // return
  117. // }
  118. // sGroupId := strconv.Itoa(groupId)
  119. // ids = append(ids, &sGroupId)
  120. // var idList []string
  121. // for _, id := range ids {
  122. // idList = append(idList, *id)
  123. // }
  124. // sid := strings.Join(idList,",")
  125. //
  126. // condition += ` AND group_id IN (` + sid + `) `
  127. //}
  128. list, err = system.GetSysuserList(condition, pars, startSize, pageSize)
  129. if err != nil {
  130. br.Msg = "获取失败"
  131. br.ErrMsg = "获取失败,Err:" + err.Error()
  132. return
  133. }
  134. lenList := len(list)
  135. for i := 0; i < lenList; i++ {
  136. item := list[i]
  137. //adminIdArr = append(adminIdArr, strconv.Itoa(item.AdminId))
  138. adminIdArr = append(adminIdArr, item.AdminId)
  139. var secondName *string
  140. if item.GroupId != 0 {
  141. pid, err := company.GetParentIdFromGroup(item.GroupId)
  142. if err != nil {
  143. br.Msg = "获取失败"
  144. br.ErrMsg = "查询父级id异常" + err.Error()
  145. return
  146. }
  147. if pid != nil && *pid != 0 {
  148. secondName, err = company.GetGroupNamesById(*pid)
  149. if err != nil {
  150. br.Msg = "获取失败"
  151. br.ErrMsg = "查询二级组名异常" + err.Error()
  152. return
  153. }
  154. }
  155. if pid != nil && *pid > 0 {
  156. list[i].TeamId = list[i].GroupId
  157. list[i].GroupId = *pid
  158. }
  159. }
  160. if item.DepartmentName != "" {
  161. if item.GroupName == "" {
  162. list[i].DepartmentGroup = item.DepartmentName
  163. } else if secondName != nil && *secondName != `` {
  164. list[i].DepartmentGroup = item.DepartmentName + "/" + *secondName + "/" + item.GroupName
  165. } else {
  166. list[i].DepartmentGroup = item.DepartmentName + "/" + item.GroupName
  167. }
  168. }
  169. labelVal := 0
  170. fmt.Println("item.RoleTypeCode:", item.RoleTypeCode)
  171. fmt.Println("item.Authority:", item.Authority)
  172. if item.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
  173. labelVal = 1
  174. } else if item.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN ||
  175. item.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
  176. labelVal = 2
  177. } else {
  178. if item.Authority == 1 {
  179. labelVal = 3
  180. } else if item.Authority == 2 && item.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  181. labelVal = 4
  182. } else if item.Authority == 2 && item.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
  183. labelVal = 5
  184. } else if item.Authority == 4 {
  185. labelVal = 4
  186. }
  187. }
  188. list[i].LabelVal = labelVal
  189. }
  190. } else {
  191. condition += ` AND group_id=? `
  192. pars = append(pars, teamId)
  193. list, err = system.GetSysuserList(condition, pars, startSize, pageSize)
  194. if err != nil {
  195. br.Msg = "获取失败"
  196. br.ErrMsg = "获取失败,Err:" + err.Error()
  197. return
  198. }
  199. groupItem, err := system.GetSysGroupById(groupId)
  200. if err != nil {
  201. br.Msg = "获取失败"
  202. br.ErrMsg = "获取失败,Err:" + err.Error()
  203. return
  204. }
  205. lenList := len(list)
  206. for i := 0; i < lenList; i++ {
  207. item := list[i]
  208. //adminIdArr = append(adminIdArr, strconv.Itoa(item.AdminId))
  209. adminIdArr = append(adminIdArr, item.AdminId)
  210. if item.DepartmentName != "" {
  211. if item.GroupName == "" {
  212. list[i].DepartmentGroup = item.DepartmentName
  213. } else if item.GroupName != "" {
  214. list[i].DepartmentGroup = item.DepartmentName + "/" + groupItem.GroupName + "/" + item.GroupName
  215. } else {
  216. list[i].DepartmentGroup = item.DepartmentName + "/" + item.GroupName
  217. }
  218. }
  219. labelVal := 0
  220. if item.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
  221. labelVal = 1
  222. } else if item.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN ||
  223. item.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
  224. labelVal = 2
  225. } else {
  226. if item.Authority == 1 {
  227. labelVal = 3
  228. } else if item.Authority == 2 && item.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  229. labelVal = 4
  230. } else if item.Authority == 2 && item.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
  231. labelVal = 5
  232. } else if item.Authority == 4 {
  233. labelVal = 4
  234. }
  235. }
  236. list[i].LabelVal = labelVal
  237. }
  238. }
  239. //if teamId > 0 {
  240. // var groupIdSlice []string
  241. // var groupIds string
  242. // for _, item := range list {
  243. // groupIdSlice = append(groupIdSlice, strconv.Itoa(groupId))
  244. // }
  245. // groupIds = strings.Join(groupIdSlice, ",")
  246. // fmt.Println("groupIds:", groupIds)
  247. //}
  248. if teamId > 0 {
  249. for _, item := range list {
  250. item.TeamId = teamId
  251. item.GroupId = groupId
  252. }
  253. }
  254. // 研究方向分组
  255. //if len(adminIdArr) > 0 && utils.BusinessCode == utils.BusinessCodeRelease {
  256. // //adminIds := strings.Join(adminIdArr, ",")
  257. // //researchGroupList, e := system.GetAdminResearchGroupListByAdminId(adminIds)
  258. // researchGroupList, e := models.GetAdminVarietyTagRelationListByAdminId(adminIdArr)
  259. // if e != nil {
  260. // br.Msg = "获取失败"
  261. // br.ErrMsg = "获取研究方向分组列表失败, Err:" + e.Error()
  262. // return
  263. // }
  264. // researchGroupAdminIdName := make(map[int]string, 0)
  265. // for _, g := range researchGroupList {
  266. // researchGroupAdminIdName[g.AdminId] = g.GroupNameStr
  267. // }
  268. // for _, v := range list {
  269. // v.ResearchGroupName = researchGroupAdminIdName[v.AdminId]
  270. // }
  271. //}
  272. fmt.Println("teamId:", teamId)
  273. page := paging.GetPaging(currentIndex, pageSize, total)
  274. resp := new(system.SysuserListResp)
  275. resp.List = list
  276. resp.Paging = page
  277. br.Ret = 200
  278. br.Success = true
  279. br.Msg = "获取成功"
  280. br.Data = resp
  281. }
  282. // Add
  283. // @Title 新增系统用户
  284. // @Description 新增系统用户接口
  285. // @Param request body system.SysuserAddReq true "type json string"
  286. // @Success 200 新增成功
  287. // @router /sysuser/add [post]
  288. func (this *SysAdminController) Add() {
  289. br := new(models.BaseResponse).Init()
  290. defer func() {
  291. this.Data["json"] = br
  292. this.ServeJSON()
  293. }()
  294. var req system.SysuserAddReq
  295. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  296. if err != nil {
  297. br.Msg = "参数解析异常!"
  298. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  299. return
  300. }
  301. if req.RoleId <= 0 {
  302. br.Msg = "请选择角色"
  303. br.ErrMsg = "角色ID小于等于0"
  304. return
  305. }
  306. count, err := system.GetSysAdminCount(req.AdminName)
  307. if err != nil {
  308. br.Msg = "获取数据失败"
  309. br.ErrMsg = "获取数据失败"
  310. return
  311. }
  312. if count > 0 {
  313. br.Msg = "账号已存在,请重新输入"
  314. br.IsSendEmail = false
  315. return
  316. }
  317. // 手机号和邮箱必填一个
  318. req.Mobile = strings.TrimSpace(req.Mobile)
  319. req.Email = strings.TrimSpace(req.Email)
  320. if req.Mobile == "" && req.Email == "" {
  321. br.Msg = "至少输入一个手机号或邮箱"
  322. return
  323. }
  324. if req.Mobile != "" {
  325. if req.TelAreaCode == "86" {
  326. if !utils.ValidateMobileFormatat(req.Mobile) {
  327. br.Msg = "手机号格式有误, 请检查"
  328. return
  329. }
  330. }
  331. mobileCount, err := system.GetSysAdminCountByMobile(req.Mobile, 0)
  332. if err != nil {
  333. br.Msg = "判断手机号是否存在失败"
  334. br.ErrMsg = "判断手机号是否存在失败,Err:" + err.Error()
  335. return
  336. }
  337. if mobileCount > 0 {
  338. br.Msg = "手机号已存在,请重新填写"
  339. br.IsSendEmail = false
  340. return
  341. }
  342. }
  343. if req.Email != "" {
  344. if !utils.ValidateEmailFormatat(req.Email) {
  345. br.Msg = "邮箱格式有误, 请检查"
  346. return
  347. }
  348. emailUser, e := system.GetSysUserByEmail(req.Email)
  349. if e != nil && !utils.IsErrNoRow(e) {
  350. br.Msg = "操作失败"
  351. br.ErrMsg = "邮箱获取用户失败"
  352. return
  353. }
  354. if emailUser != nil && emailUser.AdminId > 0 {
  355. br.Msg = "邮箱已存在, 请重新填写"
  356. return
  357. }
  358. }
  359. var roleName, departmentName, groupName, teamName string
  360. roleItem, err := system.GetSysRoleById(req.RoleId)
  361. if err != nil {
  362. if utils.IsErrNoRow(err) {
  363. br.Msg = "所选角色不存在"
  364. return
  365. }
  366. br.Msg = "获取数据失败"
  367. br.ErrMsg = "获取角色数据失败,Err:" + err.Error()
  368. return
  369. }
  370. if roleItem.RoleId > 0 {
  371. roleName = roleItem.RoleName
  372. }
  373. if req.DepartmentId > 0 {
  374. departmentItem, err := system.GetSysDepartmentById(req.DepartmentId)
  375. if err != nil {
  376. if utils.IsErrNoRow(err) {
  377. br.Msg = "所选部门不存在"
  378. return
  379. }
  380. br.Msg = "获取数据失败"
  381. br.ErrMsg = "获取部门数据失败,Err:" + err.Error()
  382. return
  383. }
  384. if departmentItem.DepartmentId > 0 {
  385. departmentName = departmentItem.DepartmentName
  386. }
  387. }
  388. if req.GroupId > 0 {
  389. groupItem, err := system.GetSysGroupById(req.GroupId)
  390. if err != nil {
  391. if utils.IsErrNoRow(err) {
  392. br.Msg = "所选分组不存在"
  393. return
  394. }
  395. br.Msg = "获取数据失败"
  396. br.ErrMsg = "获取分组数据失败,Err:" + err.Error()
  397. return
  398. }
  399. if groupItem.GroupId > 0 {
  400. groupName = groupItem.GroupName
  401. }
  402. }
  403. if req.TeamId > 0 {
  404. teamItem, err := system.GetSysGroupById(req.TeamId)
  405. if err != nil {
  406. if utils.IsErrNoRow(err) {
  407. br.Msg = "所选小组不存在"
  408. return
  409. }
  410. br.Msg = "获取数据失败"
  411. br.ErrMsg = "获取小组数据失败,Err:" + err.Error()
  412. return
  413. }
  414. if teamItem.GroupId > 0 {
  415. teamName = teamItem.GroupName
  416. }
  417. }
  418. var originPass, pass string
  419. if req.Password != "" {
  420. pwdByte, e := base64.StdEncoding.DecodeString(req.Password)
  421. if e != nil {
  422. br.Msg = "解析数据失败"
  423. br.ErrMsg = "解析数据失败,Err:" + e.Error()
  424. return
  425. }
  426. originPass = string(pwdByte)
  427. }
  428. // 系统用户-密码必填且需要校验密码格式
  429. if req.IsLdap == 0 {
  430. if originPass == "" {
  431. br.Msg = "请输入密码"
  432. return
  433. }
  434. if !utils.CheckPwd(originPass) {
  435. br.Msg = "密码格式错误,请重新输入"
  436. return
  437. }
  438. pass = utils.MD5(originPass)
  439. }
  440. // 域用户-密码非必填(实际登录用不到这个密码)
  441. if req.IsLdap == 1 {
  442. if originPass != "" {
  443. pass = utils.MD5(originPass)
  444. } else {
  445. // 未填写的话给个初始密码即可
  446. pass = utils.MD5(utils.LdapInitPassword)
  447. }
  448. }
  449. // 员工工号
  450. req.EmployeeId = strings.TrimSpace(req.EmployeeId)
  451. admin := new(system.Admin)
  452. admin.AdminName = req.AdminName
  453. admin.RealName = req.RealName
  454. admin.Password = pass
  455. admin.LastUpdatedPasswordTime = time.Now().Format(utils.FormatDateTime)
  456. admin.Enabled = req.Enabled
  457. admin.LastLoginTime = time.Now().Format(utils.FormatDateTime)
  458. admin.CreatedTime = time.Now()
  459. admin.LastUpdatedTime = time.Now().Format(utils.FormatDateTime)
  460. admin.Mobile = req.Mobile
  461. admin.RoleType = 0
  462. admin.RoleId = req.RoleId
  463. admin.RoleName = roleName
  464. admin.RoleTypeCode = roleItem.RoleTypeCode
  465. admin.DepartmentId = req.DepartmentId
  466. admin.DepartmentName = departmentName
  467. admin.AdminAvatar = req.AdminAvatar
  468. if req.TeamId <= 0 {
  469. admin.GroupId = req.GroupId
  470. admin.GroupName = groupName
  471. } else {
  472. admin.GroupId = req.TeamId
  473. admin.GroupName = teamName
  474. }
  475. if strings.Contains(admin.RoleTypeCode, "researcher") {
  476. admin.Role = "researcher"
  477. } else if strings.Contains(admin.RoleTypeCode, "seller") {
  478. admin.Role = "sales"
  479. } else {
  480. admin.Role = "admin"
  481. }
  482. admin.EmployeeId = req.EmployeeId
  483. admin.Email = req.Email
  484. var authority int
  485. if roleItem.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
  486. authority = 3
  487. } else if roleItem.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_TEAM {
  488. authority = 4
  489. } else if roleItem.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  490. authority = 2
  491. } else {
  492. if strings.Contains(roleItem.RoleType, "销售主管") {
  493. authority = 2
  494. } else if strings.Contains(roleItem.RoleType, "部门经理") {
  495. authority = 1
  496. } else {
  497. authority = 0
  498. }
  499. }
  500. admin.Authority = authority
  501. admin.Position = req.Position
  502. admin.Province = req.Province
  503. admin.ProvinceCode = req.ProvinceCode
  504. admin.City = req.City
  505. admin.CityCode = req.CityCode
  506. admin.TelAreaCode = req.TelAreaCode
  507. admin.IsLdap = req.IsLdap
  508. err = system.AddAdmin(admin)
  509. if err != nil {
  510. br.Msg = "新增失败"
  511. br.ErrMsg = "新增失败,Err:" + err.Error()
  512. return
  513. }
  514. // 同步用户缓存
  515. //if utils.BusinessCode == utils.BusinessCodeRelease {
  516. // var syncData system.SyncAdminData
  517. // syncData.Source = utils.SOURCE_ETA_FLAG
  518. // syncData.AdminName = admin.AdminName
  519. // _ = utils.Rc.LPush(utils.CACHE_SYNC_ADMIN, syncData)
  520. //
  521. // e := services.UpdateResearcherTagGroup(admin.AdminId, req.ResearchGroupIds)
  522. // if e != nil {
  523. // br.Msg = "新增失败"
  524. // br.ErrMsg = "新增用户研究方向分组失败, Err:" + e.Error()
  525. // return
  526. // }
  527. //}
  528. // 清楚系统用户列表缓存key
  529. utils.Rc.Delete(utils.CACHE_KEY_ADMIN)
  530. utils.Rc.Delete(utils.CACHE_KEY_ADMIN_ID)
  531. //thirdGroupId := 0 //角色:2=研究员,3=机构销售
  532. if admin.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_RESEARCHR ||
  533. admin.RoleTypeCode == utils.ROLE_TYPE_CODE_RESEARCHR ||
  534. admin.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_RESEARCHR ||
  535. admin.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_DEPARTMENT ||
  536. admin.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_DEPARTMENT {
  537. //thirdGroupId = 2
  538. } else if admin.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER ||
  539. admin.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP ||
  540. admin.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER ||
  541. admin.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  542. //thirdGroupId = 3
  543. }
  544. //if thirdGroupId > 0 {
  545. // go roadshow.CreateOaUser(admin.Mobile, admin.RealName, thirdGroupId)
  546. //}
  547. go eta_forum.AdminSave(admin.AdminId)
  548. br.Ret = 200
  549. br.Success = true
  550. br.Msg = "新增成功"
  551. }
  552. // Edit
  553. // @Title 编辑系统用户
  554. // @Description 编辑系统用户接口
  555. // @Param request body system.SysuserEditReq true "type json string"
  556. // @Success 200 编辑成功
  557. // @router /sysuser/edit [post]
  558. func (this *SysAdminController) Edit() {
  559. br := new(models.BaseResponse).Init()
  560. defer func() {
  561. this.Data["json"] = br
  562. this.ServeJSON()
  563. }()
  564. var req system.SysuserEditReq
  565. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  566. if err != nil {
  567. br.Msg = "参数解析异常!"
  568. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  569. return
  570. }
  571. if req.RoleId <= 0 {
  572. br.Msg = "请选择角色"
  573. br.ErrMsg = "角色ID小于等于0"
  574. return
  575. }
  576. //根据用户id获取用户信息
  577. adminInfo, err := system.GetSysAdminById(req.AdminId)
  578. if err != nil {
  579. if utils.IsErrNoRow(err) {
  580. br.Msg = "用户已被删除, 请刷新页面"
  581. return
  582. }
  583. br.Msg = "获取数据失败"
  584. br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error() + ";AdminId:" + fmt.Sprint(req.AdminId)
  585. return
  586. }
  587. // 根据用户登录用户名获取用户信息
  588. item, err := system.GetSysAdminByName(req.AdminName)
  589. if err != nil {
  590. if !utils.IsErrNoRow(err) {
  591. br.Msg = "获取数据失败"
  592. br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error() + ";AdminName:" + req.AdminName
  593. return
  594. }
  595. } else {
  596. if item.AdminId != req.AdminId {
  597. br.Msg = "账号名称已存在,请重新输入"
  598. return
  599. }
  600. }
  601. // 手机号和邮箱必填一个
  602. req.Mobile = strings.TrimSpace(req.Mobile)
  603. req.Email = strings.TrimSpace(req.Email)
  604. if req.Mobile == "" && req.Email == "" {
  605. br.Msg = "至少输入一个手机号或邮箱"
  606. return
  607. }
  608. if req.Mobile != "" {
  609. if req.TelAreaCode == "86" {
  610. if !utils.ValidateMobileFormatat(req.Mobile) {
  611. br.Msg = "手机号格式有误, 请检查"
  612. return
  613. }
  614. }
  615. mobileCount, e := system.GetSysAdminCountByMobile(req.Mobile, adminInfo.AdminId)
  616. if e != nil {
  617. br.Msg = "判断手机号是否存在失败"
  618. br.ErrMsg = "判断手机号是否存在失败,Err:" + e.Error()
  619. return
  620. }
  621. if mobileCount > 0 {
  622. br.Msg = "手机号已存在,请重新填写"
  623. br.IsSendEmail = false
  624. return
  625. }
  626. }
  627. if req.Email != "" {
  628. if !utils.ValidateEmailFormatat(req.Email) {
  629. br.Msg = "邮箱格式有误, 请检查"
  630. return
  631. }
  632. emailUser, e := system.GetSysUserByEmail(req.Email)
  633. if e != nil {
  634. if !utils.IsErrNoRow(e) {
  635. br.Msg = "操作失败"
  636. br.ErrMsg = "邮箱获取用户信息失败, Err: " + e.Error()
  637. return
  638. }
  639. } else {
  640. if emailUser.AdminId != adminInfo.AdminId {
  641. br.Msg = "邮箱已存在, 请检查"
  642. return
  643. }
  644. }
  645. }
  646. // 角色
  647. var roleName string
  648. roleItem, err := system.GetSysRoleById(req.RoleId)
  649. if err != nil {
  650. if utils.IsErrNoRow(err) {
  651. br.Msg = "角色不存在,请重新选择"
  652. br.ErrMsg = "角色不存在"
  653. return
  654. }
  655. br.Msg = "获取数据失败"
  656. br.ErrMsg = "获取角色数据失败,Err:" + err.Error()
  657. return
  658. }
  659. if roleItem.RoleId > 0 {
  660. roleName = roleItem.RoleName
  661. }
  662. // 员工工号
  663. req.EmployeeId = strings.TrimSpace(req.EmployeeId)
  664. // 管理权限
  665. var authority int
  666. if roleItem.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
  667. authority = 3
  668. } else if roleItem.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_TEAM {
  669. authority = 4
  670. } else if roleItem.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  671. authority = 2
  672. } else {
  673. if strings.Contains(roleItem.RoleType, "销售主管") {
  674. authority = 2
  675. } else if strings.Contains(roleItem.RoleType, "部门经理") {
  676. authority = 1
  677. } else {
  678. authority = 0
  679. }
  680. }
  681. adminInfo.AdminName = req.AdminName
  682. adminInfo.RealName = req.RealName
  683. adminInfo.LastUpdatedTime = time.Now().Format(utils.FormatDateTime)
  684. adminInfo.Mobile = req.Mobile
  685. adminInfo.RoleId = req.RoleId
  686. adminInfo.RoleName = roleName
  687. adminInfo.Enabled = req.Enabled
  688. adminInfo.Authority = authority
  689. adminInfo.Position = req.Position
  690. adminInfo.RoleTypeCode = roleItem.RoleTypeCode
  691. adminInfo.Province = req.Province
  692. adminInfo.ProvinceCode = req.ProvinceCode
  693. adminInfo.City = req.City
  694. adminInfo.CityCode = req.CityCode
  695. adminInfo.EmployeeId = req.EmployeeId
  696. adminInfo.Email = req.Email
  697. adminInfo.TelAreaCode = req.TelAreaCode
  698. adminInfo.IsLdap = req.IsLdap
  699. cols := []string{
  700. "AdminName", "RealName", "LastUpdatedTime", "Mobile", "RoleId", "RoleName", "Enabled", "Authority",
  701. "Position", "RoleTypeCode", "Province", "ProvinceCode", "City", "CityCode", "EmployeeId", "Email", "TelAreaCode", "IsLdap",
  702. }
  703. if e := adminInfo.Update(cols); e != nil {
  704. br.Msg = "编辑失败"
  705. br.ErrMsg = "更新用户信息失败, Err:" + e.Error()
  706. return
  707. }
  708. // 同步用户缓存
  709. //if utils.BusinessCode == utils.BusinessCodeRelease {
  710. // var syncData system.SyncAdminData
  711. // syncData.Source = utils.SOURCE_ETA_FLAG
  712. // syncData.AdminName = adminInfo.AdminName
  713. // _ = utils.Rc.LPush(utils.CACHE_SYNC_ADMIN, syncData)
  714. //
  715. // // 研究方向分组
  716. // if e := services.UpdateResearcherTagGroup(req.AdminId, req.ResearchGroupIds); e != nil {
  717. // br.Msg = "编辑失败"
  718. // br.ErrMsg = "更新用户研究方向失败, Err:" + e.Error()
  719. // return
  720. // }
  721. //}
  722. // 用户登出
  723. logOutSystemUser(adminInfo.AdminId)
  724. // 清楚系统用户列表缓存key
  725. utils.Rc.Delete(utils.CACHE_KEY_ADMIN)
  726. utils.Rc.Delete(utils.CACHE_KEY_ADMIN_ID)
  727. go eta_forum.AdminSave(adminInfo.AdminId)
  728. br.Ret = 200
  729. br.Success = true
  730. br.IsAddLog = true
  731. br.Msg = "编辑成功"
  732. }
  733. // @Title 开启/禁用系统用户
  734. // @Description 开启/禁用系统用户接口
  735. // @Param request body system.SysuserEditReq true "type json string"
  736. // @Success 200 操作成功
  737. // @router /sysuser/editEnabled [post]
  738. func (this *SysAdminController) EditEnabled() {
  739. br := new(models.BaseResponse).Init()
  740. defer func() {
  741. this.Data["json"] = br
  742. this.ServeJSON()
  743. }()
  744. var req system.SysuserEditEnabledReq
  745. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  746. if err != nil {
  747. br.Msg = "参数解析异常!"
  748. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  749. return
  750. }
  751. adminItem, err := system.GetSysAdminById(req.AdminId)
  752. if err != nil {
  753. br.Msg = "获取数据失败"
  754. br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error()
  755. return
  756. }
  757. if req.Enabled == 0 {
  758. //禁用
  759. err = system.DisableAdmin(req.AdminId)
  760. if err != nil {
  761. br.Msg = "修改失败"
  762. br.ErrMsg = "修改系统用户数据失败,Err:" + err.Error()
  763. return
  764. }
  765. } else {
  766. admin := new(system.Admin)
  767. admin.Enabled = req.Enabled
  768. admin.AdminId = req.AdminId
  769. err = system.EditAdminEnabled(admin)
  770. if err != nil {
  771. br.Msg = "修改失败"
  772. br.ErrMsg = "修改系统用户数据失败,Err:" + err.Error()
  773. return
  774. }
  775. }
  776. //用户被禁用的情况下,需要将他对应的token给过期
  777. if adminItem.Enabled == 1 && req.Enabled == 0 {
  778. logOutSystemUser(adminItem.AdminId)
  779. }
  780. if err != nil {
  781. br.Msg = "操作失败"
  782. br.ErrMsg = "操作失败,Err:" + err.Error()
  783. return
  784. }
  785. go eta_forum.AdminSave(adminItem.AdminId)
  786. br.Ret = 200
  787. br.Success = true
  788. br.IsAddLog = true
  789. br.Msg = "操作成功"
  790. }
  791. // @Title 删除系统用户
  792. // @Description 删除系统用户接口
  793. // @Param request body system.SysuserDeleteReq true "type json string"
  794. // @Success 200 删除成功
  795. // @router /sysuser/delete [post]
  796. func (this *SysAdminController) Delete() {
  797. br := new(models.BaseResponse).Init()
  798. defer func() {
  799. this.Data["json"] = br
  800. this.ServeJSON()
  801. }()
  802. var req system.SysuserDeleteReq
  803. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  804. if err != nil {
  805. br.Msg = "参数解析异常!"
  806. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  807. return
  808. }
  809. if req.AdminId <= 0 {
  810. br.Msg = "参数错误"
  811. br.ErrMsg = "参数错误,GroupId 小于等于0 "
  812. return
  813. }
  814. adminInfo, _ := system.GetSysUserById(req.AdminId)
  815. err = system.DeleteSysuser(req.AdminId)
  816. if err != nil {
  817. br.Msg = "删除失败"
  818. br.ErrMsg = "删除失败,Err:" + err.Error()
  819. return
  820. }
  821. // 删除手工数据关联用户
  822. {
  823. go data_manage.DeleteManualUser(req.AdminId)
  824. }
  825. // 清楚系统用户列表缓存key
  826. utils.Rc.Delete(utils.CACHE_KEY_ADMIN)
  827. utils.Rc.Delete(utils.CACHE_KEY_ADMIN_ID)
  828. go eta_forum.AdminDelete(adminInfo.AdminName)
  829. br.Ret = 200
  830. br.Success = true
  831. br.IsAddLog = true
  832. br.Msg = "删除成功"
  833. }
  834. // SetConfig
  835. // @Title 用户信息配置接口
  836. // @Description 用户信息配置接口
  837. // @Success 200 {object} system.SetAdminConfigReq
  838. // @router /sysuser/config/set [post]
  839. func (this *SysAdminController) SetConfig() {
  840. br := new(models.BaseResponse).Init()
  841. defer func() {
  842. this.Data["json"] = br
  843. this.ServeJSON()
  844. }()
  845. sysUser := this.SysUser
  846. if sysUser == nil {
  847. br.Msg = "请登录"
  848. br.ErrMsg = "请登录,SysUser Is Empty"
  849. br.Ret = 408
  850. return
  851. }
  852. var req system.SetAdminConfigReq
  853. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  854. if err != nil {
  855. br.Msg = "参数解析异常!"
  856. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  857. return
  858. }
  859. item, err := system.GetConfigDetailByCode(this.SysUser.AdminId, req.ConfigCode)
  860. if err != nil {
  861. if !utils.IsErrNoRow(err) {
  862. br.Msg = "设置失败"
  863. br.ErrMsg = "设置失败,Err:" + err.Error()
  864. return
  865. }
  866. // 获取默认配置
  867. defaultConfig, err := system.GetDefaultConfigDetailByCode(req.ConfigCode)
  868. if err != nil {
  869. br.Msg = "设置失败"
  870. br.ErrMsg = "获取默认配置失败,Err:" + err.Error()
  871. return
  872. }
  873. adminConfigItem := &system.AdminConfig{
  874. //ConfigId: 0,
  875. AdminId: this.SysUser.AdminId,
  876. ConfigCode: req.ConfigCode,
  877. ConfigValue: req.ConfigValue,
  878. Remark: defaultConfig.Remark,
  879. CreateTime: time.Now(),
  880. }
  881. err = adminConfigItem.Create()
  882. if err != nil {
  883. br.Msg = "设置失败"
  884. br.ErrMsg = "设置失败,Err:" + err.Error()
  885. return
  886. }
  887. } else {
  888. // 存在配置,那么就修改
  889. item.ConfigValue = req.ConfigValue
  890. err = item.Update([]string{"ConfigValue"})
  891. if err != nil {
  892. br.Msg = "设置失败"
  893. br.ErrMsg = "设置失败,Err:" + err.Error()
  894. return
  895. }
  896. }
  897. br.Ret = 200
  898. br.Success = true
  899. br.Msg = "设置成功"
  900. }
  901. // logOutSystemUser 用户登出
  902. func logOutSystemUser(adminId int) {
  903. // 退出管理后台
  904. _ = system.ExpiredSysSessionByAdminId(adminId)
  905. // 退出随手办公小程序
  906. _ = system.UnBindAdminRecordByUserId(adminId)
  907. }
  908. // Move
  909. // @Title 移动分组
  910. // @Description 移动分组
  911. // @Param request body system.SysUserMoveReq true "type json string"
  912. // @Success 200 编辑成功
  913. // @router /sysuser/move [post]
  914. func (this *SysAdminController) Move() {
  915. br := new(models.BaseResponse).Init()
  916. defer func() {
  917. this.Data["json"] = br
  918. this.ServeJSON()
  919. }()
  920. var req system.SysUserMoveReq
  921. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  922. if err != nil {
  923. br.Msg = "参数解析异常!"
  924. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  925. return
  926. }
  927. if req.AdminId <= 0 {
  928. br.Msg = "参数有误"
  929. br.ErrMsg = "参数有误, AdminId"
  930. return
  931. }
  932. if req.DepartmentId <= 0 {
  933. br.Msg = "请选择部门"
  934. return
  935. }
  936. adminInfo, err := system.GetSysAdminById(req.AdminId)
  937. if err != nil && !utils.IsErrNoRow(err) {
  938. br.Msg = "获取数据失败"
  939. br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error() + ";AdminId:" + fmt.Sprint(req.AdminId)
  940. return
  941. }
  942. var departmentName, groupName, teamName string
  943. if req.DepartmentId > 0 {
  944. departmentItem, err := system.GetSysDepartmentById(req.DepartmentId)
  945. if err != nil {
  946. br.Msg = "获取数据失败"
  947. br.ErrMsg = "获取部门数据失败,Err:" + err.Error()
  948. return
  949. }
  950. if departmentItem.DepartmentId > 0 {
  951. departmentName = departmentItem.DepartmentName
  952. }
  953. }
  954. if req.GroupId > 0 {
  955. groupItem, err := system.GetSysGroupById(req.GroupId)
  956. if err != nil {
  957. br.Msg = "获取数据失败"
  958. br.ErrMsg = "获取分组数据失败,Err:" + err.Error()
  959. return
  960. }
  961. if groupItem.GroupId > 0 {
  962. groupName = groupItem.GroupName
  963. }
  964. }
  965. if req.TeamId > 0 {
  966. teamItem, err := system.GetSysGroupById(req.TeamId)
  967. if err != nil {
  968. br.Msg = "获取数据失败"
  969. br.ErrMsg = "获取小组数据失败,Err:" + err.Error()
  970. return
  971. }
  972. if teamItem.GroupId > 0 {
  973. teamName = teamItem.GroupName
  974. }
  975. }
  976. adminInfo.DepartmentId = req.DepartmentId
  977. adminInfo.DepartmentName = departmentName
  978. if req.TeamId <= 0 {
  979. adminInfo.GroupId = req.GroupId
  980. adminInfo.GroupName = groupName
  981. } else {
  982. adminInfo.GroupId = req.TeamId
  983. adminInfo.GroupName = teamName
  984. }
  985. adminInfo.LastUpdatedTime = time.Now().Format(utils.FormatDateTime)
  986. if e := adminInfo.Update([]string{"DepartmentId", "DepartmentName", "GroupId", "GroupName", "LastUpdatedTime"}); e != nil {
  987. br.Msg = "操作失败"
  988. br.ErrMsg = "更新系统用户分组失败, Err: " + e.Error()
  989. return
  990. }
  991. // 修改客户关联的分组
  992. //{
  993. // if req.TeamId > 0 {
  994. // if req.TeamId != adminInfo.GroupId {
  995. // err = company.ModifyCompanyGroupId(req.AdminId, req.TeamId)
  996. // if err != nil {
  997. // br.Msg = "编辑失败"
  998. // br.ErrMsg = "ModifyCompanyGroupId,Err:" + err.Error()
  999. // return
  1000. // }
  1001. // }
  1002. // } else {
  1003. // if req.GroupId != adminInfo.GroupId {
  1004. // err = company.ModifyCompanyGroupId(req.AdminId, req.GroupId)
  1005. // if err != nil {
  1006. // br.Msg = "编辑失败"
  1007. // br.ErrMsg = "ModifyCompanyGroupId,Err:" + err.Error()
  1008. // return
  1009. // }
  1010. // }
  1011. // }
  1012. //
  1013. // if req.DepartmentId != adminInfo.DepartmentId {
  1014. // err = company.ModifyCompanyDepartmentId(req.AdminId, req.DepartmentId)
  1015. // if err != nil {
  1016. // br.Msg = "编辑失败"
  1017. // br.ErrMsg = "ModifyCompanyDepartmentId,Err:" + err.Error()
  1018. // return
  1019. // }
  1020. // }
  1021. //}
  1022. // 清除系统用户列表缓存key
  1023. _ = utils.Rc.Delete(utils.CACHE_KEY_ADMIN)
  1024. _ = utils.Rc.Delete(utils.CACHE_KEY_ADMIN_ID)
  1025. br.Ret = 200
  1026. br.Success = true
  1027. br.IsAddLog = true
  1028. br.Msg = "操作成功"
  1029. }
  1030. // ResetPass
  1031. // @Title 重置密码
  1032. // @Description 重置密码
  1033. // @Param request body system.SysUserResetPassReq true "type json string"
  1034. // @Success 200 编辑成功
  1035. // @router /sysuser/reset_pass [post]
  1036. func (this *SysAdminController) ResetPass() {
  1037. br := new(models.BaseResponse).Init()
  1038. defer func() {
  1039. this.Data["json"] = br
  1040. this.ServeJSON()
  1041. }()
  1042. var req system.SysUserResetPassReq
  1043. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1044. if err != nil {
  1045. br.Msg = "参数解析异常!"
  1046. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1047. return
  1048. }
  1049. if req.AdminId <= 0 {
  1050. br.Msg = "参数有误"
  1051. br.ErrMsg = "参数有误, AdminId"
  1052. return
  1053. }
  1054. req.Password = strings.TrimSpace(req.Password)
  1055. if req.Password == "" {
  1056. br.Msg = "新密码不能为空"
  1057. return
  1058. }
  1059. req.RePassword = strings.TrimSpace(req.RePassword)
  1060. if req.RePassword == "" {
  1061. br.Msg = "确认密码不能为空"
  1062. return
  1063. }
  1064. if req.Password != req.RePassword {
  1065. br.Msg = "两次输入密码不一致,请重新填写"
  1066. return
  1067. }
  1068. adminInfo, err := system.GetSysAdminById(req.AdminId)
  1069. if err != nil {
  1070. if utils.IsErrNoRow(err) {
  1071. br.Msg = "用户已被删除, 请刷新页面"
  1072. return
  1073. }
  1074. br.Msg = "获取数据失败"
  1075. br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error() + ";AdminId:" + fmt.Sprint(req.AdminId)
  1076. return
  1077. }
  1078. b, err := base64.StdEncoding.DecodeString(req.Password)
  1079. if err != nil {
  1080. br.Msg = "解析数据失败"
  1081. br.ErrMsg = "解析数据失败,Err:" + err.Error()
  1082. return
  1083. }
  1084. pwd := string(b)
  1085. //pwd = strings.ToLower(pwd)
  1086. pwd = utils.MD5(pwd)
  1087. adminInfo.Password = pwd
  1088. adminInfo.LastUpdatedPasswordTime = time.Now().Format(utils.FormatDateTime)
  1089. adminInfo.LastUpdatedTime = time.Now().Format(utils.FormatDateTime)
  1090. adminInfo.LastLoginTime = time.Now().Format(utils.FormatDateTime)
  1091. if e := adminInfo.Update([]string{"Password", "LastUpdatedPasswordTime", "LastUpdatedTime", "LastLoginTime"}); e != nil {
  1092. br.Msg = "操作失败"
  1093. br.ErrMsg = "更新系统用户分组失败, Err: " + e.Error()
  1094. return
  1095. }
  1096. // 清除系统用户列表缓存key及异常登录缓存
  1097. _ = utils.Rc.Delete(utils.CACHE_KEY_ADMIN)
  1098. _ = utils.Rc.Delete(utils.CACHE_KEY_ADMIN_ID)
  1099. abnormalKey := fmt.Sprint(utils.CACHE_ABNORMAL_LOGIN, adminInfo.AdminName)
  1100. errPassKey := fmt.Sprint(utils.CACHE_LOGIN_ERR_PASS, adminInfo.AdminName)
  1101. _ = utils.Rc.Delete(abnormalKey)
  1102. _ = utils.Rc.Delete(errPassKey)
  1103. br.Ret = 200
  1104. br.Success = true
  1105. br.IsAddLog = true
  1106. br.Msg = "重置密码成功"
  1107. }
  1108. // Add
  1109. // @Title 用户详情信息
  1110. // @Description 用户详情信息
  1111. // @Param request body system.SysuserAddReq true "type json string"
  1112. // @Success 200 新增成功
  1113. // @router /sysuser/detail [get]
  1114. func (this *SysAdminController) Detail() {
  1115. br := new(models.BaseResponse).Init()
  1116. defer func() {
  1117. this.Data["json"] = br
  1118. this.ServeJSON()
  1119. }()
  1120. br.Data = this.SysUser
  1121. br.Ret = 200
  1122. br.Success = true
  1123. br.Msg = "获取成功"
  1124. }