From 237c7a3b9743adc8fa36fc9b6b5758f03834b243 Mon Sep 17 00:00:00 2001 From: 3136352472 <3136352472> Date: Tue, 9 Jun 2020 18:47:04 +0800 Subject: [PATCH] fix --- core.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core.go b/core.go index 869ce6b..1f8119c 100644 --- a/core.go +++ b/core.go @@ -3,6 +3,7 @@ package time_arrow import ( "errors" "fmt" + "github.com/google/uuid" "log" "sort" "strings" @@ -23,7 +24,7 @@ type DateSlice struct { } type TimeArrow struct { - TimeArrowId int `json:"time_arrow_id"` + TimeArrowId string `json:"time_arrow_id"` Group string `json:"group"` Type TimeArrowType `json:"type"` //可选 @@ -165,9 +166,15 @@ func isInExpandTags(ta TimeArrow, expandTag string) bool { return false } +func createUUID() string { + uid := uuid.Must(uuid.NewUUID()) + return uid.String() +} + //CreateDayOfWeekTypePlan 创建一个每周计划 func CreateDayOfWeekTypePlan(group string, dayOfWeek []int, timesOnDay []string, expandValue interface{}, expandTags []string, weights float64) TimeArrow { return TimeArrow{ + TimeArrowId: createUUID(), Type: TimeArrowTypeDayOfWeek, Group: group, DayOfWeek: dayOfWeek, @@ -181,6 +188,7 @@ func CreateDayOfWeekTypePlan(group string, dayOfWeek []int, timesOnDay []string, //CreateDayOfMonthTypePlan 创建一个每月计划 func CreateDayOfMonthTypePlan(group string, dayOfMonth []int, timesOnDay []string, expandValue interface{}, expandTags []string, weights float64) TimeArrow { return TimeArrow{ + TimeArrowId: createUUID(), Type: TimeArrowTypeDayOfMonth, Group: group, DayOfMonth: dayOfMonth, @@ -194,6 +202,7 @@ func CreateDayOfMonthTypePlan(group string, dayOfMonth []int, timesOnDay []strin //CreateDateSliceTypePlan 创建一个时间段计划 func CreateDateSliceTypePlan(group string, dateSlice []DateSlice, timesOnDay []string, expandValue interface{}, expandTags []string, weights float64) TimeArrow { return TimeArrow{ + TimeArrowId: createUUID(), Type: TimeArrowTypeDateSlice, Group: group, DateSlice: dateSlice,