master
nima 2024-05-27 23:06:25 +03:30
parent cad140daae
commit 6b2ac4b006
30 changed files with 885 additions and 38 deletions

View File

@ -0,0 +1,48 @@
package commands
import (
"netina/models"
l "netina/repositories/license"
"time"
)
type CreateLicenseHandler struct {
Repository l.LicenseCommandRepository
}
func(r *CreateLicenseHandler) Handle (command models.CreateLicenseCommand) error {
license := &models.License{
Plan_id: command.Plan_id,
Period: command.Period,
Created_at: time.Now(),
Modified_by: command.Modified_by,
}
return r.Repository.CreateLicense(license)
}
type UpdateLicenseHandler struct {
Repository l.LicenseCommandRepository
}
func (r *UpdateLicenseHandler) Handle (id uint , command models.UpdateLicenseCommand) (*models.License , error) {
license := &models.License{
Plan_id: command.Plan_id,
Period: command.Period,
Modified_by: command.Modified_by,
}
return r.Repository.UpdateLicense(id , license)
}
type RemoveLicenseHandler struct {
Repository l.LicenseCommandRepository
}
func ( r *RemoveLicenseHandler) Handle (id uint) error {
return r.Repository.RemoveLicense(id)
}

View File

@ -0,0 +1,54 @@
package commands
import (
"netina/models"
o "netina/repositories/owner"
"time"
)
type CreateOwnerHandler struct{
Repository o.OwnerCommandRepository
}
func (r *CreateOwnerHandler) Handle(command models.CreateOwnerCommand) error {
owner := &models.Owner{
PhoneNumber: command.PhoneNumber,
FirstName: command.FirstName,
LastName: command.LastName,
NationalCode: command.NationalCode,
Created_at: time.Now(),
Modified_by: command.Modified_by,
}
return r.Repository.CreateOwner(owner)
}
type UpdateOwnerHandler struct {
Repository o.OwnerCommandRepository
}
func (r *UpdateOwnerHandler) Handle(id uint , command models.UpdateOwnerCommand)(*models.Owner , error) {
owner := &models.Owner{
PhoneNumber: command.PhoneNumber,
FirstName: command.FirstName,
LastName: command.LastName,
NationalCode: command.NationalCode,
Modified_by: command.Modified_by,
}
return r.Repository.UpdateOwner(id , owner)
}
type RemoveOwnerCommand struct {
Repository o.OwnerCommandRepository
}
func (r *RemoveOwnerCommand) Handle(id uint) error {
return r.Repository.RemoveOwner(id)
}

View File

@ -0,0 +1,54 @@
package commands
import (
"netina/models"
p "netina/repositories/plan"
"time"
)
type CreatePlanHandler struct {
Repository p.PlanCommandRepository
}
func (r *CreatePlanHandler) Handle(command models.CreatePlanCommand) error {
plan := &models.Plan{
Price: command.Price,
Priod: command.Priod,
Partnership: command.Partnership,
PercentageOfOwner: command.PercentageOfOwner,
Created_at: time.Now(),
Modified_by: command.Modified_by,
}
return r.Repository.CreatePlan(plan)
}
type UpdatePlanHandler struct {
Repository p.PlanCommandRepository
}
func (r *UpdatePlanHandler) Handle (id uint , command models.UpdatePlanCommand)(*models.Plan , error) {
plan := &models.Plan{
Price: command.Price,
Priod: command.Priod,
Partnership: command.Partnership,
PercentageOfOwner: command.PercentageOfOwner,
Modified_by: command.Modified_by,
}
return r.Repository.UpdatePlan(id , plan)
}
type RemovePlanHandler struct {
Repository p.PlanCommandRepository
}
func (r *RemovePlanHandler) Handle (id uint )error {
return r.Repository.RemovePlan(id)
}

View File

