Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean err define in methods. #803

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/admin/service/sys_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ func (e *SysConfig) Remove(d *dto.SysConfigDeleteReq) error {

db := e.Orm.Delete(&data, d.Ids)
if err = db.Error; err != nil {
err = db.Error
e.Log.Errorf("Service RemoveSysConfig error:%s", err)
return err
}
Expand All @@ -168,8 +167,7 @@ func (e *SysConfig) GetWithKey(c *dto.SysConfigByKeyReq, resp *dto.GetSysConfigB
}

func (e *SysConfig) GetWithKeyList(c *dto.SysConfigGetToSysAppReq, list *[]models.SysConfig) error {
var err error
err = e.Orm.
err := e.Orm.
Scopes(
cDto.MakeCondition(c.GetNeedSearch()),
).
Expand Down
1 change: 0 additions & 1 deletion app/admin/service/sys_dept.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ func (e *SysDept) Remove(d *dto.SysDeptDeleteReq) error {

db := e.Orm.Model(&data).Delete(&data, d.GetId())
if err = db.Error; err != nil {
err = db.Error
e.Log.Errorf("Delete error: %s", err)
return err
}
Expand Down
1 change: 0 additions & 1 deletion app/admin/service/sys_dict_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func (e *SysDictData) Remove(c *dto.SysDictDataDeleteReq) error {

db := e.Orm.Delete(&data, c.GetId())
if err = db.Error; err != nil {
err = db.Error
e.Log.Errorf("Delete error: %s", err)
return err
}
Expand Down
4 changes: 2 additions & 2 deletions app/admin/service/sys_dict_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package service
import (
"errors"
"fmt"

"github.com/go-admin-team/go-admin-core/sdk/service"
"gorm.io/gorm"

Expand Down Expand Up @@ -60,7 +61,7 @@ func (e *SysDictType) Insert(c *dto.SysDictTypeInsertReq) error {
var count int64
e.Orm.Model(&data).Where("dict_type = ?", data.DictType).Count(&count)
if count > 0 {
return errors.New(fmt.Sprintf("当前字典类型[%s]已经存在!", data.DictType))
return fmt.Errorf("当前字典类型[%s]已经存在!", data.DictType)
}
err = e.Orm.Create(&data).Error
if err != nil {
Expand Down Expand Up @@ -95,7 +96,6 @@ func (e *SysDictType) Remove(d *dto.SysDictTypeDeleteReq) error {

db := e.Orm.Delete(&data, d.GetId())
if err = db.Error; err != nil {
err = db.Error
e.Log.Errorf("Delete error: %s", err)
return err
}
Expand Down
1 change: 0 additions & 1 deletion app/admin/service/sys_login_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func (e *SysLoginLog) Remove(c *dto.SysLoginLogDeleteReq) error {

db := e.Orm.Delete(&data, c.GetId())
if err = db.Error; err != nil {
err = db.Error
e.Log.Errorf("Delete error: %s", err)
return err
}
Expand Down
1 change: 0 additions & 1 deletion app/admin/service/sys_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ func (e *SysMenu) Remove(d *dto.SysMenuDeleteReq) *SysMenu {

db := e.Orm.Model(&data).Delete(&data, d.Ids)
if err = db.Error; err != nil {
err = db.Error
e.Log.Errorf("Delete error: %s", err)
_ = e.AddError(err)
}
Expand Down
5 changes: 2 additions & 3 deletions app/admin/service/sys_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (e *SysPost) Get(d *dto.SysPostGetReq, model *models.SysPost) error {
e.Log.Errorf("db error:%s", err)
return err
}
if err = db.Error; err != nil {
if err != nil {
e.Log.Errorf("db error:%s", err)
return err
}
Expand Down Expand Up @@ -93,7 +93,6 @@ func (e *SysPost) Remove(d *dto.SysPostDeleteReq) error {

db := e.Orm.Model(&data).Delete(&data, d.GetId())
if err = db.Error; err != nil {
err = db.Error
e.Log.Errorf("Delete error: %s", err)
return err
}
Expand All @@ -102,4 +101,4 @@ func (e *SysPost) Remove(d *dto.SysPostDeleteReq) error {
return err
}
return nil
}
}