Search in sources :

Example 16 with AjaxResult

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

the class NetCourseController method saveLoad.

@RequestMapping(value = "/saveLocalNet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String saveLoad(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]));
        LNetWorkload workload;
        workload = JSON.parseObject(String.valueOf(jsonObject), LNetWorkload.class);
        if (netService.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) LNetWorkload(com.hfut.entity.LNetWorkload) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 17 with AjaxResult

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

the class NetCourseController method removeLoad.

@RequestMapping(value = "/removeLocalNet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String removeLoad(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]));
        LNetWorkload workload;
        workload = JSON.parseObject(String.valueOf(jsonObject), LNetWorkload.class);
        if (netService.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) LNetWorkload(com.hfut.entity.LNetWorkload) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 18 with AjaxResult

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

the class ProjectController method removeLoad.

@RequestMapping(value = "/removeLocalProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String removeLoad(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]));
        LProjectWorkload workload;
        workload = JSON.parseObject(String.valueOf(jsonObject), LProjectWorkload.class);
        if (projectService.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) LProjectWorkload(com.hfut.entity.LProjectWorkload) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 19 with AjaxResult

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

the class ProjectController method saveLoad.

@RequestMapping(value = "/saveLocalProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String saveLoad(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]));
        LProjectWorkload workload;
        workload = JSON.parseObject(String.valueOf(jsonObject), LProjectWorkload.class);
        if (projectService.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) LProjectWorkload(com.hfut.entity.LProjectWorkload) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 20 with AjaxResult

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

the class ProjectController method getLoadList.

@RequestMapping(value = "/LProject/{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 = 10;
    } else {
        limit = Integer.valueOf(limitParam);
    }
    if (pageParam == null) {
        page = 0;
    } else {
        page = (Integer.valueOf(pageParam) - 1) * limit;
    }
    System.out.println(page + " " + limit);
    List<LProjectWorkload> list = projectService.getList(years, teacher, page, limit);
    AjaxResult ajaxResult = new AjaxResult();
    ajaxResult.setCount(projectService.getCount(years, teacher));
    ajaxResult.ok();
    ajaxResult.setData(list);
    String json = JSON.toJSONString(ajaxResult);
    return json;
}
Also used : AjaxResult(com.hfut.entity.AjaxResult) LProjectWorkload(com.hfut.entity.LProjectWorkload) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

AjaxResult (com.hfut.entity.AjaxResult)63 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)56 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)56 JSONObject (com.alibaba.fastjson.JSONObject)30 User (com.hfut.entity.User)6 Subject (org.apache.shiro.subject.Subject)6 CustomException (com.hfut.exception.CustomException)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Expriment (com.hfut.entity.Expriment)3 LGraDesignWorkload (com.hfut.entity.LGraDesignWorkload)3 LGraPracticeWorkload (com.hfut.entity.LGraPracticeWorkload)3 LMatchWorkload (com.hfut.entity.LMatchWorkload)3 LNetWorkload (com.hfut.entity.LNetWorkload)3 LPracticeWorkload (com.hfut.entity.LPracticeWorkload)3 LProjectWorkload (com.hfut.entity.LProjectWorkload)3 LocalCourseWorkload (com.hfut.entity.LocalCourseWorkload)3 LocalDesignWorkload (com.hfut.entity.LocalDesignWorkload)3 LocalExpWorkload (com.hfut.entity.LocalExpWorkload)3 RemoteDesignWorkload (com.hfut.entity.RemoteDesignWorkload)3