From beed29248e7931ec3ae098200bbb01c3e611323b Mon Sep 17 00:00:00 2001 From: "fuqihao.foliet" Date: Thu, 12 Oct 2023 17:27:12 +0800 Subject: [PATCH] chore --- biz/application/service/system.go | 4 ++-- go.mod | 2 ++ go.sum | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/biz/application/service/system.go b/biz/application/service/system.go index a6240eb..86d427b 100644 --- a/biz/application/service/system.go +++ b/biz/application/service/system.go @@ -4,6 +4,7 @@ import ( "context" "time" + "github.com/samber/lo" "github.com/xh-polaris/service-idl-gen-go/kitex_gen/meowchat/system" "go.mongodb.org/mongo-driver/bson/primitive" @@ -326,12 +327,11 @@ func (s *SystemServiceImpl) RetrieveUserRole(ctx context.Context, req *system.Re return nil, err } } - var res = make([]*system.Role, len(userRole.Roles)) for i, role := range userRole.Roles { res[i] = &system.Role{ RoleType: RoleTypeValue[role.Type], - CommunityId: &role.CommunityId, + CommunityId: lo.EmptyableToPtr(role.CommunityId), } } diff --git a/go.mod b/go.mod index d1f817f..649d483 100644 --- a/go.mod +++ b/go.mod @@ -63,6 +63,7 @@ require ( github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/procfs v0.10.1 // indirect + github.com/samber/lo v1.38.1 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/stretchr/testify v1.8.4 // indirect github.com/tidwall/gjson v1.14.4 // indirect @@ -88,6 +89,7 @@ require ( go.uber.org/automaxprocs v1.5.3 // indirect golang.org/x/arch v0.2.0 // indirect golang.org/x/crypto v0.13.0 // indirect + golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect golang.org/x/net v0.15.0 // indirect golang.org/x/sync v0.3.0 // indirect golang.org/x/sys v0.12.0 // indirect diff --git a/go.sum b/go.sum index 6849301..bed394a 100644 --- a/go.sum +++ b/go.sum @@ -348,6 +348,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= +github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM= +github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= @@ -474,6 +476,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM= +golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=