diff --git a/app/admin/md/md_enterprise_manage.go b/app/admin/md/md_enterprise_manage.go index b21871e..74d2caf 100644 --- a/app/admin/md/md_enterprise_manage.go +++ b/app/admin/md/md_enterprise_manage.go @@ -2,9 +2,12 @@ package md type EnterpriseUserListReq struct { EnterpriseId int `json:"enterprise_id" label:"企业id"` + GradeId int `json:"grade_id" label:"年级id"` + ClassId int `json:"class_id" label:"班级id"` Limit int `json:"limit" binding:"required"` Page int `json:"page" binding:"required"` Nickname string `json:"nickname" label:"支付宝昵称"` + Name string `json:"name" label:"用户名称"` Phone string `json:"phone" label:"手机号"` IsTeacher int `json:"is_teacher" label:"是否教师"` EnterpriseName string `json:"enterprise_name" label:"校企名称"` diff --git a/app/admin/svc/enterprise_manage/svc_enterprise_manage.go b/app/admin/svc/enterprise_manage/svc_enterprise_manage.go index c5efff8..cc10c52 100644 --- a/app/admin/svc/enterprise_manage/svc_enterprise_manage.go +++ b/app/admin/svc/enterprise_manage/svc_enterprise_manage.go @@ -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,