當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Model.Id方法代碼示例

本文整理匯總了Golang中github.com/hjqhezgh/lessgo.Model.Id方法的典型用法代碼示例。如果您正苦於以下問題:Golang Model.Id方法的具體用法?Golang Model.Id怎麽用?Golang Model.Id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/hjqhezgh/lessgo.Model的用法示例。


在下文中一共展示了Model.Id方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TmkStatisticsDetailAction

/*
select c.id,e.really_name,ce.name,c.mother,c.mother_phone,c.father,c.father_phone,c.home_phone,c.child,c.contact_status
from tmk_consumer tc
left join consumer c on tc.consumer_id=c.id
left join employee e on e.user_id=tc.employee_id
left join center ce on ce.cid=c.center_id
where tc.employee_id=?
*/
func TmkStatisticsDetailAction(w http.ResponseWriter, r *http.Request) {
	m := make(map[string]interface{})

	employee := lessgo.GetCurrentEmployee(r)

	if employee.UserId == "" {
		lessgo.Log.Warn("用戶未登陸")
		m["success"] = false
		m["code"] = 100
		m["msg"] = "用戶未登陸"
		commonlib.OutputJson(w, m, " ")
		return
	}

	err := r.ParseForm()

	if err != nil {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "出現錯誤,請聯係IT部門,錯誤信息:" + err.Error()
		commonlib.OutputJson(w, m, " ")
		return
	}

	pageNoString := r.FormValue("page")
	pageNo := 1
	if pageNoString != "" {
		pageNo, err = strconv.Atoi(pageNoString)
		if err != nil {
			pageNo = 1
			lessgo.Log.Warn("錯誤的pageNo:", pageNo)
		}
	}

	pageSizeString := r.FormValue("rows")
	pageSize := 10
	if pageSizeString != "" {
		pageSize, err = strconv.Atoi(pageSizeString)
		if err != nil {
			lessgo.Log.Warn("錯誤的pageSize:", pageSize)
		}
	}

	id := r.FormValue("id")

	params := []interface{}{}

	sql := " select c.id,e.user_id,e.really_name,ce.name,c.mother,c.mother_phone,c.father,c.father_phone,c.home_phone,c.child,c.contact_status "
	sql += " from tmk_consumer tc "
	sql += " left join consumer c on tc.consumer_id=c.id "
	sql += " left join employee e on e.user_id=tc.employee_id "
	sql += " left join center ce on ce.cid=c.center_id "
	sql += " where tc.employee_id=? "

	countSql := "select count(1) from tmk_consumer where employee_id=?"

	params = append(params, id)

	lessgo.Log.Debug(countSql)

	db := lessgo.GetMySQL()
	defer db.Close()

	rows, err := db.Query(countSql, params...)

	if err != nil {
		lessgo.Log.Warn(err.Error())
		m["success"] = false
		m["code"] = 100
		m["msg"] = "係統發生錯誤,請聯係IT部門"
		commonlib.OutputJson(w, m, " ")
		return
	}

	totalNum := 0

	if rows.Next() {
		err := rows.Scan(&totalNum)

		if err != nil {
			lessgo.Log.Warn(err.Error())
			m["success"] = false
			m["code"] = 100
			m["msg"] = "係統發生錯誤,請聯係IT部門"
			commonlib.OutputJson(w, m, " ")
			return
		}
	}

	totalPage := int(math.Ceil(float64(totalNum) / float64(pageSize)))

	currPageNo := pageNo
//.........這裏部分代碼省略.........
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:101,代碼來源:tmkStatisticsAction.go

示例2: ConsultantPhoneListAction

//顧問分頁數據服務
func ConsultantPhoneListAction(w http.ResponseWriter, r *http.Request) {

	m := make(map[string]interface{})

	employee := lessgo.GetCurrentEmployee(r)

	if employee.UserId == "" {
		lessgo.Log.Warn("用戶未登陸")
		m["success"] = false
		m["code"] = 100
		m["msg"] = "用戶未登陸"
		commonlib.OutputJson(w, m, " ")
		return
	}

	err := r.ParseForm()

	if err != nil {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "出現錯誤,請聯係IT部門,錯誤信息:" + err.Error()
		commonlib.OutputJson(w, m, " ")
		return
	}

	pageNoString := r.FormValue("page")
	pageNo := 1
	if pageNoString != "" {
		pageNo, err = strconv.Atoi(pageNoString)
		if err != nil {
			pageNo = 1
			lessgo.Log.Warn("錯誤的pageNo:", pageNo)
		}
	}

	pageSizeString := r.FormValue("rows")
	pageSize := 10
	if pageSizeString != "" {
		pageSize, err = strconv.Atoi(pageSizeString)
		if err != nil {
			lessgo.Log.Warn("錯誤的pageSize:", pageSize)
		}
	}

	dataType := ""

	roleCodes := strings.Split(employee.RoleCode, ",")

	for _, roleCode := range roleCodes {
		if roleCode == "admin" || roleCode == "yyzj" || roleCode == "zjl" || roleCode == "yyzy" {
			dataType = "all"
			break
		} else if roleCode == "cd" {
			dataType = "center"
			break
		} else {
			dataType = "self"
		}
	}

	cid := r.FormValue("cid-eq")
	employeeId := r.FormValue("employee_id-eq")
	year := r.FormValue("year-eq")
	month := r.FormValue("month-eq")
	week := r.FormValue("week-eq")
	startTime := r.FormValue("start_time-eq")

	st := ""
	et := ""
	flag := true

	if startTime != "" {
		st = startTime + " 00:00:00"
		et = startTime + " 23:59:59"
	} else {
		if week != "" && month != "" && year != "" {
			st, et, flag = lessgo.FindRangeTimeDim("", "", year+month+week)
		} else if month != "" && year != "" {
			st, et, flag = lessgo.FindRangeTimeDim("", year+month, "")
		} else if year != "" {
			st, et, flag = lessgo.FindRangeTimeDim(year, "", "")
		}
	}

	params := []interface{}{}

	sql := ""
	countSql := ""

	if dataType == "all" {

		sql += "select c.name,c.cid,e.user_id,e.really_name,phone_count.num a,rank.rowNo b,phone_count.localphone from (select count(*) num,localphone,cid from audio where remotephone!='' and remotephone is not null "

		if cid != "" {
			sql += " and cid=? "
			params = append(params, cid)
		}

		if flag {
//.........這裏部分代碼省略.........
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:101,代碼來源:consultantPhoneListAction.go


注:本文中的github.com/hjqhezgh/lessgo.Model.Id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。