func CoursewareUploadCallBack(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) err := r.ParseForm() if err != nil { m["success"] = false m["code"] = 100 m["msg"] = "出现错误,请联系IT部门,错误信息:" + err.Error() commonlib.OutputJson(w, m, " ") return } state := r.FormValue("state") suffix := r.FormValue("suffix") fileName := r.FormValue("fileName") srcFileName := r.FormValue("srcFileName") fileSize := r.FormValue("fileSize") if state == "SUCCESS" { m["success"] = true m["suffix"] = suffix m["fileName"] = fileName m["srcFileName"] = srcFileName m["fileSize"] = fileSize } else { m["success"] = false m["msg"] = "文件上传发生错误,请重试" } commonlib.OutputJson(w, m, " ") return }
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") }
func CoursewareLoadAction(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) 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 } id := r.FormValue("id") loadFormObjects, err := logic.LoadCourseware(id) if err != nil { m["success"] = false m["code"] = 100 m["msg"] = "出现错误,请联系IT部门,错误信息:" + err.Error() commonlib.OutputJson(w, m, " ") return } m["success"] = true m["datas"] = loadFormObjects commonlib.OutputJson(w, m, " ") }
func years(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) err := r.ParseForm() if err != nil { m["success"] = false m["code"] = 100 m["msg"] = "出现错误,请联系IT部门,错误信息:" + err.Error() commonlib.OutputJson(w, m, " ") return } years, err := FindYear() 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"] = years commonlib.OutputJson(w, m, " ") return }
func weeks(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) 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") weeks, err := FindWeek(year, month) 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"] = weeks commonlib.OutputJson(w, m, " ") return }
//处理实体的分页ajax请求 func dealEntityLoad(entity Entity, w http.ResponseWriter, r *http.Request) { Log.Debug("路径:", r.URL.Path, "访问实体", entity.Id, "的load单实体ajax请求") m := make(map[string]interface{}) vars := mux.Vars(r) id := vars["id"] model, err := FindById(entity, id) if err != nil { m["success"] = false m["code"] = 100 m["msg"] = "出现错误,请联系IT部门,错误信息:" + err.Error() commonlib.OutputJson(w, m, " ") return } if model.Id == 0 { m["success"] = false m["code"] = 100 m["msg"] = "出现错误,请联系IT部门,错误信息:找不到相应的实体" commonlib.OutputJson(w, m, " ") return } m["Entity"] = entity m["Model"] = model m["FieldLength"] = len(entity.Fields) - 1 commonlib.RenderTemplate(w, r, "entity_load.json", m, template.FuncMap{"getPropValue": getPropValue, "compareInt": compareInt}, "../template/entity_load.json") }
//处理实体的删除页请求 func dealEntityDelete(entity Entity, w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) employee := GetCurrentEmployee(r) if employee.UserId == "" { Log.Warn("用户未登陆") m["success"] = false m["code"] = 100 m["msg"] = "用户未登陆" commonlib.OutputJson(w, m, " ") return } Log.Debug("路径:", r.URL.Path, "访问实体", entity.Id, "的删除页") id := r.FormValue("id") err := deleteEntity(entity, 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 commonlib.OutputJson(w, m, " ") return }
func regions(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) err := r.ParseForm() if err != nil { m["success"] = false m["reason"] = "请求解析异常" commonlib.OutputJson(w, m, " ") return } code := r.FormValue("code") regions, err := FindRegionByParentCode(code) if err != nil { m["success"] = false m["reason"] = "服务器异常" commonlib.OutputJson(w, m, " ") return } m["success"] = true m["regions"] = regions commonlib.OutputJson(w, m, " ") return }
//处理实体的删除页请求 func dealEntityDelete(entity Entity, w http.ResponseWriter, r *http.Request) { Log.Debug("路径:", r.URL.Path, "访问实体", entity.Id, "的删除页") m := make(map[string]interface{}) vars := mux.Vars(r) id := vars["id"] err := Delete(entity, 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 commonlib.OutputJson(w, m, " ") return }
//保存通话记录备注 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, " ") }
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获取员工列表 func EmployeeListByRoleIdAction(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) 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") db := lessgo.GetMySQL() defer db.Close() sql := "select e.user_id,e.really_name from (select distinct(user_id) uid from employee_role where role_id =?) a left join employee e on a.uid = e.user_id" lessgo.Log.Debug(sql) rows, err := db.Query(sql, id) if err != nil { m["success"] = false m["code"] = 100 m["msg"] = "出现错误,请联系IT部门,错误信息:" + err.Error() commonlib.OutputJson(w, m, " ") return } employees := []lessgo.Employee{} for rows.Next() { employee := lessgo.Employee{} err := commonlib.PutRecord(rows, &employee.UserId, &employee.ReallyName) if err != nil { lessgo.Log.Warn(err.Error()) m["success"] = false m["code"] = 100 m["msg"] = "系统发生错误,请联系IT部门" commonlib.OutputJson(w, m, " ") return } employees = append(employees, employee) } m["success"] = true m["code"] = 200 m["datas"] = employees commonlib.OutputJson(w, m, " ") }
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 }
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 }
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 }
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 }
func ClassByCenterIdAction(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) id := r.FormValue("id") db := lessgo.GetMySQL() defer db.Close() sql := "select class_id,name from wyclass where center_id=? " lessgo.Log.Debug(sql) rows, err := db.Query(sql, id) if err != nil { m["success"] = false m["code"] = 100 m["msg"] = "出现错误,请联系IT部门,错误信息:" + err.Error() commonlib.OutputJson(w, m, " ") return } classes := []WyClass{} for rows.Next() { wyClass := WyClass{} err := commonlib.PutRecord(rows, &wyClass.ClassId, &wyClass.Name) if err != nil { lessgo.Log.Warn(err.Error()) m["success"] = false m["code"] = 100 m["msg"] = "系统发生错误,请联系IT部门" commonlib.OutputJson(w, m, " ") return } classes = append(classes, wyClass) } m["success"] = true m["code"] = 200 m["datas"] = classes commonlib.OutputJson(w, m, " ") }
//处理实体的所有数据ajax请求 func dealEntityAllData(entity Entity, w http.ResponseWriter, r *http.Request) { Log.Debug("路径:", r.URL.Path, "访问实体", entity.Id, "的所有数据ajax请求") err := r.ParseForm() m := make(map[string]interface{}) models, err := FindAllData(entity) if err != nil { m["success"] = false m["code"] = 100 m["msg"] = "出现错误,请联系IT部门,错误信息:" + err.Error() commonlib.OutputJson(w, m, " ") return } m["Models"] = models m["Entity"] = entity m["DataLength"] = len(models) - 1 if len(models) > 0 { m["FieldLength"] = len(models[0].Props) - 1 } commonlib.RenderTemplate(w, r, "entity_alldata.json", m, template.FuncMap{"getPropValue": getPropValue, "compareInt": compareInt}, "../template/entity_alldata.json") }
func LoginAction(w http.ResponseWriter, r *http.Request) { data := make(map[string]interface{}) username := r.FormValue("username") if username == "" { lessgo.Log.Warn("username is NULL!") return } password := r.FormValue("password") if password == "" { lessgo.Log.Warn("password is NULL!") return } ret, employee, msg := CheckPwd(username, password) if ret { //密码正确 data["success"] = true lessgo.SetCurrentEmployee(employee, w, r) } else { data["success"] = false data["msg"] = msg } commonlib.OutputJson(w, data, "") return }
func NewsImageUplaodAction(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) newsImgDir, _ := lessgo.Config.GetValue("wooyou", "newsImgDir") _, err := os.Stat(newsImgDir) if err != nil && os.IsNotExist(err) { lessgo.Log.Info(newsImgDir, ",创建") os.Mkdir(newsImgDir, 0777) } fn, header, err := r.FormFile("imgFile") if err != nil && os.IsNotExist(err) { m["error"] = 1 m["message"] = err.Error() lessgo.Log.Error("获取上传图片发生错误,信息如下:", err.Error()) commonlib.OutputJson(w, m, " ") return } suffix := commonlib.Substr(header.Filename, strings.LastIndex(header.Filename, ".")+1, len(header.Filename)) newFileName := findRandomFileName(header.Filename) + "." + suffix f, err := os.Create(newsImgDir + "/" + newFileName) if err != nil { m["error"] = 1 m["message"] = err.Error() lessgo.Log.Error("获取上传图片发生错误,信息如下:", err.Error()) commonlib.OutputJson(w, m, " ") return } defer f.Close() io.Copy(f, fn) m["error"] = 0 m["url"] = "/newsimg/" + newFileName commonlib.OutputJson(w, m, " ") }
func GalleryImageCategoryAction(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) options, err := GetSubcategories() if err != nil { m["success"] = false m["code"] = "100" m["msg"] = "获取类别信息出错" + err.Error() commonlib.OutputJson(w, m, "") return } m["success"] = true m["code"] = "200" m["datas"] = options commonlib.OutputJson(w, m, "") return }
func GalleryLoadAction(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) id := r.FormValue("id") gallery, msg, err := GalleryLoad(id) if err != nil { m["success"] = false m["msg"] = msg commonlib.OutputJson(w, m, "") return } datas := []lessgo.LoadFormObject{} jsonId := lessgo.LoadFormObject{"id", id} datas = append(datas, jsonId) jsonTitle := lessgo.LoadFormObject{"title", gallery.Title} datas = append(datas, jsonTitle) jsonComment := lessgo.LoadFormObject{"comment", gallery.Comment} datas = append(datas, jsonComment) jsonImageCategory := lessgo.LoadFormObject{"image_category", gallery.ImageCategory} datas = append(datas, jsonImageCategory) jsonImageName := lessgo.LoadFormObject{"image_name", gallery.ImageName} datas = append(datas, jsonImageName) jsonImageSuffix := lessgo.LoadFormObject{"image_suffix", gallery.ImageSuffix} datas = append(datas, jsonImageSuffix) imagePath := "/artimg/" jsonImage1 := lessgo.LoadFormObject{"image1", imagePath + gallery.ImageName + "_" + IMAGE_SIZE_1 + "." + gallery.ImageSuffix} datas = append(datas, jsonImage1) jsonImage2 := lessgo.LoadFormObject{"image2", imagePath + gallery.ImageName + "_" + IMAGE_SIZE_2 + "." + gallery.ImageSuffix} datas = append(datas, jsonImage2) jsonImage3 := lessgo.LoadFormObject{"image3", imagePath + gallery.ImageName + "_" + IMAGE_SIZE_3 + "." + gallery.ImageSuffix} datas = append(datas, jsonImage3) if err != nil { m["sucess"] = false m["msg"] = msg } else { m["success"] = true m["datas"] = datas } commonlib.OutputJson(w, m, "") return }
func ImageUpload(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) _, err := os.Stat("../tmp") if err != nil && os.IsNotExist(err) { Log.Info("tmp文件夹不存在,创建") os.Mkdir("../tmp", 0777) } fn, header, err := r.FormFile("pid") if err != nil && os.IsNotExist(err) { m["success"] = false m["code"] = 100 Log.Error("获取上传图片发生错误,信息如下:", err.Error()) commonlib.OutputJson(w, m, " ") return } newFileName := findRandomFileName(header.Filename) f, err := os.Create("../tmp/" + newFileName) if err != nil { m["success"] = false m["code"] = 100 Log.Error("获取上传图片发生错误,信息如下:", err.Error()) commonlib.OutputJson(w, m, " ") return } defer f.Close() io.Copy(f, fn) m["success"] = true m["code"] = 200 m["tmpfile"] = "/tmp/" + newFileName commonlib.OutputJson(w, m, " ") }
// 获取当前用户信息 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, " ") }
func kindeditorImageUpload(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) _, err := os.Stat("../imageupload") if err != nil && os.IsNotExist(err) { Log.Info("imageupload,创建") os.Mkdir("../imageupload", 0777) } fn, header, err := r.FormFile("imgFile") if err != nil && os.IsNotExist(err) { m["error"] = 1 m["message"] = err.Error() Log.Error("获取上传图片发生错误,信息如下:", err.Error()) commonlib.OutputJson(w, m, " ") return } newFileName := findRandomFileName(header.Filename) f, err := os.Create("../imageupload/" + newFileName) if err != nil { m["error"] = 1 m["message"] = err.Error() Log.Error("获取上传图片发生错误,信息如下:", err.Error()) commonlib.OutputJson(w, m, " ") return } defer f.Close() io.Copy(f, fn) m["error"] = 0 m["url"] = "/imageupload/" + newFileName commonlib.OutputJson(w, m, " ") }
func RoleCodesAction(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) roleCodes, err := tool.GetCurrentEmployeeRoles(r) if err != nil { lessgo.Log.Error(err) m["success"] = false m["code"] = 100 m["msg"] = err.Error() commonlib.OutputJson(w, m, " ") return } m["success"] = true m["code"] = "200" m["datas"] = roleCodes commonlib.OutputJson(w, m, "") return }
func NewsLoadAction(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) id := r.FormValue("id") news, msg, err := NewsLoad(id) if err != nil { m["success"] = false m["msg"] = msg commonlib.OutputJson(w, m, "") return } datas := []lessgo.LoadFormObject{} jsonId := lessgo.LoadFormObject{"id", id} datas = append(datas, jsonId) jsonTitle := lessgo.LoadFormObject{"title", news.Title} datas = append(datas, jsonTitle) jsonNewsContent := lessgo.LoadFormObject{"news_content", news.NewsContent} datas = append(datas, jsonNewsContent) previewImage := "/newsimg/" + news.PreviewImage jsonPreviewImage := lessgo.LoadFormObject{"preview_image", previewImage} datas = append(datas, jsonPreviewImage) jsonPreviewText := lessgo.LoadFormObject{"preview_text", news.PreviewText} datas = append(datas, jsonPreviewText) jsonIsCarousel := lessgo.LoadFormObject{"is_carousel", news.IsCarousel} datas = append(datas, jsonIsCarousel) carouselImage := "/newsimg/" + news.CarouselImage jsonCarouselImage := lessgo.LoadFormObject{"carousel_image", carouselImage} datas = append(datas, jsonCarouselImage) if err != nil { m["sucess"] = false m["msg"] = msg } else { m["success"] = true m["datas"] = datas } commonlib.OutputJson(w, m, "") return }
func QueryMenusAction(w http.ResponseWriter, r *http.Request) { data := make(map[string]interface{}) username := r.FormValue("username") if username == "" { Log.Error("username is NULL!") return } data["menus"] = GetMenus(username) Log.Debug(data) commonlib.OutputJson(w, data, "") }
func HandleApplyAction(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) roleCodes, err := tool.GetCurrentEmployeeRoles(r) if err != nil { lessgo.Log.Error(err) m["success"] = false m["code"] = 100 m["msg"] = err.Error() commonlib.OutputJson(w, m, " ") return } handleApply := new(HandleApply) handleApply.PendingReceiptAmount = GetPendingReceiptAmount(roleCodes) handleApply.CompletedReceiptAmount = GetCompletedReceiptAmount(roleCodes) m["success"] = true m["code"] = "200" m["datas"] = handleApply commonlib.OutputJson(w, m, "") return }
func ClassifiedReceiptListAction(w http.ResponseWriter, r *http.Request) { m := make(map[string]interface{}) userId := "1" //CD // userId := "2"//管理 role := GetUserRole(userId) receiptType := r.FormValue("status") week := r.FormValue("week") code := r.FormValue("code") lessgo.Log.Info("receiptType: ", receiptType, " week: ", week, " code: ", code) receiptList := getClassifiedReceiptList(role, receiptType) m["success"] = true m["code"] = "200" m["datas"] = receiptList commonlib.OutputJson(w, m, "") return }