This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"sample-app/handler" | |
"sample-app/provider" | |
"sample-app/provider/sql" | |
"sample-app/service" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package handler | |
import ( | |
"net/http" | |
"github.com/go-chi/chi" | |
"sample-app/handler/api" | |
"sample-app/service" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package api | |
import ( | |
"net/http" | |
"strconv" | |
"sample-app/service" | |
"sample-app/util" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package service | |
type BaseFactory interface { | |
NewBase() Base | |
} | |
type baseFactory struct { | |
StorageFactory | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package service | |
import ( | |
"encoding/json" | |
) | |
type Base interface { | |
GetData() json.RawMessage | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sql | |
import ( | |
"github.com/jinzhu/gorm" | |
"sample-app/service" | |
) | |
type storageFactory struct { | |
Db *gorm.DB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sql | |
import ( | |
"encoding/json" | |
"fmt" | |
"reflect" | |
"github.com/jinzhu/gorm" | |
"sample-app/model" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package service | |
import "encoding/json" | |
type BaseRepository interface { | |
GetRows(models []string) json.RawMessage | |
} | |
type StorageFactory interface { | |
NewBaseRepository() BaseRepository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package provider | |
import ( | |
"github.com/jinzhu/gorm" | |
_ "github.com/lib/pq" | |
"sample-app/model" | |
"sample-app/util" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package model | |
import ( | |
"encoding/json" | |
"time" | |
) | |
type Building struct { | |
ID uint `gorm:"primary_key" json:"id"` | |
CreatedAt time.Time `json:"-"` |