@@ -318,3 +318,99 @@ func SelfSupportForSchoolTeacherDelete(c *gin.Context) { | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func SelfSupportForSchoolWorkerList(c *gin.Context) { | |||
var req md.SelfSupportForSchoolWorkerListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
resp, total, err := svc2.SelfSupportForSchoolWorkerList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": resp, | |||
"total": total, | |||
"collect_face_type_list": []map[string]interface{}{ | |||
{ | |||
"name": "个采", | |||
"value": 1, | |||
}, | |||
{ | |||
"name": "集采", | |||
"value": 2, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func SelfSupportForSchoolWorkerUpdate(c *gin.Context) { | |||
var req md.SelfSupportForSchoolWorkerUpdateReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(0) | |||
userIdentity, err := userIdentityDb.GetUserIdentity(req.UserIdentityId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if userIdentity == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
userIdentity.IdNo = req.IdNo | |||
userIdentity.Name = req.Name | |||
_, err = userIdentityDb.UserIdentityUpdate(req.UserIdentityId, userIdentity, "id_no", "name") | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func SelfSupportForSchoolWorkerDelete(c *gin.Context) { | |||
var req md.SelfSupportForSchoolWorkerDeleteReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
//删除 user_identity | |||
_, err = db.Db.Where("enterprise_id =?", req.EnterpriseId).In("id", req.UserIdentityIds).Delete(model.UserIdentity{}) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} |
@@ -298,3 +298,31 @@ type SelfSupportForSchoolTeacherDeleteReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
UserIdentityIds []int `json:"user_identity_ids" binding:"required" label:"用户身份id"` | |||
} | |||
type SelfSupportForSchoolWorkerListReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
Limit int `json:"limit" binding:"required"` | |||
Page int `json:"page" binding:"required"` | |||
Name string `json:"name" label:"姓名"` | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
} | |||
type SelfSupportForSchoolWorkerListResp struct { | |||
UserIdentityId int `json:"user_identity_id" label:"用户身份id"` | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
Phone string `json:"parent_phone" label:"电话"` | |||
Name string `json:"name" label:"姓名"` | |||
CreateAt string `json:"create_at" label:"创建时间"` | |||
} | |||
type SelfSupportForSchoolWorkerUpdateReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
UserIdentityId int `json:"user_identity_id" binding:"required" label:"用户身份id"` | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
Name string `json:"name" label:"姓名"` | |||
} | |||
type SelfSupportForSchoolWorkerDeleteReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
UserIdentityIds []int `json:"user_identity_ids" binding:"required" label:"用户身份id"` | |||
} |
@@ -241,7 +241,7 @@ func SelfSupportForSchoolStudentList(req md.SelfSupportForSchoolStudentListReq) | |||
classWithUserIdentityIdsTwo = append(classWithUserIdentityIdsTwo, v.UserIdentityId) | |||
} | |||
} | |||
sess := db.Db.Where("user_identity.enterprise_id =?", req.EnterpriseId).And("identity =?", enum2.UserIdentityForCentralKitchenForStudent) | |||
sess := db.Db.Where("user_identity.enterprise_id =?", req.EnterpriseId).And("identity =?", enum2.UserIdentityForSelfSupportForStudent) | |||
if req.Name != "" { | |||
sess.And("user_identity.name like ?", "%"+req.Name+"%") | |||
} | |||
@@ -287,7 +287,7 @@ func SelfSupportForSchoolTeacherList(req md.SelfSupportForSchoolTeacherListReq) | |||
classWithUserDb := db.ClassWithUserDb{} | |||
classWithUserDb.Set() | |||
sess := db.Db.Where("user_identity.enterprise_id =?", req.EnterpriseId).And("user_identity.identity =?", enum2.UserIdentityForCentralKitchenForTeacher) | |||
sess := db.Db.Where("user_identity.enterprise_id =?", req.EnterpriseId).And("user_identity.identity =?", enum2.UserIdentityForSelfSupportForTeacher) | |||
if req.Name != "" { | |||
sess.And("user_identity.name like ?", "%"+req.Name+"%") | |||
} | |||
@@ -429,3 +429,46 @@ func SelfSupportForSchoolStudentAdmission(req md.SelfSupportForSchoolStudentAdmi | |||
return | |||
} | |||
func SelfSupportForSchoolWorkerList(req md.SelfSupportForSchoolWorkerListReq) (resp []md.SelfSupportForSchoolWorkerListResp, count int64, err error) { | |||
var classWithUserIdentityIdsOne []int | |||
var classWithUserIdentityIdsTwo []int | |||
classWithUserDb := db.ClassWithUserDb{} | |||
classWithUserDb.Set() | |||
sess := db.Db.Where("user_identity.enterprise_id =?", req.EnterpriseId).And("user_identity.identity =?", enum2.UserIdentityForSelfSupportForWorker) | |||
if req.Name != "" { | |||
sess.And("user_identity.name like ?", "%"+req.Name+"%") | |||
} | |||
if req.IdNo != "" { | |||
sess.And("user_identity.id_no like ?", "%"+req.IdNo+"%") | |||
} | |||
if len(classWithUserIdentityIdsOne) > 0 { | |||
sess.In("user_identity.id", classWithUserIdentityIdsOne) | |||
} | |||
if len(classWithUserIdentityIdsTwo) > 0 { | |||
sess.In("user_identity.id", classWithUserIdentityIdsTwo) | |||
} | |||
var m []*db.UserIdentityWithUser | |||
count, err = sess. | |||
Join("LEFT", "user", "user_identity.uid = user.id"). | |||
Join("LEFT", "class_with_user", "class_with_user.user_identity_id = user_identity.id"). | |||
Join("LEFT", "class", "class_with_user.class_id = class.id"). | |||
Join("LEFT", "grade", "class.grade_id = grade.id"). | |||
Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m) | |||
if err != nil { | |||
return nil, 0, err | |||
} | |||
for _, v := range m { | |||
resp = append(resp, md.SelfSupportForSchoolWorkerListResp{ | |||
UserIdentityId: v.UserIdentity.Id, | |||
IdNo: v.UserIdentity.IdNo, | |||
Phone: v.User.Phone, | |||
Name: v.UserIdentity.Name, | |||
CreateAt: v.UserIdentity.CreateAt, | |||
}) | |||
} | |||
return | |||
} |
@@ -144,6 +144,9 @@ func rEnterpriseManage(r *gin.RouterGroup) { | |||
r.POST("/selfSupportForSchool/teacherList", hdl.SelfSupportForSchoolTeacherList) //"自营-学校"教师列表 | |||
r.POST("/selfSupportForSchool/teacherUpdate", hdl.SelfSupportForSchoolTeacherUpdate) //"自营-学校"教师编辑 | |||
r.POST("/selfSupportForSchool/teacherDelete", hdl.SelfSupportForSchoolTeacherDelete) //"自营-学校"教师删除 | |||
r.POST("/selfSupportForSchool/workerList", hdl.SelfSupportForSchoolWorkerList) //"自营-学校"工作人员列表 | |||
r.POST("/selfSupportForSchool/workerUpdate", hdl.SelfSupportForSchoolWorkerUpdate) //"自营-学校"工作人员编辑 | |||
r.POST("/selfSupportForSchool/workerDelete", hdl.SelfSupportForSchoolWorkerDelete) //"自营-学校"工作人员删除 | |||
} | |||