@ -0,0 +1,68 @@
package commands
import (
"netina/models"
s "netina/repositories/store"
"time"
)
type CreateStoreHandler struct {
Repository s.StoreCommandRepository
}
func (r *CreateStoreHandler) Handle (command models.CreateStoreCommand)error {
store := &models.Store{
Owner_id: command.Owner_id,
Name: command.Name,
Address: command.Address,
PhoneNumber: command.PhoneNumber,
WebAddress: command.WebAddress,
ApiAddress: command.ApiAddress,
AdminPanelAddress: command.AdminPanelAddress,
StorageAddress: command.StorageAddress,
License_id: command.License_id,
Modified_by: command.Modified_by,
Created_at: time.Now(),
}
return r.Repository.CreateStore(store)
}
type UpdateStoreHandler struct {
Repository s.StoreCommandRepository
}
func (r *UpdateStoreHandler) Handle (id uint ,command models.UpdateStoreCommand)(*models.Store , error) {
store := &models.Store{
Owner_id: command.Owner_id,
Name: command.Name,
Address: command.Address,
PhoneNumber: command.PhoneNumber,
WebAddress: command.WebAddress,
ApiAddress: command.ApiAddress,
AdminPanelAddress: command.AdminPanelAddress,
StorageAddress: command.StorageAddress,
License_id: command.License_id,
Modified_by: command.Modified_by,
}
return r.Repository.UpdateStore(id ,store )
}
type RemoveStoreHandler struct {
Repository s.StoreCommandRepository
}
func (r *RemoveStoreHandler) Handle (id uint) error {
return r.Repository.RemoveStore(id)
}

5
config/.env 100644
View File

@ -0,0 +1,5 @@
DB_HOST="localhost"
DB_PORT=5433
DB_USER="postgres"
DB_PASSWORD="1"
DB_NAME="netina"

64
database/db.go 100644
View File

