正在显示
14 个修改的文件
包含
389 行增加
和
3 行删除
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | +) | ||
9 | + | ||
10 | +type StatisticsQuery struct { | ||
11 | +} | ||
12 | + | ||
13 | +func (q *StatisticsQuery) Valid(validation *validation.Validation) { | ||
14 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
15 | +} | ||
16 | + | ||
17 | +func (q *StatisticsQuery) ValidateQuery() error { | ||
18 | + valid := validation.Validation{} | ||
19 | + b, err := valid.Valid(q) | ||
20 | + if err != nil { | ||
21 | + return err | ||
22 | + } | ||
23 | + if !b { | ||
24 | + elem := reflect.TypeOf(q).Elem() | ||
25 | + for _, validErr := range valid.Errors { | ||
26 | + field, isExist := elem.FieldByName(validErr.Field) | ||
27 | + if isExist { | ||
28 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
29 | + } else { | ||
30 | + return fmt.Errorf(validErr.Message) | ||
31 | + } | ||
32 | + } | ||
33 | + } | ||
34 | + return nil | ||
35 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "github.com/linmadan/egglib-go/utils/xtime" | ||
6 | + "github.com/zeromicro/go-zero/core/fx" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/querySet/query" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" | ||
10 | +) | ||
11 | + | ||
12 | +func (querySetService *QuerySetService) StatisticsQuery(ctx *domain.Context, query *query.StatisticsQuery) (interface{}, error) { | ||
13 | + if err := query.ValidateQuery(); err != nil { | ||
14 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
15 | + } | ||
16 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
17 | + if err != nil { | ||
18 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
19 | + } | ||
20 | + querySetRepository, _, _ := factory.FastPgQuerySet(transactionContext, 0) | ||
21 | + var ( | ||
22 | + total int64 | ||
23 | + totalToday int64 | ||
24 | + totalYesterday int64 | ||
25 | + totalEnable int64 | ||
26 | + platformTotal int64 | ||
27 | + platformTotalYesterday int64 | ||
28 | + ) | ||
29 | + fx.Parallel(func() { | ||
30 | + total, _, err = querySetRepository.Find(map[string]interface{}{ | ||
31 | + "context": ctx, | ||
32 | + "limit": 1, | ||
33 | + "type": domain.SchemaTable.ToString(), | ||
34 | + }) | ||
35 | + if err != nil { | ||
36 | + return | ||
37 | + } | ||
38 | + totalEnable, _, err = querySetRepository.Find(map[string]interface{}{ | ||
39 | + "context": ctx, | ||
40 | + "limit": 1, | ||
41 | + "type": domain.SchemaTable.ToString(), | ||
42 | + "status": domain.StatusOn, | ||
43 | + }) | ||
44 | + if err != nil { | ||
45 | + return | ||
46 | + } | ||
47 | + totalToday, _, err = querySetRepository.Find(map[string]interface{}{ | ||
48 | + "context": ctx, | ||
49 | + "limit": 1, | ||
50 | + "type": domain.SchemaTable.ToString(), | ||
51 | + "beginTime": xtime.BeginningOfDay().Local(), | ||
52 | + "endTime": xtime.BeginningOfDay().AddDate(0, 0, 1).Local(), | ||
53 | + }) | ||
54 | + if err != nil { | ||
55 | + return | ||
56 | + } | ||
57 | + totalYesterday, _, err = querySetRepository.Find(map[string]interface{}{ | ||
58 | + "context": ctx, | ||
59 | + "limit": 1, | ||
60 | + "type": domain.SchemaTable.ToString(), | ||
61 | + "beginTime": xtime.BeginningOfDay().AddDate(0, 0, -1).Local(), | ||
62 | + "endTime": xtime.BeginningOfDay().Local(), | ||
63 | + }) | ||
64 | + if err != nil { | ||
65 | + return | ||
66 | + } | ||
67 | + }, func() { | ||
68 | + platformTotal, _, err = querySetRepository.Find(map[string]interface{}{ | ||
69 | + "limit": 1, | ||
70 | + "type": domain.SchemaTable.ToString(), | ||
71 | + }) | ||
72 | + if err != nil { | ||
73 | + return | ||
74 | + } | ||
75 | + platformTotalYesterday, _, err = querySetRepository.Find(map[string]interface{}{ | ||
76 | + "limit": 1, | ||
77 | + "type": domain.SchemaTable.ToString(), | ||
78 | + "beginTime": xtime.BeginningOfDay().AddDate(0, 0, -1).Local(), | ||
79 | + "endTime": xtime.BeginningOfDay().Local(), | ||
80 | + }) | ||
81 | + if err != nil { | ||
82 | + return | ||
83 | + } | ||
84 | + }) | ||
85 | + | ||
86 | + if err != nil { | ||
87 | + return nil, factory.FastError(err) | ||
88 | + } | ||
89 | + return map[string]interface{}{ | ||
90 | + "schemaStatistics": map[string]interface{}{ | ||
91 | + "total": total, | ||
92 | + "totalToday": totalToday, | ||
93 | + "totalYesterday": totalYesterday, | ||
94 | + "totalEnable": totalEnable, | ||
95 | + }, | ||
96 | + "platformSchemaStatistics": map[string]interface{}{ | ||
97 | + "total": platformTotal, | ||
98 | + "totalYesterday": platformTotalYesterday, | ||
99 | + }, | ||
100 | + }, nil | ||
101 | +} |
pkg/application/table/command/row_delete.go
0 → 100644
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain" | ||
6 | + "reflect" | ||
7 | + "strings" | ||
8 | + | ||
9 | + "github.com/beego/beego/v2/core/validation" | ||
10 | +) | ||
11 | + | ||
12 | +type RowsDeleteCommand struct { | ||
13 | + // 表Id | ||
14 | + TableId int `cname:"表Id" json:"tableId" valid:"Required"` | ||
15 | + Where domain.Where `json:"where"` | ||
16 | +} | ||
17 | + | ||
18 | +func (cmd *RowsDeleteCommand) Valid(validation *validation.Validation) { | ||
19 | +} | ||
20 | + | ||
21 | +func (cmd *RowsDeleteCommand) ValidateCommand() error { | ||
22 | + valid := validation.Validation{} | ||
23 | + b, err := valid.Valid(cmd) | ||
24 | + if err != nil { | ||
25 | + return err | ||
26 | + } | ||
27 | + if !b { | ||
28 | + elem := reflect.TypeOf(cmd).Elem() | ||
29 | + for _, validErr := range valid.Errors { | ||
30 | + field, isExist := elem.FieldByName(validErr.Field) | ||
31 | + if isExist { | ||
32 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
33 | + } else { | ||
34 | + return fmt.Errorf(validErr.Message) | ||
35 | + } | ||
36 | + } | ||
37 | + } | ||
38 | + return nil | ||
39 | +} |
@@ -97,6 +97,42 @@ func (tableService *TableService) RowEditV2(ctx *domain.Context, cmd *command.Ro | @@ -97,6 +97,42 @@ func (tableService *TableService) RowEditV2(ctx *domain.Context, cmd *command.Ro | ||
97 | return struct{}{}, nil | 97 | return struct{}{}, nil |
98 | } | 98 | } |
99 | 99 | ||
100 | +func (tableService *TableService) RowsDelete(ctx *domain.Context, cmd *command.RowsDeleteCommand) (interface{}, error) { | ||
101 | + if err := cmd.ValidateCommand(); err != nil { | ||
102 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
103 | + } | ||
104 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
105 | + if err != nil { | ||
106 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
107 | + } | ||
108 | + //if err := transactionContext.StartTransaction(); err != nil { | ||
109 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
110 | + //} | ||
111 | + //defer func() { | ||
112 | + // transactionContext.RollbackTransaction() | ||
113 | + //}() | ||
114 | + | ||
115 | + var table *domain.Table | ||
116 | + _, table, err = factory.FastPgTable(transactionContext, cmd.TableId) | ||
117 | + if err != nil { | ||
118 | + return nil, factory.FastError(err) | ||
119 | + } | ||
120 | + | ||
121 | + var options = starrocks.QueryOptions{ | ||
122 | + TableName: table.SQLName, | ||
123 | + Select: []*domain.Field{domain.PK()}, //table.Fields(true), | ||
124 | + Where: []starrocks.Condition{}, | ||
125 | + } | ||
126 | + options.SetCondition(cmd.Where.Conditions) | ||
127 | + total, err := starrocks.WrapDeleteFuncWithDB(starrocks.DB)(options) | ||
128 | + //if err := transactionContext.CommitTransaction(); err != nil { | ||
129 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
130 | + //} | ||
131 | + return map[string]interface{}{ | ||
132 | + "rowsAffected": total, | ||
133 | + }, nil | ||
134 | +} | ||
135 | + | ||
100 | func MapArrayToFieldValues(list []map[string]string, table *domain.Table, dataTable *domain.DataTable, mustMatch bool) []*domain.FieldValues { | 136 | func MapArrayToFieldValues(list []map[string]string, table *domain.Table, dataTable *domain.DataTable, mustMatch bool) []*domain.FieldValues { |
101 | var result = make([]*domain.FieldValues, 0) | 137 | var result = make([]*domain.FieldValues, 0) |
102 | history := dto.ToFieldDataByPK(table, dataTable) | 138 | history := dto.ToFieldDataByPK(table, dataTable) |
@@ -266,6 +266,24 @@ func pin(name string) string { | @@ -266,6 +266,24 @@ func pin(name string) string { | ||
266 | return newPinyin.String() | 266 | return newPinyin.String() |
267 | } | 267 | } |
268 | 268 | ||
269 | +func pinFull(name string) string { | ||
270 | + prefixBuf := bytes.NewBuffer(nil) | ||
271 | + runes := []rune(name) | ||
272 | + for _, r := range runes { | ||
273 | + if r > 0xFF { | ||
274 | + if prefixBuf.Len() > 0 { | ||
275 | + prefixBuf.WriteString("_") | ||
276 | + } | ||
277 | + prefixBuf.WriteString(pin(string(r))) | ||
278 | + continue | ||
279 | + } | ||
280 | + //if isDigital(byte(r)) || isLetters(byte(r)){ | ||
281 | + prefixBuf.WriteRune(r) | ||
282 | + //} | ||
283 | + } | ||
284 | + return prefixBuf.String() | ||
285 | +} | ||
286 | + | ||
269 | func isDigital(b byte) bool { | 287 | func isDigital(b byte) bool { |
270 | return b >= byte('0') && b <= byte('9') | 288 | return b >= byte('0') && b <= byte('9') |
271 | } | 289 | } |
1 | +package domainService | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/stretchr/testify/assert" | ||
5 | + "testing" | ||
6 | +) | ||
7 | + | ||
8 | +func Test_PinName(t *testing.T) { | ||
9 | + inputs := []struct { | ||
10 | + s string | ||
11 | + want string | ||
12 | + }{ | ||
13 | + {"a我们", "a_wo_men"}, | ||
14 | + {"a2我们", "a2_wo_men"}, | ||
15 | + {"1我们", "1_wo_men"}, | ||
16 | + {"10.我们", "10._wo_men"}, | ||
17 | + {"我们", "wo_men"}, | ||
18 | + {"z.我们", "z._wo_men"}, | ||
19 | + {"123", "123"}, | ||
20 | + {"年度", "nian_du"}, | ||
21 | + {"333", "333"}, | ||
22 | + {"yyy", "yyy"}, | ||
23 | + {"1.2.3", "1.2.3"}, | ||
24 | + } | ||
25 | + for _, input := range inputs { | ||
26 | + got := pinFull(input.s) | ||
27 | + assert.Equal(t, input.want, got) | ||
28 | + } | ||
29 | +} |
@@ -41,7 +41,7 @@ func (ptr *QuerySetService) Create(ctx *domain.Context, qs *domain.QuerySet) (*d | @@ -41,7 +41,7 @@ func (ptr *QuerySetService) Create(ctx *domain.Context, qs *domain.QuerySet) (*d | ||
41 | Flag: qs.Flag, | 41 | Flag: qs.Flag, |
42 | Name: qs.Name, | 42 | Name: qs.Name, |
43 | ParentId: qs.ParentId, | 43 | ParentId: qs.ParentId, |
44 | - PinName: pin(qs.Name), | 44 | + PinName: pinFull(qs.Name), |
45 | Status: domain.StatusOn, | 45 | Status: domain.StatusOn, |
46 | QuerySetInfo: &domain.QuerySetInfo{}, | 46 | QuerySetInfo: &domain.QuerySetInfo{}, |
47 | QueryComponents: make([]*domain.QueryComponent, 0), | 47 | QueryComponents: make([]*domain.QueryComponent, 0), |
@@ -1032,7 +1032,7 @@ func copyQuerySet(qs *domain.QuerySet, t string, groupId int, name string) *doma | @@ -1032,7 +1032,7 @@ func copyQuerySet(qs *domain.QuerySet, t string, groupId int, name string) *doma | ||
1032 | Type: t, | 1032 | Type: t, |
1033 | Flag: qs.Flag, | 1033 | Flag: qs.Flag, |
1034 | Name: name, | 1034 | Name: name, |
1035 | - PinName: pin(name), | 1035 | + PinName: pinFull(name), |
1036 | ParentId: groupId, | 1036 | ParentId: groupId, |
1037 | Status: qs.Status, | 1037 | Status: qs.Status, |
1038 | QuerySetInfo: qs.QuerySetInfo, | 1038 | QuerySetInfo: qs.QuerySetInfo, |
1 | +package domainService | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + pG "github.com/linmadan/egglib-go/transaction/pg" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/pg" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/repository" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log" | ||
9 | +) | ||
10 | + | ||
11 | +func Script() { | ||
12 | + ScriptRenameQuerySetPinName() | ||
13 | +} | ||
14 | + | ||
15 | +func ScriptRenameQuerySetPinName() { | ||
16 | + defer func() { | ||
17 | + if p := recover(); p != nil { | ||
18 | + log.Logger.Error(fmt.Sprintf("%v", p)) | ||
19 | + } | ||
20 | + }() | ||
21 | + var err error | ||
22 | + transactionContext := pG.NewPGTransactionContext(pg.DB) | ||
23 | + if err != nil { | ||
24 | + return | ||
25 | + } | ||
26 | + if err := transactionContext.StartTransaction(); err != nil { | ||
27 | + return | ||
28 | + } | ||
29 | + defer func() { | ||
30 | + transactionContext.RollbackTransaction() | ||
31 | + }() | ||
32 | + querySetRepository, _ := repository.NewQuerySetRepository(transactionContext) | ||
33 | + _, querySets, _ := querySetRepository.Find(map[string]interface{}{}) | ||
34 | + for i := range querySets { | ||
35 | + pinName := pinFull(querySets[i].Name) | ||
36 | + log.Logger.Info(fmt.Sprintf("%v %v -> %v", querySets[i].QuerySetId, querySets[i].Name, querySets[i])) | ||
37 | + querySets[i].PinName = pinName | ||
38 | + _, err := querySetRepository.Save(querySets[i]) | ||
39 | + if err != nil { | ||
40 | + log.Logger.Error(err.Error(), map[string]interface{}{"qs": querySets[i]}) | ||
41 | + } | ||
42 | + } | ||
43 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
44 | + return | ||
45 | + } | ||
46 | +} |
@@ -5,6 +5,8 @@ import ( | @@ -5,6 +5,8 @@ import ( | ||
5 | "fmt" | 5 | "fmt" |
6 | "github.com/go-pg/pg/v10" | 6 | "github.com/go-pg/pg/v10" |
7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils" | 7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils" |
8 | + "strconv" | ||
9 | + "time" | ||
8 | 10 | ||
9 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" | 11 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" |
10 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 12 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
@@ -171,13 +173,25 @@ func (repository *QuerySetRepository) Find(queryOptions map[string]interface{}) | @@ -171,13 +173,25 @@ func (repository *QuerySetRepository) Find(queryOptions map[string]interface{}) | ||
171 | query.Where("query_set_info->'BindTableId' in (?)", pg.In(utils.ToArrayString(v.([]int)))) | 173 | query.Where("query_set_info->'BindTableId' in (?)", pg.In(utils.ToArrayString(v.([]int)))) |
172 | } | 174 | } |
173 | if v, ok := queryOptions["sortByName"]; ok && len(v.(string)) > 0 { | 175 | if v, ok := queryOptions["sortByName"]; ok && len(v.(string)) > 0 { |
174 | - query.SetOrderDirect("name", v.(string))//pin_name | 176 | + query.SetOrderDirect("pin_name", v.(string)) //pin_name |
175 | } else if v, ok := queryOptions["sortByTime"]; ok && len(v.(string)) > 0 { | 177 | } else if v, ok := queryOptions["sortByTime"]; ok && len(v.(string)) > 0 { |
176 | query.SetOrderDirect("created_at", v.(string)) | 178 | query.SetOrderDirect("created_at", v.(string)) |
177 | } else { | 179 | } else { |
178 | query.SetOrderDirect("parent_id", "ASC") | 180 | query.SetOrderDirect("parent_id", "ASC") |
179 | query.SetOrderDirect("sort", "ASC") | 181 | query.SetOrderDirect("sort", "ASC") |
180 | } | 182 | } |
183 | + if v, ok := queryOptions["beginTime"]; ok { | ||
184 | + query.Where("created_at >= ?", v.(time.Time)) | ||
185 | + } | ||
186 | + if v, ok := queryOptions["endTime"]; ok { | ||
187 | + query.Where("created_at < ?", v.(time.Time)) | ||
188 | + } | ||
189 | + if limit, ok := queryOptions["limit"]; ok { | ||
190 | + limit, _ := strconv.ParseInt(fmt.Sprintf("%v", limit), 10, 64) | ||
191 | + if limit > 0 { | ||
192 | + query.Limit(int(limit)) | ||
193 | + } | ||
194 | + } | ||
181 | if count, err := query.SelectAndCount(); err != nil { | 195 | if count, err := query.SelectAndCount(); err != nil { |
182 | return 0, querySets, err | 196 | return 0, querySets, err |
183 | } else { | 197 | } else { |
@@ -342,6 +342,43 @@ func WrapQueryFuncWithDB(db *gorm.DB) func(QueryOptions) (*sql.Rows, error) { | @@ -342,6 +342,43 @@ func WrapQueryFuncWithDB(db *gorm.DB) func(QueryOptions) (*sql.Rows, error) { | ||
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | +func WrapDeleteFuncWithDB(db *gorm.DB) func(QueryOptions) (int64, error) { | ||
346 | + return func(params QueryOptions) (int64, error) { | ||
347 | + query := db.Table(params.TableName) | ||
348 | + queryWithoutLimitOffset(query, params) | ||
349 | + //if params.Offset > 0 { | ||
350 | + // query.Offset(params.Offset) | ||
351 | + //} | ||
352 | + //if params.Limit > 0 { | ||
353 | + // query.Limit(params.Limit) | ||
354 | + //} | ||
355 | + //if params.Context != nil { | ||
356 | + // query.Where(fmt.Sprintf("context->>'companyId'='%v'", params.Context.CompanyId)) | ||
357 | + //} | ||
358 | + rows, err := query.Rows() | ||
359 | + defer rows.Close() | ||
360 | + if err != nil { | ||
361 | + return 0, err | ||
362 | + } | ||
363 | + dataTable := &domain.DataTable{} | ||
364 | + dataTable.Data, err = ScanRows(rows) | ||
365 | + idList := make([]string, 0) | ||
366 | + for _, row := range dataTable.Data { | ||
367 | + if len(row) == 0 { | ||
368 | + continue | ||
369 | + } | ||
370 | + idList = append(idList, row[0]) | ||
371 | + } | ||
372 | + if len(idList) == 0 { | ||
373 | + return 0, nil | ||
374 | + } | ||
375 | + c := Condition{} | ||
376 | + sql := fmt.Sprintf("delete from %v where id in %v", params.TableName, c.InArgs(idList)) | ||
377 | + query = db.Exec(sql) | ||
378 | + return int64(len(idList)), query.Error | ||
379 | + } | ||
380 | +} | ||
381 | + | ||
345 | func SetTable(query *gorm.DB, tableName string) { | 382 | func SetTable(query *gorm.DB, tableName string) { |
346 | query.Statement.Table = tableName | 383 | query.Statement.Table = tableName |
347 | } | 384 | } |
@@ -154,3 +154,11 @@ func (controller *QuerySetController) CalculateSetExport() { | @@ -154,3 +154,11 @@ func (controller *QuerySetController) CalculateSetExport() { | ||
154 | data, err := querySetService.CalculateSetExport(ParseContext(controller.BaseController), updateQuerySetCommand) | 154 | data, err := querySetService.CalculateSetExport(ParseContext(controller.BaseController), updateQuerySetCommand) |
155 | controller.Response(data, err) | 155 | controller.Response(data, err) |
156 | } | 156 | } |
157 | + | ||
158 | +func (controller *QuerySetController) QuerySetStatistics() { | ||
159 | + querySetService := service.NewQuerySetService(nil) | ||
160 | + q := &query.StatisticsQuery{} | ||
161 | + Must(controller.Unmarshal(q)) | ||
162 | + data, err := querySetService.StatisticsQuery(ParseContext(controller.BaseController), q) | ||
163 | + controller.Response(data, err) | ||
164 | +} |
@@ -6,6 +6,8 @@ import ( | @@ -6,6 +6,8 @@ import ( | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/query" | 6 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/query" |
7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/service" | 7 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/table/service" |
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" | ||
10 | + "strings" | ||
9 | 11 | ||
10 | filecommand "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/command" | 12 | filecommand "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/command" |
11 | fileservice "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/service" | 13 | fileservice "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/service" |
@@ -277,6 +279,14 @@ func (controller *TableController) RowEdit() { | @@ -277,6 +279,14 @@ func (controller *TableController) RowEdit() { | ||
277 | controller.Response(data, err) | 279 | controller.Response(data, err) |
278 | } | 280 | } |
279 | 281 | ||
282 | +func (controller *TableController) RowsDelete() { | ||
283 | + tableService := service.NewTableService(nil) | ||
284 | + cmd := &command.RowsDeleteCommand{} | ||
285 | + Must(controller.Unmarshal(cmd)) | ||
286 | + data, err := tableService.RowsDelete(ParseContext(controller.BaseController), cmd) | ||
287 | + controller.Response(data, err) | ||
288 | +} | ||
289 | + | ||
280 | func (controller *TableController) DependencyGraph() { | 290 | func (controller *TableController) DependencyGraph() { |
281 | tableService := service.NewTableService(nil) | 291 | tableService := service.NewTableService(nil) |
282 | updateTableCommand := &query.GetTableQuery{} | 292 | updateTableCommand := &query.GetTableQuery{} |
@@ -284,3 +294,12 @@ func (controller *TableController) DependencyGraph() { | @@ -284,3 +294,12 @@ func (controller *TableController) DependencyGraph() { | ||
284 | data, err := tableService.DependencyGraph(ParseContext(controller.BaseController), updateTableCommand) | 294 | data, err := tableService.DependencyGraph(ParseContext(controller.BaseController), updateTableCommand) |
285 | controller.Response(data, err) | 295 | controller.Response(data, err) |
286 | } | 296 | } |
297 | + | ||
298 | +func (controller *TableController) ExecScript() { | ||
299 | + name := controller.GetString(":name") | ||
300 | + switch strings.ToLower(name) { | ||
301 | + case "qsrename": | ||
302 | + domainService.ScriptRenameQuerySetPinName() | ||
303 | + } | ||
304 | + controller.Response(nil, nil) | ||
305 | +} |
@@ -37,4 +37,6 @@ func init() { | @@ -37,4 +37,6 @@ func init() { | ||
37 | 37 | ||
38 | web.Router("/data/query-sets/formula/calculate-item-preview", &controllers.QuerySetController{}, "Post:CalculateItemPreview") | 38 | web.Router("/data/query-sets/formula/calculate-item-preview", &controllers.QuerySetController{}, "Post:CalculateItemPreview") |
39 | web.Router("/data/query-sets/formula/calculate-item-export", &controllers.QuerySetController{}, "Post:CalculateItemExport") | 39 | web.Router("/data/query-sets/formula/calculate-item-export", &controllers.QuerySetController{}, "Post:CalculateItemExport") |
40 | + | ||
41 | + web.Router("/data/query-sets/statistics", &controllers.QuerySetController{}, "Post:QuerySetStatistics") | ||
40 | } | 42 | } |
@@ -34,6 +34,7 @@ func init() { | @@ -34,6 +34,7 @@ func init() { | ||
34 | 34 | ||
35 | web.Router("/data/tables/table-preview", tableController, "Post:TablePreview") | 35 | web.Router("/data/tables/table-preview", tableController, "Post:TablePreview") |
36 | web.Router("/data/tables/row-edit", tableController, "Post:RowEdit") | 36 | web.Router("/data/tables/row-edit", tableController, "Post:RowEdit") |
37 | + web.Router("/data/tables/row-delete", tableController, "Post:RowsDelete") | ||
37 | 38 | ||
38 | web.Router("/data/field-optional-values", tableController, "Post:FieldOptionalValues") | 39 | web.Router("/data/field-optional-values", tableController, "Post:FieldOptionalValues") |
39 | web.Router("/data/table-object-search", tableController, "Post:TableObjectSearch") | 40 | web.Router("/data/table-object-search", tableController, "Post:TableObjectSearch") |
@@ -41,4 +42,5 @@ func init() { | @@ -41,4 +42,5 @@ func init() { | ||
41 | web.Router("/business/db-table-preview", tableController, "Post:DBTablePreview") | 42 | web.Router("/business/db-table-preview", tableController, "Post:DBTablePreview") |
42 | web.Router("/data/table-preview", tableController, "Post:Preview") | 43 | web.Router("/data/table-preview", tableController, "Post:Preview") |
43 | 44 | ||
45 | + web.Router("/data/tables/exec/:name", tableController, "Get:ExecScript") | ||
44 | } | 46 | } |
-
请 注册 或 登录 后发表评论