rbac/controllers/rbac.go
zhangkun9038@dingtalk.com 9ac7597a62 first add
2025-02-16 12:18:39 +08:00

25 lines
488 B
Go

package controllers
import (
"net/http"
"zjmud.xyz/phyer/rbcp/models"
"zjmud.xyz/phyer/rbcp/services"
"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)
}