use of com.hfut.entity.AjaxResult in project Workload by amoxu.
the class TeachPracticeController method saveLoad.
@RequestMapping(value = "/saveLocalTPractice", 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]));
LPracticeWorkload workload;
workload = JSON.parseObject(String.valueOf(jsonObject), LPracticeWorkload.class);
if (practiceService.updateLoad(workload)) {
ajaxResult.ok();
ajaxResult.setMsg("保存成功");
} else {
ajaxResult.failed();
ajaxResult.setMsg("保存失败");
}
} else {
ajaxResult.failed();
ajaxResult.setMsg("参数错误");
}
return JSON.toJSONString(ajaxResult);
}
use of com.hfut.entity.AjaxResult in project Workload by amoxu.
the class TeachPracticeController method removeLoad.
@RequestMapping(value = "/removeLocalTPractice", 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]));
LPracticeWorkload workload;
workload = JSON.parseObject(String.valueOf(jsonObject), LPracticeWorkload.class);
if (practiceService.removeLoad(workload.getId())) {
ajaxResult.ok();
ajaxResult.setMsg("删除成功");
} else {
ajaxResult.failed();
ajaxResult.setMsg("删除失败");
}
} else {
ajaxResult.failed();
ajaxResult.setMsg("参数错误");
}
return JSON.toJSONString(ajaxResult);
}
use of com.hfut.entity.AjaxResult in project Workload by amoxu.
the class ExpController method getLoadList.
@RequestMapping(value = "/Exp/{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<Expriment> list = expService.getList(years, teacher, page, limit);
AjaxResult ajaxResult = new AjaxResult();
ajaxResult.setCount(expService.getCount(years, teacher));
ajaxResult.ok();
ajaxResult.setData(list);
String json = JSON.toJSONString(ajaxResult);
return json;
}
use of com.hfut.entity.AjaxResult in project Workload by amoxu.
the class ExpController method removeLoad.
@RequestMapping(value = "/removeExp", 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]));
Expriment workload;
workload = JSON.parseObject(String.valueOf(jsonObject), Expriment.class);
if (expService.removeLoad(workload.getId())) {
ajaxResult.ok();
ajaxResult.setMsg("删除成功");
} else {
ajaxResult.failed();
ajaxResult.setMsg("删除失败");
}
} else {
ajaxResult.failed();
ajaxResult.setMsg("参数错误");
}
return JSON.toJSONString(ajaxResult);
}
use of com.hfut.entity.AjaxResult in project Workload by amoxu.
the class TeacherController method addTeacher.
@RequestMapping(value = "/teacher/add/{location}", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8", method = RequestMethod.POST)
@ResponseBody
public String addTeacher(@RequestParam(name = "data") String req, @PathVariable("location") Integer location) {
Teacher teacher = JSON.parseObject(req, Teacher.class);
AjaxResult result = new AjaxResult();
teacher.setLocation(1);
logger.info(teacher);
try {
if (teacher != null) {
if (location == 0) {
teacher.setLocation(0);
} else {
teacher.setLocation(1);
}
teacherService.addTeacher(teacher);
result.ok();
} else {
result.failed();
result.setMsg("资源错误");
}
} catch (Exception e) {
e.printStackTrace();
result.failed();
result.setMsg(e.getMessage());
return result.toString();
}
return result.toString();
}
Aggregations