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
package service
import (
"gin-vue-admin/global"
"gin-vue-admin/model"
"strconv"
)
func GetMoc(mocType int) map[int]string {
list := make([]model.Moc, 0)
table := " moc "
//table := " survey_log as sl left join customer_user as cu on sl.user_id=cu.id "
field := " id, name "
conditions := ""
if mocType != 0 {
conditions += " AND moc_type = " + strconv.Itoa(mocType)
}
sqlStr2 := "SELECT " + field +
" FROM " + table +
" WHERE 1>0 " + conditions
global.GVA_DB.Raw(sqlStr2).Scan(&list)
if global.GVA_DB.Error != nil {
return nil
}
reply := make(map[int]string, 0)
for _, v := range list {
reply[v.Id] = v.Name
}
return reply
}