Commit f493fde3 by 彭芳

[minor]: format return data

parent 8d68ce9a
......@@ -8,10 +8,10 @@ const (
)
type PageRequest struct {
Page int `form:"page" json:"page"` // 页码
PageSize int `form:"page_size" json:"page_size" ` // 每页大小
OrderBy string // 排序字段
OrderByMode string // 排序方式 desc asc
Page int `form:"page" json:"page"` // 页码
PageSize int `form:"page_size" json:"page_size" ` // 每页大小
OrderBy string `form:"order_by" json:"order_by"` // 排序字段
OrderByMode string `form:"order_by_mode" json:"order_by_mode"` // 排序方式 desc asc
}
func (p *PageRequest) Offset() int {
......
package util
import "time"
type CivilTime time.Time
func (c CivilTime) MarshalJSON() ([]byte, error) {
return []byte(`"` + time.Time(c).Format("2006-01-02 15:04:05") + `"`), nil
}
package util
import (
"fmt"
"strconv"
"time"
)
const layout = `20060102150405`
type Second int64
func NewSecond(ts ...time.Time) Second {
......@@ -12,7 +15,14 @@ func NewSecond(ts ...time.Time) Second {
if len(ts) > 0 {
t = ts[0]
}
v := t.Format(`20060102150405`)
minute, _ := strconv.Atoi(v)
minute, _ := strconv.Atoi(t.Format(layout))
return Second(minute)
}
func (p Second) MarshalJSON() ([]byte, error) {
t, err := time.ParseInLocation(layout, fmt.Sprint(p), time.Local)
if err != nil {
return nil, err
}
return []byte(`"` + t.Format("2006-01-02 15:04:05") + `"`), nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment