重构
This commit is contained in:
34
core/result.go
Normal file
34
core/result.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"omc/core/parse"
|
||||
)
|
||||
|
||||
// Result
|
||||
// 配合 request.GetConnection().SendMsg()
|
||||
func Result(name string, data map[string]string) []byte {
|
||||
return parse.Pack(name, data)
|
||||
}
|
||||
|
||||
// ResultError ackLoginAlarm;result=fail;resDesc=username-error
|
||||
// request.GetConnection().SendMsg(omc.AckSyncAlarmMsg, core.ResultError("ackSyncAlarmMsg", err.Error(), ""))
|
||||
func ResultError(name string, desc, reqID string) []byte {
|
||||
data := map[string]string{
|
||||
"result": "fail",
|
||||
"reqId": reqID,
|
||||
"resDesc": desc,
|
||||
}
|
||||
|
||||
return Result(name, data)
|
||||
}
|
||||
|
||||
// request.GetConnection().SendMsg(omc.AckSyncAlarmMsg, core.ResultSuccess("ackSyncAlarmMsg", err.Error(), ""))
|
||||
func ResultSuccess(name string, desc, reqID string) []byte {
|
||||
data := map[string]string{
|
||||
"result": "succ",
|
||||
"reqId": reqID,
|
||||
"resDesc": desc,
|
||||
}
|
||||
|
||||
return Result(name, data)
|
||||
}
|
||||
Reference in New Issue
Block a user