diff --git a/1.7.3/api/logic.tpl b/1.7.3/api/logic.tpl index 798d5c2..0e4a01e 100644 --- a/1.7.3/api/logic.tpl +++ b/1.7.3/api/logic.tpl @@ -50,7 +50,7 @@ func (l *{{.logic}}) {{.function}}({{.request}}) {{.responseType}} { // gormRes := l.svcCtx.GormDb.Where("name = ?",req.Name).Find(&{{.pkgName}}) // 调用Gorm的Find方法,查询多条记录 // // 判断是否发生错误 - // if gormRes.Error != nil || gormRes.RowsAffected == 0 { // 如果操作数据发生错误,或为找到数据,则返回错误信息 + // if gormRes.Error != nil { // 如果操作数据发生错误,则返回错误信息 // return &types.Response{ // Success: false, // Code : 500, @@ -59,6 +59,16 @@ func (l *{{.logic}}) {{.function}}({{.request}}) {{.responseType}} { // },nil // } + // // 判断是否未找到数据 + // if gormRes.RowsAffected == 0 { // 如果未找到数据,则返回错误信息 + // return &types.Response{ + // Success: false, + // Code : 404, + // Msg: "{{if .hasDoc}}{{.doc}}{{end}}"+"未找到数据", // 修改未找到数据时返回信息 + // Data: "未找到数据", + // },nil + // } + // 返回正确信息 return &types.Response{ Success: true,