You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

410 lines
12 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package BaseClassController
import (
"dsBaseWeb/Business/BaseClass/BaseClassService"
"dsBaseWeb/Model"
"dsBaseWeb/Utils/CommonUtil"
"github.com/gin-gonic/gin"
"net/http"
)
//模块的路由配置
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)
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 string true "学部ID"
// @Param rxnf query int true "入学年份"
// @Success 200 {object} Model.Res
// @Router /base/class/PageClassInfo [get]
// @X-EmptyLimit ["page","limit","orgId","stageId","rxnf"]
// @X-LengthLimit [{"orgId":"36,36"}]
// @X-IntRangeLimit [{"page":"1,1000"},{"limit":"1,1000"},{"rxnf":"1990,2100"}]
// @X-LengthLimit [{"stageId":"1,1"}]
// @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 := c.Query("stageId")
//入学年份
rxnf := CommonUtil.ConvertStringToInt32(c.Query("rxnf"))
//操作人
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, 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 string 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,99"},{"endBh":"1,99"}]
// @X-LengthLimit [{"orgId":"36,36"},{"stageId":"1,1"},{"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 := 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 string 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 := 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,
})
}