diff --git a/app/customer/hdl/hdl_user_identity.go b/app/customer/hdl/hdl_user_identity.go index 0bf6a6a..713a08f 100644 --- a/app/customer/hdl/hdl_user_identity.go +++ b/app/customer/hdl/hdl_user_identity.go @@ -31,7 +31,7 @@ func SaveCentralKitchenForSchoolUserIdentity(c *gin.Context) { //1、判断当前身份是否已绑定 userIdentityDb := db.UserIdentityDb{} userIdentityDb.Set(user.Id) - isHasUserIdentity, err := userIdentityDb.UserIdentityExistV1(req.EnterpriseId, req.Name, req.ClassId) + isHasUserIdentity, err := userIdentityDb.UserIdentityExistV1(req.EnterpriseId, req.Name) if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return diff --git a/app/db/db_user_identity.go b/app/db/db_user_identity.go index bb7f4c0..d6a85c0 100644 --- a/app/db/db_user_identity.go +++ b/app/db/db_user_identity.go @@ -42,33 +42,45 @@ func (userIdentityDb *UserIdentityDb) UserIdentityExist(enterpriseId int, idNo s return m, nil } -func (userIdentityDb *UserIdentityDb) UserIdentityExistV1(enterpriseId int, name string, classId int) (m *model.UserIdentity, err error) { +func (userIdentityDb *UserIdentityDb) UserIdentityExistV1(enterpriseId int, name string) (m *model.UserIdentity, err error) { m = new(model.UserIdentity) - var mm []model.UserIdentity - if err = userIdentityDb.Db.Where("enterprise_id =?", enterpriseId).And("name =?", name).Find(&mm); err != nil { + has, err := userIdentityDb.Db.Where("enterpriseId =?", enterpriseId).And("uid =?", userIdentityDb.Uid).And("name =?", name).Get(m) + if err != nil { return nil, logx.Error(err) } - if len(mm) <= 0 { + if has == false { return nil, nil } - classWithUserDb := ClassWithUserDb{} - classWithUserDb.Set() - for _, v := range mm { - //查找 class_with_user - class, err1 := classWithUserDb.GetClassWithUserByUserIdentityId(v.Id) - if err1 != nil { - return nil, err - } - //if class == nil { - // return nil, errors.New("当前学生身份待管理员确认") - //} - if class.ClassId == classId { - return m, nil - } - } - return nil, nil + return m, nil } +//func (userIdentityDb *UserIdentityDb) UserIdentityExistV2(enterpriseId int, name string, classId int) (m *model.UserIdentity, err error) { +// m = new(model.UserIdentity) +// var mm []model.UserIdentity +// if err = userIdentityDb.Db.Where("enterpriseId =?", enterpriseId).And("uid =?", userIdentityDb.Uid).And("name =?", name).Find(&mm); err != nil { +// return nil, logx.Error(err) +// } +// if len(mm) <= 0 { +// return nil, nil +// } +// classWithUserDb := ClassWithUserDb{} +// classWithUserDb.Set() +// for _, v := range mm { +// //查找 class_with_user +// class, err1 := classWithUserDb.GetClassWithUserByUserIdentityId(v.Id) +// if err1 != nil { +// return nil, err +// } +// //if class == nil { +// // return nil, errors.New("当前学生身份待管理员确认") +// //} +// if class.ClassId == classId { +// return m, nil +// } +// } +// return nil, nil +//} + func (userIdentityDb *UserIdentityDb) FindUserIdentity() (*[]UserIdentityWithEnterprise, error) { var m []UserIdentityWithEnterprise if err := userIdentityDb.Db.