正在显示
4 个修改的文件
包含
22 行增加
和
2 行删除
@@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
5 | "fmt" | 5 | "fmt" |
6 | "github.com/samber/lo" | 6 | "github.com/samber/lo" |
7 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/internal/pkg/domain" | 7 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/internal/pkg/domain" |
8 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/contextdata" | ||
8 | 9 | ||
9 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/api/internal/svc" | 10 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/api/internal/svc" |
10 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/api/internal/types" | 11 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/api/internal/types" |
@@ -31,10 +32,13 @@ func (l *ChatDatasetSearchLogic) ChatDatasetSearch(req *types.ChatDatasetSearchR | @@ -31,10 +32,13 @@ func (l *ChatDatasetSearchLogic) ChatDatasetSearch(req *types.ChatDatasetSearchR | ||
31 | conn = l.svcCtx.DefaultDBConn() | 32 | conn = l.svcCtx.DefaultDBConn() |
32 | dms []*domain.ChatDataset | 33 | dms []*domain.ChatDataset |
33 | total int64 | 34 | total int64 |
35 | + token = contextdata.GetUserTokenFromCtx(l.ctx) | ||
34 | ) | 36 | ) |
35 | 37 | ||
36 | queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size). | 38 | queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size). |
37 | - WithKV("status", req.Status) | 39 | + WithKV("status", req.Status). |
40 | + WithKV("companyId", token.CompanyId). | ||
41 | + WithKV("userId", token.UserId) | ||
38 | if req.Name != "" { | 42 | if req.Name != "" { |
39 | queryOptions.WithKV("name", fmt.Sprintf("%%%v%%", req.Name)) | 43 | queryOptions.WithKV("name", fmt.Sprintf("%%%v%%", req.Name)) |
40 | } | 44 | } |
@@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
4 | "context" | 4 | "context" |
5 | "fmt" | 5 | "fmt" |
6 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/internal/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/internal/pkg/domain" |
7 | + "gitlab.fjmaimaimai.com/allied-creation/su-micro/pkg/contextdata" | ||
7 | 8 | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/api/internal/svc" | 9 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/api/internal/svc" |
9 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/api/internal/types" | 10 | "gitlab.fjmaimaimai.com/allied-creation/su-micro/cmd/ep/chat/api/internal/types" |
@@ -30,11 +31,14 @@ func (l *ChatDocumentSearchLogic) ChatDocumentSearch(req *types.ChatDocumentSear | @@ -30,11 +31,14 @@ func (l *ChatDocumentSearchLogic) ChatDocumentSearch(req *types.ChatDocumentSear | ||
30 | conn = l.svcCtx.DefaultDBConn() | 31 | conn = l.svcCtx.DefaultDBConn() |
31 | dms []*domain.ChatDocument | 32 | dms []*domain.ChatDocument |
32 | total int64 | 33 | total int64 |
34 | + token = contextdata.GetUserTokenFromCtx(l.ctx) | ||
33 | ) | 35 | ) |
34 | 36 | ||
35 | queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size). | 37 | queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size). |
36 | WithKV("fileType", req.FileType). | 38 | WithKV("fileType", req.FileType). |
37 | - WithKV("status", req.Status) | 39 | + WithKV("status", req.Status). |
40 | + WithKV("companyId", token.CompanyId). | ||
41 | + WithKV("userId", token.UserId) | ||
38 | if req.Name != "" { | 42 | if req.Name != "" { |
39 | queryOptions.WithKV("name", fmt.Sprintf("%%%v%%", req.Name)) | 43 | queryOptions.WithKV("name", fmt.Sprintf("%%%v%%", req.Name)) |
40 | } | 44 | } |
@@ -141,6 +141,12 @@ func (repository *ChatDatasetRepository) Find(ctx context.Context, conn transact | @@ -141,6 +141,12 @@ func (repository *ChatDatasetRepository) Find(ctx context.Context, conn transact | ||
141 | ) | 141 | ) |
142 | queryFunc := func() (interface{}, error) { | 142 | queryFunc := func() (interface{}, error) { |
143 | tx = tx.Model(&ms).Order("id desc") | 143 | tx = tx.Model(&ms).Order("id desc") |
144 | + if v, ok := queryOptions["companyId"]; ok { | ||
145 | + tx.Where("company_id = ?", v) | ||
146 | + } | ||
147 | + if v, ok := queryOptions["userId"]; ok { | ||
148 | + tx.Where("user_id = ?", v) | ||
149 | + } | ||
144 | if v, ok := queryOptions["name"]; ok { | 150 | if v, ok := queryOptions["name"]; ok { |
145 | tx.Where("name like ?", v) | 151 | tx.Where("name like ?", v) |
146 | } | 152 | } |
@@ -141,6 +141,12 @@ func (repository *ChatDocumentRepository) Find(ctx context.Context, conn transac | @@ -141,6 +141,12 @@ func (repository *ChatDocumentRepository) Find(ctx context.Context, conn transac | ||
141 | ) | 141 | ) |
142 | queryFunc := func() (interface{}, error) { | 142 | queryFunc := func() (interface{}, error) { |
143 | tx = tx.Model(&ms).Order("id desc") | 143 | tx = tx.Model(&ms).Order("id desc") |
144 | + if v, ok := queryOptions["companyId"]; ok { | ||
145 | + tx.Where("company_id = ?", v) | ||
146 | + } | ||
147 | + if v, ok := queryOptions["userId"]; ok { | ||
148 | + tx.Where("user_id = ?", v) | ||
149 | + } | ||
144 | if v, ok := queryOptions["name"]; ok { | 150 | if v, ok := queryOptions["name"]; ok { |
145 | tx.Where("name like ?", v) | 151 | tx.Where("name like ?", v) |
146 | } | 152 | } |
-
请 注册 或 登录 后发表评论