正在显示
3 个修改的文件
包含
41 行增加
和
5 行删除
@@ -28,6 +28,21 @@ func (cmd *RowEditCommandV2) Valid(validation *validation.Validation) { | @@ -28,6 +28,21 @@ func (cmd *RowEditCommandV2) Valid(validation *validation.Validation) { | ||
28 | } | 28 | } |
29 | } | 29 | } |
30 | 30 | ||
31 | +func (cmd *RowEditCommandV2) IdList() []interface{} { | ||
32 | + ids := make([]interface{}, 0) | ||
33 | + for _, m := range cmd.UpdateList { | ||
34 | + if v, ok := m[domain.DefaultPkField]; ok { | ||
35 | + ids = append(ids, v) | ||
36 | + } | ||
37 | + } | ||
38 | + for _, m := range cmd.RemoveList { | ||
39 | + if v, ok := m[domain.DefaultPkField]; ok { | ||
40 | + ids = append(ids, v) | ||
41 | + } | ||
42 | + } | ||
43 | + return ids | ||
44 | +} | ||
45 | + | ||
31 | func (cmd *RowEditCommandV2) ValidateCommand() error { | 46 | func (cmd *RowEditCommandV2) ValidateCommand() error { |
32 | valid := validation.Validation{} | 47 | valid := validation.Validation{} |
33 | b, err := valid.Valid(cmd) | 48 | b, err := valid.Valid(cmd) |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/command" | 6 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/command" |
7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/dto" | 7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/dto" |
8 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/domainService" | ||
9 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks" | 10 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks" |
10 | ) | 11 | ) |
11 | 12 | ||
@@ -56,10 +57,23 @@ func (tableService *TableService) RowEditV2(ctx *domain.Context, cmd *command.Ro | @@ -56,10 +57,23 @@ func (tableService *TableService) RowEditV2(ctx *domain.Context, cmd *command.Ro | ||
56 | var options = starrocks.QueryOptions{ | 57 | var options = starrocks.QueryOptions{ |
57 | TableName: table.SQLName, | 58 | TableName: table.SQLName, |
58 | Select: table.Fields(true), | 59 | Select: table.Fields(true), |
60 | + Where: []starrocks.Condition{}, | ||
59 | } | 61 | } |
60 | - options.SetCondition(cmd.Where.Conditions).SetDefaultOrder() | ||
61 | - options.SetOffsetLimit(cmd.Where.PageNumber, cmd.Where.PageSize) | ||
62 | var dataTable *domain.DataTable | 62 | var dataTable *domain.DataTable |
63 | + var idList = cmd.IdList() | ||
64 | + | ||
65 | + if len(idList) > 0 { | ||
66 | + options.Where = append(options.Where, starrocks.Condition{ | ||
67 | + Condition: domain.Condition{ | ||
68 | + Field: domainService.PK(), | ||
69 | + In: cmd.IdList(), | ||
70 | + }, | ||
71 | + }) | ||
72 | + options.SetCondition(cmd.Where.Conditions).SetDefaultOrder() | ||
73 | + options.SetOffsetLimit(0, 2000) | ||
74 | + } else { | ||
75 | + options.SetOffsetLimit(0, 1) | ||
76 | + } | ||
63 | dataTable, err = factory.FastDataTable(options) | 77 | dataTable, err = factory.FastDataTable(options) |
64 | if err != nil { | 78 | if err != nil { |
65 | return nil, factory.FastError(err) | 79 | return nil, factory.FastError(err) |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" |
7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/repository" | 7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/repository" |
8 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks" | 8 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/starrocks" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log" | ||
9 | ) | 10 | ) |
10 | 11 | ||
11 | type TableEditDataService struct { | 12 | type TableEditDataService struct { |
@@ -38,7 +39,9 @@ func (ptr *TableEditDataService) RowEdit(ctx *domain.Context, request domain.Edi | @@ -38,7 +39,9 @@ func (ptr *TableEditDataService) RowEdit(ctx *domain.Context, request domain.Edi | ||
38 | } | 39 | } |
39 | 40 | ||
40 | for _, l := range request.AddList { | 41 | for _, l := range request.AddList { |
41 | - ptr.add(ctx, table, l, request.Where) | 42 | + if addErr := ptr.add(ctx, table, l, request.Where); addErr != nil { |
43 | + log.Logger.Error(addErr.Error()) | ||
44 | + } | ||
42 | } | 45 | } |
43 | if len(request.RemoveList) > 0 { | 46 | if len(request.RemoveList) > 0 { |
44 | // 日志 | 47 | // 日志 |
@@ -49,11 +52,15 @@ func (ptr *TableEditDataService) RowEdit(ctx *domain.Context, request domain.Edi | @@ -49,11 +52,15 @@ func (ptr *TableEditDataService) RowEdit(ctx *domain.Context, request domain.Edi | ||
49 | return nil, err | 52 | return nil, err |
50 | } | 53 | } |
51 | for _, l := range request.RemoveList { | 54 | for _, l := range request.RemoveList { |
52 | - ptr.remove(ctx, table, l, request.Where) | 55 | + if e := ptr.remove(ctx, table, l, request.Where); e != nil { |
56 | + log.Logger.Error(e.Error()) | ||
57 | + } | ||
53 | } | 58 | } |
54 | } | 59 | } |
55 | for _, l := range request.UpdateList { | 60 | for _, l := range request.UpdateList { |
56 | - ptr.update(ctx, table, l, request.Where) | 61 | + if e := ptr.update(ctx, table, l, request.Where); e != nil { |
62 | + log.Logger.Error(e.Error()) | ||
63 | + } | ||
57 | } | 64 | } |
58 | 65 | ||
59 | return nil, nil | 66 | return nil, nil |
-
请 注册 或 登录 后发表评论