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.

226 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 BasePositionController
import (
"dsBaseWeb/Business/BasePosition/BasePositionService"
"dsBaseWeb/Model"
"dsBaseWeb/Utils/CommonUtil"
"github.com/gin-gonic/gin"
"net/http"
)
func Routers(r *gin.RouterGroup) {
rr := r.Group("/position")
//配置接口
rr.POST("/AddPositionInfo", AddPositionInfo)
rr.POST("/DeletePositionInfo", DeletePositionInfo)
rr.POST("/UpdatePositionInfo", UpdatePositionInfo)
rr.GET("/GetPositionInfoById", GetPositionInfoById)
rr.GET("/TreePositionInfo", TreePositionInfo)
rr.GET("/ListPositionByBureauId", ListPositionByBureauId)
return
}
// @Summary 增加职务信息
// @Description 增加职务信息
// @Tags 职务
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Param nodeName formData string true "职务名称"
// @Param parentId formData string true "上级节点ID"
// @Param areaLevel formData int true "区域级别,传上一级节点的area_level"
// @Param orgType formData int true "单位类型,传上一级节点的org_type"
// @Param xxbxlxm formData string true "学校办学类型,传上一级节点的xxbxlxm"
// @Param sortId formData int false "排序号"
// @Success 200 {object} Model.Res
// @Router /base/position/AddPositionInfo [post]
// @X-EmptyLimit ["nodeName","parentId","areaLevel","orgType","xxbxlxm"]
// @X-IntLimit ["areaLevel","orgType","sortId"]
// @X-IntRangeLimit [{"sortId":"1,9999"}]
// @X-LengthLimit [{"parentId":"36,36"},{"nodeName":"2,30"}]
// @X-RoleLimit ["1"]
// @X-Sort [1]
func AddPositionInfo(c *gin.Context) {
//职务名称
nodeName := c.PostForm("nodeName")
//上级节点ID
parentId := c.PostForm("parentId")
//区域级别,传上一级节点的area_level
areaLevel := CommonUtil.ConvertStringToInt32(c.PostForm("areaLevel"))
//单位类型,传上一级节点的org_type
orgType := CommonUtil.ConvertStringToInt32(c.PostForm("orgType"))
//学校办学类型,传上一级节点的xxbxlxm
xxbxlxm := c.PostForm("xxbxlxm")
//排序号
sortId := CommonUtil.ConvertStringToInt32(c.PostForm("sortId"))
r, err := BasePositionService.AddPositionInfo(nodeName, parentId, areaLevel, orgType, xxbxlxm, sortId)
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 id formData string true "职务ID"
// @Success 200 {object} Model.Res
// @Router /base/position/DeletePositionInfo [post]
// @X-EmptyLimit ["id"]
// @X-LengthLimit [{"id":"36,36"}]
// @X-RoleLimit ["1"]
// @X-Sort [2]
func DeletePositionInfo(c *gin.Context) {
//职务ID
id := c.PostForm("id")
r, err := BasePositionService.DeletePositionInfo(id)
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 id formData string true "职务ID"
// @Param nodeName formData string true "职务名称"
// @Param sortId formData int false "排序号"
// @Success 200 {object} Model.Res
// @Router /base/position/UpdatePositionInfo [post]
// @X-EmptyLimit ["id","nodeName"]
// @X-IntLimit ["areaLevel","orgType","sortId"]
// @X-IntRangeLimit [{"sortId":"1,9999"}]
// @X-LengthLimit [{"id":"36,36"},{"nodeName":"2,30"}]
// @X-RoleLimit ["1"]
// @X-Sort [3]
func UpdatePositionInfo(c *gin.Context) {
//职务ID
id := c.PostForm("id")
//职务名称
nodeName := c.PostForm("nodeName")
//排序号
sortId := CommonUtil.ConvertStringToInt32(c.PostForm("sortId"))
r, err := BasePositionService.UpdatePositionInfo(id, nodeName, sortId)
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 id query string true "职务ID"
// @Success 200 {object} Model.Res
// @Router /base/position/GetPositionInfoById [get]
// @X-EmptyLimit ["id"]
// @X-LengthLimit [{"id":"36,36"}]
// @X-RoleLimit ["1"]
// @X-RemoveSwaggerField ["id_int","b_use","last_updated_time"]
// @X-Sort [4]
func GetPositionInfoById(c *gin.Context) {
//职务ID
id := c.Query("id")
r, err := BasePositionService.GetPositionInfoById(id)
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
// @Success 200 {object} Model.Res
// @Router /base/position/TreePositionInfo [get]
// @X-RoleLimit ["1"]
// @X-RemoveSwaggerField ["id_int","b_use","last_updated_time","postion_flag"]
// @X-Sort [5]
func TreePositionInfo(c *gin.Context) {
r, err := BasePositionService.TreePositionInfo()
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 根据单位ID获取职务列表信息
// @Description 根据单位ID获取职务列表信息
// @Tags 职务
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Param bureauId query string true "单位ID"
// @Success 200 {object} Model.Res
// @Router /base/position/ListPositionByBureauId [get]
// @X-EmptyLimit ["bureauId"]
// @X-LengthLimit [{"bureauId":"36,36"}]
// @X-RoleLimit ["1","3","4"]
// @X-Sort [6]
func ListPositionByBureauId(c *gin.Context) {
//职务ID
bureauId := c.Query("bureauId")
r, err := BasePositionService.ListPositionByBureauId(bureauId)
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),
})
}