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.

233 lines
6.5 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 SysDictController
import (
"dsBaseWeb/Business/SysDict/SysDictService"
"dsBaseWeb/Model"
"dsBaseWeb/Utils/CommonUtil"
"github.com/gin-gonic/gin"
"net/http"
)
//模块的路由配置
func Routers(r *gin.RouterGroup) {
rr := r.Group("/dict")
//教育局相关接口
rr.GET("/GetDictInfo", GetDictInfo)
rr.GET("/PageDict", PageDict)
rr.GET("/GetStageInfo", GetStageInfo)
rr.GET("/GetSubjectInfo", GetSubjectInfo)
rr.GET("/GetMultipleDictInfo", GetMultipleDictInfo)
return
}
// @Summary 根据字典分类和字典编码获取字典信息
// @Description 根据字典分类和字典编码获取字典信息
// @Tags 字典
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Param dictKind query string true "字典分类"
// @Param dictCode query string true "字典编码"
// @Success 200 {object} Model.Res
// @Router /base/dict/GetDictInfo [get]
// @X-EmptyLimit ["dictKind","dictCode"]
// @X-LengthLimit [{"dictKind":"1,20"},{"dictCode":"1,10"}]
// @X-RoleLimit ["1","2","3","4","5","6","7"]
// @X-InterfaceName ["GetSysDict"]
// @X-TableName ["t_sys_dict"]
// @X-RemoveSwaggerField ["dict_id","dict_kind","dict_remark","dict_parent","sort_id","b_use"]
// @X-Sort [1]
func GetDictInfo(c *gin.Context) {
//字典分类
dictKind := c.Query("dictKind")
//字典编码
dictCode := c.Query("dictCode")
//操作人
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 := SysDictService.GetDictInfo(dictKind, dictCode, 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),
})
}
// @Summary 根据字典分类、上级字典编码获取字典信息
// @Description 根据字典分类、上级字典编码获取字典信息
// @Tags 字典
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Param dictKind query string true "字典分类"
// @Param dictParent query string false "上级字典编码"
// @Success 200 {object} Model.Res
// @Router /base/dict/PageDict [get]
// @X-EmptyLimit ["dictKind"]
// @X-LengthLimit [{"dictKind":"1,20"},{"dictParent":"1,10"}]
// @X-RoleLimit ["1","2","3","4","5","6","7"]
// @X-InterfaceName ["PageSysDict"]
// @X-TableName ["t_sys_dict"]
// @X-RemoveSwaggerField ["dict_id","dict_kind","dict_remark","dict_parent","sort_id","b_use"]
// @X-Sort [2]
func PageDict(c *gin.Context) {
//字典分类
dictKind := c.Query("dictKind")
//上级字典编码
dictParent := c.Query("dictParent")
//操作人
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 := SysDictService.PageDict(dictKind, dictParent, 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
// @Success 200 {object} Model.Res
// @Router /base/dict/GetStageInfo [get]
// @X-RoleLimit ["1","2","3","4","5","6","7"]
// @X-InterfaceName ["PageSysDict"]
// @X-TableName ["t_dm_stage"]
// @X-RemoveSwaggerField ["b_use","sort_id"]
// @X-Sort [3]
func GetStageInfo(c *gin.Context) {
r, err := SysDictService.GetStageInfo()
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获取学科信息
// @Description 根据学段ID获取学科信息
// @Tags 字典
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Param stageId query string true "学段ID"
// @Success 200 {object} Model.Res
// @Router /base/dict/GetSubjectInfo [get]
// @X-EmptyLimit ["stageId"]
// @X-LengthLimit [{"stageId":"1,1"}]
// @X-RoleLimit ["1","2","3","4","5","6","7"]
// @X-InterfaceName ["PageSysDict"]
// @X-TableName ["t_dm_subject"]
// @X-RemoveSwaggerField ["b_use","sort_id"]
// @X-Sort [4]
func GetSubjectInfo(c *gin.Context) {
//学段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 := SysDictService.GetSubjectInfo(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.ConvertJsonStringToMapArray(r.List),
Count: r.Count,
})
}
// @Summary 根据多个dict_kind获取字典信息
// @Description 根据多个dict_kind获取字典信息
// @Tags 字典
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Param dictKinds query string true "字典分类,多个用逗号分隔"
// @Success 200 {object} Model.Res
// @Router /base/dict/GetMultipleDictInfo [get]
// @X-EmptyLimit ["dictKinds"]
// @X-LengthLimit [{"dictKinds":"1,500"}]
// @X-RoleLimit ["1","2","3","4","5","6","7"]
// @X-Sort [5]
func GetMultipleDictInfo(c *gin.Context) {
dictKinds := c.Query("dictKinds")
//操作人
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 := SysDictService.GetMultipleDictInfo(dictKinds, 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.ConvertJsonStringToMap(r.List),
Count: r.Count,
})
}