fix: 移除所有 空条件 卫语句

main
NoahLan 1 year ago
parent f2e4af32a5
commit 9e8141875b

@ -38,10 +38,6 @@ func (l *GetOauthProviderListLogic) GetOauthProviderList(in *core.OauthProviderR
if in.Init != nil { if in.Init != nil {
predicates = append(predicates, oauthprovider.InitEQ(in.GetInit())) predicates = append(predicates, oauthprovider.InitEQ(in.GetInit()))
} }
if len(predicates) == 0 {
return &core.OauthProviderListResp{}, nil
}
query := l.svcCtx.DB.OauthProvider.Query().Where(predicates...) query := l.svcCtx.DB.OauthProvider.Query().Where(predicates...)
var ( var (
pagination *core.Pagination pagination *core.Pagination

@ -41,9 +41,6 @@ func (l *GetOauthProviderLogic) GetOauthProvider(in *core.OauthProviderReq) (*co
if in.Init != nil { if in.Init != nil {
predicates = append(predicates, oauthprovider.InitEQ(in.GetInit())) predicates = append(predicates, oauthprovider.InitEQ(in.GetInit()))
} }
if len(predicates) == 0 {
return l.svcCtx.Convert.ConvertOAuthProviderRpc(l.ctx, nil), nil
}
Query: Query:
dbData, err := l.svcCtx.DB.OauthProvider.Query(). dbData, err := l.svcCtx.DB.OauthProvider.Query().
Where(predicates...). Where(predicates...).

@ -26,17 +26,12 @@ func NewGetRoleListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRo
func (l *GetRoleListLogic) GetRoleList(in *core.RoleReq) (*core.RoleListResp, error) { func (l *GetRoleListLogic) GetRoleList(in *core.RoleReq) (*core.RoleListResp, error) {
var predicates []predicate.Role var predicates []predicate.Role
if in.ID != 0 {
predicates = append(predicates, role.IDEQ(in.ID))
goto Query
}
if in.Name != "" { if in.Name != "" {
predicates = append(predicates, role.NameContains(in.Name)) predicates = append(predicates, role.NameContains(in.Name))
} }
if in.Code != "" { if in.Code != "" {
predicates = append(predicates, role.CodeEQ(in.Code)) predicates = append(predicates, role.CodeContains(in.Code))
} }
Query:
query := l.svcCtx.DB.Role.Query(). query := l.svcCtx.DB.Role.Query().
Where(predicates...) Where(predicates...)
if in.WithUser { if in.WithUser {

@ -26,9 +26,6 @@ func NewGetUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUs
func (l *GetUserListLogic) GetUserList(in *core.UserReq) (*core.UserListResp, error) { func (l *GetUserListLogic) GetUserList(in *core.UserReq) (*core.UserListResp, error) {
var predicates []predicate.User var predicates []predicate.User
if in.ID != 0 {
predicates = append(predicates, user.IDEQ(in.ID))
}
if in.Username != "" { if in.Username != "" {
predicates = append(predicates, user.UsernameContains(in.Username)) predicates = append(predicates, user.UsernameContains(in.Username))
} }

Loading…
Cancel
Save