mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 10:13:01 +00:00
refactor🎨 api数据初始化调整
This commit is contained in:
@@ -39,7 +39,7 @@ func (e *SysApi) GetSysApiPage(c *dto.SysApiSearch, p *actions.DataPermission, l
|
||||
}
|
||||
|
||||
// GetSysApi 获取SysApi对象
|
||||
func (e *SysApi) GetSysApi(d *dto.SysApiById, p *actions.DataPermission, model *models.SysApi) error {
|
||||
func (e *SysApi) GetSysApi(d *dto.SysApiById, p *actions.DataPermission, model *models.SysApi) *SysApi {
|
||||
var data models.SysApi
|
||||
|
||||
err := e.Orm.Model(&data).
|
||||
@@ -50,11 +50,13 @@ func (e *SysApi) GetSysApi(d *dto.SysApiById, p *actions.DataPermission, model *
|
||||
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
err = errors.New("查看对象不存在或无权查看")
|
||||
e.Log.Errorf("Service GetSysApi error:%s", err)
|
||||
return err
|
||||
e.AddError(err)
|
||||
return e
|
||||
}
|
||||
if err != nil {
|
||||
e.Log.Errorf("db error:%s", err)
|
||||
return err
|
||||
e.AddError(err)
|
||||
return e
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -62,7 +64,9 @@ func (e *SysApi) GetSysApi(d *dto.SysApiById, p *actions.DataPermission, model *
|
||||
// InsertSysApi 创建SysApi对象
|
||||
func (e *SysApi) CheckStorageSysApi(c *[]runtime.Router) error {
|
||||
for _, v := range *c {
|
||||
err := e.Orm.Debug().Where(models.SysApi{Path: v.RelativePath, Action: v.HttpMethod}).Attrs(models.SysApi{Handle: v.Handler}).FirstOrCreate(&models.SysApi{}).Error
|
||||
err := e.Orm.Debug().Where(models.SysApi{Path: v.RelativePath, Action: v.HttpMethod}).
|
||||
Attrs(models.SysApi{Handle: v.Handler}).
|
||||
FirstOrCreate(&models.SysApi{}).Error
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Service CheckStorageSysApi error: %s \r\n ", err.Error())
|
||||
return err
|
||||
@@ -103,4 +107,4 @@ func (e *SysApi) RemoveSysApi(d *dto.SysApiById, p *actions.DataPermission) erro
|
||||
return errors.New("无权删除该数据")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user