加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
GetWeekCourseNew.go 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
高峰 提交于 2020-11-21 16:43 . 微课表服务端
package main
import (
"encoding/json"
"fmt"
"strconv"
"strings"
)
type WeekCourseNew struct {
CourseName string
TeacherName string
RoomName string
CourseTimes []CourseTime
}
var myWeekCourseNew []WeekCourseNew
var tmpCourseNew WeekCourseNew
var myCourseResultNew WeekCourseResultNew
func GetWeekCourseNew(UserName string, PassWord string, WeekDay int) string {
myWeekCourseNew = nil
myCourseResultNew.Type = "course"
var tmpResultNew CourseResult
var allCoursesNew []Course
allCoursesNew = nil
var cstr string = GetCourse(UserName, PassWord)
err := json.Unmarshal([]byte(cstr), &tmpResultNew)
if err != nil {
fmt.Println(err)
}
allCoursesNew = tmpResultNew.Data
for _, c1 := range allCoursesNew {
schoolWeek := strconv.Itoa(WeekDay)
intWeek, _ := strconv.Atoi(schoolWeek)
if c1.Weeks[intWeek] == '1' {
arr := GetTeacherObj()
for _, thisteacher := range arr {
if strings.Contains(c1.CourseID, thisteacher.CourseID) {
tmpCourseNew.TeacherName = thisteacher.CourseTeacher
tmpCourseNew.CourseName = thisteacher.CourseName
tmpCourseNew.RoomName = c1.RoomName
tmpCourseNew.CourseTimes = c1.CourseTimes
myWeekCourseNew = append(myWeekCourseNew, tmpCourseNew)
}
}
}
}
myCourseResultNew.Data = myWeekCourseNew
js, _ := json.MarshalIndent(myCourseResultNew, "", "\t")
return B2S(js)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化