|
|
@@ -17,6 +17,7 @@ func EnterpriseUserListByCentralKitchenForSchool(req md.EnterpriseUserListReq) ( |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
userIdentities, err := userIdentityDb.FindUserIdentityForEnterprise(req.EnterpriseId) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
@@ -122,6 +123,64 @@ func EnterpriseUserListByCentralKitchenForSchoolV2(req md.EnterpriseUserListReq) |
|
|
|
if req.IsTeacher == 2 { |
|
|
|
sess.And("user_identity.identity = ?", enum2.UserIdentityForCentralKitchenForStudent) |
|
|
|
} |
|
|
|
|
|
|
|
userIdentityDb := db.UserIdentityDb{} |
|
|
|
userIdentityDb.Set(0) |
|
|
|
userIdentitiy, err := userIdentityDb.FindUserIdentityForEnterprise(req.EnterpriseId) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
var uids []int |
|
|
|
for _, v := range *userIdentitiy { |
|
|
|
uids = append(uids, v.Uid) |
|
|
|
} |
|
|
|
if len(uids) > 0 { |
|
|
|
sess.In("id", uids) |
|
|
|
} |
|
|
|
|
|
|
|
var classWithUserIdentityIdsOne []int |
|
|
|
var classWithUserIdentityIdsTwo []int |
|
|
|
classWithUserDb := db.ClassWithUserDb{} |
|
|
|
classWithUserDb.Set() |
|
|
|
if req.ClassId != 0 { |
|
|
|
classWithUsers, err2 := classWithUserDb.FindUserIdentity(req.ClassId) |
|
|
|
if err2 != nil { |
|
|
|
return resp, err2 |
|
|
|
} |
|
|
|
for _, v := range *classWithUsers { |
|
|
|
classWithUserIdentityIdsOne = append(classWithUserIdentityIdsOne, v.UserIdentityId) |
|
|
|
} |
|
|
|
} |
|
|
|
if req.GradeId != 0 { |
|
|
|
classDb := db.ClassDb{} |
|
|
|
classDb.Set(req.GradeId) |
|
|
|
classes, err3 := classDb.FindClass() |
|
|
|
if err3 != nil { |
|
|
|
return resp, err3 |
|
|
|
} |
|
|
|
var classesId []int |
|
|
|
for _, v := range *classes { |
|
|
|
classesId = append(classesId, v.Id) |
|
|
|
} |
|
|
|
classWithUsers, err4 := classWithUserDb.FindUserIdentity(classesId) |
|
|
|
if err4 != nil { |
|
|
|
return resp, err4 |
|
|
|
} |
|
|
|
for _, v := range *classWithUsers { |
|
|
|
classWithUserIdentityIdsTwo = append(classWithUserIdentityIdsTwo, v.UserIdentityId) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if req.Name != "" { |
|
|
|
sess.And("user_identity.name like ?", "%"+req.Name+"%") |
|
|
|
} |
|
|
|
if len(classWithUserIdentityIdsOne) > 0 { |
|
|
|
sess.In("user_identity.id", classWithUserIdentityIdsOne) |
|
|
|
} |
|
|
|
if len(classWithUserIdentityIdsTwo) > 0 { |
|
|
|
sess.In("user_identity.id", classWithUserIdentityIdsTwo) |
|
|
|
} |
|
|
|
|
|
|
|
var m []*db.UserWithUserIdentity |
|
|
|
count, _ := sess. |
|
|
|
Join("LEFT", "user_identity", "user.id = user_identity.uid"). |
|
|
@@ -129,7 +188,6 @@ func EnterpriseUserListByCentralKitchenForSchoolV2(req md.EnterpriseUserListReq) |
|
|
|
resp.Total = count |
|
|
|
|
|
|
|
var userIdentitiesMap = map[string][]db.UserIdentityWithClass{} |
|
|
|
userIdentityDb := db.UserIdentityDb{} |
|
|
|
for _, v := range m { |
|
|
|
userIdentityDb.Set(v.User.Id) |
|
|
|
userIdentities, err1 := userIdentityDb.FindUserIdentityWithClass() |
|
|
@@ -141,8 +199,6 @@ func EnterpriseUserListByCentralKitchenForSchoolV2(req md.EnterpriseUserListReq) |
|
|
|
} |
|
|
|
} |
|
|
|
fmt.Println("!!!!!!!!!") |
|
|
|
classWithUserDb := db.ClassWithUserDb{} |
|
|
|
classWithUserDb.Set() |
|
|
|
for _, v := range m { |
|
|
|
temp := md.EnterpriseUserListByCentralKitchenForSchoolStruct{ |
|
|
|
Id: v.User.Id, |
|
|
|