You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package msg
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.noahlan.cn/noahlan/ntool-biz/core/nstatus/code"
|
|
|
|
"sync"
|
|
|
|
)
|
|
|
|
|
|
|
|
var codeMsgMap sync.Map
|
|
|
|
|
|
|
|
// message keys
|
|
|
|
const (
|
|
|
|
Success = "common.success"
|
|
|
|
Failed = "common.failed"
|
|
|
|
UpdateSuccess = "common.updateSuccess"
|
|
|
|
UpdateFailed = "common.updateFailed"
|
|
|
|
CreateSuccess = "common.createSuccess"
|
|
|
|
CreateFailed = "common.createFailed"
|
|
|
|
DeleteSuccess = "common.deleteSuccess"
|
|
|
|
DeleteFailed = "common.deleteFailed"
|
|
|
|
ObjectNotFound = "common.objectNotFound"
|
|
|
|
DatabaseError = "common.databaseError"
|
|
|
|
CacheError = "common.cacheError"
|
|
|
|
ConstraintError = "common.constraintError"
|
|
|
|
ValidationError = "common.validationError"
|
|
|
|
NotSingularError = "common.notSingularError"
|
|
|
|
PermissionDeny = "common.permissionDeny"
|
|
|
|
|
|
|
|
AlreadyInit = "init.alreadyInit"
|
|
|
|
InitRunning = "init.initializeIsRunning"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Add 添加消息
|
|
|
|
func Add(c code.Code, msg string) {
|
|
|
|
codeMsgMap.Store(c, msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Msg 获取string消息
|
|
|
|
func Msg(c code.Code) string {
|
|
|
|
msg, ok := codeMsgMap.Load(c)
|
|
|
|
if ok {
|
|
|
|
return msg.(string)
|
|
|
|
}
|
|
|
|
return Failed
|
|
|
|
}
|