Skip to content

Commit

Permalink
feat: refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
tx7do committed Nov 13, 2023
1 parent 575ae2c commit 6a3143f
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 25 deletions.
8 changes: 5 additions & 3 deletions blog-backend/app/core/service/internal/data/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"time"

"entgo.io/ent/dialect/sql"

"github.com/go-kratos/kratos/v2/log"

entgo "github.com/tx7do/go-utils/entgo/query"
util "github.com/tx7do/go-utils/time"
util "github.com/tx7do/go-utils/timeutil"

"kratos-cms/app/core/service/internal/data/ent"
"kratos-cms/app/core/service/internal/data/ent/attachment"
Expand Down Expand Up @@ -71,7 +71,9 @@ func (r *AttachmentRepo) List(ctx context.Context, req *pagination.PagingRequest
err, whereSelectors, querySelectors := entgo.BuildQuerySelector(
req.GetQuery(), req.GetOrQuery(),
req.GetPage(), req.GetPageSize(), req.GetNoPaging(),
req.GetOrderBy(), attachment.FieldCreateTime)
req.GetOrderBy(), attachment.FieldCreateTime,
req.GetFieldMask().GetPaths(),
)
if err != nil {
r.log.Errorf("解析条件发生错误[%s]", err.Error())
return nil, err
Expand Down
9 changes: 6 additions & 3 deletions blog-backend/app/core/service/internal/data/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ package data

import (
"context"
v1 "kratos-cms/gen/api/go/content/service/v1"
"time"

"entgo.io/ent/dialect/sql"
"github.com/go-kratos/kratos/v2/log"

entgo "github.com/tx7do/go-utils/entgo/query"
util "github.com/tx7do/go-utils/time"
util "github.com/tx7do/go-utils/timeutil"

"kratos-cms/app/core/service/internal/data/ent"
"kratos-cms/app/core/service/internal/data/ent/category"

pagination "github.com/tx7do/kratos-bootstrap/gen/api/go/pagination/v1"
v1 "kratos-cms/gen/api/go/content/service/v1"
)

type CategoryRepo struct {
Expand Down Expand Up @@ -69,7 +70,9 @@ func (r *CategoryRepo) List(ctx context.Context, req *pagination.PagingRequest)
err, whereSelectors, querySelectors := entgo.BuildQuerySelector(
req.GetQuery(), req.GetOrQuery(),
req.GetPage(), req.GetPageSize(), req.GetNoPaging(),
req.GetOrderBy(), category.FieldCreateTime)
req.GetOrderBy(), category.FieldCreateTime,
req.GetFieldMask().GetPaths(),
)
if err != nil {
r.log.Errorf("解析条件发生错误[%s]", err.Error())
return nil, err
Expand Down
7 changes: 5 additions & 2 deletions blog-backend/app/core/service/internal/data/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (

"entgo.io/ent/dialect/sql"
"github.com/go-kratos/kratos/v2/log"

entgo "github.com/tx7do/go-utils/entgo/query"
util "github.com/tx7do/go-utils/time"
util "github.com/tx7do/go-utils/timeutil"

"kratos-cms/app/core/service/internal/data/ent"
"kratos-cms/app/core/service/internal/data/ent/comment"
Expand Down Expand Up @@ -72,7 +73,9 @@ func (r *CommentRepo) List(ctx context.Context, req *pagination.PagingRequest) (
err, whereSelectors, querySelectors := entgo.BuildQuerySelector(
req.GetQuery(), req.GetOrQuery(),
req.GetPage(), req.GetPageSize(), req.GetNoPaging(),
req.GetOrderBy(), comment.FieldCreateTime)
req.GetOrderBy(), comment.FieldCreateTime,
req.GetFieldMask().GetPaths(),
)
if err != nil {
r.log.Errorf("解析条件发生错误[%s]", err.Error())
return nil, err
Expand Down
13 changes: 8 additions & 5 deletions blog-backend/app/core/service/internal/data/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (

"entgo.io/ent/dialect/sql"
"github.com/go-kratos/kratos/v2/log"
entgo "github.com/tx7do/go-utils/entgo/query"
util "github.com/tx7do/go-utils/time"

pagination "github.com/tx7do/kratos-bootstrap/gen/api/go/pagination/v1"
v1 "kratos-cms/gen/api/go/content/service/v1"
entgo "github.com/tx7do/go-utils/entgo/query"
util "github.com/tx7do/go-utils/timeutil"

"kratos-cms/app/core/service/internal/data/ent"
"kratos-cms/app/core/service/internal/data/ent/link"

pagination "github.com/tx7do/kratos-bootstrap/gen/api/go/pagination/v1"
v1 "kratos-cms/gen/api/go/content/service/v1"
)

type LinkRepo struct {
Expand Down Expand Up @@ -66,7 +67,9 @@ func (r *LinkRepo) List(ctx context.Context, req *pagination.PagingRequest) (*v1
err, whereSelectors, querySelectors := entgo.BuildQuerySelector(
req.GetQuery(), req.GetOrQuery(),
req.GetPage(), req.GetPageSize(), req.GetNoPaging(),
req.GetOrderBy(), link.FieldCreateTime)
req.GetOrderBy(), link.FieldCreateTime,
req.GetFieldMask().GetPaths(),
)
if err != nil {
r.log.Errorf("解析条件发生错误[%s]", err.Error())
return nil, err
Expand Down
7 changes: 5 additions & 2 deletions blog-backend/app/core/service/internal/data/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (

"entgo.io/ent/dialect/sql"
"github.com/go-kratos/kratos/v2/log"

entgo "github.com/tx7do/go-utils/entgo/query"
util "github.com/tx7do/go-utils/time"
util "github.com/tx7do/go-utils/timeutil"

"kratos-cms/app/core/service/internal/data/ent"
"kratos-cms/app/core/service/internal/data/ent/post"
Expand Down Expand Up @@ -81,7 +82,9 @@ func (r *PostRepo) List(ctx context.Context, req *pagination.PagingRequest) (*v1
err, whereSelectors, querySelectors := entgo.BuildQuerySelector(
req.GetQuery(), req.GetOrQuery(),
req.GetPage(), req.GetPageSize(), req.GetNoPaging(),
req.GetOrderBy(), post.FieldCreateTime)
req.GetOrderBy(), post.FieldCreateTime,
req.GetFieldMask().GetPaths(),
)
if err != nil {
r.log.Errorf("解析条件发生错误[%s]", err.Error())
return nil, err
Expand Down
7 changes: 5 additions & 2 deletions blog-backend/app/core/service/internal/data/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (

"entgo.io/ent/dialect/sql"
"github.com/go-kratos/kratos/v2/log"

entgo "github.com/tx7do/go-utils/entgo/query"
util "github.com/tx7do/go-utils/time"
util "github.com/tx7do/go-utils/timeutil"

"kratos-cms/app/core/service/internal/data/ent"
"kratos-cms/app/core/service/internal/data/ent/tag"
Expand Down Expand Up @@ -66,7 +67,9 @@ func (r *TagRepo) List(ctx context.Context, req *pagination.PagingRequest) (*v1.
err, whereSelectors, querySelectors := entgo.BuildQuerySelector(
req.GetQuery(), req.GetOrQuery(),
req.GetPage(), req.GetPageSize(), req.GetNoPaging(),
req.GetOrderBy(), tag.FieldCreateTime)
req.GetOrderBy(), tag.FieldCreateTime,
req.GetFieldMask().GetPaths(),
)
if err != nil {
r.log.Errorf("解析条件发生错误[%s]", err.Error())
return nil, err
Expand Down
7 changes: 5 additions & 2 deletions blog-backend/app/core/service/internal/data/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (

"entgo.io/ent/dialect/sql"
"github.com/go-kratos/kratos/v2/log"

"github.com/tx7do/go-utils/crypto"
entgo "github.com/tx7do/go-utils/entgo/query"
util "github.com/tx7do/go-utils/time"
util "github.com/tx7do/go-utils/timeutil"
"github.com/tx7do/go-utils/trans"

"kratos-cms/app/core/service/internal/data/ent"
Expand Down Expand Up @@ -75,7 +76,9 @@ func (r *UserRepo) List(ctx context.Context, req *pagination.PagingRequest) (*v1
err, whereSelectors, querySelectors := entgo.BuildQuerySelector(
req.GetQuery(), req.GetOrQuery(),
req.GetPage(), req.GetPageSize(), req.GetNoPaging(),
req.GetOrderBy(), user.FieldCreateTime)
req.GetOrderBy(), user.FieldCreateTime,
req.GetFieldMask().GetPaths(),
)
if err != nil {
r.log.Errorf("解析条件发生错误[%s]", err.Error())
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions blog-backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ require (
github.com/jackc/pgx/v4 v4.18.1
github.com/lib/pq v1.10.9
github.com/redis/go-redis/v9 v9.3.0
github.com/tx7do/go-utils v1.1.4
github.com/tx7do/go-utils/entgo v1.1.6
github.com/tx7do/go-utils v1.1.8
github.com/tx7do/go-utils/entgo v1.1.10
github.com/tx7do/kratos-authn v1.0.0
github.com/tx7do/kratos-authn/engine/jwt v1.0.0
github.com/tx7do/kratos-authn/middleware v1.0.0
Expand Down
8 changes: 4 additions & 4 deletions blog-backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1569,10 +1569,10 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/tx7do/go-utils v1.1.4 h1:gEQnUBFWWNdmwIIT/YQuFqx3rwhPWOX2PXdwTPahRUw=
github.com/tx7do/go-utils v1.1.4/go.mod h1:6AIxTCgdBxAkaiWEs/eO9YnvPsC5xjFLVC7F/swZrYs=
github.com/tx7do/go-utils/entgo v1.1.6 h1:q9DJX1v6gg+CzAAriX6xgF0X3smcGUUhD9ykjlcQiyY=
github.com/tx7do/go-utils/entgo v1.1.6/go.mod h1:BiAq4JuJ8RClEEzbuXxMCcqqQVp+9kPxT08MCQGpoDQ=
github.com/tx7do/go-utils v1.1.8 h1:uwNnhXYZWrqrWpQWuWcWBQXvYtDAsotrZYWO+Nv26uE=
github.com/tx7do/go-utils v1.1.8/go.mod h1:8bsPp6A1zeRbjBElfzA6yTMeSLR0Z2U9XZgO/oF9NME=
github.com/tx7do/go-utils/entgo v1.1.10 h1:0dbqMykcY1sGGxXIaKpZEy04CrZJEq7nRhagF1aFUSU=
github.com/tx7do/go-utils/entgo v1.1.10/go.mod h1:BiAq4JuJ8RClEEzbuXxMCcqqQVp+9kPxT08MCQGpoDQ=
github.com/tx7do/kratos-authn v1.0.0 h1:+dLtYDPfk7yT9nLO4qTjsrLO9cHqYVlCXfHf8fVQmBY=
github.com/tx7do/kratos-authn v1.0.0/go.mod h1:iDys5Pfomo9onMENYJRyhGx+TLf3C8EhFViQhXWbowA=
github.com/tx7do/kratos-authn/engine/jwt v1.0.0 h1:GcAkb5/vteUcetcYd/6+BR8iAHOcyMgt1HttCXrqvg8=
Expand Down

0 comments on commit 6a3143f

Please sign in to comment.