mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 04:10:20 +08:00
feat: return most backend API errors to frontend (#1836)
* feat: return most backend API errros to frontend Signed-off-by: yehong <239859435@qq.com> * refactor: reduce int type change Signed-off-by: yehong <239859435@qq.com> * feat: return err backend in token.go Signed-off-by: yehong <239859435@qq.com> --------- Signed-off-by: yehong <239859435@qq.com>
This commit is contained in:
@ -19,22 +19,25 @@ type Affiliation struct {
|
||||
Name string `xorm:"varchar(128)" json:"name"`
|
||||
}
|
||||
|
||||
func (syncer *Syncer) getAffiliations() []*Affiliation {
|
||||
func (syncer *Syncer) getAffiliations() ([]*Affiliation, error) {
|
||||
affiliations := []*Affiliation{}
|
||||
err := syncer.Adapter.Engine.Table(syncer.AffiliationTable).Asc("id").Find(&affiliations)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return affiliations
|
||||
return affiliations, nil
|
||||
}
|
||||
|
||||
func (syncer *Syncer) getAffiliationMap() ([]*Affiliation, map[int]string) {
|
||||
affiliations := syncer.getAffiliations()
|
||||
func (syncer *Syncer) getAffiliationMap() ([]*Affiliation, map[int]string, error) {
|
||||
affiliations, err := syncer.getAffiliations()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
m := map[int]string{}
|
||||
for _, affiliation := range affiliations {
|
||||
m[affiliation.Id] = affiliation.Name
|
||||
}
|
||||
return affiliations, m
|
||||
return affiliations, m, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user