-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhandler.go
More file actions
32 lines (28 loc) · 835 Bytes
/
Copy pathhandler.go
File metadata and controls
32 lines (28 loc) · 835 Bytes
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
package libQuery
import (
"fmt"
"net/http"
)
func HandleCheckDuplicate(code int, desc, dupDesc string, record []QueryData, err error) (int, string, error) {
if desc != NO_DATA_FOUND && len(record) != 0 {
return http.StatusBadRequest, dupDesc, fmt.Errorf("check duplicate faile: %s", dupDesc)
}
if desc != NO_DATA_FOUND && err != nil {
return code, desc, err
}
return http.StatusOK, "", nil
}
func HandleCheckExistence(code int, desc, notExistDesc string, record []QueryData, err error) (int, string, error) {
if err != nil {
if desc == NO_DATA_FOUND || len(record) == 0 {
return http.StatusBadRequest, notExistDesc, fmt.Errorf("check existance faile: %s", notExistDesc)
}
return code, desc, err
}
return http.StatusOK, "", nil
}
func (m QueryRunnerModel) Close() {
if m.Mode == MockDB {
m.DB.Close()
}
}