importFoundation
import Moya
struct ServerMgr {
//打包用test或者release,dev用户权限服务连的是后端本地
letconfig= {() ->Server in
#if DEBUG
return Server.dev
#elseif DEBUG_DEV
return Server.dev
#elseif DEBUG_SIT
return Server.sit
#elseif DEBUG_UAT
return Server.uat
#elseif DEBUG_PRD
return Server.release
#elseif RELEASE_DEV
return Server.dev
#elseif RELEASE_SIT
return Server.sit
#elseif RELEASE_UAT
return Server.uat
#elseif RELEASE_PRD
return Server.release
#else
//生产环境打包
return Server.release
#endif
}()
static let shared = ServerMgr()
}
enum Server {
// dev开发环境
case dev
// test测试环境
case test
// 正式环境
case release
}
extension Server {
var ContentHost: String {
switch self{
case.dev:
return "https://hh-dev.hellokitty.com:9009"
case .test:
return "https://hh-test.hellokitty.com:9009"
default:
return "https://hh-dev.hellokitty.com:9009"
}
}
// 用户权限服务
var UserHost:String{
switch self{
case .dev:
return "https://hh-dev.hellokitty.com"
case .test:
return "https://hh-test.hellokitty.com"
default:
return "https://hh-dev.hellokitty.com"
}
}
// web端h5权限服务
var WebHost:String{
switch self{
case .dev:
return "https://hello-dev.hh.com"
case .test:
return "https://hello-test.hh.com"
default:
return "https://hello-dev.hh.com"
}
}
// 网关
var ContentGateway: String {
switch self{
case .dev:
return"/hh-api/"
case.test:
return"/hh-api/"
default:
return"/hh-api/"
}
}
// 权限网关
var UserGateway: String {
switch self{
case .dev:
return "/hello/"
case .test:
return "/hello/"
default:
return "/hello/"
}
}
// web端h5网关
var WebGateway: String {
switch self{
case .dev:
return "/xx/"
case .test:
return"/xx/"
default:
return"/xx/"
}
}
}
extension TarType {
varbaseURL:URL{
returnURL(string: ServerMgr.shared.config.ContentHost + ServerMgr.shared.config.ContentGateway)!
}
var sampleData: Data {
return "".data(using: .utf8)!
}
varheaders: [String:String]? {
return ["Content-type": "application/json", "grp_id": "100", "token": Global.token ?? "", "app_id": "125", "deviceType": "9","source":"23","_popId":Global._popId ?? "","bntVersionCode":DInfo.buildVersion]
}
}
网友评论