Search in sources :

Example 1 with RemoteNonLesson

use of com.hfut.entity.RemoteNonLesson in project Workload by amoxu.

the class RemoteNonLessonController method getLoadList.

@RequestMapping(value = "/RNonLesson/{years}/{teacher}", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String getLoadList(HttpServletRequest request, @PathVariable("years") Integer years, @PathVariable("teacher") String teacher) throws Exception {
    String limitParam = request.getParameter("limit");
    String pageParam = request.getParameter("page");
    Integer page, limit;
    if (limitParam == null) {
        limit = 30;
    } else {
        limit = Integer.valueOf(limitParam);
    }
    if (pageParam == null) {
        page = 0;
    } else {
        page = (Integer.valueOf(pageParam) - 1) * limit;
    }
    System.out.println(page + " " + limit);
    List<RemoteNonLesson> list = service.getList(years, teacher, page, limit);
    AjaxResult ajaxResult = new AjaxResult();
    ajaxResult.setCount(service.getCount(years, teacher));
    ajaxResult.ok();
    ajaxResult.setData(list);
    return JSON.toJSONString(ajaxResult);
}
Also used : AjaxResult(com.hfut.entity.AjaxResult) RemoteNonLesson(com.hfut.entity.RemoteNonLesson) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with RemoteNonLesson

use of com.hfut.entity.RemoteNonLesson in project Workload by amoxu.

the class RemoteNonLessonController method listRemove.

@RequestMapping(value = "/nonLesson/remove", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String listRemove(HttpServletRequest request) throws Exception {
    Map<String, String[]> req = request.getParameterMap();
    AjaxResult ajaxResult = new AjaxResult();
    if (req.get("data") != null) {
        JSONObject jsonObject = JSON.parseObject(String.valueOf(req.get("data")[0]));
        RemoteNonLesson workload;
        workload = JSON.parseObject(String.valueOf(jsonObject), RemoteNonLesson.class);
        if (service.removeLoad(workload.getId())) {
            ajaxResult.ok();
            ajaxResult.setMsg("删除成功");
        } else {
            ajaxResult.failed();
            ajaxResult.setMsg("删除失败");
        }
    } else {
        ajaxResult.failed();
        ajaxResult.setMsg("参数错误");
    }
    return JSON.toJSONString(ajaxResult);
}
Also used : AjaxResult(com.hfut.entity.AjaxResult) JSONObject(com.alibaba.fastjson.JSONObject) RemoteNonLesson(com.hfut.entity.RemoteNonLesson) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with RemoteNonLesson

use of com.hfut.entity.RemoteNonLesson in project Workload by amoxu.

the class RemoteNonLessonController method updataRecord.

@RequestMapping(value = "/nonLesson/save", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String updataRecord(HttpServletRequest request) throws Exception {
    Map<String, String[]> req = request.getParameterMap();
    AjaxResult ajaxResult = new AjaxResult();
    if (req.get("data") != null) {
        JSONObject jsonObject = JSON.parseObject(String.valueOf(req.get("data")[0]));
        RemoteNonLesson workload;
        workload = JSON.parseObject(String.valueOf(jsonObject), RemoteNonLesson.class);
        logger.info(workload.toString());
        if (service.updateLoad(workload)) {
            ajaxResult.ok();
            ajaxResult.setMsg("保存成功");
        } else {
            ajaxResult.failed();
            ajaxResult.setMsg("保存失败");
        }
    } else {
        ajaxResult.failed();
        ajaxResult.setMsg("参数错误");
    }
    return JSON.toJSONString(ajaxResult);
}
Also used : AjaxResult(com.hfut.entity.AjaxResult) JSONObject(com.alibaba.fastjson.JSONObject) RemoteNonLesson(com.hfut.entity.RemoteNonLesson) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

AjaxResult (com.hfut.entity.AjaxResult)3 RemoteNonLesson (com.hfut.entity.RemoteNonLesson)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 JSONObject (com.alibaba.fastjson.JSONObject)2