|
|
package BaseClassController
|
|
|
|
|
|
import (
|
|
|
"dsBaseWeb/Business/BaseClass/BaseClassService"
|
|
|
"dsBaseWeb/Model"
|
|
|
"dsBaseWeb/Utils/CommonUtil"
|
|
|
"fmt"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"net/http"
|
|
|
"os"
|
|
|
)
|
|
|
|
|
|
//模块的路由配置
|
|
|
func Routers(r *gin.RouterGroup) {
|
|
|
rr := r.Group("/class")
|
|
|
|
|
|
rr.GET("/PageClassInfo", PageClassInfo)
|
|
|
rr.GET("/GetClassInfo", GetClassInfo)
|
|
|
rr.POST("/AddClassInfo", AddClassInfo)
|
|
|
rr.POST("/DeleteClassInfo", DeleteClassInfo)
|
|
|
rr.POST("/UpdateClassInfo", UpdateClassInfo)
|
|
|
rr.POST("/SetClassTeacher", SetClassTeacher)
|
|
|
rr.GET("/GetStageInfo", GetStageInfo)
|
|
|
rr.GET("/GetRxnfInfo", GetRxnfInfo)
|
|
|
|
|
|
rr.POST("/ImportXJCSV", ImportXJCSV)
|
|
|
rr.GET("/DownLoadXJCSV", DownLoadXJCSV)
|
|
|
|
|
|
rr.GET("/RestoreGraduate", RestoreGraduate)
|
|
|
|
|
|
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 stageId query int true "学部ID"
|
|
|
// @Param rxnf query int true "入学年份"
|
|
|
// @Param removeClassId query string false "需要滤掉的班级ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/class/PageClassInfo [get]
|
|
|
// @X-EmptyLimit ["page","limit","orgId","stageId","rxnf"]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"},{"removeClassId":"36,36"}]
|
|
|
// @X-IntRangeLimit [{"page":"1,1000"},{"limit":"1,1000"},{"rxnf":"1990,2100"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["PageBaseClass"]
|
|
|
// @X-ExtendSwaggerField [{"column_name":"student_count","sample_data":"41","column_comment":"学生人数"},{"column_name":"teacher_name","sample_data":"李老师","column_comment":"班主任"}]
|
|
|
// @X-TableName ["t_base_class"]
|
|
|
// @X-RemoveSwaggerField ["id_int","bh","class_code","rxnf","rxjj","schooling_length","stage_id","org_id","bureau_id","b_use","province_code","city_code","district_code","main_school_id","last_updated_time"]
|
|
|
// @X-Sort [1]
|
|
|
func PageClassInfo(c *gin.Context) {
|
|
|
//第几页
|
|
|
page := CommonUtil.ConvertStringToInt32(c.Query("page"))
|
|
|
//一页显示多少条
|
|
|
limit := CommonUtil.ConvertStringToInt32(c.Query("limit"))
|
|
|
//学校ID
|
|
|
bureauId := c.Query("orgId")
|
|
|
//学部ID
|
|
|
stageId := CommonUtil.ConvertStringToInt32(c.Query("stageId"))
|
|
|
//入学年份
|
|
|
rxnf := CommonUtil.ConvertStringToInt32(c.Query("rxnf"))
|
|
|
//需要滤掉的班级ID
|
|
|
removeClassId := c.Query("removeClassId")
|
|
|
//操作人
|
|
|
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 := BaseClassService.PageClassInfo(page, limit, bureauId, stageId, rxnf, removeClassId, 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 classId query string true "班级ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/class/GetClassInfo [get]
|
|
|
// @X-EmptyLimit ["classId"]
|
|
|
// @X-LengthLimit [{"classId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["GetBaseClass"]
|
|
|
// @X-TableName ["t_base_class"]
|
|
|
// @X-RemoveSwaggerField ["id_int","class_code","rxjj","teacher_id","org_id","bureau_id","b_use","province_code","city_code","district_code","main_school_id","last_updated_time"]
|
|
|
// @X-Sort [2]
|
|
|
func GetClassInfo(c *gin.Context) {
|
|
|
//班级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 := BaseClassService.GetClassInfo(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,
|
|
|
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 stageId formData int true "学部ID"
|
|
|
// @Param schoolingLength formData int true "学制"
|
|
|
// @Param rxnf formData int true "入学年份"
|
|
|
// @Param startBh formData int false "开始班号"
|
|
|
// @Param endBh formData int false "结束班号"
|
|
|
// @Param classAlias formData string false "班级别名(只有单个班级时才有)"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/class/AddClassInfo [post]
|
|
|
// @X-EmptyLimit ["orgId","stageId","schoolingLength","rxnf","startBh","endBh"]
|
|
|
// @X-IntRangeLimit [{"rxnf":"1990,2100"},{"schoolingLength":"1,10"},{"startBh":"1,999"},{"endBh":"1,999"}]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"},{"xbm":"1,1"},{"classAlias":"1,30"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["AddBaseClass"]
|
|
|
// @X-Sort [3]
|
|
|
func AddClassInfo(c *gin.Context) {
|
|
|
//学校ID
|
|
|
bureauId := c.PostForm("orgId")
|
|
|
//学部ID
|
|
|
stageId := CommonUtil.ConvertStringToInt32(c.PostForm("stageId"))
|
|
|
//学制
|
|
|
schoolingLength := CommonUtil.ConvertStringToInt32(c.PostForm("schoolingLength"))
|
|
|
//入学年份
|
|
|
rxnf := CommonUtil.ConvertStringToInt32(c.PostForm("rxnf"))
|
|
|
//开始班号
|
|
|
startBh := CommonUtil.ConvertStringToInt32(c.PostForm("startBh"))
|
|
|
//结束班号
|
|
|
endBh := CommonUtil.ConvertStringToInt32(c.PostForm("endBh"))
|
|
|
//班级别名(只有单个班级时才有)
|
|
|
classAlias := c.PostForm("classAlias")
|
|
|
//操作人
|
|
|
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 := BaseClassService.AddClassInfo(bureauId, stageId, schoolingLength, rxnf, startBh, endBh, classAlias, 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 classIds formData string true "班级ID,多个用逗号分隔"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/class/DeleteClassInfo [post]
|
|
|
// @X-EmptyLimit ["classIds"]
|
|
|
// @X-LengthLimit [{"classId":"36,1800"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["DeleteBaseClass"]
|
|
|
// @X-Sort [4]
|
|
|
func DeleteClassInfo(c *gin.Context) {
|
|
|
//班级ID
|
|
|
classIds := c.PostForm("classIds")
|
|
|
//操作人
|
|
|
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 := BaseClassService.DeleteClassInfo(classIds, 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 classId formData string true "班级ID"
|
|
|
// @Param classAlias formData string true "班级别名"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/class/UpdateClassInfo [post]
|
|
|
// @X-EmptyLimit ["classId","classAlias"]
|
|
|
// @X-LengthLimit [{"classId":"36,36"},{"classAlias":"1,30"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["UpdateBaseClass"]
|
|
|
// @X-Sort [5]
|
|
|
func UpdateClassInfo(c *gin.Context) {
|
|
|
//班级ID
|
|
|
classId := c.PostForm("classId")
|
|
|
//班级别名
|
|
|
classAlias := c.PostForm("classAlias")
|
|
|
//操作人
|
|
|
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 := BaseClassService.UpdateClassInfo(classId, classAlias, 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 classId formData string true "班级ID"
|
|
|
// @Param teacherId formData string true "教师ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/class/SetClassTeacher [post]
|
|
|
// @X-EmptyLimit ["classId","teacherId"]
|
|
|
// @X-LengthLimit [{"classId":"36,36"},{"teacherId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["UpdateBaseClass"]
|
|
|
// @X-Sort [6]
|
|
|
func SetClassTeacher(c *gin.Context) {
|
|
|
//班级ID
|
|
|
classId := c.PostForm("classId")
|
|
|
//教师ID
|
|
|
teacherId := c.PostForm("teacherId")
|
|
|
//操作人
|
|
|
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 := BaseClassService.SetClassTeacher(classId, teacherId, 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 orgId query string true "学校ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/class/GetStageInfo [get]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["PageBaseClass"]
|
|
|
// @X-TableName ["t_dm_stage"]
|
|
|
// @X-RemoveSwaggerField ["b_use","sort_id"]
|
|
|
// @X-Sort [7]
|
|
|
func GetStageInfo(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 := BaseClassService.GetStageInfo(bureauId, 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 根据学校ID和学部(学段)ID获取入学年份
|
|
|
// @Description 根据学校ID和学部(学段)ID获取入学年份
|
|
|
// @Tags 班级信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Param orgId query string true "学校ID"
|
|
|
// @Param stageId query int true "学部(学段)ID"
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/class/GetRxnfInfo [get]
|
|
|
// @X-LengthLimit [{"orgId":"36,36"}]
|
|
|
// @X-RoleLimit ["1","2","3","4","6","7"]
|
|
|
// @X-InterfaceName ["PageBaseClass"]
|
|
|
// @X-Sort [8]
|
|
|
func GetRxnfInfo(c *gin.Context) {
|
|
|
//学校ID
|
|
|
bureauId := c.Query("orgId")
|
|
|
//学部(学段)ID
|
|
|
stageId := CommonUtil.ConvertStringToInt32(c.Query("stageId"))
|
|
|
//操作人
|
|
|
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 := BaseClassService.GetRxnfInfo(bureauId, stageId, 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.ConvertStringArrayToArray(r.List),
|
|
|
Count: r.Count,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// @Summary 导入学籍CSV文件
|
|
|
// @Description 导入学籍CSV文件
|
|
|
// @Tags 班级信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/class/ImportXJCSV [post]
|
|
|
// @X-Sort [9]
|
|
|
func ImportXJCSV(c *gin.Context) {
|
|
|
classIds := "B1413D43-35D0-486F-81D3-6ABF6BA4FB23"
|
|
|
//操作人
|
|
|
actionPersonId, err := c.Cookie("person_id")
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: false,
|
|
|
Message: "未获取到Cookie中的人员编码!",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
//操作IP
|
|
|
actionIpAddress := c.ClientIP()
|
|
|
|
|
|
BaseClassService.ImportXJCSV(classIds, 1, actionPersonId, actionIpAddress)
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: true,
|
|
|
Message: "操作成功!",
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
// @Summary 下载学籍CSV文件
|
|
|
// @Description 下载学籍CSV文件
|
|
|
// @Tags 班级信息
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
// @Produce json
|
|
|
// @Success 200 {object} Model.Res
|
|
|
// @Router /base/class/DownLoadXJCSV [get]
|
|
|
// @X-Sort [10]
|
|
|
func DownLoadXJCSV(c *gin.Context) {
|
|
|
rootPath, _ := os.Getwd()
|
|
|
filePath := rootPath + "/Html/CSV/F860A002-D6BA-11EA-8CD6-000C29496EB0.csv"
|
|
|
|
|
|
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "学生名单.csv"))
|
|
|
c.Writer.Header().Set("Content-Type", "application/octet-stream")
|
|
|
c.File(filePath)
|
|
|
}
|
|
|
|
|
|
func RestoreGraduate(c *gin.Context) {
|
|
|
classIds := "B1413D43-35D0-486F-81D3-6ABF6BA4FB23"
|
|
|
|
|
|
BaseClassService.ImportXJCSV(classIds, -3, "EF01A2DA-0012-4D2D-B142-61958284E449", "127.0.0.1")
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
Success: true,
|
|
|
Message: "操作成功!",
|
|
|
})
|
|
|
}
|