@@ -16,14 +16,31 @@ import (
1616
1717// Structure representing an entry in the db
1818type Entry struct {
19- ID int `gorm:"column:id;autoIncrement;primaryKey"`
20- Title string `gorm:"column:title"`
21- User string `gorm:"column:user"`
22- Url string `gorm:"column:url"`
23- Password string `gorm:"column:password"`
24- Notes string `gorm:"column:notes"`
25- Tags string `gorm:"column:tags"`
26- Timestamp time.Time `gorm:"type:timestamp;default:(datetime('now','localtime'))"` // sqlite3
19+ ID int `gorm:"column:id;autoIncrement;primaryKey"`
20+ Type string `gorm:"column:type"` // Type of entry - password (default), card, identity etc
21+ Title string `gorm:"column:title"`
22+ Name string `gorm:"column:name"` // Card holder name/ID card name - for types cards/identity
23+ Company string `gorm:"column:company"` // Company name of person - for type identity and
24+ // Credit card company for type CC
25+ Number string `gorm:"column:number"` // Number type - CC number for credit cards
26+ // ID card number for identity types
27+ SecurityCode string `gorm:"security_code"` // CVV number/security code for CC type
28+ ExpiryMonth string `gorm:"expiry_month"` // CC or Identity document expiry month
29+ ExpiryDay string `gorm:"expiry_day"` // Identity document expiry day
30+ ExpiryYear string `gorm:"expiry_year"` // CC or Identity document expiry year
31+ FirstName string `gorm:"column:first_name"` // first name - for ID card types
32+ MiddleName string `gorm:"column:middle_name"` // middle name - for ID card types
33+ LastName string `gorm:"column:last_name"` // last name - for ID card types
34+ Email string `gorm:"email"` // Email - for ID card types
35+ PhoneNumber string `gorm:"phone_number"` // Phone number - for ID card types
36+
37+ Active bool `gorm:"active;default:true"` // Is the id card/CC active ?
38+ User string `gorm:"column:user"`
39+ Url string `gorm:"column:url"`
40+ Password string `gorm:"column:password"`
41+ Notes string `gorm:"column:notes"`
42+ Tags string `gorm:"column:tags"`
43+ Timestamp time.Time `gorm:"type:timestamp;default:(datetime('now','localtime'))"` // sqlite3
2744}
2845
2946func (e * Entry ) TableName () string {
@@ -45,16 +62,69 @@ func (ex *ExtendedEntry) TableName() string {
4562 return "exentries"
4663}
4764
65+ type Address struct {
66+ ID int `gorm:"column:id;autoIncrement;primaryKey"`
67+ Number string `gorm:"column:number"` // Flat or building number
68+ Building string `gorm:"column:building"` // Apartment or building or society name
69+ Street string `gorm:"column:street"` // Street address
70+ Locality string `gorm:"column:locality"` // Name of the locality e.g: Whitefield
71+ Area string `gorm:"column:area"` // Name of the larger area e.g: East Bangalore
72+ City string `gorm:"column:city"` // Name of the city e.g: Bangalore
73+ State string `gorm:"column:state"` // Name of the state e.g: Karnataka
74+ Country string `gorm:"column:country"` // Name of the country e.g: India
75+
76+ Landmark string `gorm:"column:landmark"` // Name of landmark if any
77+ ZipCode string `gorm:"column:zipcode"` // PIN/ZIP code
78+ Type string `gorm:"column:type"` // Type of address: Home/Work/Business
79+
80+ Entry Entry `gorm:"foreignKey:EntryID"`
81+ EntryID int
82+ }
83+
84+ func (ad * Address ) TableName () string {
85+ return "address"
86+ }
87+
4888// Clone an entry
4989func (e1 * Entry ) Copy (e2 * Entry ) {
5090
51- if e2 != nil {
52- e1 .Title = e2 .Title
53- e1 .User = e2 .User
54- e1 .Url = e2 .Url
55- e1 .Password = e2 .Password
56- e1 .Notes = e2 .Notes
57- }
91+ if e2 != nil {
92+ switch (e2 .Type ) {
93+ case "password" :
94+ e1 .Title = e2 .Title
95+ e1 .User = e2 .User
96+ e1 .Url = e2 .Url
97+ e1 .Password = e2 .Password
98+ e1 .Notes = e2 .Notes
99+ e1 .Tags = e2 .Tags
100+ e1 .Type = e2 .Type
101+ case "card" :
102+ e1 .Title = e2 .Title
103+ e1 .Name = e2 .Name // card holder name
104+ e1 .Company = e2 .Company
105+ e1 .Number = e2 .Number
106+ e1 .SecurityCode = e2 .SecurityCode
107+ e1 .ExpiryMonth = e2 .ExpiryMonth
108+ e1 .ExpiryYear = e2 .ExpiryYear
109+ e1 .Tags = e2 .Tags
110+ e1 .Notes = e2 .Notes
111+ e1 .Type = e2 .Type
112+ case "identity" :
113+ e1 .Title = e2 .Title
114+ e1 .Name = e2 .Name
115+ e1 .Company = e2 .Company
116+ e1 .FirstName = e2 .FirstName
117+ e1 .LastName = e2 .LastName
118+ e1 .MiddleName = e2 .MiddleName
119+ e1 .User = e2 .User
120+ e1 .Email = e2 .Email
121+ e1 .PhoneNumber = e2 .PhoneNumber
122+ e1 .Number = e2 .Number
123+ e1 .Notes = e2 .Notes
124+ e1 .Tags = e2 .Tags
125+ e1 .Type = e2 .Type
126+ }
127+ }
58128}
59129
60130// Clone an entry
0 commit comments