sys_admin.go 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220
  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. /*
  835. func init() {
  836. fmt.Println("start")
  837. pwdStr:=`11111`
  838. //compile := `(\d+.*[^a-zA-Z]+){6,12}|([^a-zA-Z]+.*\d+){6,12}`
  839. compile := `([0-9a-z]+){6,12}|(a-z0-9]+){6,12}`
  840. ///^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/
  841. ///^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/
  842. reg := regexp.MustCompile(compile)
  843. flag := reg.MatchString(pwdStr)
  844. fmt.Println(flag)
  845. fmt.Println("end")
  846. }*/
  847. // SetConfig
  848. // @Title 用户信息配置接口
  849. // @Description 用户信息配置接口
  850. // @Success 200 {object} system.SetAdminConfigReq
  851. // @router /sysuser/config/set [post]
  852. func (this *SysAdminController) SetConfig() {
  853. br := new(models.BaseResponse).Init()
  854. defer func() {
  855. this.Data["json"] = br
  856. this.ServeJSON()
  857. }()
  858. sysUser := this.SysUser
  859. if sysUser == nil {
  860. br.Msg = "请登录"
  861. br.ErrMsg = "请登录,SysUser Is Empty"
  862. br.Ret = 408
  863. return
  864. }
  865. var req system.SetAdminConfigReq
  866. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  867. if err != nil {
  868. br.Msg = "参数解析异常!"
  869. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  870. return
  871. }
  872. item, err := system.GetConfigDetailByCode(this.SysUser.AdminId, req.ConfigCode)
  873. if err != nil {
  874. if !utils.IsErrNoRow(err) {
  875. br.Msg = "设置失败"
  876. br.ErrMsg = "设置失败,Err:" + err.Error()
  877. return
  878. }
  879. // 获取默认配置
  880. defaultConfig, err := system.GetDefaultConfigDetailByCode(req.ConfigCode)
  881. if err != nil {
  882. br.Msg = "设置失败"
  883. br.ErrMsg = "获取默认配置失败,Err:" + err.Error()
  884. return
  885. }
  886. adminConfigItem := &system.AdminConfig{
  887. //ConfigId: 0,
  888. AdminId: this.SysUser.AdminId,
  889. ConfigCode: req.ConfigCode,
  890. ConfigValue: req.ConfigValue,
  891. Remark: defaultConfig.Remark,
  892. CreateTime: time.Now(),
  893. }
  894. err = adminConfigItem.Create()
  895. if err != nil {
  896. br.Msg = "设置失败"
  897. br.ErrMsg = "设置失败,Err:" + err.Error()
  898. return
  899. }
  900. } else {
  901. // 存在配置,那么就修改
  902. item.ConfigValue = req.ConfigValue
  903. err = item.Update([]string{"ConfigValue"})
  904. if err != nil {
  905. br.Msg = "设置失败"
  906. br.ErrMsg = "设置失败,Err:" + err.Error()
  907. return
  908. }
  909. }
  910. br.Ret = 200
  911. br.Success = true
  912. br.Msg = "设置成功"
  913. }
  914. // logOutSystemUser 用户登出
  915. func logOutSystemUser(adminId int) {
  916. // 退出管理后台
  917. _ = system.ExpiredSysSessionByAdminId(adminId)
  918. // 退出随手办公小程序
  919. _ = system.UnBindAdminRecordByUserId(adminId)
  920. }
  921. // Move
  922. // @Title 移动分组
  923. // @Description 移动分组
  924. // @Param request body system.SysUserMoveReq true "type json string"
  925. // @Success 200 编辑成功
  926. // @router /sysuser/move [post]
  927. func (this *SysAdminController) Move() {
  928. br := new(models.BaseResponse).Init()
  929. defer func() {
  930. this.Data["json"] = br
  931. this.ServeJSON()
  932. }()
  933. var req system.SysUserMoveReq
  934. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  935. if err != nil {
  936. br.Msg = "参数解析异常!"
  937. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  938. return
  939. }
  940. if req.AdminId <= 0 {
  941. br.Msg = "参数有误"
  942. br.ErrMsg = "参数有误, AdminId"
  943. return
  944. }
  945. if req.DepartmentId <= 0 {
  946. br.Msg = "请选择部门"
  947. return
  948. }
  949. adminInfo, err := system.GetSysAdminById(req.AdminId)
  950. if err != nil && !utils.IsErrNoRow(err) {
  951. br.Msg = "获取数据失败"
  952. br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error() + ";AdminId:" + fmt.Sprint(req.AdminId)
  953. return
  954. }
  955. var departmentName, groupName, teamName string
  956. if req.DepartmentId > 0 {
  957. departmentItem, err := system.GetSysDepartmentById(req.DepartmentId)
  958. if err != nil {
  959. br.Msg = "获取数据失败"
  960. br.ErrMsg = "获取部门数据失败,Err:" + err.Error()
  961. return
  962. }
  963. if departmentItem.DepartmentId > 0 {
  964. departmentName = departmentItem.DepartmentName
  965. }
  966. }
  967. if req.GroupId > 0 {
  968. groupItem, err := system.GetSysGroupById(req.GroupId)
  969. if err != nil {
  970. br.Msg = "获取数据失败"
  971. br.ErrMsg = "获取分组数据失败,Err:" + err.Error()
  972. return
  973. }
  974. if groupItem.GroupId > 0 {
  975. groupName = groupItem.GroupName
  976. }
  977. }
  978. if req.TeamId > 0 {
  979. teamItem, err := system.GetSysGroupById(req.TeamId)
  980. if err != nil {
  981. br.Msg = "获取数据失败"
  982. br.ErrMsg = "获取小组数据失败,Err:" + err.Error()
  983. return
  984. }
  985. if teamItem.GroupId > 0 {
  986. teamName = teamItem.GroupName
  987. }
  988. }
  989. adminInfo.DepartmentId = req.DepartmentId
  990. adminInfo.DepartmentName = departmentName
  991. if req.TeamId <= 0 {
  992. adminInfo.GroupId = req.GroupId
  993. adminInfo.GroupName = groupName
  994. } else {
  995. adminInfo.GroupId = req.TeamId
  996. adminInfo.GroupName = teamName
  997. }
  998. adminInfo.LastUpdatedTime = time.Now().Format(utils.FormatDateTime)
  999. if e := adminInfo.Update([]string{"DepartmentId", "DepartmentName", "GroupId", "GroupName", "LastUpdatedTime"}); e != nil {
  1000. br.Msg = "操作失败"
  1001. br.ErrMsg = "更新系统用户分组失败, Err: " + e.Error()
  1002. return
  1003. }
  1004. // 修改客户关联的分组
  1005. //{
  1006. // if req.TeamId > 0 {
  1007. // if req.TeamId != adminInfo.GroupId {
  1008. // err = company.ModifyCompanyGroupId(req.AdminId, req.TeamId)
  1009. // if err != nil {
  1010. // br.Msg = "编辑失败"
  1011. // br.ErrMsg = "ModifyCompanyGroupId,Err:" + err.Error()
  1012. // return
  1013. // }
  1014. // }
  1015. // } else {
  1016. // if req.GroupId != adminInfo.GroupId {
  1017. // err = company.ModifyCompanyGroupId(req.AdminId, req.GroupId)
  1018. // if err != nil {
  1019. // br.Msg = "编辑失败"
  1020. // br.ErrMsg = "ModifyCompanyGroupId,Err:" + err.Error()
  1021. // return
  1022. // }
  1023. // }
  1024. // }
  1025. //
  1026. // if req.DepartmentId != adminInfo.DepartmentId {
  1027. // err = company.ModifyCompanyDepartmentId(req.AdminId, req.DepartmentId)
  1028. // if err != nil {
  1029. // br.Msg = "编辑失败"
  1030. // br.ErrMsg = "ModifyCompanyDepartmentId,Err:" + err.Error()
  1031. // return
  1032. // }
  1033. // }
  1034. //}
  1035. // 清除系统用户列表缓存key
  1036. _ = utils.Rc.Delete(utils.CACHE_KEY_ADMIN)
  1037. _ = utils.Rc.Delete(utils.CACHE_KEY_ADMIN_ID)
  1038. br.Ret = 200
  1039. br.Success = true
  1040. br.IsAddLog = true
  1041. br.Msg = "操作成功"
  1042. }
  1043. // ResetPass
  1044. // @Title 重置密码
  1045. // @Description 重置密码
  1046. // @Param request body system.SysUserResetPassReq true "type json string"
  1047. // @Success 200 编辑成功
  1048. // @router /sysuser/reset_pass [post]
  1049. func (this *SysAdminController) ResetPass() {
  1050. br := new(models.BaseResponse).Init()
  1051. defer func() {
  1052. this.Data["json"] = br
  1053. this.ServeJSON()
  1054. }()
  1055. var req system.SysUserResetPassReq
  1056. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1057. if err != nil {
  1058. br.Msg = "参数解析异常!"
  1059. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1060. return
  1061. }
  1062. if req.AdminId <= 0 {
  1063. br.Msg = "参数有误"
  1064. br.ErrMsg = "参数有误, AdminId"
  1065. return
  1066. }
  1067. req.Password = strings.TrimSpace(req.Password)
  1068. if req.Password == "" {
  1069. br.Msg = "新密码不能为空"
  1070. return
  1071. }
  1072. req.RePassword = strings.TrimSpace(req.RePassword)
  1073. if req.RePassword == "" {
  1074. br.Msg = "确认密码不能为空"
  1075. return
  1076. }
  1077. if req.Password != req.RePassword {
  1078. br.Msg = "两次输入密码不一致,请重新填写"
  1079. return
  1080. }
  1081. adminInfo, err := system.GetSysAdminById(req.AdminId)
  1082. if err != nil {
  1083. if utils.IsErrNoRow(err) {
  1084. br.Msg = "用户已被删除, 请刷新页面"
  1085. return
  1086. }
  1087. br.Msg = "获取数据失败"
  1088. br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error() + ";AdminId:" + fmt.Sprint(req.AdminId)
  1089. return
  1090. }
  1091. b, err := base64.StdEncoding.DecodeString(req.Password)
  1092. if err != nil {
  1093. br.Msg = "解析数据失败"
  1094. br.ErrMsg = "解析数据失败,Err:" + err.Error()
  1095. return
  1096. }
  1097. pwd := string(b)
  1098. //pwd = strings.ToLower(pwd)
  1099. pwd = utils.MD5(pwd)
  1100. adminInfo.Password = pwd
  1101. adminInfo.LastUpdatedPasswordTime = time.Now().Format(utils.FormatDateTime)
  1102. adminInfo.LastUpdatedTime = time.Now().Format(utils.FormatDateTime)
  1103. adminInfo.LastLoginTime = time.Now().Format(utils.FormatDateTime)
  1104. if e := adminInfo.Update([]string{"Password", "LastUpdatedPasswordTime", "LastUpdatedTime", "LastLoginTime"}); e != nil {
  1105. br.Msg = "操作失败"
  1106. br.ErrMsg = "更新系统用户分组失败, Err: " + e.Error()
  1107. return
  1108. }
  1109. // 清除系统用户列表缓存key及异常登录缓存
  1110. _ = utils.Rc.Delete(utils.CACHE_KEY_ADMIN)
  1111. _ = utils.Rc.Delete(utils.CACHE_KEY_ADMIN_ID)
  1112. abnormalKey := fmt.Sprint(utils.CACHE_ABNORMAL_LOGIN, adminInfo.AdminName)
  1113. errPassKey := fmt.Sprint(utils.CACHE_LOGIN_ERR_PASS, adminInfo.AdminName)
  1114. _ = utils.Rc.Delete(abnormalKey)
  1115. _ = utils.Rc.Delete(errPassKey)
  1116. br.Ret = 200
  1117. br.Success = true
  1118. br.IsAddLog = true
  1119. br.Msg = "重置密码成功"
  1120. }
  1121. // Add
  1122. // @Title 用户详情信息
  1123. // @Description 用户详情信息
  1124. // @Param request body system.SysuserAddReq true "type json string"
  1125. // @Success 200 新增成功
  1126. // @router /sysuser/detail [get]
  1127. func (this *SysAdminController) Detail() {
  1128. br := new(models.BaseResponse).Init()
  1129. defer func() {
  1130. this.Data["json"] = br
  1131. this.ServeJSON()
  1132. }()
  1133. br.Data = this.SysUser
  1134. br.Ret = 200
  1135. br.Success = true
  1136. br.Msg = "获取成功"
  1137. }