import { RoleVO } from '@/api/system/role/types';
import { PostVO } from '@/api/system/post/types';

/**
 * 用户信息
 */
export interface UserInfo {
  user: UserVO;
  roles: string[];
  permissions: string[];
}

/**
 * 用户查询对象类型
 */
export interface UserQuery extends PageQuery {
  userName?: string;
  nickName?: string;
  phonenumber?: string;
  status?: string;
  deptId?: string | number;
  roleId?: string | number;
  userIds?: string;
}

/**
 * 用户返回对象
 */
export interface UserVO extends BaseEntity {
  userId: string | number;
  tenantId: string;
  deptId: number;
  userName: string;
  nickName: string;
  userType: string;
  email: string;
  phonenumber: string;
  sex: string;
  avatar: string;
  status: string;
  delFlag: string;
  loginIp: string;
  loginDate: string;
  remark: string;
  deptName: string;
  roles: RoleVO[];
  roleIds: any;
  postIds: any;
  roleId: any;
  admin: boolean;
}

/**
 * 用户表单类型
 */
export interface UserForm {
  id?: string;
  userId?: string;
  deptId?: number;
  userName: string;
  nickName?: string;
  password: string;
  phonenumber?: string;
  email?: string;
  sex?: string;
  status: string;
  remark?: string;
  postIds: string[];
  roleIds: string[];
}

export interface UserInfoVO {
  user: UserVO;
  roles: RoleVO[];
  roleIds: string[];
  posts: PostVO[];
  postIds: string[];
  roleGroup: string;
  postGroup: string;
}

export interface ResetPwdForm {
  oldPassword: string;
  newPassword: string;
  confirmPassword: string;
}

/**
 * 商户信息VO
 */
export interface SysMerchantVO extends BaseEntity {
  // 商户信息（顶层）
  userId: string | number;
  agentId?: string | number;
  agentName?: string;
  lastActiveTime?: string;
  expireDate?: string;
  status: string;
  remark?: string;
  
  // 用户基本信息（嵌套对象）
  userInfo?: {
    userId: string | number;
    tenantId?: string;
    deptId?: string | number;
    userName?: string;
    nickName?: string;
    userType?: string;
    email?: string;
    phonenumber?: string;
    sex?: string;
    avatar?: string;
    status?: string;
    loginIp?: string;
    loginDate?: string;
    createTime?: string;
    remark?: string;
    deptName?: string;
    roles?: any;
    roleIds?: number[];
    postIds?: number[];
    roleId?: number;
    areaCode?: string;
    province?: string;
    city?: string;
    district?: string;
  };
}

/**
 * 商户信息表单
 */
export interface SysMerchantForm extends BaseEntity {
  userId?: string | number;
  areaCode?: string;
  province?: string;
  city?: string;
  district?: string;
  lastActiveTime?: string;
  expireDate?: string;
  status?: string;
  remark?: string;
  agentId?: string | number;
  codeArr?: string[];
}

/**
 * 商户查询对象
 */
export interface SysMerchantQuery extends PageQuery {
  userId?: string | number;
  tenantId?: string | number;
  userName?: string;
  phonenumber?: string;
  areaCode?: string;
  province?: string;
  city?: string;
  district?: string;
  lastActiveTime?: string;
  expireDate?: string;
  status?: string;
  agentId?: string | number;
  params?: any;
}

/**
 * 系统用户表单
 */
export interface SysUserForm extends BaseEntity {
  userId?: string | number;
  deptId?: string | number;
  userName?: string;
  nickName?: string;
  userType?: string;
  identity?: string;
  email?: string;
  phonenumber?: string;
  sex?: string;
  password?: string;
  status?: string;
  remark?: string;
  roleIds?: number[];
  postIds?: number[];
  areaCode?: string;
  province?: string;
  city?: string;
  district?: string;
  codeArr?: string[];
}

/**
 * 用户商户组合表单
 */
export interface SysUserMerchantForm {
  user?: SysUserForm;
  merchant?: SysMerchantForm;
}