3136352472 5 years ago
parent
commit
237c7a3b97
  1. 11
      core.go

11
core.go

@ -3,6 +3,7 @@ package time_arrow
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/google/uuid"
"log" "log"
"sort" "sort"
"strings" "strings"
@ -23,7 +24,7 @@ type DateSlice struct {
} }
type TimeArrow struct { type TimeArrow struct {
TimeArrowId int `json:"time_arrow_id"`
TimeArrowId string `json:"time_arrow_id"`
Group string `json:"group"` Group string `json:"group"`
Type TimeArrowType `json:"type"` Type TimeArrowType `json:"type"`
//可选 //可选
@ -165,9 +166,15 @@ func isInExpandTags(ta TimeArrow, expandTag string) bool {
return false return false
} }
func createUUID() string {
uid := uuid.Must(uuid.NewUUID())
return uid.String()
}
//CreateDayOfWeekTypePlan 创建一个每周计划 //CreateDayOfWeekTypePlan 创建一个每周计划
func CreateDayOfWeekTypePlan(group string, dayOfWeek []int, timesOnDay []string, expandValue interface{}, expandTags []string, weights float64) TimeArrow { func CreateDayOfWeekTypePlan(group string, dayOfWeek []int, timesOnDay []string, expandValue interface{}, expandTags []string, weights float64) TimeArrow {
return TimeArrow{ return TimeArrow{
TimeArrowId: createUUID(),
Type: TimeArrowTypeDayOfWeek, Type: TimeArrowTypeDayOfWeek,
Group: group, Group: group,
DayOfWeek: dayOfWeek, DayOfWeek: dayOfWeek,
@ -181,6 +188,7 @@ func CreateDayOfWeekTypePlan(group string, dayOfWeek []int, timesOnDay []string,
//CreateDayOfMonthTypePlan 创建一个每月计划 //CreateDayOfMonthTypePlan 创建一个每月计划
func CreateDayOfMonthTypePlan(group string, dayOfMonth []int, timesOnDay []string, expandValue interface{}, expandTags []string, weights float64) TimeArrow { func CreateDayOfMonthTypePlan(group string, dayOfMonth []int, timesOnDay []string, expandValue interface{}, expandTags []string, weights float64) TimeArrow {
return TimeArrow{ return TimeArrow{
TimeArrowId: createUUID(),
Type: TimeArrowTypeDayOfMonth, Type: TimeArrowTypeDayOfMonth,
Group: group, Group: group,
DayOfMonth: dayOfMonth, DayOfMonth: dayOfMonth,
@ -194,6 +202,7 @@ func CreateDayOfMonthTypePlan(group string, dayOfMonth []int, timesOnDay []strin
//CreateDateSliceTypePlan 创建一个时间段计划 //CreateDateSliceTypePlan 创建一个时间段计划
func CreateDateSliceTypePlan(group string, dateSlice []DateSlice, timesOnDay []string, expandValue interface{}, expandTags []string, weights float64) TimeArrow { func CreateDateSliceTypePlan(group string, dateSlice []DateSlice, timesOnDay []string, expandValue interface{}, expandTags []string, weights float64) TimeArrow {
return TimeArrow{ return TimeArrow{
TimeArrowId: createUUID(),
Type: TimeArrowTypeDateSlice, Type: TimeArrowTypeDateSlice,
Group: group, Group: group,
DateSlice: dateSlice, DateSlice: dateSlice,

Loading…
Cancel
Save