resource.go 506 Bytes
Newer Older
kzkzzzz's avatar
kzkzzzz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
package dao

import (
	"hilo/app/service/user/internal/model"
)

func (d *Dao) GetAllMedal() ([]*model.ResMedal, error) {
	rows := make([]*model.ResMedal, 0)
	err := d.DB.Find(&rows).Error
	if err != nil {
		return nil, err
	}
	return rows, nil
}

func (d *Dao) GetAllMedalMap() (map[int]*model.ResMedal, error) {
	rows, err := d.GetAllMedal()
	if err != nil {
		return nil, err
	}
	result := make(map[int]*model.ResMedal, len(rows))
	for _, i := range rows {
		result[(i.Id)] = i
	}
	return result, nil
}