diff --git a/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go b/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go index 319257b..bb30095 100644 --- a/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go +++ b/app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go @@ -732,6 +732,117 @@ func SelfSupportForSchoolAddTeacher(c *gin.Context) { return } +func SelfSupportForSchoolAddStudent(c *gin.Context) { + var req md.SelfSupportForSchoolStudentAddReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + //1、查找当前身份是否已存在 + userIdentityDb := db.UserIdentityDb{} + userIdentityDb.Set(0) + isHasUserIdentity, err := userIdentityDb.UserIdentityExist(req.EnterpriseId, req.IdNo) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if isHasUserIdentity != nil { + e.OutErr(c, e.ERR, "当前身份已存在,直接修改身份即可!") + return + } + + now := time.Now() + //2、新增身份信息 + userIdentity := &model.UserIdentity{ + Uid: 0, + Name: req.Name, + IdNo: req.IdNo, + Kind: enum.UserIdentityKindForCommon, + Identity: enum.UserIdentityForSelfSupportForStudent, + EnterpriseId: req.EnterpriseId, + State: enum.UserIdentityStateForNormal, + Memo: "", + CreateAt: now.Format("2006-01-02 15:04:05"), + UpdateAt: now.Format("2006-01-02 15:04:05"), + } + insertAffected, err := userIdentityDb.UserIdentityInsert(userIdentity) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if insertAffected <= 0 { + e.OutErr(c, e.ERR_DB_ORM, "新增身份数据失败") + return + } + + classWithUserDb := db.ClassWithUserDb{} + _, err = classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{ + UserIdentityId: insertAffected, + ClassId: req.ClassId, + CreateAt: now.Format("2006-01-02 15:04:05"), + UpdateAt: now.Format("2006-01-02 15:04:05"), + }) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + //更新 self_support_for_user_face_info + selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{} + selfSupportForUserFaceInfoDb.Set(insertAffected) + info, err := selfSupportForUserFaceInfoDb.GetSelfSupportForUserFaceInfo() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if info == nil { + selfSupportForSchoolInfoDb := db.SelfSupportForSchoolInfoDb{} + selfSupportForSchoolInfoDb.Set(req.EnterpriseId) + selfSupportForSchoolInfo, err1 := selfSupportForSchoolInfoDb.GetSelfSupportForSchoolInfo() + if err1 != nil { + e.OutErr(c, e.ERR_DB_ORM, err1.Error()) + return + } + if selfSupportForSchoolInfo == nil { + e.OutErr(c, e.ERR, "当前学校暂未完成《一脸通行入驻》") + return + } + info = &model.SelfSupportForUserFaceInfo{ + EnterpriseId: req.EnterpriseId, + UserIdentityId: insertAffected, + CollectFaceType: req.CollectFaceType, //教师都是个采 + SchoolCode: selfSupportForSchoolInfo.SchoolCode, + SchoolStdCode: selfSupportForSchoolInfo.SchoolStdCode, + ParentUserId: "", + ParentLogonId: "", + UserId: "", + SchoolFacePassStatus: "CLOSE", + SchoolFacePaymentStatus: "CLOSE", + ConcentrateSchoolFacePassStatus: 1, + CreateAt: now.Format("2006-01-02 15:04:05"), + UpdateAt: now.Format("2006-01-02 15:04:05"), + } + _, err1 = selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoInsert(info) + if err1 != nil { + e.OutErr(c, e.ERR, err1.Error()) + return + } + } else { + info.CollectFaceType = req.CollectFaceType + _, err = selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoUpdate(info, "collect_face_type") + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + } + + e.OutSuc(c, "success", nil) + return +} + func SelfSupportForSchoolImportTeacher(c *gin.Context) { enterpriseIdStr := c.DefaultQuery("enterprise_id", "") enterpriseId := utils.StrToInt(enterpriseIdStr) diff --git a/app/admin/md/md_enterprise_manage.go b/app/admin/md/md_enterprise_manage.go index e6ed37a..b3c6449 100644 --- a/app/admin/md/md_enterprise_manage.go +++ b/app/admin/md/md_enterprise_manage.go @@ -359,6 +359,15 @@ type SelfSupportForSchoolStudentUpdateReq struct { CollectFaceType int `json:"collect_face_type" label:"采集人脸方式(1:个采 2:集采)"` } +type SelfSupportForSchoolStudentAddReq struct { + EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` + IdNo string `json:"id_no" label:"身份证号"` + Name string `json:"name" label:"姓名"` + GradeId int `json:"grade_id" label:"年级id"` + ClassId int `json:"class_id" label:"班级id"` + CollectFaceType int `json:"collect_face_type" label:"采集人脸方式(1:个采 2:集采)"` +} + type SelfSupportForSchoolStudentDeleteReq struct { EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` UserIdentityIds []int `json:"user_identity_ids" binding:"required" label:"用户身份id"` diff --git a/app/customer/hdl/hdl_user_identity.go b/app/customer/hdl/hdl_user_identity.go index 713a08f..840114d 100644 --- a/app/customer/hdl/hdl_user_identity.go +++ b/app/customer/hdl/hdl_user_identity.go @@ -231,7 +231,7 @@ func SaveSelfSupportForSchoolUserIdentity(c *gin.Context) { return } } else { - if isHasUserIdentity != nil && isHasUserIdentity.Uid != 0 && isHasUserIdentity.Uid != user.Id { + if isHasUserIdentity.Uid != 0 && isHasUserIdentity.Uid != user.Id { e.OutErr(c, e.ERR, "当前身份信息已被绑定使用") return } diff --git a/app/router/admin_router.go b/app/router/admin_router.go index f543590..e4d3622 100644 --- a/app/router/admin_router.go +++ b/app/router/admin_router.go @@ -207,6 +207,7 @@ func rEnterpriseManage(r *gin.RouterGroup) { r.DELETE("/selfSupportForSchool/gradeDelete/:id", hdl.SelfSupportForSchoolGradeDelete) //"自营-学校"年级删除 r.POST("/selfSupportForSchool/classList", hdl.SelfSupportForSchoolClassList) //"自营-学校"班级列表 r.DELETE("/selfSupportForSchool/classDelete/:id", hdl.SelfSupportForSchoolClassDelete) //"自营-学校"班级删除 + r.POST("/selfSupportForSchool/addStudent", hdl.SelfSupportForSchoolAddStudent) //"自营-学校"添加学生 r.POST("/selfSupportForSchool/addWorker", hdl.SelfSupportForSchoolAddWorker) //"自营-学校"添加工作人员 r.POST("/selfSupportForSchool/addTeacher", hdl.SelfSupportForSchoolAddTeacher) //"自营-学校"添加老师 r.POST("/selfSupportForSchool/importTeacher", hdl.SelfSupportForSchoolImportTeacher) //"自营-学校"导入老师