batch create nonexistent transaction tags when import transaction

This commit is contained in:
MaysWind
2025-03-29 21:02:56 +08:00
parent 94ef7f450b
commit 91b6047f2e
9 changed files with 248 additions and 4 deletions
+19
View File
@@ -23,6 +23,12 @@ type TransactionTagCreateRequest struct {
Name string `json:"name" binding:"required,notBlank,max=64"`
}
// TransactionTagCreateBatchRequest represents all parameters of transaction tag batch creation request
type TransactionTagCreateBatchRequest struct {
Tags []*TransactionTagCreateRequest `json:"tags" binding:"required"`
SkipExists bool `json:"skipExists"`
}
// TransactionTagModifyRequest represents all parameters of transaction tag modification request
type TransactionTagModifyRequest struct {
Id int64 `json:"id,string" binding:"required,min=1"`
@@ -59,6 +65,19 @@ type TransactionTagInfoResponse struct {
Hidden bool `json:"hidden"`
}
// FillFromOtherTag fills all the fields in this current tag from other transaction tag
func (t *TransactionTag) FillFromOtherTag(tag *TransactionTag) {
t.TagId = tag.TagId
t.Uid = tag.Uid
t.Deleted = tag.Deleted
t.Name = tag.Name
t.DisplayOrder = tag.DisplayOrder
t.Hidden = tag.Hidden
t.CreatedUnixTime = tag.CreatedUnixTime
t.UpdatedUnixTime = tag.UpdatedUnixTime
t.DeletedUnixTime = tag.DeletedUnixTime
}
// ToTransactionTagInfoResponse returns a view-object according to database model
func (t *TransactionTag) ToTransactionTagInfoResponse() *TransactionTagInfoResponse {
return &TransactionTagInfoResponse{