-
Notifications
You must be signed in to change notification settings - Fork 0
/
building.go
42 lines (37 loc) · 1.2 KB
/
building.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package models
import (
"crypto/md5"
"errors"
"fmt"
)
var (
// ErrMissingRequiredParameters reqd parameter missing
ErrMissingRequiredParameters = errors.New("missing required parameter")
// ErrRecordsNotFound list is empty
ErrRecordsNotFound = errors.New("record(s) not found")
// ErrRecordNotFound data not exiss
ErrRecordNotFound = errors.New("record not found")
// ErrRecordMismatch generated hashkey by name is a mismatch
ErrRecordMismatch = errors.New("record id/name mismatch")
// ErrRecordExists data already exiss
ErrRecordExists = errors.New("record exists")
// ErrDBTransaction internal storage error
ErrDBTransaction = errors.New("db storage failed")
)
// BuildingData data row in the storage
type BuildingData struct {
ID string `json:"id"`
Name string `json:"name"`
Address string `json:"address,omitempty"`
Floors []string `json:"floors,omitempty"`
Created string `json:"created,omitempty"`
Modified string `json:"modified,omitempty"`
}
// NewBuildingData new instance
func NewBuildingData() *BuildingData {
return &BuildingData{}
}
// HashKey convert to md5 hash
func (q BuildingData) HashKey(s string) string {
return fmt.Sprintf("%x", md5.Sum([]byte(s)))
}