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

help: 帮忙看看 这种如何用呢 #1

Open
bytegolang opened this issue May 6, 2022 · 3 comments
Open

help: 帮忙看看 这种如何用呢 #1

bytegolang opened this issue May 6, 2022 · 3 comments

Comments

@bytegolang
Copy link

bytegolang commented May 6, 2022

比如:下面的gorm 转换sqlc如何做

if len(roleApis) > 0 {

		db := db.Orm.Debug().Model(&models.Api{}).
			Select("system_api.id").
			Joins("left join system_menu_api on system_menu_api.api = system_api.id")

		for _, p := range roleApis {
			db = db.Or("system_api.url = ? and system_api.method = ?", p[1], p[2])
		}
		err = db.Where("system_menu_api.menu = ?", menuId).Pluck("system_api.id", &apis).Error
		if err != nil {
			response.Error(c, err, response.GetApiError)
			return
		}
	}
@bytegolang bytegolang changed the title help: 帮忙看看 这种如何用呢。 我看where 应该都是 and 不知 or 的情况 如何做 help: 帮忙看看 这种如何用呢 May 6, 2022
@yiplee
Copy link
Owner

yiplee commented May 6, 2022

发一个简单的完整 Raw SQL 出来看看

@yiplee
Copy link
Owner

yiplee commented May 6, 2022

之前只考虑了 AND 串联,需要的话可以实现一个 OR 方法

@bytegolang
Copy link
Author

之前只考虑了 AND 串联,需要的话可以实现一个 OR 方法

or 的使用场景还是有的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants