user_yanxuan_permission.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package cygx
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hz_crm_api/models/cygx"
  6. "hongze/hz_crm_api/services/alarm_msg"
  7. "hongze/hz_crm_api/utils"
  8. "time"
  9. )
  10. // 添加更新日志记录
  11. func AddCygxUserYanxuanPermissionLog(item *cygx.CygxUserYanxuanPermission) {
  12. var err error
  13. defer func() {
  14. if err != nil {
  15. fmt.Println(err)
  16. go alarm_msg.SendAlarmMsg(fmt.Sprint(item, err.Error()), 2)
  17. }
  18. }()
  19. itemLog := new(cygx.CygxUserYanxuanPermissionLog)
  20. itemLog.Status = item.Status
  21. itemLog.UserId = item.UserId
  22. itemLog.CompanyId = item.CompanyId
  23. itemLog.CompanyName = item.CompanyName
  24. itemLog.StartDate = item.StartDate
  25. itemLog.EndDate = item.EndDate
  26. itemLog.Mobile = item.Mobile
  27. itemLog.Email = item.Email
  28. itemLog.RealName = item.RealName
  29. itemLog.AdminId = item.AdminId
  30. itemLog.AdminRealName = item.AdminRealName
  31. itemLog.CreatedTime = time.Now()
  32. itemLog.LastUpdatedTime = time.Now()
  33. itemLog.ModifyTime = time.Now()
  34. _, e := cygx.AddCygxUserYanxuanPermissionLog(itemLog)
  35. if e != nil {
  36. err = errors.New("AddCygxUserYanxuanPermissionLog, Err: " + e.Error())
  37. return
  38. }
  39. return
  40. }
  41. // GetCygxUserYanxuanPermissionItem 根据用户ID 获取对应的研选权限信息
  42. func GetCygxUserYanxuanPermissionMapItem(userIds []int) (mapResp map[int]*cygx.CygxUserYanxuanPermission) {
  43. lenArr := len(userIds)
  44. if lenArr == 0 {
  45. return
  46. }
  47. var err error
  48. defer func() {
  49. if err != nil {
  50. fmt.Println(err)
  51. go alarm_msg.SendAlarmMsg(fmt.Sprint("userIds", userIds, err.Error()), 2)
  52. }
  53. }()
  54. var condition string
  55. var pars []interface{}
  56. condition += " AND status = '试用' AND user_id IN(" + utils.GetOrmInReplace(lenArr) + ") "
  57. pars = append(pars, userIds)
  58. list, e := cygx.GetCygxUserYanxuanPermissionList(condition, pars, 0, lenArr)
  59. if e != nil {
  60. err = errors.New("GetCygxUserYanxuanPermissionList, Err: " + e.Error())
  61. return
  62. }
  63. mapResp = make(map[int]*cygx.CygxUserYanxuanPermission, 0)
  64. for _, v := range list {
  65. mapResp[v.UserId] = v
  66. }
  67. return
  68. }