feat: 目录及代码优化调整

This commit is contained in:
meilin.huang
2021-03-24 17:18:39 +08:00
parent 4c2e6b6155
commit 39e9f15def
116 changed files with 2964 additions and 310 deletions

49
base/biz/assert.go Normal file
View File

@@ -0,0 +1,49 @@
package biz
import (
"fmt"
"reflect"
)
func BizErrIsNil(err error, msg string, params ...interface{}) {
if err != nil {
panic(NewBizErr(fmt.Sprintf(msg, params...)))
}
}
func ErrIsNil(err error, msg string) {
if err != nil {
panic(err)
}
}
func IsTrue(exp bool, msg string, params ...interface{}) {
if !exp {
panic(NewBizErr(fmt.Sprintf(msg, params...)))
}
}
func IsTrueBy(exp bool, err BizError) {
if !exp {
panic(err)
}
}
func NotEmpty(str string, msg string, params ...interface{}) {
if str == "" {
panic(NewBizErr(fmt.Sprintf(msg, params...)))
}
}
func NotNil(data interface{}, msg string) {
if reflect.ValueOf(data).IsNil() {
panic(NewBizErr(msg))
}
}
func Nil(data interface{}, msg string) {
if !reflect.ValueOf(data).IsNil() {
panic(NewBizErr(msg))
}
}