server/api/v1层代码swagger备注错误修改及代码优化
This commit is contained in:
@@ -1,56 +1,54 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gin-vue-admin/global/response"
|
||||
"gin-vue-admin/global"
|
||||
"gin-vue-admin/model/request"
|
||||
resp "gin-vue-admin/model/response"
|
||||
"gin-vue-admin/model/response"
|
||||
"gin-vue-admin/service"
|
||||
"gin-vue-admin/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// @Tags casbin
|
||||
// @Summary 更改角色api权限
|
||||
// @Tags Casbin
|
||||
// @Summary 更新角色api权限
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body request.CasbinInReceive true "更改角色api权限"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Param data body request.CasbinInReceive true "权限id, 权限模型列表"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
|
||||
// @Router /casbin/UpdateCasbin [post]
|
||||
func UpdateCasbin(c *gin.Context) {
|
||||
var cmr request.CasbinInReceive
|
||||
_ = c.ShouldBindJSON(&cmr)
|
||||
AuthorityIdVerifyErr := utils.Verify(cmr, utils.CustomizeMap["AuthorityIdVerify"])
|
||||
if AuthorityIdVerifyErr != nil {
|
||||
response.FailWithMessage(AuthorityIdVerifyErr.Error(), c)
|
||||
if err := utils.Verify(cmr, utils.AuthorityIdVerify); err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
err := service.UpdateCasbin(cmr.AuthorityId, cmr.CasbinInfos)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("添加规则失败,%v", err), c)
|
||||
if err := service.UpdateCasbin(cmr.AuthorityId, cmr.CasbinInfos); err != nil {
|
||||
global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
|
||||
response.FailWithMessage("更新失败", c)
|
||||
} else {
|
||||
response.OkWithMessage("添加规则成功", c)
|
||||
response.OkWithMessage("更新成功", c)
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags casbin
|
||||
// @Tags Casbin
|
||||
// @Summary 获取权限列表
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body request.CasbinInReceive true "获取权限列表"
|
||||
// @Param data body request.CasbinInReceive true "权限id, 权限模型列表"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /casbin/getPolicyPathByAuthorityId [post]
|
||||
func GetPolicyPathByAuthorityId(c *gin.Context) {
|
||||
var cmr request.CasbinInReceive
|
||||
_ = c.ShouldBindJSON(&cmr)
|
||||
AuthorityIdVerifyErr := utils.Verify(cmr, utils.CustomizeMap["AuthorityIdVerify"])
|
||||
if AuthorityIdVerifyErr != nil {
|
||||
response.FailWithMessage(AuthorityIdVerifyErr.Error(), c)
|
||||
var casbin request.CasbinInReceive
|
||||
_ = c.ShouldBindJSON(&casbin)
|
||||
if err := utils.Verify(casbin, utils.AuthorityIdVerify); err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
paths := service.GetPolicyPathByAuthorityId(cmr.AuthorityId)
|
||||
response.OkWithData(resp.PolicyPathResponse{Paths: paths}, c)
|
||||
paths := service.GetPolicyPathByAuthorityId(casbin.AuthorityId)
|
||||
response.OkWithDetailed(response.PolicyPathResponse{Paths: paths}, "获取成功", c)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user