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 }