package BasePurviewController import ( "dsBaseWeb/Business/BasePurview/BasePurviewService" "dsBaseWeb/Model" "dsBaseWeb/Utils/CommonUtil" "github.com/gin-gonic/gin" "net/http" ) func Routers(r *gin.RouterGroup) { rr := r.Group("/purview") //配置接口 rr.POST("/AddPurviewInfo", AddPurviewInfo) rr.POST("/DeletePurviewInfo", DeletePurviewInfo) rr.POST("/UpdatePurviewInfo", UpdatePurviewInfo) rr.GET("/GetPurviewInfoById", GetPurviewInfoById) rr.GET("/PagePurviewInfoByBusinessCode", PagePurviewInfoByBusinessCode) rr.GET("/PagePurviewInfoByPersonIdBusinessCode", PagePurviewInfoByPersonIdBusinessCode) return } // @Summary 增加权限信息 // @Description 增加权限信息 // @Tags 权限 // @Accept application/x-www-form-urlencoded // @Produce json // @Param purviewName formData string true "权限名称" // @Param businessCode formData string true "业务系统编码" // @Param purviewType formData int true "权限类型 1:菜单 2:按钮" // @Param menuUrl formData string true "菜单的URL 没有填#" // @Param parentId formData string true "父节点ID" // @Param sortId formData int false "排序号" // @Success 200 {object} Model.Res // @Router /base/purview/AddPurviewInfo [post] // @X-EmptyLimit ["purviewName","businessCode","purviewType","menuUrl","parentId"] // @X-IntLimit ["purviewType","sortId"] // @X-IntRangeLimit [{"purviewType":"1,2"},{"sortId":"1,9999"}] // @X-LengthLimit [{"purviewName":"1,100"},{"businessCode":"6,6"},{"menuUrl":"1,300"},{"parentId":"36,36"}] // @X-RoleLimit ["1"] // @X-InterfaceName ["AddBasePurview"] // @X-Sort [1] func AddPurviewInfo(c *gin.Context) { //权限名称 purviewName := c.PostForm("purviewName") //业务系统编码 businessCode := c.PostForm("businessCode") //权限类型 1:菜单 2:按钮 purviewType := CommonUtil.ConvertStringToInt32(c.PostForm("purviewType")) //菜单的URL 没有填# menuUrl := c.PostForm("menuUrl") //父节点ID parentId := c.PostForm("parentId") //排序号 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 := BasePurviewService.AddPurviewInfo(purviewName, businessCode, purviewType, menuUrl, parentId, 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 purviewIds formData string true "权限ID,如果是多个用逗号分隔" // @Success 200 {object} Model.Res // @Router /base/purview/DeletePurviewInfo [post] // @X-EmptyLimit ["purviewIds"] // @X-LengthLimit [{"purviewIds":"36,1800"}] // @X-RoleLimit ["1"] // @X-InterfaceName ["DeleteBasePurview"] // @X-Sort [2] func DeletePurviewInfo(c *gin.Context) { //权限ID purviewIds := c.PostForm("purviewIds") //操作人 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 := BasePurviewService.DeletePurviewInfo(purviewIds, 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 purviewId formData string true "权限ID" // @Param purviewName formData string true "权限名称" // @Param businessCode formData string true "业务系统编码" // @Param purviewType formData int true "权限类型 1:菜单 2:按钮" // @Param menuUrl formData string true "菜单的URL 没有填#" // @Param sortId formData int false "排序号" // @Success 200 {object} Model.Res // @Router /base/purview/UpdatePurviewInfo [post] // @X-EmptyLimit ["purviewId","purviewName","businessCode","purviewType","menuUrl"] // @X-IntLimit ["purviewType","sortId"] // @X-IntRangeLimit [{"purviewType":"1,2"},{"sortId":"1,9999"}] // @X-LengthLimit [{"purviewId":"36,36"},{"purviewName":"1,100"},{"businessCode":"6,6"},{"menuUrl":"1,300"}] // @X-RoleLimit ["1"] // @X-InterfaceName ["UpdateBasePurview"] // @X-Sort [3] func UpdatePurviewInfo(c *gin.Context) { //权限ID purviewId := c.PostForm("purviewId") //权限名称 purviewName := c.PostForm("purviewName") //业务系统编码 businessCode := c.PostForm("businessCode") //权限类型 1:菜单 2:按钮 purviewType := CommonUtil.ConvertStringToInt32(c.PostForm("purviewType")) //菜单的URL 没有填# menuUrl := c.PostForm("menuUrl") //排序号 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 := BasePurviewService.UpdatePurviewInfo(purviewId, purviewName, businessCode, purviewType, menuUrl, 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 purviewId query string true "权限ID" // @Success 200 {object} Model.Res // @Router /base/purview/GetPurviewInfoById [get] // @X-EmptyLimit ["purviewId"] // @X-LengthLimit [{"purviewId":"36,36"}] // @X-RoleLimit ["1"] // @X-InterfaceName ["GetBasePurview"] // @X-TableName ["t_base_purview"] // @X-RemoveSwaggerField ["id_int","purview_type","menu_icon","b_use","last_updated_time"] // @X-Sort [4] func GetPurviewInfoById(c *gin.Context) { //权限ID purviewId := c.Query("purviewId") //操作人 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 := BasePurviewService.GetPurviewInfoById(purviewId, 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 page query int true "第几页" // @Param limit query int true "一页显示多少条" // @Param businessCode query string true "业务系统编码" // @Success 200 {object} Model.Res // @Router /base/purview/PagePurviewInfoByBusinessCode [get] // @X-EmptyLimit ["page","limit","businessCode"] // @X-IntLimit ["page","limit"] // @X-IntRangeLimit [{"page":"1,1000"},{"limit":"1,1000"}] // @X-LengthLimit [{"businessCode":"6,6"}] // @X-RoleLimit ["1"] // @X-InterfaceName ["PageBasePurview"] // @X-TableName ["t_base_purview"] // @X-RemoveSwaggerField ["id_int","purview_type","menu_icon","b_use","last_updated_time"] // @X-Sort [5] func PagePurviewInfoByBusinessCode(c *gin.Context) { //第几页 page := CommonUtil.ConvertStringToInt32(c.Query("page")) //一页显示多少条 limit := CommonUtil.ConvertStringToInt32(c.Query("limit")) //业务系统编码 businessCode := c.Query("businessCode") //操作人 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 := BasePurviewService.PagePurviewInfoByBusinessCode(page, limit, businessCode, 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和业务系统编码获取权限信息信息 // @Description 根据人员ID和业务系统编码获取权限信息信息 // @Tags 权限 // @Accept application/x-www-form-urlencoded // @Produce json // @Param page query int true "第几页" // @Param limit query int true "一页显示多少条" // @Success 200 {object} Model.Res // @Router /base/purview/PagePurviewInfoByPersonIdBusinessCode [get] // @X-EmptyLimit ["page","limit"] // @X-IntLimit ["page","limit"] // @X-IntRangeLimit [{"page":"1,1000"},{"limit":"1,1000"}] // @X-RoleLimit ["1","2","3","4","5","6","7"] // @X-InterfaceName ["PageBasePurview"] // @X-TableName ["t_base_purview"] // @X-RemoveSwaggerField ["id_int","purview_type","business_code","b_use","last_updated_time"] // @X-Sort [6] func PagePurviewInfoByPersonIdBusinessCode(c *gin.Context) { //第几页 page := CommonUtil.ConvertStringToInt32(c.Query("page")) //一页显示多少条 limit := CommonUtil.ConvertStringToInt32(c.Query("limit")) //人员ID personId, err := c.Cookie("person_id") if err != nil { c.JSON(http.StatusOK, Model.Res{ Success: false, Message: "未获取到Cookie中的人员编码!", }) return } //业务系统编码 businessCode := "B00001" //操作人 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 := BasePurviewService.PagePurviewInfoByPersonIdBusinessCode(page, limit, personId, businessCode, 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, }) }