52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package api
|
|
|
|
import (
|
|
"SciencesServer/app/api/admin/controller/auth"
|
|
"SciencesServer/app/basic/api"
|
|
"SciencesServer/app/session"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type Auth struct{}
|
|
|
|
type authForm struct {
|
|
ParentID string `json:"parent_id" form:"parent_id"`
|
|
Kind int `json:"kind" form:"kind" binding:"required"`
|
|
Name string `json:"name" form:"name" binding:"required"`
|
|
Auth string `json:"auth" form:"auth" binding:"required"`
|
|
Sort int `json:"sort" form:"sort"`
|
|
Remark string `json:"remark" form:"remark"`
|
|
}
|
|
|
|
func (*Auth) Index(c *gin.Context) {
|
|
data, err := auth.NewInstance()(api.GetSession()(c).(*session.Admin)).Index()
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*Auth) Add(c *gin.Context) {
|
|
form := &struct {
|
|
RoleID string `json:"role_id" form:"role_id" binding:"required"`
|
|
AuthIDs []string `json:"auth_ids" form:"auth_ids" binding:"required"`
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
}
|
|
|
|
func (*Auth) Edit(c *gin.Context) {
|
|
form := &struct {
|
|
RoleID string `json:"role_id" form:"role_id" binding:"required"`
|
|
AuthIDs []string `json:"auth_ids" form:"auth_ids" binding:"required"`
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
}
|
|
|
|
func (*Auth) Delete(c *gin.Context) {
|
|
|
|
}
|