package model

import (
	v1 "kami/api/sysUser/v1"
	"kami/internal/model/entity"

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

	"github.com/gogf/gf/v2/os/gtime"

	"kami/api/commonApi"
)

// User is the golang structure for table user.
type User struct {
	commonApi.CommonIntId
	Username  string      `json:"username"  description:"账号"`
	IsAdmin   int         `json:"isAdmin"   description:"是否是管理员"`
	Phone     string      `json:"phone"     description:"手机号"`
	CreatedAt *gtime.Time `json:"createdAt" description:""`
	UpdatedAt *gtime.Time `json:"updatedAt" description:""`
	DeletedAt *gtime.Time `json:"deletedAt" description:""`
}

type UserSearchInput struct {
	v1.UserSearchReq
}

type UserSearchWithPaymentOutput struct {
	entity.V1SysUser
	Payment struct {
		g.Meta `orm:"table:sys_user_payment, do:true"`
		entity.V1SysUserPayment
	} `json:"payment" orm:"with:user_id=id"`
}

type UserSearchWithPaymentAndCfgOutput struct {
	UserSearchWithPaymentOutput
	ChannelCfg []SysUserChannelCfg `json:"channelCfg" orm:"with:sys_user_id=id"`
}

type UserAddInput struct {
	*v1.UserAddReq
}

type UserEditInput struct {
	v1.UserEditReq
}

type UserGetEditOutput struct {
	v1.UserGetEditRes
}

type UserChangePwdInput struct {
	v1.UserChangePwdReq
	UserId string
}

type UserStatusInput struct {
	v1.UserStatusReq
}

type SysUserSimpleOutput struct {
	Id         string `orm:"id,primary"       json:"id"`         //
	UserName   string `orm:"user_name,unique" json:"userName"`   // 用户名
	UserStatus uint   `orm:"user_status"      json:"userStatus"` // 用户状态;0:禁用,1:正常,2:未验证
	IsAdmin    int    `orm:"is_admin"         json:"isAdmin"`    // 是否后台管理员 1 是  0   否
}

type UserLoginOutInput struct {
	v1.UserLoginOutReq
}

type LoginUserOutput struct {
	Id           string `json:"id"           orm:"id"            description:"ID"`
	Username     string `json:"username"     orm:"username"      description:"账号"`
	UserSalt     string `json:"userSalt"`
	UserStatus   uint   `json:"userStatus"`
	UserPassword string `json:"userPassword"`
	OtpSecret    string `json:"otpSecret"`
	OtpKey       string `json:"otpKey"`
}

type UserLoginOutOutput struct {
	v1.UserLoginOutRes
}

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