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.
ntool-biz/core/nstatus/msg/msg.go

45 lines
1.0 KiB
Go

2 years ago
package msg
import (
"git.noahlan.cn/noahlan/ntool-biz/core/nstatus/code"
"sync"
)
var codeMsgMap sync.Map
2 years ago
// 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"
2 years ago
AlreadyInit = "init.alreadyInit"
InitRunning = "init.initializeIsRunning"
2 years ago
)
// 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
}