Skip to content

Commit

Permalink
Merge pull request #803 from zhanluxianshen/clean-err-use-in-method
Browse files Browse the repository at this point in the history
clean err define in methods.
  • Loading branch information
wenjianzhang authored Aug 29, 2024
2 parents c0c1603 + 2d76430 commit 9a8e0cd
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 12 deletions.
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
}
}

0 comments on commit 9a8e0cd

Please sign in to comment.