func (c *POIOrderMonitorController) OrderMonitor() { c.Layout = "layout/layout_monitor.tpl" c.TplNames = "monitor/order_monitor.tpl" resp := models.POIMonitorOrderResponse{} content, _ := libs.ParseGetRequest(libs.MONITOR_ORDER_URL, nil) json.Unmarshal([]byte(content), &resp) dispatchOrders := make([]*models.POIOrder, 0) orderDispatchInfo := resp.Content.OrderDispatchInfo for _, master := range orderDispatchInfo { order := models.QueryOrderById(master.MasterId) var dispatchdTeachers string for _, slave := range master.Slaves { teacher := models.QueryUserById(slave.SlaveId) teacherInfo := fmt.Sprintf("%s(%d)", teacher.Nickname, slave.SlaveId) dispatchdTeachers = dispatchdTeachers + "," + teacherInfo } if len(dispatchdTeachers) > 0 { order.DispatchdTeachers = dispatchdTeachers[1:] } dispatchOrders = append(dispatchOrders, order) } // teacherOrderDispatchInfo := resp.Content.TeacherOrderDispatchInfo // userOrderDispatchInfo := resp.Content.UserOrderDispatchInfo c.Data["dispatchOrders"] = dispatchOrders c.Data["type"] = "order" }
func (c *POIUserMonitorController) GetAvailableTeachers() { c.Layout = "layout/layout_monitor.tpl" c.TplNames = "monitor/live_teachers.tpl" resp := models.POIMonitorUserResponse{} content, _ := libs.ParseGetRequest(libs.MONITOR_USER_URL, nil) json.Unmarshal([]byte(content), &resp) availableTeachers := make([]*models.POIUser, 0) for i := range resp.Content.LiveTeachers { userInfo := resp.Content.LiveTeachers[i] user := models.QueryUserById(userInfo.User.UserId) user.Locked = userInfo.Locked availableTeachers = append(availableTeachers, user) } c.Data["availableTeachers"] = availableTeachers c.Data["type"] = "user" }