package dto

import "time"

type APIRequest struct {
	ID          uint   `json:"ID"`
	Path        string `json:"path"`
	Description string `json:"description"`
	APIGroup    string `json:"apiGroup"`
	Method      string `json:"method"`
}

type APIListRequest struct {
	Page        int    `json:"page"`
	PageSize    int    `json:"pageSize"`
	Path        string `json:"path"`
	Description string `json:"description"`
	APIGroup    string `json:"apiGroup"`
	Method      string `json:"method"`
	OrderKey    string `json:"orderKey"`
	Desc        bool   `json:"desc"`
}

type APIResponse struct {
	ID          uint      `json:"ID"`
	CreatedAt   time.Time `json:"CreatedAt"`
	UpdatedAt   time.Time `json:"UpdatedAt"`
	DeletedAt   any       `json:"-"`
	Path        string    `json:"path"`
	Description string    `json:"description"`
	APIGroup    string    `json:"apiGroup"`
	Method      string    `json:"method"`
}

type DeleteAPIRequest struct {
	ID uint `json:"ID"`
}
type DeleteAPIsRequest struct {
	IDs []uint `json:"ids"`
}
type GetAPIRequest struct {
	ID uint `json:"id"`
}
type SetAPIRolesRequest struct {
	Path         string `json:"path"`
	Method       string `json:"method"`
	AuthorityIDs []uint `json:"authorityIds"`
}
type IgnoreAPIRequest struct {
	Path   string `json:"path"`
	Method string `json:"method"`
	Flag   bool   `json:"flag"`
}
type ApplyAPISyncRequest struct {
	NewAPIs    []APIRequest `json:"newApis"`
	DeleteAPIs []APIRequest `json:"deleteApis"`
}
type PolicyPathRequest struct {
	Path   string `json:"path"`
	Method string `json:"method"`
}
type SetPolicyPathsRequest struct {
	AuthorityID uint                `json:"authorityId"`
	Infos       []PolicyPathRequest `json:"casbinInfos"`
}
type GetPolicyPathsRequest struct {
	AuthorityID uint `json:"authorityId"`
}

type APISyncResponse struct {
	NewAPIs    []*APIResponse `json:"newApis"`
	DeleteAPIs []*APIResponse `json:"deleteApis"`
	IgnoreAPIs []*APIResponse `json:"ignoreApis"`
}
