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
}
