parent
29c064f702
commit
eb07dba9bd
@ -1,23 +1,44 @@
|
|||||||
package msg
|
package msg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.noahlan.cn/noahlan/ntool-biz/core/nstatus/code"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var codeMsgMap sync.Map
|
||||||
|
|
||||||
// message keys
|
// message keys
|
||||||
const (
|
const (
|
||||||
Success = "common.success"
|
Success = "common.success"
|
||||||
Failed = "common.failed"
|
Failed = "common.failed"
|
||||||
UpdateSuccess = "common.updateSuccess"
|
UpdateSuccess = "common.updateSuccess"
|
||||||
UpdateFailed = "common.updateFailed"
|
UpdateFailed = "common.updateFailed"
|
||||||
CreateSuccess = "common.createSuccess"
|
CreateSuccess = "common.createSuccess"
|
||||||
CreateFailed = "common.createFailed"
|
CreateFailed = "common.createFailed"
|
||||||
DeleteSuccess = "common.deleteSuccess"
|
DeleteSuccess = "common.deleteSuccess"
|
||||||
DeleteFailed = "common.deleteFailed"
|
DeleteFailed = "common.deleteFailed"
|
||||||
ObjectNotFound = "common.objectNotFound"
|
ObjectNotFound = "common.objectNotFound"
|
||||||
DatabaseError = "common.databaseError"
|
DatabaseError = "common.databaseError"
|
||||||
CacheError = "common.cacheError"
|
CacheError = "common.cacheError"
|
||||||
ConstraintError = "common.constraintError"
|
ConstraintError = "common.constraintError"
|
||||||
ValidationError = "common.validationError"
|
ValidationError = "common.validationError"
|
||||||
NotSingularError = "common.notSingularError"
|
NotSingularError = "common.notSingularError"
|
||||||
PermissionDeny = "common.permissionDeny"
|
PermissionDeny = "common.permissionDeny"
|
||||||
|
|
||||||
AlreadyInit = "init.alreadyInit"
|
AlreadyInit = "init.alreadyInit"
|
||||||
InitRunning = "init.initializeIsRunning"
|
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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue