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.

287 lines
8.6 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 BaseGlobalController
import (
"dsBaseWeb/Business/BaseGlobal/BaseGlobalService"
"dsBaseWeb/Model"
"dsBaseWeb/Utils/CommonUtil"
"github.com/gin-gonic/gin"
"net/http"
)
//模块的路由配置
func Routers(r *gin.RouterGroup) {
rr := r.Group("/global")
//注册get方法
rr.POST("/AddGlobalInfo", AddGlobalInfo)
rr.POST("/DeleteGlobalInfo", DeleteGlobalInfo)
rr.POST("/UpdateGlobalInfo", UpdateGlobalInfo)
rr.GET("/PageGlobalInfo", PageGlobalInfo)
rr.GET("/GetGlobalInfo", GetGlobalInfo)
rr.GET("/GetGlobalValueByCodes", GetGlobalValueByCodes)
return
}
// @Summary 增加全局变量
// @Description 增加全局变量
// @Tags 全局变量
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Param globalTypeId formData int true "全局变量分类"
// @Param globalCode formData string true "全局变量代码"
// @Param globalValue formData string true "全局变量值"
// @Param globalRemarks formData string false "全局变量备注"
// @Param sortId formData int true "排序号"
// @Success 200 {object} Model.Res
// @Router /base/global/AddGlobalInfo [post]
// @X-EmptyLimit ["globalTypeId","globalCode","globalValue","sortId"]
// @X-IntLimit ["globalTypeId","sortId"]
// @X-LengthLimit [{"globalCode":"2,50"},{"globalValue":"1,255"},{"globalRemarks":"1,500"}]
// @X-RoleLimit ["1"]
// @X-Sort [4]
func AddGlobalInfo(c *gin.Context) {
globalTypeId := CommonUtil.ConvertStringToInt(c.PostForm("globalTypeId"))
globalCode := c.PostForm("globalCode")
globalValue := c.PostForm("globalValue")
globalRemarks := c.PostForm("globalRemarks")
sortId := CommonUtil.ConvertStringToInt32(c.PostForm("sortId"))
//操作人
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 := BaseGlobalService.AddGlobalInfo(globalTypeId, globalCode, globalValue, globalRemarks, sortId, 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 globalIds formData string true "全局变量ID多个用逗号分隔"
// @Success 200 {object} Model.Res
// @Router /base/global/DeleteGlobalInfo [post]
// @X-EmptyLimit ["globalIds"]
// @X-LengthLimit [{"globalIds":"36,1800"}]
// @X-RoleLimit ["1"]
// @X-Sort [5]
func DeleteGlobalInfo(c *gin.Context) {
globalIds := c.PostForm("globalIds")
//操作人
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 := BaseGlobalService.DeleteGlobalInfo(globalIds, 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 globalId formData string true "全局变量ID"
// @Param globalTypeId formData int true "全局变量分类"
// @Param globalCode formData string true "全局变量代码"
// @Param globalValue formData string true "全局变量值"
// @Param globalRemarks formData string false "全局变量备注"
// @Param sortId formData int true "排序号"
// @Success 200 {object} Model.Res
// @Router /base/global/UpdateGlobalInfo [post]
// @X-EmptyLimit ["globalId","globalTypeId","globalCode","globalValue","sortId"]
// @X-IntLimit ["globalId","globalTypeId","sortId"]
// @X-LengthLimit [{"globalId":"36,36"},{"globalCode":"2,50"},{"globalValue":"1,255"},{"globalRemarks":"1,500"}]
// @X-RoleLimit ["1"]
// @X-Sort [6]
func UpdateGlobalInfo(c *gin.Context) {
globalId := c.PostForm("globalId")
globalTypeId := CommonUtil.ConvertStringToInt32(c.PostForm("globalTypeId"))
globalCode := c.PostForm("globalCode")
globalValue := c.PostForm("globalValue")
globalRemarks := c.PostForm("globalRemarks")
sortId := CommonUtil.ConvertStringToInt32(c.PostForm("sortId"))
//操作人
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 := BaseGlobalService.UpdateGlobalInfo(globalId, globalTypeId, globalCode, globalValue, globalRemarks, sortId, 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 page query int true "第几页"
// @Param limit query int true "一页显示多少条"
// @Param globalTypeId query int true "全局变量分类(全部传-1"
// @Success 200 {object} Model.Res
// @Router /base/global/PageGlobalInfo [get]
// @X-EmptyLimit ["page","limit","globalTypeId"]
// @X-IntLimit ["page","limit","globalTypeId"]
// @X-RoleLimit ["1"]
// @X-TableName ["t_base_global"]
// @X-Sort [1]
func PageGlobalInfo(c *gin.Context) {
page := CommonUtil.ConvertStringToInt32(c.Query("page"))
limit := CommonUtil.ConvertStringToInt32(c.Query("limit"))
globalTypeId := CommonUtil.ConvertStringToInt32(c.Query("globalTypeId"))
//操作人
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 := BaseGlobalService.PageGlobalInfo(page, limit, globalTypeId, 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,
List: CommonUtil.ConvertJsonStringToMapArray(r.List),
Message: r.Message,
Count: r.Count,
})
}
// @Summary 获取全局变量信息
// @Description 获取全局变量信息
// @Tags 全局变量
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Param globalId query string true "全局变量ID"
// @Success 200 {object} Model.Res
// @Router /base/global/GetGlobalInfo [get]
// @X-EmptyLimit ["globalId"]
// @X-LengthLimit [{"globalId":"36,36"}]
// @X-RoleLimit ["1"]
// @X-InterfaceName ["GetBaseGlobal"]
// @X-TableName ["t_base_global"]
// @X-Sort [2]
func GetGlobalInfo(c *gin.Context) {
//全局变量ID
globalId := c.Query("globalId")
//操作人
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 := BaseGlobalService.GetGlobalInfo(globalId, 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 根据多个全局变量Code获取全局变量值
// @Description 根据多个全局变量Code获取全局变量值
// @Tags 全局变量
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Param codes query string true "全局变量Code多个用逗号分隔"
// @Success 200 {object} Model.Res
// @Router /base/global/GetGlobalValueByCodes [get]
// @X-EmptyLimit ["codes"]
// @X-LengthLimit [{"codes":"1,500"}]
// @X-RoleLimit ["1","2","3","4","5","6","7"]
// @X-InterfaceName ["GetBaseGlobal"]
// @X-TableName ["t_base_global"]
// @X-Sort [3]
func GetGlobalValueByCodes(c *gin.Context) {
//全局变量Code多个用逗号分隔
codes := c.Query("codes")
r, err := BaseGlobalService.GetGlobalValueByCodes(codes)
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,
})
}