智慧食堂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdl_user.go 2.2 KiB

1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
1 年之前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package hdl
  2. import (
  3. "applet/app/customer/svc"
  4. "applet/app/db"
  5. "applet/app/e"
  6. "applet/app/enum"
  7. "github.com/gin-gonic/gin"
  8. )
  9. func UserInfo(c *gin.Context) {
  10. //1、获取用户信息
  11. userInfo := svc.GetUser(c)
  12. //2、获取用户身份信息
  13. userIdentityDb := db.UserIdentityDb{}
  14. userIdentityDb.Set(userInfo.Id)
  15. identity, err := userIdentityDb.FindUserIdentity()
  16. if err != nil {
  17. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  18. return
  19. }
  20. var identityList []map[string]interface{}
  21. classWithUserDb := db.ClassWithUserDb{}
  22. classWithUserDb.Set()
  23. for _, v := range *identity {
  24. var tmp = map[string]interface{}{
  25. "identity": v.UserIdentity,
  26. "enterprise": v.Enterprise,
  27. "grade": nil,
  28. "class": nil,
  29. }
  30. if v.UserIdentity.Identity == enum.UserIdentityForCentralKitchenForStudent || v.UserIdentity.Identity == enum.UserIdentityForSelfSupportForStudent {
  31. //央厨学生 or 自营学生
  32. data, err1 := classWithUserDb.GetInfoByUserIdentityId(v.UserIdentity.Id)
  33. if err1 != nil {
  34. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  35. return
  36. }
  37. if data != nil {
  38. tmp["grade"] = data.Grade
  39. tmp["class"] = data.Class
  40. }
  41. }
  42. identityList = append(identityList, tmp)
  43. }
  44. e.OutSuc(c, map[string]interface{}{
  45. "user_info": userInfo,
  46. "user_identity": identityList,
  47. "user_identity_kind_list": []map[string]interface{}{
  48. {
  49. "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForStudent),
  50. "value": enum.UserIdentityForCentralKitchenForStudent,
  51. },
  52. {
  53. "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForTeacher),
  54. "value": enum.UserIdentityForCentralKitchenForTeacher,
  55. },
  56. {
  57. "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForWorker),
  58. "value": enum.UserIdentityForCentralKitchenForWorker,
  59. },
  60. {
  61. "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForStudent),
  62. "value": enum.UserIdentityForSelfSupportForStudent,
  63. },
  64. {
  65. "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForTeacher),
  66. "value": enum.UserIdentityForSelfSupportForTeacher,
  67. },
  68. {
  69. "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForWorker),
  70. "value": enum.UserIdentityForSelfSupportForWorker,
  71. },
  72. },
  73. }, nil)
  74. return
  75. }