@ -0,0 +1,64 @@
package database
import (
"fmt"
"netina/models"
"os"
"strconv"
"github.com/joho/godotenv"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
func Db() gorm.DB {
err := godotenv.Load("./config/.env")
if err != nil {
panic(err)
}
host := os.Getenv("DB_HOST")
port, err := strconv.Atoi(os.Getenv("DB_PORT"))
if err != nil {
fmt.Println(os.Getenv("DB_PORT"))
panic(err)
}
user := os.Getenv("DB_USER")
password := os.Getenv("DB_PASSWORD")
dbname := os.Getenv("DB_NAME")
dbc := fmt.Sprintf("host=%s port=%d user=%s "+
"password=%s dbname=%s sslmode=disable",
host, port, user, password, dbname)
db, err := gorm.Open(postgres.Open(dbc), &gorm.Config{})
if err != nil {
panic(err)
}
return *db
}
func Create_tables()error{
db := Db()
err := db.AutoMigrate(&models.Owner{})
if err != nil {
return err
}
err = db.AutoMigrate(&models.Store{})
if err != nil {
return err
}
err = db.AutoMigrate(&models.License{})
if err != nil {
return err
}
err = db.AutoMigrate(&models.Plan{})
if err != nil {
return err
}
return nil
}

16
go.mod
View File

@ -1,3 +1,19 @@
module netina
go 1.21.4
require (
github.com/joho/godotenv v1.5.1
gorm.io/driver/postgres v1.5.7
gorm.io/gorm v1.25.10
)
require (
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.4.3 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/text v0.13.0 // indirect
)

34
go.sum 100644
View File

@ -0,0 +1,34 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.4.3 h1:cxFyXhxlvAifxnkKKdlxv8XqUf59tDlYjnV5YYfsJJY=
github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/postgres v1.5.7 h1:8ptbNJTDbEmhdr62uReG5BGkdQyeasu/FZHxI0IMGnM=
gorm.io/driver/postgres v1.5.7/go.mod h1:3e019WlBaYI5o5LIdNV+LyxCMNtLOQETBXL2h4chKpA=
gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s=
gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=

10
main.go
View File

@ -1 +1,11 @@
package main
import (
db "netina/database"
)
func main(){
db.Create_tables()
}

22
models/Store.go 100644
View File

@ -0,0 +1,22 @@
package models
import "time"
type Store struct {
Store_id uint `gorm:"primaryKey"`
Owner_id uint
Owner Owner `gorm:"references:Owner_id"`
Name string
Address string
PhoneNumber string
WebAddress string
ApiAddress string
StorageAddress string
AdminPanelAddress string
License_id uint
License License `gorm:"references:License_id"`
Created_at time.Time
Modified_at time.Time
Modified_by string
Is_removed bool `gorm:"default:false"`
}

14
models/license.go 100644
View File

@ -0,0 +1,14 @@
package models
import "time"
type License struct {
License_id uint `gorm:"primaryKey"`
Plan_id uint
Plan Plan `gorm:"references:Plan_id"`
Period time.Time
Created_at time.Time
Modified_at time.Time
Modified_by string
Is_removed bool `gorm:"default:false"`
}

View File

@ -0,0 +1,17 @@
package models
import "time"
type CreateLicenseCommand struct {
Plan_id uint
Period time.Time
Modified_by string
}
type UpdateLicenseCommand struct {
Plan_id uint
Period time.Time
Modified_by string
}

View File

@ -1,38 +0,0 @@
package models
import "time"
type owner struct {
ID uint
PhoneNumber uint
FullName string
NationalCode string
Stores []uint
Created_at string
Is_removed bool
}
type store struct {
ID uint
OwnerID uint
Name string
Address string
PhoneNumber uint
WebAddress string
ApiAddress string
StorageAddress string
AdminPanelAddress string
LicenseID string
Created_at string
Is_removed bool
}
type License struct {
ID uint
Price uint
Period time.Time
Partnership bool
PercentageOfOwner uint
Created_at string
Is_removed bool
}

15
models/owner.go 100644
View File

@ -0,0 +1,15 @@
package models
import "time"
type Owner struct {
Owner_id uint `gorm:"primaryKey"`
PhoneNumber string
FirstName string
LastName string
NationalCode string
Created_at time.Time
Modified_at time.Time
Modified_by string
Is_removed bool `gorm:"default:false"`
}

View File

@ -0,0 +1,17 @@
package models
type CreateOwnerCommand struct {
PhoneNumber string
FirstName string
LastName string
NationalCode string
Modified_by string
}
type UpdateOwnerCommand struct {
PhoneNumber string
FirstName string
LastName string
NationalCode string
Modified_by string
}

15
models/plan.go 100644
View File

@ -0,0 +1,15 @@
package models
import "time"
type Plan struct {
Plan_id uint `gorm:"primaryKey"`
Price uint
Priod time.Time
Partnership bool
PercentageOfOwner uint
Created_at time.Time
Modified_at time.Time
Modified_by string
Is_removed bool `gorm:"default:false"`
}

View File

@ -0,0 +1,21 @@
package models
import "time"
type CreatePlanCommand struct {
Price uint
Priod time.Time
Partnership bool
PercentageOfOwner uint
Modified_by string
}
type UpdatePlanCommand struct {
Price uint
Priod time.Time
Partnership bool
PercentageOfOwner uint
Modified_by string
}

View File

@ -0,0 +1,27 @@
package models
type CreateStoreCommand struct {
Owner_id uint
Name string
Address string
PhoneNumber string
WebAddress string
ApiAddress string
StorageAddress string
AdminPanelAddress string
License_id uint
Modified_by string
}
type UpdateStoreCommand struct {
Owner_id uint
Name string
Address string
PhoneNumber string
WebAddress string
ApiAddress string
StorageAddress string
AdminPanelAddress string
License_id uint
Modified_by string
}

View File

@ -0,0 +1,57 @@
package license_repository
import (
"netina/models"
"gorm.io/gorm"
)
type LicenseCommand interface{
CreateLicense(o *models.License) error
UpdateLicense(id uint , o *models.License)(*models.License , error)
RemoveLicense(id uint)error
}
type LicenseCommandRepository struct{
DB *gorm.DB
}
func (r *LicenseCommandRepository) CreateLicense(License *models.License)error{
if err := r.DB.Create(&License).Error ; err != nil {
return err
}
return nil
}
func (r *LicenseCommandRepository) UpdateLicense(id uint , license *models.License)(*models.License , error){
var temp models.License
if err := r.DB.Where("is_removed = ?" , false).Where("license_id = ?" , id).First(&temp).Error ; err != nil {
return nil , err
}
temp.Period = license.Period
temp.Modified_at = license.Modified_at
temp.Modified_by = license.Modified_by
if err := r.DB.Save(&temp).Error; err != nil {
return nil , err
}
return &temp , nil
}
func (r *LicenseCommandRepository) RemoveLicense(id uint)error{
if err := r.DB.Where("license_id = ?" , id).Error;err != nil {
return err
}
return nil
}

View File

@ -0,0 +1,30 @@
package license_repository
import (
"netina/models"
"gorm.io/gorm"
)
type LicenseQuery interface{
GetLicense(id uint)(*models.License , error)
}
type LicenseQueryRepository struct{
DB *gorm.DB
}
func (r *LicenseQueryRepository) GetLicense(id uint)(*models.License , error){
var License models.License
if err := r.DB.Where("is_removed = ?" , false).Where("license_id = ?" , id).First(&License).Error; err != nil {
return nil , err
}
return &License , nil
}

View File

@ -0,0 +1,59 @@
package owner_repository
import (
"netina/models"
"gorm.io/gorm"
)
type OwnerCommand interface{
CreateOwner(o *models.Owner) error
UpdateOwner(id uint , o *models.Owner)(*models.Owner , error)
RemoveOwner(id uint)error
}
type OwnerCommandRepository struct{
DB *gorm.DB
}
func (r *OwnerCommandRepository) CreateOwner(owner *models.Owner)error{
if err := r.DB.Create(&owner).Error ; err != nil {
return err
}
return nil
}
func (r *OwnerCommandRepository) UpdateOwner(id uint , owner *models.Owner)(*models.Owner , error){
var temp models.Owner
if err := r.DB.Where("is_removed = ?" , false).Where("owner_id = ?" , id).First(&temp).Error ; err != nil {
return nil , err
}
temp.FirstName = owner.FirstName
temp.LastName = owner.LastName
temp.Modified_at = owner.Modified_at
temp.Modified_by = owner.Modified_by
temp.PhoneNumber = owner.PhoneNumber
temp.NationalCode = owner.NationalCode
if err := r.DB.Save(&temp).Error; err != nil {
return nil , err
}
return &temp , nil
}
func (r *OwnerCommandRepository) RemoveOwner(id uint)error{
if err := r.DB.Where("owner_id = ?" , id).Error;err != nil {
return err
}
return nil
}

View File

@ -0,0 +1,28 @@
package owner_repository
import (
"netina/models"
"gorm.io/gorm"
)
type OwnerQuery interface {
GetOwner(id uint) (*models.Owner, error)
}
type OwnerQueryRepository struct{
DB *gorm.DB
}
func (r *OwnerQueryRepository) GetOwner(id uint)(*models.Owner , error){
var owner models.Owner
if err := r.DB.Where("is_removed = ?" , false).Where("owner_id = ?" , id).First(&owner).Error; err != nil {
return nil , err
}
return &owner , nil
}

View File

@ -0,0 +1,66 @@
package plan_repository
import (
"netina/models"
"gorm.io/gorm"
)
type PlanCommand interface{
CreatePlan(o *models.Plan) error
GetPlan(id uint)(*models.Plan , error)
UpdatePlan(id uint , o *models.Plan)(*models.Plan , error)
RemovePlan(id uint)error
}
type PlanCommandRepository struct{
DB *gorm.DB
}
func (r *PlanCommandRepository) CreatePlan(plan *models.Plan)error{
if err := r.DB.Create(&plan).Error ; err != nil {
return err
}
return nil
}
func (r *PlanCommandRepository) GetPlan(id uint)(*models.Plan , error){
var Plan models.Plan
if err := r.DB.Where("is_removed = ?" , false).Where("plan_id = ?" , id).First(&Plan).Error; err != nil {
return nil , err
}
return &Plan , nil
}
func (r *PlanCommandRepository) UpdatePlan(id uint , plan *models.Plan)(*models.Plan , error){
var temp models.Plan
if err := r.DB.Where("is_removed = ?" , false).Where("plan_id = ?" , id).First(&temp).Error ; err != nil {
return nil , err
}
temp.Partnership = plan.Partnership
temp.Modified_at = plan.Modified_at
temp.Modified_by = plan.Modified_by
temp.PercentageOfOwner = plan.PercentageOfOwner
temp.Price = plan.Price
if err := r.DB.Save(&temp).Error; err != nil {
return nil , err
}
return &temp , nil
}
func (r *PlanCommandRepository) RemovePlan(id uint)error{
if err := r.DB.Where("plan_id = ?" , id).Error;err != nil {
return err
}
return nil
}

View File

@ -0,0 +1,26 @@
package plan_repository
import (
"netina/models"
"gorm.io/gorm"
)
type PlanQuery interface{
GetPlan(id uint)(*models.Plan , error)
}
type PlanQueryRepository struct{
DB *gorm.DB
}
func (r *PlanQueryRepository) GetPlan(id uint)(*models.Plan , error){
var Plan models.Plan
if err := r.DB.Where("is_removed = ?" , false).Where("plan_id = ?" , id).First(&Plan).Error; err != nil {
return nil , err
}
return &Plan , nil
}

View File

@ -0,0 +1,78 @@
package store_repository
import (
"netina/models"
"gorm.io/gorm"
)
type StoreCommand interface{
CreateStore(o *models.Store) error
UpdateStore(id uint , o *models.Store)(*models.Store , error)
RemoveStore(id uint)error
}
type StoreCommandRepository struct{
DB *gorm.DB
}
func (r *StoreCommandRepository) CreateStore(store *models.Store)error{
if err := r.DB.Create(&store).Error ; err != nil {
return err
}
return nil
}
func (r *StoreCommandRepository) GetStore(id uint)(*models.Store , error){
var store models.Store
if err := r.DB.Where("is_removed = ?" , false).Where("store_id = ?" , id).First(&store).Error; err != nil {
return nil , err
}
return &store , nil
}
func (r *StoreCommandRepository) GetStores(id uint)([]models.Store , error){
var store []models.Store
if err := r.DB.Where("is_removed = ?" , false).Where("owner_id = ?" , id).Find(&store).Error; err != nil {
return nil , err
}
return store , nil
}
func (r *StoreCommandRepository) UpdateStore(id uint , store *models.Store)(*models.Store , error){
var temp models.Store
if err := r.DB.Where("is_removed = ?" , false).Where("store_id = ?" , id).First(&temp).Error ; err != nil {
return nil , err
}
temp.Address = store.Address
temp.AdminPanelAddress = store.AdminPanelAddress
temp.ApiAddress = store.ApiAddress
temp.Modified_at = store.Modified_at
temp.Modified_by = store.Modified_by
temp.StorageAddress = store.StorageAddress
temp.Name = store.Name
temp.WebAddress = store.WebAddress
if err := r.DB.Save(&temp).Error; err != nil {
return nil , err
}
return &temp , nil
}
func (r *StoreCommandRepository) RemoveStore(id uint)error{
if err := r.DB.Where("store_id = ?" , id).Error;err != nil {
return err
}
return nil
}

View File

@ -0,0 +1,36 @@
package store_repository
import (
"netina/models"
"gorm.io/gorm"
)
type StoreQuery interface{
GetStore(id uint)(*models.Store , error)
GetStores(id uint)([]models.Store , error)
}
type StoreQueryRepository struct{
DB *gorm.DB
}
func (r *StoreQueryRepository) GetStore(id uint)(*models.Store , error){
var store models.Store
if err := r.DB.Where("is_removed = ?" , false).Where("store_id = ?" , id).First(&store).Error; err != nil {
return nil , err
}
return &store , nil
}
func (r *StoreQueryRepository) GetStores(id uint)([]models.Store , error){
var store []models.Store
if err := r.DB.Where("is_removed = ?" , false).Where("owner_id = ?" , id).Find(&store).Error; err != nil {
return nil , err
}
return store , nil
}

View File

@ -0,0 +1 @@
package handlers

View File

@ -0,0 +1 @@
package handlers

1
services/plan.go 100644
View File

@ -0,0 +1 @@
package handlers

View File

@ -0,0 +1 @@
package handlers