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


Golang lessgo.GetCurrentEmployee函數代碼示例

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


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

示例1: ChildInNormalScheduleAction

func ChildInNormalScheduleAction(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)
		}
	}

	scheduleId := r.FormValue("scheduleId")

	pageData, err := logic.ChildInNormalSchedulePage(scheduleId, pageNo, pageSize)

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

	m["PageData"] = pageData
	m["DataLength"] = len(pageData.Datas) - 1

	commonlib.RenderTemplate(w, r, "page.json", m, template.FuncMap{"getPropValue": lessgo.GetPropValue, "compareInt": lessgo.CompareInt, "dealJsonString": lessgo.DealJsonString}, "../lessgo/template/page.json")
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:60,代碼來源:child_web.go

示例2: AudioNoteSaveAction

//保存通話記錄備注
func AudioNoteSaveAction(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
	}

	id := r.FormValue("aid")
	note := r.FormValue("note")

	sql := "update audio set note=? where aid=? "

	lessgo.Log.Debug(sql)

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

	stmt, err := db.Prepare(sql)

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

	_, err = stmt.Exec(note, id)

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

	m["success"] = true
	commonlib.OutputJson(w, m, " ")
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:61,代碼來源:audioNote.go

示例3: ClassScheduleAttachSaveAction

func ClassScheduleAttachSaveAction(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
	}

	id := r.FormValue("id")
	intro := r.FormValue("intro")

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

	updateSql := "update class_schedule_attach set intro=?  where id=? "

	lessgo.Log.Debug(updateSql)

	stmt, err := db.Prepare(updateSql)

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

	_, err = stmt.Exec(intro, id)

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

	m["success"] = true
	commonlib.OutputJson(w, m, " ")
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:59,代碼來源:classScheduleAttach.go

示例4: ContractCheckInSaveAction

