-
Notifications
You must be signed in to change notification settings - Fork 1
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 #14 from coticom/main
support team_name query
- Loading branch information
Showing
11 changed files
with
166 additions
and
26 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
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,16 @@ | ||
package entity | ||
|
||
const TableNameSpecialAwards = "special_awards" | ||
|
||
type SpecialAwards struct { | ||
ID int64 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键" json:"id"` | ||
Rank int `gorm:"column:rank" json:"rank"` | ||
TeamName string `gorm:"column:team_name" json:"team_name"` | ||
TaskCompleted string `gorm:"column:task_completed" json:"task_completed"` | ||
FinalScore int `gorm:"column:final_score" json:"final_score"` | ||
UpdateTime int64 `gorm:"column:update_time" json:"update_time"` | ||
} | ||
|
||
func (*SpecialAwards) TableName() string { | ||
return TableNameSpecialAwards | ||
} |
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,18 @@ | ||
package cache | ||
|
||
import ( | ||
"github.com/bianjieai/icndev-server/internal/app/model/entity" | ||
"github.com/bianjieai/icndev-server/internal/app/repository" | ||
) | ||
|
||
type SpecialAwardsCacheRepo struct { | ||
dbr *repository.SpecialAwardsRepo | ||
} | ||
|
||
func NewSpecialAwardsCacheRepo(dbr *repository.SpecialAwardsRepo) *SpecialAwardsCacheRepo { | ||
return &SpecialAwardsCacheRepo{dbr: dbr} | ||
} | ||
|
||
func (repo *SpecialAwardsCacheRepo) FindAll() ([]*entity.SpecialAwards, int64, error) { | ||
return repo.dbr.FindAll() | ||
} |
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,27 @@ | ||
package repository | ||
|
||
import ( | ||
"github.com/bianjieai/icndev-server/internal/app/model/entity" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type ISpecialAwardsRepo interface { | ||
FindAll() ([]*entity.SpecialAwards, int64, error) | ||
} | ||
|
||
type SpecialAwardsRepo struct { | ||
db *gorm.DB | ||
} | ||
|
||
func NewSpecialAwardsRepo(db *gorm.DB) *SpecialAwardsRepo { | ||
return &SpecialAwardsRepo{db: db} | ||
} | ||
|
||
func (repo *SpecialAwardsRepo) FindAll() ([]*entity.SpecialAwards, int64, error) { | ||
var res []*entity.SpecialAwards | ||
var total int64 | ||
var err error | ||
tx := repo.db.Table(entity.TableNameSpecialAwards) | ||
err = tx.Count(&total).Find(&res).Error | ||
return res, total, err | ||
} |
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