Documentation
¶
Index ¶
- Constants
- Variables
- func ByteAarray2Obj(b []byte, obj interface{})
- func GetFinalPwdBySalt(password string, salts string) (pwd string)
- func GetFinalPwdWithSalt(password string) (pwd string, salts string)
- func IsEmail(s string) bool
- func IsMobile(s string) bool
- func IsPassword(s string) bool
- func ItoStr(i int) string
- func Obj2ByteAarray(obj interface{}) []byte
- func ObjectIds2Strs(ids []*bson.ObjectId) []string
- func RandBirth(ageStart, ageEnd int) time.Time
- func RandInt(intStart, intEnd int) int
- func RandomNumberString(n int) string
- func RandomString(n int) string
- func RemoveDuplicatesAndEmpty(s []string) (ret []string)
- func StoB(s string) (bool, error)
- func StoI(s string) (int, error)
- func StoI64(s string) (int64, error)
- func Str2ObjectId(id string) bson.ObjectId
- func Str2Time(ts string) time.Time
- func Str2UUID(a string) uuid.UUID
- func Strs2ObjectIds(ids []string) []*bson.ObjectId
- func Strs2UUIDs(as []string) []uuid.UUID
- func Time2Str(t time.Time) string
- func ToEchoLogFile(path string, log []byte, fileSizeLimit int64)
- func UUIDs2Strs(us []uuid.UUID) []string
- type ErrorType
- type LogEntry
- type MeanError
- type MeanLogger
Constants ¶
View Source
const LOG_CONFIG = "logconfig.ini" //用于存放当前正在写入的日志文件名
Variables ¶
View Source
var ( ServerErr = NewMeanError("ServerErr", -1, 500, ErrorTypeInternal) RequestParamsErr = NewMeanError("Request parameter invalid", 999, 400, ErrorTypePublic) StringConversionErr = NewMeanError("string conversion invalid", 999, 400, ErrorTypePublic) AuthErr = NewMeanError("Un Auth Access", 1, 401, ErrorTypePublic) InsufficientPermissionsErr = NewMeanError("Insufficient permissions", 2, 403, ErrorTypePublic) DeviceErr = NewMeanError("Device Token Error", 3, 401, ErrorTypePublic) )
View Source
var ( UserNotFoundErr = NewMeanError("user not found", 1000, 403, ErrorTypePublic) InvalidEmailAdressErr = NewMeanError("Invalid Email", 1001, 403, ErrorTypePublic) InvalidPhoneNumberErr = NewMeanError("Invalid Phone Number", 1002, 403, ErrorTypePublic) InvalidUserNameErr = NewMeanError("Invalid User name", 1003, 403, ErrorTypePublic) InvalidPasswordErr = NewMeanError("Wrong Password", 1004, 403, ErrorTypePublic) NameFormatErr = NewMeanError("name format error", 1005, 403, ErrorTypePublic) InvalidSecretCodeErr = NewMeanError("secret code error", 1006, 401, ErrorTypePublic) InvalidOpenIDErr = NewMeanError("Invalid OpenID", 1001, 403, ErrorTypePublic) )
Account
View Source
var ( InvalidRelationActionErr = NewMeanError("invalid relation action", 2001, 403, ErrorTypePublic) DuplicateFriendApplyErr = NewMeanError("already in friendship", 2002, 403, ErrorTypePublic) FriendApplicationNotFoundErr = NewMeanError("not applying friend yet", 2003, 403, ErrorTypePublic) NoRelationFoundErr = NewMeanError("no relation", 2004, 403, ErrorTypePublic) )
Relations
View Source
var ( //InvalidPhotoTypeErr = NewMeanError("image type already is", 3000, 403, ErrorTypePublic) //PhotoExistErr = NewMeanError("image exist", 3001, 403, ErrorTypePublic) InvalidPhotoEditParams = NewMeanError("invalid photo params", 3001, 403, ErrorTypePublic) PhotoNotFound = NewMeanError("image not found ", 3002, 403, ErrorTypePublic) )
Photo
View Source
var ( PhotoCommentAlreadyCommentedErr = NewMeanError("Photo comment already commented", 4000, 403, ErrorTypePublic) PhotoCommentNotFoundErr = NewMeanError("can't found image comment", 4001, 403, ErrorTypePublic) NewsCommentNotFoundErr = NewMeanError("can't found News comment", 4002, 403, ErrorTypePublic) DeletePhotoCommentLimitReachErr = NewMeanError("delete comment time out", 4003, 403, ErrorTypePublic) )
Comment
View Source
var ( PhotoNoteMustHaveTitleErr = NewMeanError("image note must have title", 5000, 403, ErrorTypePublic) NoteExistErr = NewMeanError("Note aleady exist on image and it's complete", 5001, 400, ErrorTypePublic) TooManyPhotoLinkNoteErr = NewMeanError("note has linked 9 image ", 5002, 403, ErrorTypePublic) NoteUpdateTimeOutErr = NewMeanError("update note time out ", 5003, 403, ErrorTypePublic) NoteNotFoundErr = NewMeanError("note not found", 5005, 400, ErrorTypePublic) NoteCharacterErr = NewMeanError("note character out of limit", 5006, 403, ErrorTypePublic) )
Note
View Source
var ( TooManyPhotoErr = NewMeanError("News can't sending with more than 9 image", 6001, 403, ErrorTypePublic) PhotoPermissionErr = NewMeanError("News image type can't be private", 6002, 403, ErrorTypePublic) NewsStarrNotFoundErr = NewMeanError("cant found starred record on News", 6003, 400, ErrorTypePublic) NewsStarForbidden = NewMeanError("News can't starred", 6004, 403, ErrorTypePublic) NewsNotFoundErr = NewMeanError("News not found", 6005, 400, ErrorTypePublic) NewsPhotoIsNil = NewMeanError("News images is not found", 6006, 400, ErrorTypeInternal) )
News
View Source
var ( FilterNotFoundErr = NewMeanError("Filter not found", 8000, 403, ErrorTypePublic) PreferFilterOutLimitErr = NewMeanError("prefer filter out of limit", 8001, 403, ErrorTypePublic) )
Filter
View Source
var (
DiaryNotFoundErr = NewMeanError("Diary not found", 7000, 403, ErrorTypePublic)
)
Diary
View Source
var (
JsonConversionErrorErr = NewMeanError("json conversino fail", 2, 500, ErrorTypePublic)
)
Functions ¶
func ByteAarray2Obj ¶
func ByteAarray2Obj(b []byte, obj interface{})
func GetFinalPwdBySalt ¶
GetFinalPwdBySalt 根据密码和盐获取最终密码
func GetFinalPwdWithSalt ¶
GetFinalPwdWithSalt 根据输入密码获取 最终密码和盐
func IsPassword ¶
func Obj2ByteAarray ¶
func Obj2ByteAarray(obj interface{}) []byte
func ObjectIds2Strs ¶
func RandomNumberString ¶
func RandomString ¶
func RemoveDuplicatesAndEmpty ¶
RemoveDuplicatesAndEmpty 去除重复和空字符串
func Str2ObjectId ¶
func Strs2ObjectIds ¶
func Strs2UUIDs ¶
func Strs2UUIDs(as []string) []uuid.UUID
func ToEchoLogFile ¶
ToEchoLogFile 将日志打印到文件
func UUIDs2Strs ¶
func UUIDs2Strs(us []uuid.UUID) []string
Types ¶
type MeanError ¶
type MeanError struct {
HttpCode int `json:"-"`
ErrorType ErrorType `json:"-"`
ErrorCode int `json:"code"`
Message string `json:"message"`
}
func NewErrDBFail ¶
func NewMeanError ¶
type MeanLogger ¶
type MeanLogger struct {
RequestID uuid.UUID
}
func NewLogger ¶
func NewLogger() *MeanLogger
func NewMeanLogger ¶
func NewMeanLogger() *MeanLogger
func (*MeanLogger) Print ¶
func (l *MeanLogger) Print(values ...interface{})
func (*MeanLogger) Println ¶
func (l *MeanLogger) Println(v ...interface{})
func (*MeanLogger) WithFields ¶
func (l *MeanLogger) WithFields(fields log.Fields) *LogEntry
Click to show internal directories.
Click to hide internal directories.