Blame view

select_config.go 1.34 KB
ea858b8a7   Marko Tikvić   refactoring
1
  package webutility
39765a430   Marko Tikvić   added list and se...
2

1d0f61553   Marko Tikvić   can't fetch clob
3
  import "gopkg.in/rana/ora.v4"
39765a430   Marko Tikvić   added list and se...
4
5
6
7
8
9
10
11
12
  
  type SelectConfig struct {
  	ListObjType string `json:"listObjectType"`
  	ObjType     string `json:"objectType"`
  	Type        string `json:"type"`
  	IdField     string `json:"idField"`
  	LabelField  string `json:"labelField"`
  	ValueField  string `json:"valueField"`
  }
e1fbb41f9   Marko Tikvić   added comments
13
  // GetSelectConfig returns select configuration slice for the given object type.
39765a430   Marko Tikvić   added list and se...
14
15
16
17
  func GetSelectConfig(db *ora.Ses, otype string) ([]SelectConfig, error) {
  	resp := make([]SelectConfig, 0)
  	var err error
  	var stmt *ora.Stmt
d2ddf82ef   Marko Tikvić   started on new rbac
18
19
20
21
22
23
24
  	query := `SELECT
  		a.LIST_OBJECT_TYPE,
  		a.OBJECT_TYPE,
  		a.ID_FIELD,
  		a.LABEL_FIELD,
  		a.TYPE,
  		b.FIELD
39765a430   Marko Tikvić   added list and se...
25
26
27
28
  		FROM LIST_SELECT_CONFIG a, LIST_VALUE_FIELD b
  		WHERE a.LIST_OBJECT_TYPE` + otype + `
  		AND b.LIST_TYPE = a.LIST_OBJECT_TYPE
  		AND b.OBJECT_TYPE = a.OBJECT_TYPE`
33fd58161   markotikvic   minor changes, sh...
29
  	stmt, err = db.Prep(query, ora.S, ora.S, ora.S, ora.S, ora.S, ora.S)
39765a430   Marko Tikvić   added list and se...
30
31
32
33
34
35
36
37
38
39
40
41
  	defer stmt.Close()
  	if err != nil {
  		return nil, err
  	}
  
  	rset, err := stmt.Qry()
  	if err != nil {
  		return nil, err
  	}
  	for rset.Next() {
  		resp = append(resp, SelectConfig{
  			ListObjType: rset.Row[0].(string),
d2ddf82ef   Marko Tikvić   started on new rbac
42
43
44
45
46
  			ObjType:     rset.Row[1].(string),
  			IdField:     rset.Row[2].(string),
  			LabelField:  rset.Row[3].(string),
  			Type:        rset.Row[4].(string),
  			ValueField:  rset.Row[5].(string),
39765a430   Marko Tikvić   added list and se...
47
48
  		})
  	}
1d0f61553   Marko Tikvić   can't fetch clob
49
50
  	if rset.Err() != nil {
  		return nil, rset.Err()
39765a430   Marko Tikvić   added list and se...
51
52
53
  	}
  
  	return resp, nil
39765a430   Marko Tikvić   added list and se...
54
  }