|
|
@@ -7,8 +7,10 @@ import ( |
|
|
|
"applet/app/db" |
|
|
|
"applet/app/db/model" |
|
|
|
"applet/app/e" |
|
|
|
"applet/app/enum" |
|
|
|
"applet/app/utils" |
|
|
|
"github.com/gin-gonic/gin" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
|
func SelfSupportForSchoolUserUpdate(c *gin.Context) { |
|
|
@@ -541,3 +543,105 @@ func SelfSupportForSchoolClassDelete(c *gin.Context) { |
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func SelfSupportForSchoolAddWorker(c *gin.Context) { |
|
|
|
var req md.SelfSupportForSchoolAddWorkerReq |
|
|
|
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.Time{} |
|
|
|
//2、新增身份信息 |
|
|
|
userIdentity := &model.UserIdentity{ |
|
|
|
Uid: 0, |
|
|
|
Name: req.Name, |
|
|
|
IdNo: req.IdNo, |
|
|
|
Kind: enum.UserIdentityKindForWorker, |
|
|
|
Identity: enum.UserIdentityForSelfSupportForWorker, |
|
|
|
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 |
|
|
|
} |
|
|
|
|
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func SelfSupportForSchoolAddTeacher(c *gin.Context) { |
|
|
|
var req md.SelfSupportForSchoolAddTeacherReq |
|
|
|
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.Time{} |
|
|
|
//2、新增身份信息 |
|
|
|
userIdentity := &model.UserIdentity{ |
|
|
|
Uid: 0, |
|
|
|
Name: req.Name, |
|
|
|
IdNo: req.IdNo, |
|
|
|
Kind: enum.UserIdentityKindForCommon, |
|
|
|
Identity: enum.UserIdentityForSelfSupportForTeacher, |
|
|
|
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 |
|
|
|
} |
|
|
|
|
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
} |