swirl/misc/misc.go

26 lines
494 B
Go
Raw Normal View History

2017-09-26 12:50:09 +00:00
package misc
2021-12-06 12:24:22 +00:00
import "github.com/cuigh/auxo/errors"
2017-09-26 12:50:09 +00:00
const (
2021-12-06 12:24:22 +00:00
ErrInvalidToken = 1001
ErrAccountDisabled = 1002
ErrOldPasswordIncorrect = 1003
ErrExternalStack = 1004
2017-09-26 12:50:09 +00:00
)
2021-12-06 12:24:22 +00:00
func Error(code int32, err error) error {
return errors.Coded(code, err.Error())
2018-03-20 05:07:19 +00:00
}
2017-09-26 12:50:09 +00:00
2021-12-06 12:24:22 +00:00
func Page(count, pageIndex, pageSize int) (start, end int) {
start = pageSize * (pageIndex - 1)
end = pageSize * pageIndex
if count < start {
start, end = 0, 0
} else if count < end {
end = count
}
return
2017-09-26 12:50:09 +00:00
}