时间由指针改回对象

This commit is contained in:
hoteas 2022-10-20 09:08:23 +08:00
parent b425024359
commit 4ab5ab9ff4
7 changed files with 883 additions and 880 deletions

View File

@ -38,8 +38,8 @@ func StrFirstToUpper(str string) string {
}
// 时间转字符串第二个参数支持1-5对应显示年月日时分秒
func Time2Str(t *time.Time, qu ...interface{}) string {
if t == nil || t.Unix() < 0 {
func Time2Str(t time.Time, qu ...interface{}) string {
if t.Unix() < 0 {
return ""
}
tp := 5

View File

@ -102,7 +102,7 @@ func (that Map) GetBool(key string, err ...*Error) bool {
}
func (that Map) GetTime(key string, err ...*Error) *time.Time {
func (that Map) GetTime(key string, err ...*Error) time.Time {
v := ObjToTime((that)[key], err...)
return v

View File

@ -20,7 +20,7 @@ func (that *Obj) ToInt(err ...Error) int {
return ObjToInt(that.Data, &that.Error)
}
func (that *Obj) ToTime(err ...Error) *time.Time {
func (that *Obj) ToTime(err ...Error) time.Time {
if len(err) != 0 {
that.Error = err[0]
}

View File

@ -97,7 +97,7 @@ func ObjToSlice(obj interface{}, e ...*Error) Slice {
return v
}
func ObjToTime(obj interface{}, e ...*Error) *time.Time {
func ObjToTime(obj interface{}, e ...*Error) time.Time {
tInt := ObjToInt64(obj)
//字符串类型只支持标准mysql datetime格式
@ -107,27 +107,27 @@ func ObjToTime(obj interface{}, e ...*Error) *time.Time {
if len(tStr) > 18 {
t, e := time.Parse("2006-01-02 15:04:05", tStr)
if e == nil {
return &t
return t
}
} else if len(tStr) > 15 {
t, e := time.Parse("2006-01-02 15:04", tStr)
if e == nil {
return &t
return t
}
} else if len(tStr) > 12 {
t, e := time.Parse("2006-01-02 15", tStr)
if e == nil {
return &t
return t
}
} else if len(tStr) > 9 {
t, e := time.Parse("2006-01-02", tStr)
if e == nil {
return &t
return t
}
} else if len(tStr) > 6 {
t, e := time.Parse("2006-01", tStr)
if e == nil {
return &t
return t
}
}
@ -136,27 +136,27 @@ func ObjToTime(obj interface{}, e ...*Error) *time.Time {
//纳秒级别
if len(ObjToStr(tInt)) > 16 {
t := time.Time{}.Add(time.Nanosecond * time.Duration(tInt))
return &t
return t
//微秒级别
} else if len(ObjToStr(tInt)) > 13 {
t := time.Time{}.Add(time.Microsecond * time.Duration(tInt))
return &t
return t
//毫秒级别
} else if len(ObjToStr(tInt)) > 10 {
t := time.Time{}.Add(time.Millisecond * time.Duration(tInt))
return &t
return t
//秒级别
} else if len(ObjToStr(tInt)) > 9 {
t := time.Time{}.Add(time.Second * time.Duration(tInt))
return &t
return t
} else if len(ObjToStr(tInt)) > 3 {
t, e := time.Parse("2006", ObjToStr(tInt))
if e == nil {
return &t
return t
}
}
return nil
return time.Time{}
}
func ObjToFloat64(obj interface{}, e ...*Error) float64 {

View File

@ -15,7 +15,7 @@ func (that Slice) GetString(key int, err ...*Error) string {
return ObjToStr((that)[key])
}
func (that Slice) GetTime(key int, err ...*Error) *time.Time {
func (that Slice) GetTime(key int, err ...*Error) time.Time {
v := ObjToTime((that)[key], err...)
return v

View File

@ -3,6 +3,7 @@
"admin": {
"sql": {
"org_id": "org_id",
"parent_ids[~]": "%,id,%",
"role_id": "role_id",
"zone_id": "zone_id"
},
@ -55,7 +56,9 @@
"table": "proj"
},
"role": {
"sql": {},
"sql": {
"id": "role_id"
},
"stop": true,
"table": "role"
},
@ -124,38 +127,6 @@
"icon": "Setting",
"label": "系统管理",
"menus": [
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "项目分类",
"table": "category"
},
{
"auth": [
"show",
"download"
],
"label": "日志管理",
"table": "logs"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "项目管理",
"table": "proj"
},
{
"auth": [
"show",
@ -168,78 +139,6 @@
"label": "角色管理",
"table": "role"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "微信信息",
"table": "wechat"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "车辆管理",
"table": "car"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "客户管理",
"table": "company"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "标签管理",
"table": "out_tag"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "用章管理",
"table": "seal_tag"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "考勤管理",
"table": "time_tag"
},
{
"auth": [
"show",
@ -261,8 +160,8 @@
"info",
"download"
],
"label": "人员管理",
"table": "admin"
"label": "项目分类",
"table": "category"
},
{
"auth": [
@ -273,8 +172,8 @@
"info",
"download"
],
"label": "城市管理",
"table": "city"
"label": "标签管理",
"table": "out_tag"
},
{
"auth": [
@ -285,8 +184,8 @@
"info",
"download"
],
"label": "供应商管理",
"table": "channel"
"label": "考勤管理",
"table": "time_tag"
},
{
"auth": [
@ -297,8 +196,16 @@
"info",
"download"
],
"label": "部门管理",
"table": "org"
"label": "车辆管理",
"table": "car"
},
{
"auth": [
"show",
"download"
],
"label": "日志管理",
"table": "logs"
},
{
"auth": [
@ -333,8 +240,32 @@
"info",
"download"
],
"label": "联盟公司",
"table": "zone"
"label": "城市管理",
"table": "city"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "项目管理",
"table": "proj"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "客户管理",
"table": "company"
},
{
"auth": [
@ -347,10 +278,116 @@
],
"label": "项目归口",
"table": "department"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "部门管理",
"table": "org"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "用章管理",
"table": "seal_tag"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "微信信息",
"table": "wechat"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "联盟公司",
"table": "zone"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "人员管理",
"table": "admin"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "供应商管理",
"table": "channel"
}
],
"name": "sys"
},
{
"auth": [
"show"
],
"icon": "Setting",
"label": "任务执行",
"menus": [
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "任务执行",
"table": "task_admin"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "任务管理",
"table": "task"
}
],
"name": "sys:task"
},
{
"auth": [
"show"
@ -372,40 +409,6 @@
}
],
"name": "sys:sea"
},
{
"auth": [
"show"
],
"icon": "Setting",
"label": "任务管理",
"menus": [
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "任务管理",
"table": "task"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "任务执行",
"table": "task_admin"
}
],
"name": "sys:task"
}
],
"name": "admin",

File diff suppressed because it is too large Load Diff