import "../base.api"

type (
    // The data of credit usage information | CreditUsage信息
    CreditUsageInfo {
        BaseIDInfo

        // user_id | 用户ID 
        UserId  *string `json:"userId,optional"`
		UserInfo UserInfo `json:"userInfo,optional"`

        // number | 积分改变量 
        Number  *float32 `json:"number,optional"`

        // status | 状态 1-正常 2-禁用 
        Status  *int `json:"status,optional"`

        // ntype | 积分变化类型：1-消耗 2-增加 
        Ntype  *int `json:"ntype,optional"`

        // table | 积分变化表名 
        Table  *string `json:"table,optional"`

        // organization_id | 租户ID 
        OrganizationId  *uint64 `json:"organizationId,optional"`
		OrganizationName  *string `json:"organizationName,optional"`

        // nid | 积分变化关联信息ID 
        Nid  *uint64 `json:"nid,optional"`

        // reason | 积分变动原因 
        Reason  *string `json:"reason,optional"`

        // operator | 积分变动人 
        Operator  *string `json:"operator,optional"`
    }

    // The response data of credit usage list | CreditUsage列表数据
    CreditUsageListResp {
        BaseDataInfo

        // CreditUsage list data | CreditUsage列表数据
        Data CreditUsageListInfo `json:"data"`
    }

    // CreditUsage list data | CreditUsage列表数据
    CreditUsageListInfo {
        BaseListInfo

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

    // Get credit usage list request params | CreditUsage列表请求参数
    CreditUsageListReq {
        PageInfo

		OrganizationId  *uint64 `json:"organizationId,optional"`
    }

    // CreditUsage information response | CreditUsage信息返回体
    CreditUsageInfoResp {
        BaseDataInfo

        // CreditUsage information | CreditUsage数据
        Data CreditUsageInfo `json:"data"`
    }
)

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

service Wechat {
    // Create credit usage information | 创建CreditUsage
    @handler createCreditUsage
    post /credit_usage/create (CreditUsageInfo) returns (BaseMsgResp)

    // Update credit usage information | 更新CreditUsage
    @handler updateCreditUsage
    post /credit_usage/update (CreditUsageInfo) returns (BaseMsgResp)

    // Delete credit usage information | 删除CreditUsage信息
    @handler deleteCreditUsage
    post /credit_usage/delete (IDsReq) returns (BaseMsgResp)

    // Get credit usage list | 获取CreditUsage列表
    @handler getCreditUsageList
    post /credit_usage/list (CreditUsageListReq) returns (CreditUsageListResp)

    // Get credit usage by ID | 通过ID获取CreditUsage
    @handler getCreditUsageById
    post /credit_usage (IDReq) returns (CreditUsageInfoResp)
}
