rbac/controllers/rbac.go
zhangkun9038@dingtalk.com 1e166e8193 up
2025-02-16 12:31:16 +08:00

25 lines
500 B
Go

package controllers
import (
"gitea.zjmud.xyz/phyer/rbac/models"
"gitea.zjmud.xyz/phyer/rbac/services"
"net/http"
"github.com/gin-gonic/gin"
)
func CreateRole(c *gin.Context) {
var role models.Role
if err := c.ShouldBindJSON(&role); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
if err := services.CreateRole(&role); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusCreated, role)
}