You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.1 KiB
58 lines
1.1 KiB
package com.gyf.csams
|
|
|
|
|
|
interface UrlPath {
|
|
fun build(): String
|
|
}
|
|
|
|
enum class TestApi(val path: String) : UrlPath {
|
|
Test("test");
|
|
|
|
override fun build(): String = "/api/${this.path}"
|
|
}
|
|
|
|
/**
|
|
* 帐号接口
|
|
*
|
|
* @property path
|
|
*/
|
|
enum class AccountApi(val path: String) : UrlPath {
|
|
Register("/register"),
|
|
CheckId("/register/checkId"),
|
|
Login("/login"),
|
|
LoginToken("/login/token"),
|
|
Logout("/logout");
|
|
|
|
|
|
override fun build(): String {
|
|
return "/api/account${this.path}"
|
|
}
|
|
}
|
|
|
|
enum class MainApi(val path: String) : UrlPath {
|
|
HotActivity("/hotActivity"),
|
|
LeaveMessage("/leaveMessage"),
|
|
GetMessage("getMessage");
|
|
|
|
override fun build(): String {
|
|
return "/api/main/${this.path}"
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 构建服务端请求接口地址
|
|
*
|
|
*/
|
|
class Api {
|
|
companion object {
|
|
fun buildUrl(urlPath: UrlPath): String {
|
|
return "${BuildConfig.SERVER_ADDRESS}${urlPath.build()}"
|
|
}
|
|
}
|
|
}
|
|
|
|
const val NOT_IMPL_TIP = "功能尚未实现!"
|
|
|
|
const val UNKNOW_ERROR = "出现未知异常,请联系管理员"
|
|
|
|
|
|
|