|
@@ -732,6 +732,117 @@ func SelfSupportForSchoolAddTeacher(c *gin.Context) { |
|
|
return |
|
|
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) { |
|
|
func SelfSupportForSchoolImportTeacher(c *gin.Context) { |
|
|
enterpriseIdStr := c.DefaultQuery("enterprise_id", "") |
|
|
enterpriseIdStr := c.DefaultQuery("enterprise_id", "") |
|
|
enterpriseId := utils.StrToInt(enterpriseIdStr) |
|
|
enterpriseId := utils.StrToInt(enterpriseIdStr) |
|
|