first commit

This commit is contained in:
Yangtao
2025-11-18 17:48:20 +08:00
commit 6e56cab848
196 changed files with 65809 additions and 0 deletions

37
pkg/utils/time_tool.go Normal file
View File

@ -0,0 +1,37 @@
package utils
import (
"database/sql/driver"
"fmt"
"github.com/anxpp/common-utils/str"
"time"
)
type Time struct {
time.Time
}
func (t *Time) UnmarshalJSON(data []byte) (e error) {
t.Time, e = time.ParseInLocation(str.TimeLayout, string(data), time.Local)
return nil
}
func (t Time) MarshalJSON() ([]byte, error) {
return ([]byte)(fmt.Sprintf("\"%s\"", t.Time.Format(str.TimeLayout))), nil
}
func (t *Time) Scan(value interface{}) error {
bytes, _ := value.([]byte)
tt, _ := time.ParseInLocation(str.TimeLayout, string(bytes), time.Local)
*t = Time{
Time: tt,
}
return nil
}
func (t Time) Value() (driver.Value, error) {
return t.Time.Format(str.TimeLayout), nil
}
func (t Time) String() string {
return str.TimeToString(t.Time)
}