# IC1101 Cocos API #### 一、通用说明 通用前缀: http://192.168.7.231:7379/new_battle 万能验证码 : `0123456789` 请求方式: `Get` 测试客户端: #### 二、枚举定义 ##### 1.登录类型枚举 `ChannelEnum` ```java public enum ChannelEnum { WD(1, "wallect connect QR code"), MetaMask(2, "Metamask网页登录"), GameAccount(3, "游戏账号登录"), Guest(4, "游客登录"), UNKNOWN(1000, "未知"); } ``` ##### 2.钱包类型 `WalletEnum` ```java public enum WalletEnum { Game(1, "游戏小钱包"), Auth(2, "认证的WEB3钱包"), UNKNOWN(1000, "未知"); } ``` ##### 3.登录类型 `LoginEnum` ```java public enum LoginEnum { Cocos(1, "Cocos"), PcUe5(2, "PcUe5"), WebSite(3, "官网"); } ``` #### 三、API列表 ##### 1.多渠道登录接口 `/loginByChannel ` image-20230215193208858 请求 | 参数名 | 类型 | 可否为空 | 是否参与加密 | 说明 | | --------- | ------ | -------- | ------------ | ------------------------------------------------------------ | | channelId | int | 否 | 是 | 1.二维码walletconnect扫码登录 2.钱包登录metamask 3.传统账密登录 ,具体见ChannelEnum结构 | | account | string | 否 | 是 | 账号名 | | pwd | string | 是 | 否 | 密码 | | sign | string | 否 | 否 | md5加密值 | | timestamp | string | 否 | 是 | 时间戳 毫秒 | | loginType | int | 否 | 是 | 登录类型,具体见LoginEnum结构 | ```http http://192.168.7.221:7379/new_battle/loginByChannel?channelId=1&account=0xeccbc87e4b5ce2fe28308fd9f2a7baf3&sign=0f6aa27a4e529987d808162e38e731ef×tamp=1676373020000&loginType=1 ``` 返回: ```json { "data": { "account": "", "authWallets": [ { "address": "0xeccbc87e4b5ce2fe28308fd9f2a7baf3", "createAt": 1677058652012, "createTime": "2023-02-22 17:37:32", "id": 12 } ], "bindAt": -1, "bindTime": "", "channelId": 1, "createAt": 1677058646727, "createTime": "2023-02-22 17:37:26", "edit": false, "email": "", "id": 13, "inviteCode": "6L79MG1TBP", "lastLoginAt": 1677058652048, "lastLoginIp": "192.168.7.231", "lastLoginTime": "2023-02-22 17:37:32", "loginType": 1, "nickName": "0xeccbc87e4b5ce2fe28308fd9f2a7baf3", "score": 100, "smallWallet": { "address": "0x00000000000000000000000000000000", "createAt": 1677058651989, "createTime": "2023-02-22 17:37:31", "hdIdx": 12, "id": 12 }, "status": 1, "token": "ZNVEtxogWA", "tokenExpireAt": 1677317852048, "tokenExpireTime": "2023-02-25 17:37:32", "user": { "accountId": 13, "createAt": 1677058651987, "createTime": "2023-02-22 17:37:31", "nickName": "0xeccbc87e4b5ce2fe28308fd9f2a7baf3" } }, "errCode": 0, "errMsg": "Success", "totalSize": 0 } ``` ##### 2 .web端账号绑定接口 `/bindAccountWithWallet` ![](https://mdres20230215.oss-cn-shanghai.aliyuncs.com/bindwallet.png) **牵涉到的功能** - 邮箱验证码认证 - 上级用户邀请码溯源后的积分增加 请求 | 参数名 | 类型 | 可否为空 | 是否参与加密 | 说明 | | ------------- | ------ | -------- | ------------ | -------------------- | | token | string | 否 | 是 | 登录成功后获取的令牌 | | account | string | 否 | 是 | 账号名 | | pwd | string | 否 | 否 | 密码 | | email | string | 否 | 是 | 邮箱 | | emailCode | string | 否 | 否 | 邮箱验证码 | | srcInviteCode | string | 否 | 否 | 我上级的邀请码 | | sign | string | 否 | 否 | md5加密值 | | timestamp | string | 否 | 是 | 时间戳 毫秒 | ```http http://127.0.0.1:7379/new_battle/bindAccountWithWallet?account=a1&pwd=123456&email=a1@qq.com&emailCode=xjhung&srcInviteCode=loqsx&sign=0f6aa27a4e529987d808162e38e731ef×tamp=1676373020000&token=kjumh ``` 返回: ```json { "data": { "account": "a1", "authWallets": [ { "address": "0xeccbc87e4b5ce2fe28308fd9f2a7baf3", "createAt": 1676459788011, "createTime": "2023-02-15 19:16:28", "id": 7 } ], "channelId": 1, "createAt": 1676459787846, "createTime": "2023-02-15 19:16:27", "edit": true, "email": "a1@qq.com", "id": 8, "inviteCode": "ADSFCSNPCU", "lastLoginIp": "", "nickName": "a1", "score": 0, "smallWallet": { "address": "0x00000000000000000000000000000000", "createAt": 1676459787993, "createTime": "2023-02-15 19:16:27", "hdIdx": 7, "id": 7 } }, "errCode": 0, "errMsg": "Success" } ``` ##### 3 .账号信息接口 `/accountInfo` 请求 | 参数名 | 类型 | 可否为空 | 是否参与加密 | 说明 | | --------- | ------ | -------- | ------------ | ----------------------------- | | token | string | 否 | 是 | 登录成功后获取的令牌 | | loginType | int | 否 | 是 | 登录类型,具体见LoginEnum结构 | | sign | string | 否 | 否 | md5加密值 | | timestamp | string | 否 | 是 | 时间戳 毫秒 | 请求 ```http http://127.0.0.1:7379/new_battle/accountInfo?token=oZtH7N6ovx&sign=0f6aa27a4e529987d808162e38e731ef×tamp=1676373020000 ``` 返回 ```json { "data": { "account": "test1111", "bindAt": -1, "bindTime": "", "channelId": 3, "createAt": 1677121736738, "createTime": "2023-02-23 11:08:56", "edit": true, "email": "guoliang@gliangliang.com", "id": 14, "inviteCode": "MHVXK00ZBK", "lastLoginAt": 0, "lastLoginIp": "127.0.0.1", "loginType": 0, "nickName": "test1111", "score": 100, "smallWallet": { "address": "0x00000000000000000000000000000000", "createAt": 1677121738056, "createTime": "2023-02-23 11:08:58", "hdIdx": 13, "id": 13 }, "status": 0, "token": "fFRHmZKSoh", "tokenExpireAt": 1677380938998, "tokenExpireTime": "2023-02-26 11:08:58", "user": { "accountId": 14, "createAt": 1677121742318, "createTime": "2023-02-23 11:09:02", "nickName": "test1111" } }, "errCode": 0, "errMsg": "Success", "totalSize": 0 } ``` ##### 4 .账号拉新积分明细 `/accountScoreDetails` 请求 | 参数名 | 类型 | 是否必填 | 是否参与加密 | 说明 | | --------- | ------ | -------- | ------------ | ---------------------------------------------------------- | | pageSize | int | 否 | 否 | 分页的单页最大记录数,-1代表不分页,获取所有数据,默认是10条 | | curIdx | int | 否 | 否 | 当前第几页,默认从0开始 | | token | string | 是 | 是 | 登录成功后获取的令牌 | | sign | string | 是 | 否 | md5加密值 | | timestamp | string | 是 | 是 | 时间戳 毫秒 | ```http http://127.0.0.1:7379/new_battle/accountScoreDetails?token=oc904uFv4f&sign=0f6aa27a4e529987d808162e38e731ef×tamp=1676373020000 ``` 返回 ```json { "data": [ { "createAt": 1676623234384, "createTime": "2023-02-17 16:40:34", "dstAccountId": 10, "dstAccountName": "", "dstPoint": 100, "eventDesc": "成功注册增加100积分", "srcAccountId": 10, "srcPoint": 0 } ], "errCode": 0, "errMsg": "Success", "totalSize": 1 } ``` ##### 5. 获取邮箱验证码 `/mailCode` **只有在AWS上的服务器才能有效发送验证码 ,本地服务器由于国内的墙的问题,无法发送邮件** 请求 | 参数名 | 类型 | 是否必填 | 是否参与加密 | 说明 | | --------- | ------ | -------- | ------------ | ----------- | | email | string | 是 | 是 | 邮箱地址 | | sign | string | 是 | 否 | md5加密值 | | timestamp | string | 是 | 是 | 时间戳 毫秒 | 请求 ```http http://127.0.0.1:7379/new_battle/mailCode?email=guoliang@gliangliang.com ``` 返回 ```json { "errCode": 0, "errMsg": "Success", "totalSize": 0 } ``` ##### 6. 忘记密码 `/passwordForget` 请求 | 参数名 | 类型 | 是否必填 | 是否参与加密 | 说明 | | --------- | ------ | -------- | ------------ | ----------- | | account | string | 是 | 是 | 账号名 | | newPwd | string | 是 | 是 | 新密码 | | email | string | 是 | 是 | 邮箱地址 | | emailCode | string | 是 | 是 | 验证码 | | sign | string | 是 | 否 | md5加密值 | | timestamp | string | 是 | 是 | 时间戳 毫秒 | ##### 7. 新用户注册 `/accountRegister` 请求 | 参数名 | 类型 | 是否必填 | 是否参与加密 | 说明 | | --------- | ------ | -------- | ------------ | ----------------------------- | | account | string | 是 | 是 | 账号 | | pwd | string | 是 | 是 | 新密码 | | email | string | 是 | 是 | 邮箱地址 | | emailCode | string | 是 | 是 | 验证码,万能验证码见文档第一章 | | sign | string | 是 | 否 | md5加密值 | | timestamp | string | 是 | 是 | 时间戳 毫秒 | | loginType | int | 否 | 是 | 登录类型,具体见LoginEnum结构 | 请求 ```http http://127.0.0.1:7379/new_battle/accountRegister?account=test1111&pwd=12321323&email=guoliang@gliangliang.com&emailCode=0123456789&sign=0f6aa27a4e529987d808162e38e731ef×tamp=1676373020000&loginType=1 ``` 返回 ```json { "data": { "account": "test1111", "bindAt": -1, "bindTime": "", "channelId": 3, "createAt": 1677121736738, "createTime": "2023-02-23 11:08:56", "edit": true, "email": "guoliang@gliangliang.com", "id": 14, "inviteCode": "MHVXK00ZBK", "lastLoginAt": 1677121738998, "lastLoginIp": "127.0.0.1", "lastLoginTime": "2023-02-23 11:08:58", "loginType": 0, "nickName": "test1111", "score": 100, "smallWallet": { "address": "0x00000000000000000000000000000000", "createAt": 1677121738056, "createTime": "2023-02-23 11:08:58", "hdIdx": 13, "id": 13 }, "status": 1, "token": "fFRHmZKSoh", "tokenExpireAt": 1677380938998, "tokenExpireTime": "2023-02-26 11:08:58", "user": { "accountId": 14, "createAt": 1677121742318, "createTime": "2023-02-23 11:09:02", "nickName": "test1111" } }, "errCode": 0, "errMsg": "Success", "totalSize": 0 } ``` ##### 8. 绑定邮箱 `/bindEmail` 请求 | 参数名 | 类型 | 是否必填 | 是否参与加密 | 说明 | | --------- | ------ | -------- | ------------ | ----------- | | account | string | 是 | 是 | 账号 | | pwd | string | 是 | 是 | 新密码 | | email | string | 是 | 是 | 邮箱地址 | | emailCode | string | 是 | 是 | 验证码 | | sign | string | 是 | 否 | md5加密值 | | timestamp | string | 是 | 是 | 时间戳 毫秒 |