我们将如何根据结果数以及计数字段输入数据?

By using go api I'm retrieving the an array object. like given below:-

[
 {0 1 Sunday 1 21600 25200 1} 
 {0 1 Sunday 2 28800 32400 2} 
 {0 1 Sunday 3 36000 39600 1}
]

This data will be arranged using struct:-

type ProviderSpot struct {
 Id         int    `json:"_id" bson:"_id"` 
 PId         int    `json:"pid" bson:"pid"`
 Day        string `json:"day" bson:"day"`
 TimeSlug   int    `json:"time_slug" bson:"time_slug"`
 StartTime   int64  `json:"start_time" bson:"start_time"`
 EndTime        int64  `json:"end_time" bson:"end_time"`
 Count      int    `json:"count" bson:"count"`
}
type ProviderSpots []ProviderSpot

See in the array object I have an count values in each object 1,2,1 then I have to store this record like that those record having count they will store in the available_spot only one time means that the upper record will save in the collection only one time having there count value 1 after that the left record will remains there count value 0,1,0 then those record having there count field value more than 0 they will save that number of times having count value in the addition_spot. The code of golang I'm using is this:-

func SaveProviderSpot(c *gin.Context) {
 response := ResponseController{}
 values := c.PostForm("array")
 var err error
 byt := []byte(values)
 var result models.ProviderSpots
 if err = json.Unmarshal(byt, &result); err != nil{
    fmt.Println(err)
 }
 fmt.Println(result)
 for i := 0; i < len(result); i++ {
    lastValue :=result[i].Count-1
    if lastValue != -1 {
        providerspot.PId = result[i].PId
        providerspot.Day = result[i].Day
        providerspot.TimeSlug = result[i].TimeSlug
        providerspot.StartTime = result[i].StartTime
        providerspot.EndTime  = result[i].EndTime
        providerspot.Count = result[i].Count - lastValue

        id, _ := models.GetAutoIncrementCounter(config.ProvidersSpotsCounterId, config.ProvidersSpotsCollection)
        providerspot.Id = id
        fmt.Println("Here We go now :- ", &providerspot)
        err = models.AddProviderSpot(&providerspot) 
    }
 }
}

Give some example of this which will solve this. Thanks for your valueable time spending on this question.

I solved that question answer but Can anyone tell me that will right for my code or not:-

func SaveProviderSpot(c *gin.Context) {
 response := ResponseController{}
 values := c.PostForm("array")
 var err error
 byt := []byte(values)
 var result models.ProviderSpots
 if err = json.Unmarshal(byt, &result); err != nil{
    fmt.Println(err)
 }
 fmt.Println(result)
 for i := 0; i < len(result); i++ {
    for j := 1; j <= result[i].Count; j++ {
        // lastValue := result[i].Count-1
        // if lastValue != -1 {
        if j == 1{
            providerspot.PId = result[i].PId
            providerspot.Day = result[i].Day
            providerspot.TimeSlug = result[i].TimeSlug
            providerspot.StartTime = result[i].StartTime
            providerspot.EndTime  = result[i].EndTime
            providerspot.Count = 1//result[i].Count - lastValue

            id, _ := models.GetAutoIncrementCounter(config.ProvidersSpotsCounterId, config.ProvidersSpotsCollection)
            providerspot.Id = id
            fmt.Println("Here We go now :- ", &providerspot)
            err = models.AddProviderSpot(&providerspot) 
        }else{
            providerspot.PId = result[i].PId
            providerspot.Day = result[i].Day
            providerspot.TimeSlug = result[i].TimeSlug
            providerspot.StartTime = result[i].StartTime
            providerspot.EndTime  = result[i].EndTime
            providerspot.Count = 1//result[i].Count - lastValue

            id, _ := models.GetAutoIncrementCounter(config.AdditionalProviderCounterSpot, config.AdditionalProviderSpot)
            providerspot.Id = id
            err = models.AddAdditionalProviderSpot(&providerspot)
        }       
    }
 }
} 

This will do want I want but I'm confused that it is right for me or not.