|
- package hdl
-
- import (
- "applet/app/customer/svc"
- "applet/app/db"
- "applet/app/e"
- "applet/app/enum"
- "github.com/gin-gonic/gin"
- )
-
- func UserInfo(c *gin.Context) {
- //1、获取用户信息
- userInfo := svc.GetUser(c)
-
- //2、获取用户身份信息
- userIdentityDb := db.UserIdentityDb{}
- userIdentityDb.Set(userInfo.Id)
- identity, err := userIdentityDb.FindUserIdentity()
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
- var identityList []map[string]interface{}
- classWithUserDb := db.ClassWithUserDb{}
- classWithUserDb.Set()
- for _, v := range *identity {
- var tmp = map[string]interface{}{
- "identity": v.UserIdentity,
- "enterprise": v.Enterprise,
- "grade": nil,
- "class": nil,
- }
- if v.UserIdentity.Identity == enum.UserIdentityForCentralKitchenForStudent || v.UserIdentity.Identity == enum.UserIdentityForSelfSupportForStudent {
- //央厨学生 or 自营学生
- data, err1 := classWithUserDb.GetInfoByUserIdentityId(v.UserIdentity.Id)
- if err1 != nil {
- e.OutErr(c, e.ERR_DB_ORM, err1.Error())
- return
- }
- if data != nil {
- tmp["grade"] = data.Grade
- tmp["class"] = data.Class
- }
- }
- identityList = append(identityList, tmp)
- }
-
- e.OutSuc(c, map[string]interface{}{
- "user_info": userInfo,
- "user_identity": identityList,
- "user_identity_kind_list": []map[string]interface{}{
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForStudent),
- "value": enum.UserIdentityForCentralKitchenForStudent,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForTeacher),
- "value": enum.UserIdentityForCentralKitchenForTeacher,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForCentralKitchenForWorker),
- "value": enum.UserIdentityForCentralKitchenForWorker,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForStudent),
- "value": enum.UserIdentityForSelfSupportForStudent,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForTeacher),
- "value": enum.UserIdentityForSelfSupportForTeacher,
- },
- {
- "name": enum.UserIdentity.String(enum.UserIdentityForSelfSupportForWorker),
- "value": enum.UserIdentityForSelfSupportForWorker,
- },
- },
- }, nil)
- return
- }
|