38 lines
954 B
Go
38 lines
954 B
Go
|
package repo
|
||
|
|
||
|
import (
|
||
|
"admin/apps/game/domain/entity"
|
||
|
"admin/apps/game/model"
|
||
|
"admin/internal/errcode"
|
||
|
"admin/internal/model/dto"
|
||
|
"gorm.io/gorm"
|
||
|
)
|
||
|
|
||
|
type IAccountRepo interface {
|
||
|
GetWhiteListAll(projectEt *entity.Project) ([]*dto.WhiteListInfo, error)
|
||
|
}
|
||
|
|
||
|
type accountRepoImpl struct {
|
||
|
db *gorm.DB
|
||
|
}
|
||
|
|
||
|
func NewAccountRepo(db *gorm.DB) IAccountRepo {
|
||
|
return &accountRepoImpl{db: db}
|
||
|
}
|
||
|
|
||
|
func (impl *accountRepoImpl) GetWhiteListAll(projectEt *entity.Project) ([]*dto.WhiteListInfo, error) {
|
||
|
list := make([]*model.WhiteList, 0)
|
||
|
err := impl.db.Where("project_id = ?", projectEt.Po.ID).Find(&list).Error
|
||
|
if err != nil {
|
||
|
return nil, errcode.New(errcode.DBError, "list project %v whitelist error:%v", projectEt.Po.ID, err)
|
||
|
}
|
||
|
retAccountList := make([]*dto.WhiteListInfo, 0, len(list))
|
||
|
for _, a := range list {
|
||
|
retAccountList = append(retAccountList, &dto.WhiteListInfo{
|
||
|
WType: a.WType,
|
||
|
Value: a.Value,
|
||
|
})
|
||
|
}
|
||
|
return retAccountList, nil
|
||
|
}
|