import "../base.api"

type (
    // The response data of user information | 用户信息
    UserInfo {
        BaseUUIDInfo

        // Status | 状态
        Status *uint32 `json:"status,optional" validate:"omitempty,lt=20"`

        // Username | 用户名
        Username *string `json:"username,optional" validate:"omitempty,max=50"`

        // Nickname | 昵称
        Nickname *string `json:"nickname,optional" validate:"omitempty,max=40"`

        // Password | 密码
        Password *string `json:"password,optional" validate:"omitempty,min=6"`

        // Description | 描述
        Description *string `json:"description,optional" validate:"omitempty,max=100"`

        // HomePath | 首页
        HomePath *string `json:"homePath,optional" validate:"omitempty,max=70"`

        // RoleId | 角色ID
        RoleIds []uint64 `json:"roleIds,optional"`

        // Mobile | 手机号
        Mobile *string `json:"mobile,optional" validate:"omitempty,max=18"`

        // Email | 邮箱
        Email *string `json:"email,optional" validate:"omitempty,max=80"`

        // Avatar | 头像地址
        Avatar *string `json:"avatar,optional" validate:"omitempty,max=300"`

        // Department ID | 部门ID
        DepartmentId *uint64 `json:"departmentId,optional,omitempty"`

        // Position ID | 职位ID
        PositionIds []uint64 `json:"positionId,optional,omitempty"`
    }

    // User information response | 用户信息返回体
    UserInfoResp {
        BaseDataInfo

        // User information | User数据
        Data UserInfo `json:"data"`
    }

    // The response data of user's basic information | 用户基本信息返回数据
    UserBaseIDInfoResp {
        BaseDataInfo

        // The  data of user's basic information | 用户基本信息
        Data UserBaseIDInfo `json:"data"`
    }

    // The  data of user's basic information | 用户基本信息
    UserBaseIDInfo {
        // User's UUID | 用户的UUID
        UUID *string `json:"userId"`

        // User's name | 用户名
        Username *string `json:"username"`

        // User's nickname | 用户的昵称
        Nickname *string `json:"nickname"`

        // The user's avatar path | 用户的头像路径
        Avatar *string `json:"avatar"`

        // The home page that the user enters after logging in | 用户登陆后进入的首页
        HomePath *string `json:"homePath"`

        // The description of user | 用户的描述信息
        Description *string `json:"desc"`

        // User's Role Name | 用户的角色名称
        RoleName   []string   `json:"roleName"`

        // Department Name | 部门名称
        DepartmentName string `json:"departmentName,optional"`

        // Department Name | 部门备注
        DepartmentRemark string `json:"departmentRemark,optional"`
    }

	UserLoginReq {
		JsCode *string `json:"js_code,optional"`
	}

	UserLoginResp {
		BaseDataInfo
		Data UserToken `json:"data,optional"`
	}

	GptsUserLoginReq {
		Username *string `json:"username"`
		Password *string `json:"password"`
	}
	GptsUserLoginResp {
		BaseDataInfo
		Data GptsUserToken `json:"data,optional"`
	}
	GptsUserToken {
		ID string `json:"id,optional"`
		Token string `json:"token,optional"`
		Username string `json:"username,optional"`
		ExpireTime uint64 `json:"expireTime,optional"`
	}
	PasswordReq {
		Password *string `json:"password"`
		Password2 *string `json:"password2"`
	}

	UserToken {
		Token *string `json:"token,optional"`
		ID *uint64 `json:"id,optional"`
		Avatar *string `json:"avatar,optional"`
		Nickname *string `json:"nickname,optional"`
	    IsVip *bool `json:"isVip,optional"`
	}

	UserVipResp {
		BaseDataInfo
		Data UserVip `json:"data,optional"`
	}

	UserVip {
		IsVip *bool `json:"isVip,optional"`
		WechatAccount *string `json:"wechatAccount"`
	}

	UserBalanceResp {
		BaseDataInfo

		// User information | User数据
		Data BalanceInfo `json:"data"`
	}
	BalanceInfo {
		Balance *float32 `json:"balance"`
	}
)

@server(
	group: User
)

service Wechat {
	// Get user basic information | 获取用户基本信息
	@handler doApiUserLogin
	post /api/user/login (UserLoginReq) returns (UserLoginResp)

	// Get user basic information | 获取用户基本信息
	@handler doGptsUserLogin
	post /gpts/user/login (GptsUserLoginReq) returns (GptsUserLoginResp)

	// Get user basic information | 获取用户基本信息
	@handler getGptsUserInfo
	post /gpts/user/info () returns (UserInfoResp)

	// Update user basic information | 修改用户基本信息
	@handler updateGptsUserInfo
	post /gpts/user/update (UserInfo) returns (BaseDataInfo)

	// Get user balance information | 获取用户余额信息
	@handler getGptsUserBalance
	post /gpts/user/balance () returns (UserBalanceResp)

	// Get user basic information | 获取用户基本信息
	@handler updateGptsUserPwd
	post /gpts/user/password (PasswordReq) returns (BaseDataInfo)
}

@server(
	jwt: Auth
	group: User
	middleware: Miniprogram
)

service Wechat {
	// Get user vip information | 获取用户VIP信息
	@handler getApiUserVip
	post /api/user/vip () returns (UserVipResp)
}

@server(
    jwt: Auth
	group: User
	middleware: Authority
)

service Wechat {
    // Get user basic information | 获取用户基本信息
    @handler getUserInfo
    get /user/info returns (UserBaseIDInfoResp)
}