-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from bnb-chain/v2
feat: add listing table to fix monitor interval mismatch between bsc and gnfd
- Loading branch information
Showing
7 changed files
with
77 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package dao | ||
|
||
import ( | ||
"context" | ||
"github.com/bnb-chain/mind-marketplace-backend/database" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type ListingDao interface { | ||
Create(context context.Context, block *database.Listing) error | ||
GetByGroupId(context context.Context, groupId int64) (database.Listing, error) | ||
} | ||
|
||
type DbListingDao struct { | ||
db *gorm.DB | ||
} | ||
|
||
func NewDbListingDao(db *gorm.DB) *DbListingDao { | ||
return &DbListingDao{ | ||
db: db, | ||
} | ||
} | ||
|
||
func (dao *DbListingDao) Create(context context.Context, listing *database.Listing) error { | ||
if err := dao.db.Create(listing).Error; err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (dao *DbListingDao) GetByGroupId(context context.Context, groupId int64) (database.Listing, error) { | ||
var listing = database.Listing{} | ||
if err := dao.db.Where("group_id = ?", groupId).Take(&listing).Error; err != nil { | ||
return listing, err | ||
} | ||
return listing, nil | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package database | ||
|
||
import ( | ||
"github.com/shopspring/decimal" | ||
) | ||
|
||
type Listing struct { | ||
Id int64 `json:"id" gorm:"primaryKey"` | ||
Price decimal.Decimal `json:"price" gorm:"type:decimal(65,0);"` | ||
ListBscHeight uint64 `gorm:"NOT NULL;"` | ||
GroupId int64 `json:"group_id" gorm:"uniqueIndex:idx_list_group_id;not null;"` | ||
} |
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
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