github.com/shoshinnikita/budget-manager@v0.7.1-0.20220131195411-8c46ff1c6778/internal/db/args.go (about) 1 package db 2 3 import ( 4 "time" 5 6 "github.com/ShoshinNikita/budget-manager/internal/pkg/money" 7 ) 8 9 // ---------------------------------------------------- 10 // Income 11 // ---------------------------------------------------- 12 13 type AddIncomeArgs struct { 14 MonthID uint 15 Title string 16 Notes string 17 Income money.Money 18 } 19 20 type EditIncomeArgs struct { 21 ID uint 22 Title *string 23 Notes *string 24 Income *money.Money 25 } 26 27 // ---------------------------------------------------- 28 // Monthly Payment 29 // ---------------------------------------------------- 30 31 type AddMonthlyPaymentArgs struct { 32 MonthID uint 33 Title string 34 TypeID uint 35 Notes string 36 Cost money.Money 37 } 38 39 type EditMonthlyPaymentArgs struct { 40 ID uint 41 42 Title *string 43 TypeID *uint 44 Notes *string 45 Cost *money.Money 46 } 47 48 // ---------------------------------------------------- 49 // Spend 50 // ---------------------------------------------------- 51 52 type AddSpendArgs struct { 53 DayID uint 54 Title string 55 TypeID uint // optional 56 Notes string // optional 57 Cost money.Money 58 } 59 60 type EditSpendArgs struct { 61 ID uint 62 Title *string 63 TypeID *uint 64 Notes *string 65 Cost *money.Money 66 } 67 68 // ---------------------------------------------------- 69 // Spend 70 // ---------------------------------------------------- 71 72 type AddSpendTypeArgs struct { 73 Name string 74 ParentID uint // optional 75 } 76 77 type EditSpendTypeArgs struct { 78 ID uint 79 Name *string 80 ParentID *uint 81 } 82 83 // ---------------------------------------------------- 84 // Search 85 // ---------------------------------------------------- 86 87 // SearchOrder is used to specify order of search results. 'Asc' by default 88 type SearchOrder int 89 90 const ( 91 OrderByAsc SearchOrder = iota 92 OrderByDesc 93 ) 94 95 // SearchSpendsArgs is used to search for spends. All fields are optional 96 type SearchSpendsArgs struct { 97 Title string // Must be in lovercase 98 Notes string // Must be in lovercase 99 100 // TitleExactly defines should we search exactly for the given title 101 TitleExactly bool 102 // NotesExactly defines should we search exactly for the given notes 103 NotesExactly bool 104 105 After time.Time 106 Before time.Time 107 108 MinCost money.Money 109 MaxCost money.Money 110 111 // TypeIDs is a list of Spend Type ids to search for. Use id '0' to search for Spends without type 112 TypeIDs []uint 113 114 Sort SearchSpendsColumn 115 Order SearchOrder 116 } 117 118 // SearchSpendsColumn is used to specify column to sort by. 'Date' by default 119 type SearchSpendsColumn int 120 121 const ( 122 SortSpendsByDate SearchSpendsColumn = iota 123 SortSpendsByTitle 124 SortSpendsByCost 125 )