package dto

type LoginRequest struct {
	Username string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
	Device   string `json:"device" validate:"omitempty,oneof=web h5 mobile"`
}

// MenuNode 菜单节点（树形结构）
type MenuNode struct {
	ID       uint       `json:"id" description:"权限ID"`
	PermCode string     `json:"perm_code" description:"权限码"`
	Name     string     `json:"name" description:"菜单名称"`
	URL      string     `json:"url" description:"路由路径"`
	Sort     int        `json:"sort" description:"排序值"`
	Children []MenuNode `json:"children" description:"子菜单"`
}

type LoginResponse struct {
	AccessToken  string     `json:"access_token"`
	RefreshToken string     `json:"refresh_token"`
	ExpiresIn    int64      `json:"expires_in"`
	User         UserInfo   `json:"user"`
	Permissions  []string   `json:"permissions" description:"所有权限码（向后兼容）"`
	Menus        []MenuNode `json:"menus" description:"菜单树"`
	Buttons      []string   `json:"buttons" description:"按钮权限码"`
}

type UserInfo struct {
	ID             uint   `json:"id" description:"用户ID"`
	Username       string `json:"username" description:"用户名"`
	Phone          string `json:"phone" description:"手机号"`
	UserType       int    `json:"user_type" description:"用户类型 (1:超级管理员, 2:平台用户, 3:代理账号, 4:企业账号)"`
	UserTypeName   string `json:"user_type_name" description:"用户类型名称"`
	ShopID         uint   `json:"shop_id,omitempty" description:"店铺ID"`
	ShopName       string `json:"shop_name,omitempty" description:"店铺名称"`
	EnterpriseID   uint   `json:"enterprise_id,omitempty" description:"企业ID"`
	EnterpriseName string `json:"enterprise_name,omitempty" description:"企业名称"`
}

type RefreshTokenRequest struct {
	RefreshToken string `json:"refresh_token" validate:"required"`
}

type RefreshTokenResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`
}

type ChangePasswordRequest struct {
	OldPassword string `json:"old_password" validate:"required"`
	NewPassword string `json:"new_password" validate:"required,min=8,max=32"`
}
