package v1

import (
	v1 "kami/api/sys_user_login/v1"
	"kami/internal/consts"

	"github.com/gogf/gf/v2/frame/g"

	"kami/api/commonApi"
	"kami/internal/model/entity"
)

type UserMenusGetReq struct {
	g.Meta `path:"/user/getUserMenus" tags:"用户管理" method:"get" summary:"获取用户菜单"`
	commonApi.Author
}

type UserMenusGetRes struct {
	g.Meta      `mime:"application/json"`
	MenuList    []*v1.UserMenus  `json:"menuList"`
	Permissions []string         `json:"permissions"`
	UserInfo    *LoginUserRecord `json:"userInfo"`
}

// UserSearchReq 用户搜索请求参数
type UserSearchReq struct {
	g.Meta   `path:"/user/list" tags:"用户管理" method:"get" summary:"用户列表"`
	Status   string `p:"status"`
	Username string `p:"username"`
	commonApi.CommonPageReq
}

type UserSearchRes struct {
	g.Meta `mime:"application/json"`
	commonApi.CommonPageRes[*SysUserRoleDeptRes]
}

type UserGetParamsReq struct {
	g.Meta `path:"/user/params" tags:"用户管理" method:"get" summary:"用户维护参数获取"`
}

type UserGetParamsRes struct {
	g.Meta   `mime:"application/json"`
	RoleList []*entity.V1SysRole `json:"roleList"`
}

// SetUserReq 添加修改用户公用请求字段
type SetUserReq struct {
	// RoleIds []int64 `p:"roleIds"`
	Status  uint `p:"status"`
	IsAdmin int  `p:"isAdmin"` // 是否后台管理员 1 是  0   否
}

type ChannelType struct {
	ChannelName consts.CardRedeemAccountCategory `json:"channelName" v:"in:walmart,jd#当前通道名称不允许"`
	Num         int                              `json:"num" v:"required#数量不能为空"`
}

// UserAddReq 添加用户参数
type UserAddReq struct {
	g.Meta `path:"/user/add" tags:"用户管理" method:"post" summary:"添加用户"`
	*SetUserReq
	ChannelList []*ChannelType `json:"channelList"`
	Username    string         `p:"username" v:"required#用户账号不能为空"`
	Password    string         `p:"password" v:"required#用户密码不能为空"`
	UserSalt    string
}

type UserAddRes struct {
	g.Meta `mime:"application/json"`
}

// UserEditReq 修改用户参数
type UserEditReq struct {
	g.Meta `path:"/user/edit" tags:"用户管理" method:"put" summary:"修改用户"`
	*SetUserReq
	commonApi.CommonStrId
	Password string `p:"password" v:"required#密码不能为空"`
	//ChannelList []*ChannelType `json:"channelList"`
}

type UserEditRes struct{}

type UserGetEditReq struct {
	g.Meta `path:"/user/getEdit" tags:"用户管理" method:"get" summary:"获取用户信息"`
	Id     uint64 `p:"id"`
}

type UserGetEditRes struct {
	g.Meta         `mime:"app/json"`
	User           *entity.V1SysUser `json:"user"`
	CheckedRoleIds []uint            `json:"checkedRoleIds"`
	CheckedPosts   []int64           `json:"checkedPosts"`
}

// UserChangePwdReq 重置用户密码状态参数
type UserChangePwdReq struct {
	g.Meta      `path:"/user/changePwd" tags:"用户管理" method:"put" summary:"重置用户密码"`
	OldPassword string `p:"oldPassword" v:"required#旧密码不能为空"`
	NewPassword string `p:"newPassword" v:"required#新密码不能为空"`
	TotpCode    string `p:"totpCode"`
}

type UserChangePwdRes struct{}

// UserStatusReq 设置用户状态参数
type UserStatusReq struct {
	g.Meta `path:"/user/setStatus" tags:"用户管理" method:"put" summary:"设置用户状态"`
	commonApi.CommonStrId
	UserStatus consts.SysUserStatus `p:"status" v:"required#用户状态不能为空"`
}

type UserStatusRes struct{}

type UserDeleteReq struct {
	g.Meta `path:"/user/delete" tags:"用户管理" method:"delete" summary:"删除用户"`
	commonApi.CommonStrId
}

type UserDeleteRes struct{}

type UserGetByIdsReq struct {
	g.Meta `path:"/user/getUsers" tags:"用户管理" method:"get" summary:"同时获取多个用户"`
	commonApi.Author
	Ids []int `p:"ids" v:"required#ids不能为空"`
}

type UserGetByIdsRes struct {
	g.Meta `mime:"application/json"`
	List   []*SysUserSimpleRes `json:"list"`
}

type UserGetAllUserReq struct {
	g.Meta `path:"/user/getSimpleAll" tags:"用户管理" method:"get" summary:"获取所有的用户(简单)"`
}

type UserGetAllSimpleUser struct {
	Id       string `orm:"id" json:"id"`
	UserName string `orm:"user_name" json:"userName"`
}

type UserGetAllUserRes struct {
	commonApi.CommonDataRes[UserGetAllSimpleUser]
}
