|
|
package BaseStudentController
|
|
|
|
|
|
import (
|
|
|
"dsBaseWeb/Business/BaseStudent/BaseStudentService"
|
|
|
"dsBaseWeb/Business/BaseTeacher/BaseTeacherService"
|
|
|
"dsBaseWeb/Model"
|
|
|
"dsBaseWeb/Utils/CommonUtil"
|
|
|
"fmt"
|
|
|
"github.com/bluesky335/IDCheck/IdNumber"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"net/http"
|
|
|
"net/url"
|
|
|
"os"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
//模块的路由配置
|
|
|
func Routers(r *gin.RouterGroup) {
|
|
|
rr := r.Group("/student")
|
|
|
|
|
|
rr.GET("/PageStudentInfo", PageStudentInfo)
|
|
|
rr.GET("/GetStudentInfo", GetStudentInfo)
|
|
|
rr.POST("/AddStudentInfo", AddStudentInfo)
|
|
|
rr.POST("/DeleteStudentInfo", DeleteStudentInfo)
|
|
|
rr.POST("/UpdateStudentInfo", UpdateStudentInfo)
|
|
|
rr.POST("/ReviseStudentClass", ReviseStudentClass)
|
|
|
rr.GET("/ExportStudentAccountExcel", ExportStudentAccountExcel)
|
|
|
rr.GET("/ExportStudentExcel", ExportStudentExcel)
|
|
|
rr.GET("/DownLoadStudentTemplateExcel", DownLoadStudentTemplateExcel)
|
|
|
rr.POST("/ImportStudentExcel", ImportStudentExcel)
|
|
|
|
|
|
rr.GET("/DownLoadErrorExcel", DownLoadErrorExcel)
|
|
|
|
|
|
rr.POST("/StudentTransferInfo", StudentTransferInfo)
|
|
|
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// @Summary 获取学生列表
|
|
|
// @Description 获取学生列表
|
|
|
// @Tags 学生信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param page query int true "第几页"
|
|
|
// @Param limit query int true "一页显示多少条"
|
|
|
// @Param classId query string true "班级ID"
|
|
|
// @Param xm query string false "学生姓名"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/student/PageStudentInfo [get]
|
|
|
// @X-EmptyLimit ["page","limit","classId"]
|
|
|
// @X-LengthLimit [{"classId":"36,36"},{"xm":"1,30"}]
|
|
|
// @X-IntRangeLimit [{"page":"1,1000"},{"limit":"1,1000"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["PageBaseStudent"]
|
|
|
// @X-TableName ["t_base_student"]
|
|
|
// @X-ExtendSwaggerField [{"column_name":"xb_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":"账号状态"}]
|
|
|
// @X-RemoveSwaggerField ["id_int","xmpy","cym","csrq","mzm","zzmmm","sfzjlxm","sfzjh","dszybz","sqznbz","jcwgrysqznbz","gebz","lsetbz","cjbz","class_id","bureau_id","b_use","state_id","province_code","city_code","district_code","main_school_id","last_updated_time"]
|
|
|
// @X-Sort [1]
|
|
|
func PageStudentInfo(c *gin.Context) {
|
|
|
//第几页
|
|
|
page := CommonUtil.ConvertStringToInt32(c.Query("page"))
|
|
|
//一页显示多少条
|
|
|
limit := CommonUtil.ConvertStringToInt32(c.Query("limit"))
|
|
|
//班级ID
|
|
|
classId := c.Query("classId")
|
|
|
//学生姓名
|
|
|
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 := BaseStudentService.PageStudentInfo(page, limit, classId, 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/student/GetStudentInfo [get]
|
|
|
// @X-EmptyLimit ["personId"]
|
|
|
// @X-LengthLimit [{"personId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["GetBaseStudent"]
|
|
|
// @X-TableName ["t_base_class"]
|
|
|
// @X-RemoveSwaggerField ["id_int","xmpy","cym","class_id","bureau_id","b_use","state_id","province_code","city_code","district_code","main_school_id","last_updated_time"]
|
|
|
// @X-Sort [2]
|
|
|
func GetStudentInfo(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 := BaseStudentService.GetStudentInfo(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 xm formData string true "学生姓名"
|
|
|
// @Param sfzjlxm formData string true "身份证件类型代码(字典:sfzjlxm)"
|
|
|
// @Param sfzjh formData int 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 dszybz formData int true "独生子女标志 -1:不是 1:是"
|
|
|
// @Param sqznbz formData int true "随迁子女标志 -1:不是 1:是"
|
|
|
// @Param jcwgrysqznbz formData int true "进城务工人员随迁子女标志 -1:不是 1:是"
|
|
|
// @Param gebz formData int true "孤儿标志 -1:不是 1:是"
|
|
|
// @Param lsetbz formData int true "留守儿童标志 -1:不是 1:是"
|
|
|
// @Param cjbz formData int true "残疾标志 -1:不是 1:是"
|
|
|
// @Param classId formData string true "班级ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/student/AddStudentInfo [post]
|
|
|
// @X-EmptyLimit ["xm","mzm","zzmmm","sfzjlxm","sfzjh","dszybz","sqznbz","jcwgrysqznbz","gebz","lsetbz","cjbz","classId"]
|
|
|
// @X-IntRangeLimit [{"sfzjlxm":"1,4"}]
|
|
|
// @X-LengthLimit [{"classId":"36,36"},{"xm":"2,30"},{"xbm":"1,1"},{"mzm":"2,2"},{"zzmmm":"2,2"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["AddBaseStudent"]
|
|
|
// @X-Sort [3]
|
|
|
func AddStudentInfo(c *gin.Context) {
|
|
|
//学生姓名
|
|
|
xm := c.PostForm("xm")
|
|
|
//性别
|
|
|
xbm := c.PostForm("xbm")
|
|
|
//出生日期
|
|
|
csrq := c.PostForm("csrq")
|
|
|
//民族
|
|
|
mzm := c.PostForm("mzm")
|
|
|
//政治面貌
|
|
|
zzmmm := c.PostForm("zzmmm")
|
|
|
//身份证件类型代码
|
|
|
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
|
|
|
}
|
|
|
}
|
|
|
//独生子女标志
|
|
|
dszybz := CommonUtil.ConvertStringToInt32(c.PostForm("dszybz"))
|
|
|
//随迁子女标志
|
|
|
sqznbz := CommonUtil.ConvertStringToInt32(c.PostForm("sqznbz"))
|
|
|
//进城务工人员随迁子女标志
|
|
|
jcwgrysqznbz := CommonUtil.ConvertStringToInt32(c.PostForm("jcwgrysqznbz"))
|
|
|
//孤儿标志
|
|
|
gebz := CommonUtil.ConvertStringToInt32(c.PostForm("gebz"))
|
|
|
//留守儿童标志
|
|
|
lsetbz := CommonUtil.ConvertStringToInt32(c.PostForm("lsetbz"))
|
|
|
//残疾标志
|
|
|
cjbz := CommonUtil.ConvertStringToInt32(c.PostForm("cjbz"))
|
|
|
//班级ID
|
|
|
classId := c.PostForm("classId")
|
|
|
//操作人
|
|
|
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 := BaseStudentService.AddStudentInfo(xm, xbm, csrq, mzm, zzmmm, sfzjlxm, sfzjh, dszybz, sqznbz, jcwgrysqznbz, gebz, lsetbz, cjbz, classId, 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/student/DeleteStudentInfo [post]
|
|
|
// @X-EmptyLimit ["personIds"]
|
|
|
// @X-LengthLimit [{"personIds":"36,1800"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["DeleteBaseStudent"]
|
|
|
// @X-Sort [4]
|
|
|
func DeleteStudentInfo(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 := BaseStudentService.DeleteStudentInfo(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 int 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 dszybz formData int true "独生子女标志 -1:不是 1:是"
|
|
|
// @Param sqznbz formData int true "随迁子女标志 -1:不是 1:是"
|
|
|
// @Param jcwgrysqznbz formData int true "进城务工人员随迁子女标志 -1:不是 1:是"
|
|
|
// @Param gebz formData int true "孤儿标志 -1:不是 1:是"
|
|
|
// @Param lsetbz formData int true "留守儿童标志 -1:不是 1:是"
|
|
|
// @Param cjbz formData int true "残疾标志 -1:不是 1:是"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/student/UpdateStudentInfo [post]
|
|
|
// @X-EmptyLimit ["personId","xm","mzm","zzmmm","sfzjlxm","sfzjh","dszybz","sqznbz","jcwgrysqznbz","gebz","lsetbz","cjbz"]
|
|
|
// @X-IntRangeLimit [{"sfzjlxm":"1,4"}]
|
|
|
// @X-LengthLimit [{"personId":"36,36"},{"xm":"2,30"},{"xbm":"1,1"},{"mzm":"2,2"},{"zzmmm":"2,2"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["UpdateBaseStudent"]
|
|
|
// @X-Sort [5]
|
|
|
func UpdateStudentInfo(c *gin.Context) {
|
|
|
//学生ID
|
|
|
personId := c.PostForm("personId")
|
|
|
//学生姓名
|
|
|
xm := c.PostForm("xm")
|
|
|
//性别
|
|
|
xbm := c.PostForm("xbm")
|
|
|
//出生日期
|
|
|
csrq := c.PostForm("csrq")
|
|
|
//民族
|
|
|
mzm := c.PostForm("mzm")
|
|
|
//政治面貌
|
|
|
zzmmm := c.PostForm("zzmmm")
|
|
|
//身份证件类型代码
|
|
|
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
|
|
|
}
|
|
|
}
|
|
|
//独生子女标志
|
|
|
dszybz := CommonUtil.ConvertStringToInt32(c.PostForm("dszybz"))
|
|
|
//随迁子女标志
|
|
|
sqznbz := CommonUtil.ConvertStringToInt32(c.PostForm("sqznbz"))
|
|
|
//进城务工人员随迁子女标志
|
|
|
jcwgrysqznbz := CommonUtil.ConvertStringToInt32(c.PostForm("jcwgrysqznbz"))
|
|
|
//孤儿标志
|
|
|
gebz := CommonUtil.ConvertStringToInt32(c.PostForm("gebz"))
|
|
|
//留守儿童标志
|
|
|
lsetbz := CommonUtil.ConvertStringToInt32(c.PostForm("lsetbz"))
|
|
|
//残疾标志
|
|
|
cjbz := CommonUtil.ConvertStringToInt32(c.PostForm("cjbz"))
|
|
|
//操作人
|
|
|
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 := BaseStudentService.UpdateStudentInfo(personId, xm, xbm, csrq, mzm, zzmmm, sfzjlxm, sfzjh, dszybz, sqznbz, jcwgrysqznbz, gebz, lsetbz, cjbz, 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 classId formData string true "调整后的班级ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/student/ReviseStudentClass [post]
|
|
|
// @X-EmptyLimit ["personIds"]
|
|
|
// @X-LengthLimit [{"personIds":"36,1800"},{"classId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-Sort [6]
|
|
|
func ReviseStudentClass(c *gin.Context) {
|
|
|
//教职工ID,多个用逗号分隔
|
|
|
personIds := c.PostForm("personIds")
|
|
|
//调整后的班级ID
|
|
|
classId := c.PostForm("classId")
|
|
|
r, err := BaseStudentService.ReviseStudentClass(personIds, classId)
|
|
|
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"
|
|
|
// @Param classId query string false "班级ID,不传为导出全校,传为导出班级"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/student/ExportStudentAccountExcel [get]
|
|
|
// @X-EmptyLimit ["orgId"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-Sort [7]
|
|
|
func ExportStudentAccountExcel(c *gin.Context) {
|
|
|
//学校ID
|
|
|
bureauId := c.Query("orgId")
|
|
|
//班级ID
|
|
|
classId := c.Query("classId")
|
|
|
//操作人
|
|
|
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 := BaseStudentService.ExportStudentAccountExcel(bureauId, classId, 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"
|
|
|
// @Param classId query string false "班级ID,不传为导出全校,传为导出班级"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/student/ExportStudentExcel [get]
|
|
|
// @X-EmptyLimit ["orgId"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-Sort [7]
|
|
|
func ExportStudentExcel(c *gin.Context) {
|
|
|
//学校ID
|
|
|
bureauId := c.Query("orgId")
|
|
|
//班级ID
|
|
|
classId := c.Query("classId")
|
|
|
//操作人
|
|
|
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 := BaseStudentService.ExportStudentExcel(bureauId, classId, 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/student/DownLoadStudentTemplateExcel [get]
|
|
|
// @X-EmptyLimit ["orgId"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-Sort [8]
|
|
|
func DownLoadStudentTemplateExcel(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 := BaseStudentService.DownLoadStudentTemplateExcel(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/student/ImportStudentExcel [post]
|
|
|
// @X-EmptyLimit ["orgId"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-Sort [9]
|
|
|
func ImportStudentExcel(c *gin.Context) {
|
|
|
header, _ := c.FormFile("excelFile")
|
|
|
fileId := CommonUtil.GetUUID()
|
|
|
rootPath, _ := os.Getwd()
|
|
|
fileDir := rootPath + "/Html/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 := BaseStudentService.ImportStudentExcel(bureauId, filePath, actionPersonId, actionIpAddress)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "调用RPC服务失败!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
message := ""
|
|
|
errorCode := ""
|
|
|
if r.Message == "01" {
|
|
|
errorCode = r.Message
|
|
|
message = "上传的模板不是系统提供的,请重新下载系统提供的模板进行上传!"
|
|
|
} else if r.Message == "02" {
|
|
|
errorCode = r.Message
|
|
|
message = c.Request.Host + "/base/student/DownLoadErrorExcel?fileId=" + fileId + "&fileName=" + url.QueryEscape(strings.Split(header.Filename, ".xlsx")[0])
|
|
|
} else if r.Message == "03" {
|
|
|
errorCode = "03"
|
|
|
message = "上传文件未找到!"
|
|
|
} else {
|
|
|
message = r.Message
|
|
|
}
|
|
|
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: r.Success,
|
|
|
ErrorCode: errorCode,
|
|
|
Message: message,
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:下载教师错误的EXCEL模板
|
|
|
作者:吴缤
|
|
|
日期:2020-07-20
|
|
|
*/
|
|
|
func DownLoadErrorExcel(c *gin.Context) {
|
|
|
fileId := c.Query("fileId")
|
|
|
fileName := c.Query("fileName")
|
|
|
|
|
|
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", fileName+".xlsx"))
|
|
|
c.Writer.Header().Set("Content-Type", "application/octet-stream")
|
|
|
rootPath, _ := os.Getwd()
|
|
|
fileDir := rootPath + "/Html/ExcelTemp/" + fileId + ".xlsx"
|
|
|
c.File(fileDir)
|
|
|
}
|
|
|
|
|
|
// @Summary 修改学生信息
|
|
|
// @Description 修改学生信息
|
|
|
// @Tags 学生信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param personId formData string true "学生ID"
|
|
|
// @Param classId formData string true "班级ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/student/StudentTransferInfo [post]
|
|
|
// @X-EmptyLimit ["classId","personId"]
|
|
|
// @X-LengthLimit [{"classId":"36,36"},{"personId":"36,36"}]
|
|
|
// @X-Sort [10]
|
|
|
func StudentTransferInfo(c *gin.Context) {
|
|
|
//班级ID
|
|
|
classId := c.PostForm("classId")
|
|
|
//人员ID
|
|
|
personId := c.PostForm("personId")
|
|
|
r, err := BaseStudentService.StudentTransferInfo(classId, personId)
|
|
|
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,
|
|
|
})
|
|
|
}
|