|
@@ -11,7 +11,9 @@ import ( |
|
|
"applet/app/e" |
|
|
"applet/app/e" |
|
|
"applet/app/enum" |
|
|
"applet/app/enum" |
|
|
"applet/app/utils" |
|
|
"applet/app/utils" |
|
|
|
|
|
"github.com/360EntSecGroup-Skylar/excelize" |
|
|
"github.com/gin-gonic/gin" |
|
|
"github.com/gin-gonic/gin" |
|
|
|
|
|
"path" |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
@@ -683,6 +685,80 @@ func SelfSupportForSchoolAddTeacher(c *gin.Context) { |
|
|
return |
|
|
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) { |
|
|
func SelfSupportForSchoolOrdList(c *gin.Context) { |
|
|
var req md.SelfSupportForSchoolOrdListReq |
|
|
var req md.SelfSupportForSchoolOrdListReq |
|
|
err := c.ShouldBindJSON(&req) |
|
|
err := c.ShouldBindJSON(&req) |
|
|