jwt validation, getting the correct database

This commit is contained in:
2018-11-07 20:13:26 +01:00
parent 549d91fbb4
commit 3347161ae9
13 changed files with 125 additions and 62 deletions

View File

@ -40,8 +40,8 @@ func AddContact(m *Contact) (id int64, err error) {
// GetContactById retrieves Contact by Id. Returns error if
// Id doesn't exist
func GetContactById(id int) (v *Contact, err error) {
o := orm.NewOrm()
func GetContactById(o orm.Ormer, id int) (v *Contact, err error) {
//o := orm.NewOrm()
v = &Contact{Id: id}
if err = o.Read(v); err == nil {
return v, nil
@ -51,9 +51,8 @@ func GetContactById(id int) (v *Contact, err error) {
// GetAllContact retrieves all Contact matches certain condition. Returns empty list if
// no records exist
func GetAllContact(query map[string]string, fields []string, sortby []string, order []string,
func GetAllContact(o orm.Ormer, query map[string]string, fields []string, sortby []string, order []string,
offset int64, limit int64) (ml []interface{}, err error) {
o := orm.NewOrm()
qs := o.QueryTable(new(Contact))
// query k=v
for k, v := range query {