package backend

import (
	"bwallet/pkg/errno"
	"bwallet/pkg/handler"
	"bwallet/service/casbin_service"
	"bwallet/validate_service"
	"github.com/gin-gonic/gin"
	"strings"
)

func GetAdminRoles(c *gin.Context) {

}

func AddAdminRole(c *gin.Context) {
	role := validate_service.AdminRole{}
	c.ShouldBindJSON(&role)

	if ok, errors := validate_service.ValidateInputs(role); !ok {
		for _, err := range errors {
			handler.SendResponse(c, errno.ErrBind, strings.Join(err, " "))
			return
		}
	}

	roleService := casbin_service.AdminRole{
		Uid:    role.Uid,
		RoleId: role.RoleId,
	}

	if err := roleService.AddAdminRole(); err != nil {
		handler.SendResponse(c, errno.ErrAddWallet, nil)
		return
	}

	handler.SendResponse(c, nil, nil)
}

func EditAdminRole(c *gin.Context) {

}

func DeleteAdminRole(c *gin.Context) {

}
