Skip to content

Commit

Permalink
fix: Fix the error that occurs during batch update menu when using my…
Browse files Browse the repository at this point in the history
…sql database
  • Loading branch information
1379 authored and 1379 committed Oct 15, 2023
1 parent 9323364 commit 8f65bdd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
10 changes: 4 additions & 6 deletions conf/config.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ logging:
### The Database configuration,You should choose one between MySQL and SQLite3,if both MySQL and SQLite3 are configured ,use Sqlite3 first

sqlite3:
enable: true
enable: false

### mysql数据库配置,请将用户名、密码、ip地址、端口、数据库名称替换为你自己的配置
### mysql database configuration, please replace the user name, password, ip address, port, database name to your own configuration.
mysql:
host: 127.0.0.1
port: 3306
db: sonicdb
username: "root"
password: "12345678"
dsn: root:12345678@tcp(127.0.0.1:3306)/sonicdb?charset=utf8mb4&parseTime=True&loc=Local&interpolateParams=true



Expand Down
2 changes: 2 additions & 0 deletions conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ logging:
sqlite3:
enable: true

### mysql数据库配置,请将用户名、密码、ip地址、端口、数据库名称替换为你自己的配置
### mysql database configuration, please replace the user name, password, ip address, port, database name to your own configuration.

mysql:
dsn: username:password@tcp(host:port)/db_name?charset=utf8mb4&parseTime=True&loc=Local&interpolateParams=true
Expand Down
5 changes: 1 addition & 4 deletions service/impl/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (m *menuServiceImpl) UpdateBatch(ctx context.Context, menuParams []*param.M
menuDAL := tx.Menu
for _, menuParam := range menuParams {
ids = append(ids, menuParam.ID)
updateResult, err := menuDAL.WithContext(ctx).Where(menuDAL.ID.Eq(menuParam.ID)).UpdateSimple(
_, err := menuDAL.WithContext(ctx).Where(menuDAL.ID.Eq(menuParam.ID)).UpdateSimple(
menuDAL.Team.Value(menuParam.Team),
menuDAL.Priority.Value(menuParam.Priority),
menuDAL.Name.Value(menuParam.Name),
Expand All @@ -45,9 +45,6 @@ func (m *menuServiceImpl) UpdateBatch(ctx context.Context, menuParams []*param.M
if err != nil {
return WrapDBErr(err)
}
if updateResult.RowsAffected != 1 {
return xerr.NoType.New("update menu failed").WithMsg("update menu failed").WithStatus(xerr.StatusInternalServerError)
}
}
return nil
})
Expand Down

0 comments on commit 8f65bdd

Please sign in to comment.