Skip to content

Commit aa6e0db

Browse files
committedMar 23, 2024
feat: add entities
1 parent f9369b3 commit aa6e0db

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed
 

‎backend/pkd/controller/client/gsclient.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ type gsStations struct {
5353
}
5454

5555
func UpdateGasStations(c *gin.Context) {
56-
time.Now().Year()
5756
year := time.Now().Year()
5857
month := time.Now().Month()
5958
day := time.Now().Day()

‎backend/pkd/database/dbmigrate/dbmigrate.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ func MigrateDB() {
7070
if !database.DB.Migrator().HasColumn(&pcmodel.CountyData{}, "GsNumDiesel") {
7171
database.DB.Migrator().AddColumn(&pcmodel.CountyData{}, "GsNumDiesel")
7272
}
73+
if !database.DB.Migrator().HasTable(&pcmodel.CountyTimeSlot{}) {
74+
database.DB.Migrator().AutoMigrate(&pcmodel.CountyTimeSlot{})
75+
}
7376

7477
log.Printf("DB Migration Done.")
7578
}

‎backend/pkd/postcode/pcmodel/countydata.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ type CountyData struct {
2121
County string `gorm:"size:256"`
2222
GsAvgValues
2323
PostCodeLocations []PostCodeLocation `gorm:"foreignKey:CountyDataID"`
24+
CountyTimeSlots []CountyTimeSlot `gorm:"foreignKey:CountyDataID"`
2425
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
- Copyright 2022 Sven Loesekann
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package pcmodel
14+
15+
import (
16+
"time"
17+
18+
"gorm.io/gorm"
19+
)
20+
21+
type CountyTimeSlot struct {
22+
gorm.Model
23+
StartDate time.Time
24+
GsAvgValues
25+
CountyDataID uint
26+
CountyData CountyData
27+
}

0 commit comments

Comments
 (0)
Please sign in to comment.