func ContractCheckInSaveAction(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 {
		lessgo.Log.Warn(err.Error())
		m["success"] = false
		m["code"] = 100
		m["msg"] = "出現錯誤,請聯係IT部門,錯誤信息:" + err.Error()
		commonlib.OutputJson(w, m, " ")
		return
	}

	childId := r.FormValue("childId")
	scheduleId := r.FormValue("scheduleId")
	contractId := r.FormValue("contractId")
	actionType := r.FormValue("type")

	flag, msg, err := logic.ContractCheckIn(childId, scheduleId, contractId, actionType)

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

	if !flag {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "保存失敗:" + msg
		commonlib.OutputJson(w, m, " ")
		return
	}

	m["success"] = true
	m["code"] = 200
	commonlib.OutputJson(w, m, " ")

	return
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:55,代碼來源:scheduleDetail_web.go

示例5: AddChildToClassQuickAction

func AddChildToClassQuickAction(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
	}

	classId := r.FormValue("classId")
	scheduleId := r.FormValue("scheduleId")
	consumerId := r.FormValue("consumerId")

	flag, msg, err := logic.AddChildToClassQuick(classId, scheduleId, consumerId, employee.UserId)

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

	if !flag {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "保存失敗:" + msg
		commonlib.OutputJson(w, m, " ")
		return
	}

	m["success"] = true
	m["code"] = 200
	commonlib.OutputJson(w, m, " ")

	return
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:53,代碼來源:scheduleDetail_web.go

示例6: ChangeClassScheduleAction

func ChangeClassScheduleAction(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
	}

	oldScheduleId := r.FormValue("oldScheduleId")
	newScheduleId := r.FormValue("newScheduleId")
	childId := r.FormValue("childId")

	flag, msg, err := logic.ChangeClassSchedule(childId, newScheduleId, oldScheduleId, employee.UserId)

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

	if !flag {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "調班失敗:" + msg
		commonlib.OutputJson(w, m, " ")
		return
	}

	m["success"] = true
	m["code"] = 200
	commonlib.OutputJson(w, m, " ")

	return
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:53,代碼來源:scheduleDetail_web.go

示例7: ConsumerPayAction

func ConsumerPayAction(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
	}

	consumerIds := r.FormValue("ids")
	payType := r.FormValue("status")

	flag, msg, err := logic.ConsumerPay(consumerIds, payType, employee.UserId)

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

	if !flag {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "操作失敗:" + msg
		commonlib.OutputJson(w, m, " ")
		return
	}

	m["success"] = true
	m["code"] = 200
	m["msg"] = "操作成功"
	commonlib.OutputJson(w, m, " ")

	return
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:52,代碼來源:consumer_web.go

示例8: GetCurrentEmployeeRoles

func GetCurrentEmployeeRoles(r *http.Request) (roleCodes []string, err error) {
	employee := lessgo.GetCurrentEmployee(r)

	if employee.UserId == "" {
		lessgo.Log.Warn("用戶未登陸")
		err = errors.New("用戶未登陸")
		return roleCodes, err
	}

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

	return roleCodes, nil
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:13,代碼來源:common.go

示例9: GetCurrentEmployeeAction

// 獲取當前用戶信息
func GetCurrentEmployeeAction(w http.ResponseWriter, r *http.Request) {
	m := make(map[string]interface{})

	user_id, err := strconv.Atoi(lessgo.GetCurrentEmployee(r).UserId)
	employee, err := FindEmployeeById(user_id)

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

	m["success"] = true
	m["code"] = 200
	m["datas"] = employee
	commonlib.OutputJson(w, m, " ")
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:20,代碼來源:employee.go

示例10: ChildSignInWithoutClassAction

func ChildSignInWithoutClassAction(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
	}

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

	for _, roleCode := range roleCodes {
		if roleCode == "tmk" {
			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
	}

	consumerIds := r.FormValue("ids")

	flag, msg, err := logic.ChildSignInWithoutClass(consumerIds, employee.UserId)

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

	if !flag {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "保存失敗:" + msg
		commonlib.OutputJson(w, m, " ")
		return
	}

	m["success"] = true
	m["code"] = 200
	m["msg"] = "操作成功"
	commonlib.OutputJson(w, m, " ")

	return
}
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:63,代碼來源:scheduleDetail_web.go

示例11: EmployeeSignInListAction

func EmployeeSignInListAction(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
	}

	dataType := ""

	roleIds := strings.Split(employee.RoleId, ",")

	for _, roleId := range roleIds {
		if roleId == "1" || roleId == "3" || roleId == "6" || roleId == "10" {
			dataType = "all"
			break
		} else if roleId == "2" {
			dataType = "center"
			break
		} else {
			dataType = "self"
		}
	}

	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)
		}
	}

	centerId := r.FormValue("cid-eq")
	st := r.FormValue("st-ge")
	et := r.FormValue("et-le")

	params := []interface{}{}

	sql := "select  esi.id,e.really_name,esi.sign_time from employee_sign_in esi left join employee e on esi.employee_id=e.user_id where 1=1 "

	if dataType == "center" {
		userId, _ := strconv.Atoi(employee.UserId)
		_employee, err := FindEmployeeById(userId)
		if err != nil {
			m["success"] = false
			m["code"] = 100
			m["msg"] = "出現錯誤,請聯係IT部門,錯誤信息:" + err.Error()
			commonlib.OutputJson(w, m, " ")
			return
		}
		params = append(params, _employee.CenterId)
		sql += " and e.center_id=? "
	}

	if centerId != "" && dataType == "all" {
		params = append(params, centerId)
		sql += " and e.center_id=? "
	}

	if dataType == "self" {
		params = append(params, employee.UserId)
		sql += " and esi.employee_id=? "
	}

	if st != "" {
		params = append(params, st)
		sql += " and esi.sign_time >= ? "
	}

	if et != "" {
		params = append(params, et)
		sql += " and esi.sign_time <= ? "
//.........這裏部分代碼省略.........
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:101,代碼來源:employeeSignIn.go

示例12: ApplyLogAddToConsumerAction

func ApplyLogAddToConsumerAction(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
	}

	year := r.FormValue("year")
	month := r.FormValue("month")
	childName := r.FormValue("childName")
	phone := r.FormValue("phone")
	comeFrom := r.FormValue("comeFrom")
	centerId := r.FormValue("centerId")
	createTime := r.FormValue("createTime")
	applyType := r.FormValue("type")
	contactsName := childName + "家長"

	remark := ""

	if comeFrom == "網站" {
		comeFrom = "5"
		remark += "通過網站報名"
	} else if comeFrom == "微信" {
		comeFrom = "6"
		remark += "通過微信報名"
	} else {
		comeFrom = "8"
	}

	if applyType == "2" {
		remark += "美術課程"
	} else if applyType == "1" {
		remark += "英語課程"
	}

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

	tx, err := db.Begin()

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

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

	phoneFlag, err := CheckConsumerPhoneExist(phone)

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

	if phoneFlag {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "聯係人電話已經存在,無需重複錄入"
		commonlib.OutputJson(w, m, " ")
		return
	}

	if homePhoneFlag {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "家庭電話已經在係統中存在,無需重複錄入"
//.........這裏部分代碼省略.........
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:101,代碼來源:applyLog.go

示例13: AddCardToSignInAction

func AddCardToSignInAction(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
	}

	ids := r.FormValue("ids")
	childId := r.FormValue("childId")

	signInIdList := strings.Split(ids, ",")

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

	getCardIdSql := "select card_id from child where cid=? "
	lessgo.Log.Debug(getCardIdSql)
	rows, err := db.Query(getCardIdSql, childId)

	cardId := ""

	if rows.Next() {
		err := commonlib.PutRecord(rows, &cardId)

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

	if cardId == "00000000" || cardId == "" {
		m["success"] = false
		m["code"] = 100
		m["msg"] = "當前學生沒有配置卡號,請配置後再補登"
		commonlib.OutputJson(w, m, " ")
		return
	}

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

	for _, signInId := range signInIdList {
		updateSql := "update sign_in set card_id=? where sid=? "
		lessgo.Log.Debug(updateSql)

		stmt, err := tx.Prepare(updateSql)

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

		_, err = stmt.Exec(cardId, signInId)

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

	tx.Commit()

	m["success"] = true
	m["code"] = 200
//.........這裏部分代碼省略.........
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:101,代碼來源:signIn.go

示例14: CallCenterStatisticsAction

/*
select ce.cid,ce.name,a.num as '全部名單', b.num as '未聯係', c.num as '待確認', d.num as '已廢棄', e.num as '已邀約',f.num as '已簽到'  from center ce
left join
(select count(1) num,center_id from consumer_new group by center_id )a on a.center_id=ce.cid
left join
(select count(1) num,center_id from consumer_new where contact_status=1 group by center_id )b on a.center_id=ce.cid
left join
(select count(1) num,center_id from consumer_new where contact_status=2 group by center_id )c on b.center_id=ce.cid
left join
(select count(1) num,center_id from consumer_new where contact_status=3 group by center_id )d on c.center_id=ce.cid
left join
(select count(1) num,center_id from consumer_new where contact_status=4 group by center_id )e on d.center_id=ce.cid
left join
(select count(1) num,center_id from consumer_new where contact_status=5 group by center_id )f on e.center_id=ce.cid
*/
func CallCenterStatisticsAction(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 {
			dataType = "center"
			break
		}
	}

	startTime := r.FormValue("startTime-ge")
	endTime := r.FormValue("endTime-le")

	params := []interface{}{}

	sql := " select ce.cid,ce.name,a.num as '全部名單', b.num as '未聯係', c.num as '撥打電話數', d.num as '邀約數', e.num as '簽到數',f.num as '定金',g.num as '全額',1,2,3  from center ce "
	sql += " left join "
	sql += " (select count(1) num,center_id from consumer_new group by center_id )a on a.center_id=ce.cid "
	sql += " left join "
	sql += " (select count(1) num,center_id from consumer_new where contact_status=1 group by center_id )b on b.center_id=ce.cid "
	sql += " left join "
	sql += " (select count(1) num,cid from audio where start_time >=? and start_time<=? group by cid )c on c.cid=ce.cid "
	sql += " left join "
	sql += " (select count(1) num,ch.center_id from schedule_detail_child sdc left join child ch on sdc.child_id=ch.cid where sdc.is_free=1 and sdc.create_time>=? and sdc.create_time <=? group by ch.center_id)d on d.center_id=ce.cid "
	sql += " left join "
	sql += " (select count(1) num,ch.center_id from sign_in si left join child ch on si.child_id=ch.cid where si.type=1 and  si.is_free=1 and si.sign_time>=? and si.sign_time<=? group by ch.center_id )e on e.center_id=ce.cid "
	sql += " left join "
	sql += " (select count(1) num,center_id from consumer_new where pay_status=1 and pay_time>=? and pay_time<=? group by center_id )f on f.center_id=ce.cid "
	sql += " left join "
	sql += " (select count(1) num,center_id from consumer_new where pay_status=2 and pay_time>=? and pay_time<=? group by center_id )g on g.center_id=ce.cid where ce.cid!=9 " //屏蔽總部數據

	defaultStartTime := "2000-01-01 00:0:000"
	defaultEndTime := "2999-12-31 00:00:00"

	if startTime != "" {
		defaultStartTime = startTime
	}
//.........這裏部分代碼省略.........
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:101,代碼來源:callCenterStatisticsAction.go

示例15: ClassScheduleAttachListAction

func ClassScheduleAttachListAction(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 {
		lessgo.Log.Error(err.Error())
		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)
		}
	}

	childId := r.FormValue("childId")
	scheduleId := r.FormValue("scheduleId")

	params := []interface{}{}

	sql := "select csa.id,csa.url,csa.intro,csa.upload_time,csa.pc_thumb_url,ce.domain_name from class_schedule_attach csa left join class_schedule_detail csd on csd.id=csa.schedule_detail_id left join center ce on ce.cid=csd.center_id where csa.schedule_detail_id=? and csa.relation_childs like ? "
	lessgo.Log.Debug(sql)

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

	countSql := ""

	countSql = "select count(1) from (" + sql + ") num"

	lessgo.Log.Debug(countSql)

	params = append(params, scheduleId)
	params = append(params, "%["+childId+"]%")

	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

	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	sql += " limit ?,? "
//.........這裏部分代碼省略.........
開發者ID:hjqhezgh,項目名稱:wooyou-admin,代碼行數:101,代碼來源:classScheduleAttach.go


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