import "../base.api"
import "./agent.api"
import "./label_relationship.api"

type (
    // The response data of wx information | Wx信息
    WxInfo {
        BaseIDInfo

        // Status 1: normal 2: ban | 状态 1 正常 2 禁用 
        Status  *uint8 `json:"status,optional"`

        // 服务器id 
        ServerId  *uint64 `json:"serverId,optional"`

        // 服务器名称
        ServerName  *string `json:"serverName,optional"`

        // 端口号 
        Port  *string `json:"port,optional"`

        // 进程号 
        ProcessId  *string `json:"processId,optional"`

        // 回调地址 
        Callback  *string `json:"callback,optional"`

        // 微信id 
        Wxid  *string `json:"wxid,optional"`

        // 微信账号 
        Account  *string `json:"account,optional"`

        // 微信昵称 
        Nickname  *string `json:"nickname,optional"`

        // 手机号 
        Tel  *string `json:"tel,optional"`

        // 微信头像 
        HeadBig  *string `json:"headBig,optional"`

        // 组织ID
        OrganizationId *uint64 `json:"organizationId,optional"`

        // 组织名称
        OrganizationName *string `json:"organizationName,optional"`

		// 模式ID
		AgentId *uint64 `json:"agentId,optional"`

		// 模式信息
		AgentInfo *AgentInfo `json:"agentInfo,optional"`

		// 大模型服务地址
        ApiBase *string `json:"apiBase,optional"`

        // 大模型服务密钥
        ApiKey *string `json:"apiKey,optional"`

        // 白名单
        AllowList []ContactInfo `json:"allowList,optional"`

        // 群白名单
        GroupAllowList []ContactInfo `json:"groupAllowList,optional"`

        // 黑名单
        BlockList []ContactInfo `json:"blockList,optional"`

        // 群黑名单
        GroupBlockList []ContactInfo `json:"groupBlockList,optional"`

        // 使用token总数
        TotalTokens *uint64 `json:"totalTokens,optional"`
    }

    UpdateBlockAndAllowListReq {
            BaseIDInfo

            // 白名单
            AllowList []string `json:"allowList,optional"`

            // 群白名单
            GroupAllowList []string `json:"groupAllowList,optional"`

            // 黑名单
            BlockList []string `json:"blockList,optional"`

            // 群黑名单
            GroupBlockList []string `json:"groupBlockList,optional"`
        }

    // The response data of wx list | Wx列表数据
    WxListResp {
        BaseDataInfo

        // Wx list data | Wx列表数据
        Data WxListInfo `json:"data"`
    }

    // Wx list data | Wx列表数据
    WxListInfo {
        BaseListInfo

        // The API list data | Wx列表数据
        Data  []WxInfo  `json:"data"`
    }

    // Get wx list request params | Wx列表请求参数
    WxListReq {
        PageInfo

        // 服务器id
        ServerId  *uint64 `json:"serverId,optional"`

        // 租户id
        OrganizationId  *uint64 `json:"organizationId,optional"`

        // 租户名称
        OrganizationName  *string `json:"organizationName,optional"`

        // 端口号 
        Port  *string `json:"port,optional"`

        // 进程号 
        ProcessId  *string `json:"processId,optional"`

        // 回调地址 
        Callback  *string `json:"callback,optional"`
    }

    // Get wx list request params | Wx列表请求参数
    WxSelectListReq {
        // 租户id
        OrganizationId  *uint64 `json:"organizationId,optional"`
    }

    // The response data of wx list | Wx列表数据
    WxSelectListResp {
        BaseDataInfo

        // Wx list data | Wx列表数据
        Data []WxSelectListInfo `json:"data"`
    }

    WxSelectListInfo {
        BaseIDInfo

        // 微信id
        Wxid  *string `json:"wxid,optional"`

        // 微信昵称
        Nickname  *string `json:"nickname,optional"`
    }

    // Wx information response | Wx信息返回体
    WxInfoResp {
        BaseDataInfo

        // Wx information | Wx数据
        Data WxInfo `json:"data"`
    }

    // 获取黑白名单列表返回体
    AllowBlockListResp {
        BaseDataInfo

        // Wx information | Wx数据
        Data AllowBlockListRespData `json:"data"`
    }

    // AllowBlockListRespData
    AllowBlockListRespData {
        // 白名单
        AllowList []*AllowBlockData `json:"allowList,optional"`

        // 群白名单
        GroupAllowList []*AllowBlockData `json:"groupAllowList,optional"`

        // 黑名单
        BlockList []*AllowBlockData `json:"blockList,optional"`

        // 群黑名单
        GroupBlockList []*AllowBlockData `json:"groupBlockList,optional"`
    }

    // AllowBlockData
    AllowBlockData {
        // 微信id 公众号微信ID
        Wxid  string `json:"wxid,optional"`

        // 微信昵称 群备注名称
        Nickname  string `json:"nickname,optional"`
    }
)

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

service Wechat {
    // Create wx information | 创建Wx
    @handler createWx
    post /wx/create (WxInfo) returns (BaseMsgResp)

    // Check wx information | 检查并更新Wx状态
    @handler checkWx
    post /wx/check (WxInfo) returns (BaseMsgResp)

    // Update wx information | 更新Wx
    @handler updateWx
    post /wx/update (WxInfo) returns (BaseMsgResp)

    // Update wx information | 更新黑白名单
    @handler updateBlockAndAllowList
    post /wx/updateBlockAndAllowList (UpdateBlockAndAllowListReq) returns (BaseMsgResp)

    // Delete wx information | 删除Wx信息
    @handler deleteWx
    post /wx/delete (IDReq) returns (BaseMsgResp)

    // Get wx list | 获取Wx列表
    @handler getWxList
    post /wx/list (WxListReq) returns (WxListResp)

    // Get wx list | 获取Wx列表
    @handler getSelectWxList
    post /wx/selectList (WxSelectListReq) returns (WxSelectListResp)

    // Get wx allow and block list | 获取黑白名单列表
    @handler getWxAllowBlockList
    post /wx/getWxAllowBlockList (IDReq) returns (AllowBlockListResp)

    // Get wx by ID | 通过ID获取Wx
    @handler getWxById
    post /wx (IDReq) returns (WxInfoResp)
}