|
|
package BaseTeacherController
|
|
|
|
|
|
import (
|
|
|
"dsBaseWeb/Business/BaseTeacher/BaseTeacherService"
|
|
|
"dsBaseWeb/Model"
|
|
|
"dsBaseWeb/Utils/CommonUtil"
|
|
|
"fmt"
|
|
|
"github.com/bluesky335/IDCheck/IdNumber"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"net/http"
|
|
|
"os"
|
|
|
)
|
|
|
|
|
|
//模块的路由配置
|
|
|
func Routers(r *gin.RouterGroup) {
|
|
|
rr := r.Group("/teacher")
|
|
|
|
|
|
rr.GET("/PageTeacherInfo", PageTeacherInfo)
|
|
|
rr.GET("/GetTeacherInfo", GetTeacherInfo)
|
|
|
rr.POST("/AddTeacherInfo", AddTeacherInfo)
|
|
|
rr.POST("/DeleteTeacherInfo", DeleteTeacherInfo)
|
|
|
rr.POST("/UpdateTeacherInfo", UpdateTeacherInfo)
|
|
|
rr.POST("/ReviseTeacherOrg", ReviseTeacherOrg)
|
|
|
rr.GET("/ExportTeacherAccountExcel", ExportTeacherAccountExcel)
|
|
|
rr.GET("/ExportTeacherExcel", ExportTeacherExcel)
|
|
|
rr.GET("/DownLoadTeacherTemplateExcel", DownLoadTeacherTemplateExcel)
|
|
|
|
|
|
rr.POST("/ImportTeacherExcel", ImportTeacherExcel)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// @Summary 获取教职工列表
|
|
|
// @Description 获取教职工列表
|
|
|
// @Tags 教师信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param page query int true "第几页"
|
|
|
// @Param limit query int true "一页显示多少条"
|
|
|
// @Param orgId query string true "部门ID"
|
|
|
// @Param xm query string false "教职工姓名"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/teacher/PageTeacherInfo [get]
|
|
|
// @X-EmptyLimit ["page","limit","orgId"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"},{"xm":"1,20"}]
|
|
|
// @X-IntRangeLimit [{"page":"1,1000"},{"limit":"1,1000"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","5","6","7"]
|
|
|
// @X-InterfaceName ["PageBaseTeacher"]
|
|
|
// @X-ExtendSwaggerField [{"column_name":"xb_name","sample_data":"男","column_comment":"性别"},{"column_name":"org_name","sample_data":"办公室","column_comment":"所属部门"},{"column_name":"login_name","sample_data":"stu001","column_comment":"登录名"},{"column_name":"original_pwd","sample_data":"159357","column_comment":"初始密码"},{"column_name":"login_status","sample_data":"已启用","column_comment":"账号状态"},{"column_name":"stage_name","sample_data":"小学","column_comment":"学段名称"},{"column_name":"subject_name","sample_data":"数学","column_comment":"学科名称"}]
|
|
|
// @X-TableName ["t_base_teacher"]
|
|
|
// @X-RemoveSwaggerField ["identity_id","id_int","xmpy","cym","csrq","mzm","zzmmm","sfzjlxm","sfzjh","xlm","xwm","zcm","bzlbm","cjny","stage_id","subject_id","gwzym","lxdh","dzxx","b_use","state_id","last_updated_time","bureau_id","org_id","main_school_id","province_code","city_code","district_code"]
|
|
|
// @X-Sort [1]
|
|
|
func PageTeacherInfo(c *gin.Context) {
|
|
|
//第几页
|
|
|
page := CommonUtil.ConvertStringToInt32(c.Query("page"))
|
|
|
//一页显示多少条
|
|
|
limit := CommonUtil.ConvertStringToInt32(c.Query("limit"))
|
|
|
//部门ID
|
|
|
orgId := c.Query("orgId")
|
|
|
//教职工姓名
|
|
|
xm := c.Query("xm")
|
|
|
//操作人
|
|
|
actionPersonId, err := c.Cookie("person_id")
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "未获取到Cookie中的人员编码!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
//操作IP
|
|
|
actionIpAddress := c.ClientIP()
|
|
|
r, err := BaseTeacherService.PageTeacherInfo(page, limit, orgId, xm, actionPersonId, actionIpAddress)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
List: CommonUtil.ConvertJsonStringToMapArray(r.List),
|
|
|
Count: r.Count,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// @Summary 获取教职工信息
|
|
|
// @Description 获取教职工信息
|
|
|
// @Tags 教师信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param personId query string true "教职工ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/teacher/GetTeacherInfo [get]
|
|
|
// @X-EmptyLimit ["personId"]
|
|
|
// @X-LengthLimit [{"personId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","5","6","7"]
|
|
|
// @X-InterfaceName ["GetBaseTeacher"]
|
|
|
// @X-TableName ["t_base_teacher"]
|
|
|
// @X-ExtendSwaggerField [{"column_name":"org_name","sample_data":"语文组","column_comment":"部门名称"}]
|
|
|
// @X-RemoveSwaggerField ["identity_id","id_int","xmpy","cym","gwzym","b_use","state_id","last_updated_time"]
|
|
|
// @X-Sort [2]
|
|
|
func GetTeacherInfo(c *gin.Context) {
|
|
|
//教职工ID
|
|
|
personId := c.Query("personId")
|
|
|
//操作人
|
|
|
actionPersonId, err := c.Cookie("person_id")
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "未获取到Cookie中的人员编码!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
//操作IP
|
|
|
actionIpAddress := c.ClientIP()
|
|
|
r, err := BaseTeacherService.GetTeacherInfo(personId, actionPersonId, actionIpAddress)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
List: CommonUtil.ConvertJsonStringToMapArray(r.List),
|
|
|
Count: r.Count,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// @Summary 增加教职工信息
|
|
|
// @Description 增加教职工信息
|
|
|
// @Tags 教师信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param orgId formData string true "部门ID"
|
|
|
// @Param xm formData string true "教职工姓名"
|
|
|
// @Param sfzjlxm formData string true "身份证件类型(字典:sfzjlxm)"
|
|
|
// @Param sfzjh formData string true "证件号"
|
|
|
// @Param xbm formData string false "性别(字典:xbm)"
|
|
|
// @Param csrq formData string false "出生日期"
|
|
|
// @Param mzm formData string true "民族(字典:mzm)"
|
|
|
// @Param zzmmm formData string true "政治面貌(字典:zzmmm)"
|
|
|
// @Param zcm formData string true "职称(字典:zcm)"
|
|
|
// @Param bzlbm formData string true "编制(字典:bzlbm)"
|
|
|
// @Param xlm formData string true "学历(字典:xlm)"
|
|
|
// @Param xwm formData string true "学位(字典:xwm)"
|
|
|
// @Param stageId formData string true "任教学段"
|
|
|
// @Param subjectId formData string true "任教学科"
|
|
|
// @Param cjny formData string false "从教年月"
|
|
|
// @Param lxdh formData string false "联系电话"
|
|
|
// @Param dzxx formData string false "电子信箱"
|
|
|
// @Param sortId formData int false "排序号"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/teacher/AddTeacherInfo [post]
|
|
|
// @X-EmptyLimit ["orgId","xm","sfzjlxm","sfzjh","mzm","zzmmm","zcm","bzlbm","xlm","xwm"]
|
|
|
// @X-IntRangeLimit [{"sortId":"1,9999"},{"sfzjlxm":"1,4"}]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"},{"xm":"2,20"},{"xbm":"1,1"},{"sfzjh":"2,30"},{"mzm":"2,2"},{"zzmmm":"2,2"},{"zcm":"1,1"},{"bzlbm":"1,1"},{"xlm":"2,2"},{"xwm":"1,1"},{"stageId":"1,1"},{"subjectId":"2,2"},{"lxdh":"2,30"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","5","6","7"]
|
|
|
// @X-InterfaceName ["AddBaseTeacher"]
|
|
|
// @X-Sort [3]
|
|
|
func AddTeacherInfo(c *gin.Context) {
|
|
|
//部门ID
|
|
|
orgId := c.PostForm("orgId")
|
|
|
//教职工姓名
|
|
|
xm := c.PostForm("xm")
|
|
|
//性别
|
|
|
xbm := c.PostForm("xbm")
|
|
|
//出生日期
|
|
|
csrq := c.PostForm("csrq")
|
|
|
//身份证件类型
|
|
|
sfzjlxm := c.PostForm("sfzjlxm")
|
|
|
//证件号
|
|
|
sfzjh := c.PostForm("sfzjh")
|
|
|
if sfzjlxm == "1" {
|
|
|
idCard := IdNumber.New(sfzjh)
|
|
|
if !idCard.IsValid() {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "不是合法身份证号!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
//民族
|
|
|
mzm := c.PostForm("mzm")
|
|
|
//政治面貌
|
|
|
zzmmm := c.PostForm("zzmmm")
|
|
|
//职称
|
|
|
zcm := c.PostForm("zcm")
|
|
|
//编制
|
|
|
bzlbm := c.PostForm("bzlbm")
|
|
|
//学历
|
|
|
xlm := c.PostForm("xlm")
|
|
|
//学位
|
|
|
xwm := c.PostForm("xwm")
|
|
|
//从教年月
|
|
|
cjny := c.PostForm("cjny")
|
|
|
//任教学段
|
|
|
stageId := c.PostForm("stageId")
|
|
|
//任教学科
|
|
|
subjectId := c.PostForm("subjectId")
|
|
|
//联系电话
|
|
|
lxdh := c.PostForm("lxdh")
|
|
|
//电子信箱
|
|
|
dzxx := c.PostForm("dzxx")
|
|
|
//排序号
|
|
|
sortId := CommonUtil.ConvertStringToInt32(c.PostForm("sortId"))
|
|
|
//操作人
|
|
|
actionPersonId, err := c.Cookie("person_id")
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "未获取到Cookie中的人员编码!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
//操作IP
|
|
|
actionIpAddress := c.ClientIP()
|
|
|
r, err := BaseTeacherService.AddTeacherInfo(orgId, xm, xbm, csrq, sfzjlxm, sfzjh, mzm, zzmmm, zcm, bzlbm, xlm, xwm, cjny, stageId, subjectId, lxdh, dzxx, sortId, actionPersonId, actionIpAddress)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// @Summary 删除教职工信息
|
|
|
// @Description 删除教职工信息
|
|
|
// @Tags 教师信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param personIds formData string true "教职工ID,多个用逗号分隔"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/teacher/DeleteTeacherInfo [post]
|
|
|
// @X-EmptyLimit ["personIds"]
|
|
|
// @X-LengthLimit [{"personIds":"36,1800"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","5","6","7"]
|
|
|
// @X-InterfaceName ["DeleteBaseTeacher"]
|
|
|
// @X-Sort [4]
|
|
|
func DeleteTeacherInfo(c *gin.Context) {
|
|
|
//教职工ID
|
|
|
personIds := c.PostForm("personIds")
|
|
|
//操作人
|
|
|
actionPersonId, err := c.Cookie("person_id")
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "未获取到Cookie中的人员编码!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
//操作IP
|
|
|
actionIpAddress := c.ClientIP()
|
|
|
r, err := BaseTeacherService.DeleteTeacherInfo(personIds, actionPersonId, actionIpAddress)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// @Summary 修改教职工信息
|
|
|
// @Description 修改教职工信息
|
|
|
// @Tags 教师信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param personId formData string true "教职工ID"
|
|
|
// @Param xm formData string true "教职工姓名"
|
|
|
// @Param sfzjlxm formData string true "身份证件类型(字典:sfzjlxm)"
|
|
|
// @Param sfzjh formData string true "证件号"
|
|
|
// @Param xbm formData string false "性别(字典:xbm)"
|
|
|
// @Param csrq formData string false "出生日期"
|
|
|
// @Param mzm formData string true "民族(字典:mzm)"
|
|
|
// @Param zzmmm formData string true "政治面貌(字典:zzmmm)"
|
|
|
// @Param zcm formData string true "职称(字典:zcm)"
|
|
|
// @Param bzlbm formData string true "编制(字典:bzlbm)"
|
|
|
// @Param xlm formData string true "学历(字典:xlm)"
|
|
|
// @Param xwm formData string true "学位(字典:xwm)"
|
|
|
// @Param stageId formData string true "任教学段"
|
|
|
// @Param subjectId formData string true "任教学科"
|
|
|
// @Param cjny formData string false "从教年月"
|
|
|
// @Param lxdh formData string false "联系电话"
|
|
|
// @Param dzxx formData string false "电子信箱"
|
|
|
// @Param sortId formData int false "排序号"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/teacher/UpdateTeacherInfo [post]
|
|
|
// @X-EmptyLimit ["personId","xm","sfzjlxm","sfzjh","mzm","zzmmm","zcm","bzlbm","xlm","xwm"]
|
|
|
// @X-IntRangeLimit [{"sortId":"1,9999"},{"sfzjlxm":"1,4"}]
|
|
|
// @X-LengthLimit [{"personId":"36,36"},{"xm":"2,20"},{"xbm":"1,1"},{"sfzjh":"2,30"},{"mzm":"2,2"},{"zzmmm":"2,2"},{"zcm":"1,1"},{"bzlbm":"1,1"},{"xlm":"2,2"},{"xwm":"1,1"},{"stageId":"1,1"},{"subjectId":"2,2"},{"lxdh":"2,30"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","5","6","7"]
|
|
|
// @X-InterfaceName ["UpdateBaseTeacher"]
|
|
|
// @X-Sort [5]
|
|
|
func UpdateTeacherInfo(c *gin.Context) {
|
|
|
//教职工ID
|
|
|
personId := c.PostForm("personId")
|
|
|
//教职工姓名
|
|
|
xm := c.PostForm("xm")
|
|
|
//性别
|
|
|
xbm := c.PostForm("xbm")
|
|
|
//出生日期
|
|
|
csrq := c.PostForm("csrq")
|
|
|
//身份证件类型
|
|
|
sfzjlxm := c.PostForm("sfzjlxm")
|
|
|
//证件号
|
|
|
sfzjh := c.PostForm("sfzjh")
|
|
|
if sfzjlxm == "1" {
|
|
|
idCard := IdNumber.New(sfzjh)
|
|
|
if !idCard.IsValid() {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "不是合法身份证号!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
//民族
|
|
|
mzm := c.PostForm("mzm")
|
|
|
//政治面貌
|
|
|
zzmmm := c.PostForm("zzmmm")
|
|
|
//职称
|
|
|
zcm := c.PostForm("zcm")
|
|
|
//编制
|
|
|
bzlbm := c.PostForm("bzlbm")
|
|
|
//学历
|
|
|
xlm := c.PostForm("xlm")
|
|
|
//学位
|
|
|
xwm := c.PostForm("xwm")
|
|
|
//从教年月
|
|
|
cjny := c.PostForm("cjny")
|
|
|
//任教学段
|
|
|
stageId := c.PostForm("stageId")
|
|
|
//任教学科
|
|
|
subjectId := c.PostForm("subjectId")
|
|
|
//联系电话
|
|
|
lxdh := c.PostForm("lxdh")
|
|
|
//电子信箱
|
|
|
dzxx := c.PostForm("dzxx")
|
|
|
//排序号
|
|
|
sortId := CommonUtil.ConvertStringToInt32(c.PostForm("sortId"))
|
|
|
//操作人
|
|
|
actionPersonId, err := c.Cookie("person_id")
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "未获取到Cookie中的人员编码!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
//操作IP
|
|
|
actionIpAddress := c.ClientIP()
|
|
|
r, err := BaseTeacherService.UpdateTeacherInfo(personId, xm, xbm, csrq, sfzjlxm, sfzjh, mzm, zzmmm, zcm, bzlbm, xlm, xwm, cjny, stageId, subjectId, lxdh, dzxx, sortId, actionPersonId, actionIpAddress)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// @Summary 调整教职工部门
|
|
|
// @Description 调整教职工部门
|
|
|
// @Tags 教师信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param personIds formData string true "教职工ID,多个用逗号分隔"
|
|
|
// @Param orgId formData string true "调整后的部门ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/teacher/ReviseTeacherOrg [post]
|
|
|
// @X-EmptyLimit ["personIds"]
|
|
|
// @X-LengthLimit [{"personIds":"36,1800"},{"sourceOrgId":"36,36"},{"targetOrgId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","5","6","7"]
|
|
|
// @X-Sort [6]
|
|
|
func ReviseTeacherOrg(c *gin.Context) {
|
|
|
//教职工ID,多个用逗号分隔
|
|
|
personIds := c.PostForm("personIds")
|
|
|
//调整后的部门ID
|
|
|
orgId := c.PostForm("orgId")
|
|
|
r, err := BaseTeacherService.ReviseTeacherOrg(personIds, orgId)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// @Summary 导出本单位教职工账号信息到EXCEL
|
|
|
// @Description 导出本单位教职工账号信息到EXCEL
|
|
|
// @Tags 教师信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param orgId query string true "单位ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/teacher/ExportTeacherAccountExcel [get]
|
|
|
// @X-EmptyLimit ["orgId"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","5","6","7"]
|
|
|
// @X-Sort [7]
|
|
|
func ExportTeacherAccountExcel(c *gin.Context) {
|
|
|
//学校ID
|
|
|
bureauId := c.Query("orgId")
|
|
|
//操作人
|
|
|
actionPersonId, err := c.Cookie("person_id")
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "未获取到Cookie中的人员编码!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
//操作IP
|
|
|
actionIpAddress := c.ClientIP()
|
|
|
r, err := BaseTeacherService.ExportTeacherAccountExcel(bureauId, actionPersonId, actionIpAddress)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "教职工账号.xlsx"))
|
|
|
c.Writer.Header().Set("Content-Type", "application/octet-stream")
|
|
|
c.File(r.ExcelPath)
|
|
|
}
|
|
|
|
|
|
// @Summary 导出本单位教职工信息到EXCEL
|
|
|
// @Description 导出本单位教职工信息到EXCEL
|
|
|
// @Tags 教师信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param orgId query string true "单位ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/teacher/ExportTeacherExcel [get]
|
|
|
// @X-EmptyLimit ["orgId"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","5","6","7"]
|
|
|
// @X-Sort [8]
|
|
|
func ExportTeacherExcel(c *gin.Context) {
|
|
|
//学校ID
|
|
|
bureauId := c.Query("orgId")
|
|
|
//操作人
|
|
|
actionPersonId, err := c.Cookie("person_id")
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "未获取到Cookie中的人员编码!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
//操作IP
|
|
|
actionIpAddress := c.ClientIP()
|
|
|
r, err := BaseTeacherService.ExportTeacherExcel(bureauId, actionPersonId, actionIpAddress)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "教职工信息.xlsx"))
|
|
|
c.Writer.Header().Set("Content-Type", "application/octet-stream")
|
|
|
c.File(r.ExcelPath)
|
|
|
}
|
|
|
|
|
|
// @Summary 下载教职工导入模板
|
|
|
// @Description 下载教职工导入模板
|
|
|
// @Tags 教师信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param orgId query string true "单位ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/teacher/DownLoadTeacherTemplateExcel [get]
|
|
|
// @X-EmptyLimit ["orgId"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","5","6","7"]
|
|
|
// @X-Sort [9]
|
|
|
func DownLoadTeacherTemplateExcel(c *gin.Context) {
|
|
|
//学校ID
|
|
|
bureauId := c.Query("orgId")
|
|
|
//操作人
|
|
|
actionPersonId, err := c.Cookie("person_id")
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "未获取到Cookie中的人员编码!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
//操作IP
|
|
|
actionIpAddress := c.ClientIP()
|
|
|
r, err := BaseTeacherService.DownLoadTeacherTemplateExcel(bureauId, actionPersonId, actionIpAddress)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "教职工模板.xlsx"))
|
|
|
c.Writer.Header().Set("Content-Type", "application/octet-stream")
|
|
|
c.File(r.ExcelPath)
|
|
|
}
|
|
|
|
|
|
// @Summary 导入教职工EXCEL
|
|
|
// @Description 导入教职工EXCEL
|
|
|
// @Tags 教师信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param orgId formData string true "单位ID"
|
|
|
// @Param excelFile formData file true "EXCEL文件"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/teacher/ImportTeacherExcel [post]
|
|
|
// @X-EmptyLimit ["orgId"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","5","6","7"]
|
|
|
// @X-Sort [10]
|
|
|
func ImportTeacherExcel(c *gin.Context) {
|
|
|
header, _ := c.FormFile("excelFile")
|
|
|
fileId := CommonUtil.GetUUID()
|
|
|
rootPath, _ := os.Getwd()
|
|
|
fileDir := rootPath + "/Static/ExcelTemp/"
|
|
|
filePath := fileDir + fileId + ".xlsx"
|
|
|
c.SaveUploadedFile(header, filePath)
|
|
|
|
|
|
//删除7天前无用的模板文件
|
|
|
BaseTeacherService.DeleteInvalidFile(fileDir)
|
|
|
|
|
|
//单位ID,多个用逗号分隔
|
|
|
bureauId := c.PostForm("orgId")
|
|
|
//操作人
|
|
|
actionPersonId, err := c.Cookie("person_id")
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "未获取到Cookie中的人员编码!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
//操作IP
|
|
|
actionIpAddress := c.ClientIP()
|
|
|
r, err := BaseTeacherService.ImportTeacherExcel(bureauId, filePath, actionPersonId, actionIpAddress)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if !r.Success {
|
|
|
r.Message = c.Request.Host + "/static/ExcelTemp/" + fileId + ".xlsx"
|
|
|
}
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
Message: r.Message,
|
|
|
})
|
|
|
}
|