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 8714862..1891a15 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 @@ -11,7 +11,9 @@ import ( "applet/app/e" "applet/app/enum" "applet/app/utils" + "github.com/360EntSecGroup-Skylar/excelize" "github.com/gin-gonic/gin" + "path" "time" ) @@ -683,6 +685,80 @@ func SelfSupportForSchoolAddTeacher(c *gin.Context) { return } +func SelfSupportForSchoolImportTeacher(c *gin.Context) { + enterpriseIdStr := c.DefaultQuery("enterprise_id", "") + enterpriseId := utils.StrToInt(enterpriseIdStr) + enterpriseDb := db.EnterpriseDb{} + enterpriseDb.Set() + enterprise, err := enterpriseDb.GetEnterprise(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 + } + files, _ := c.FormFile("file") + dst := path.Join("./static/upload", files.Filename) + err = c.SaveUploadedFile(files, dst) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + xlsx, err := excelize.OpenFile(dst) + rows := xlsx.GetRows("Sheet" + "1") + for key, row := range rows { + if key > 0 && (row[0] != "" && row[1] != "") { + idNo := row[0] + name := row[1] + //1、查找当前身份是否已存在 + userIdentityDb := db.UserIdentityDb{} + userIdentityDb.Set(0) + isHasUserIdentity, err := userIdentityDb.UserIdentityExist(enterpriseId, idNo) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if isHasUserIdentity != nil { + continue + } + + now := time.Now() + //2、新增身份信息 + userIdentity := &model.UserIdentity{ + Uid: 0, + Name: name, + IdNo: idNo, + Kind: enum.UserIdentityKindForCommon, + Identity: enum.UserIdentityForSelfSupportForTeacher, + EnterpriseId: 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 SelfSupportForSchoolDownloadTemplateExcel(c *gin.Context) { + e.OutSuc(c, "/", nil) + return +} + func SelfSupportForSchoolOrdList(c *gin.Context) { var req md.SelfSupportForSchoolOrdListReq err := c.ShouldBindJSON(&req) diff --git a/app/router/admin_router.go b/app/router/admin_router.go index 79c6554..8d0a0bc 100644 --- a/app/router/admin_router.go +++ b/app/router/admin_router.go @@ -204,6 +204,8 @@ func rEnterpriseManage(r *gin.RouterGroup) { r.DELETE("/selfSupportForSchool/classDelete/:id", hdl.SelfSupportForSchoolClassDelete) //"自营-学校"班级删除 r.POST("/selfSupportForSchool/addWorker", hdl.SelfSupportForSchoolAddWorker) //"自营-学校"添加工作人员 r.POST("/selfSupportForSchool/addTeacher", hdl.SelfSupportForSchoolAddTeacher) //"自营-学校"添加老师 + r.POST("/selfSupportForSchool/importTeacher", hdl.SelfSupportForSchoolImportTeacher) //"自营-学校"导入老师 + r.GET("/selfSupportForSchool/downloadTemplateExcel", hdl.SelfSupportForSchoolDownloadTemplateExcel) //"自营-学校"下载表格模板 r.POST("/selfSupportForSchool/ordList", hdl.SelfSupportForSchoolOrdList) //"自营-学校"订单列表 r.POST("/selfSupportForSchool/arrearsOrdList", hdl.SelfSupportForSchoolArrearsOrdList) //"自营-学校"订单欠费列表 r.POST("/selfSupportForSchool/arrearsOrdDebtRepay", hdl.SelfSupportForSchoolArrearsOrdDebtRepay) //"自营-学校"订单欠费催缴 diff --git a/static/template/自营学校(教师信息导入模板).xls b/static/template/自营学校(教师信息导入模板).xls new file mode 100644 index 0000000..86f424e Binary files /dev/null and b/static/template/自营学校(教师信息导入模板).xls differ