use of com.hfut.entity.AjaxResult in project Workload by amoxu.
the class TeacherController method getCollege.
@RequestMapping(value = "/teacher/college", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8", method = RequestMethod.GET)
@ResponseBody
public String getCollege() {
AjaxResult result = new AjaxResult();
result.setData(teacherService.getCollege());
return result.toString();
}
use of com.hfut.entity.AjaxResult in project Workload by amoxu.
the class TeacherController method updateTeacher.
@RequestMapping(value = "/teacher", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8", method = RequestMethod.POST)
@ResponseBody
public String updateTeacher(Teacher teacher) {
AjaxResult result = new AjaxResult();
logger.info(teacher);
try {
if (teacher != null) {
if (teacherService.updateTeacher(teacher)) {
result.ok();
} else {
result.setMsg("更新失败");
result.failed();
}
} else {
result.failed();
result.setMsg("资源错误");
}
} catch (Exception e) {
e.printStackTrace();
result.failed();
result.setMsg(e.getMessage());
return result.toString();
}
return result.toString();
}
use of com.hfut.entity.AjaxResult in project Workload by amoxu.
the class RemoteCourseController method saveRemote.
@RequestMapping(value = "/saveRemote", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String saveRemote(HttpServletRequest request) throws Exception {
Map<String, String[]> req = request.getParameterMap();
AjaxResult ajaxResult = new AjaxResult();
JSONObject jsonObject = JSON.parseObject(String.valueOf(req.get("data")[0]));
RemoteTeachWorkload workload;
workload = JSON.parseObject(String.valueOf(jsonObject), RemoteTeachWorkload.class);
if (teachService.updateLoad(workload)) {
ajaxResult.ok();
ajaxResult.setMsg("保存成功");
} else {
ajaxResult.failed();
ajaxResult.setMsg("保存失败");
}
return JSON.toJSONString(ajaxResult);
}
use of com.hfut.entity.AjaxResult in project Workload by amoxu.
the class RemoteDesignController method getLoadList.
@RequestMapping(value = "/RDesign/{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<RemoteDesignWorkload> list = designService.getList(years, teacher, page, limit);
AjaxResult ajaxResult = new AjaxResult();
ajaxResult.setCount(designService.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 RemoteDesignController method saveRemote.
@RequestMapping(value = "/saveRemoteDesign", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String saveRemote(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]));
RemoteDesignWorkload workload;
workload = JSON.parseObject(String.valueOf(jsonObject), RemoteDesignWorkload.class);
if (workload.getPeople() <= 50) {
workload.setLoadCoefficient(0.6F);
workload.setWorkload(workload.getLoadCoefficient() * workload.getPeople() * workload.getWeeks());
;
} else {
workload.setLoadCoefficient(0.3F);
workload.setWorkload((float) (workload.getWeeks() * (0.6 * 50 + (workload.getPeople() - 50) * 0.3)));
}
// 更新酬金
workload.setMoney(PropertyUtil.getAllowance() * workload.getWorkload());
if (designService.updateLoad(workload)) {
ajaxResult.ok();
ajaxResult.setMsg("保存成功");
} else {
ajaxResult.failed();
ajaxResult.setMsg("保存失败");
}
} else {
ajaxResult.failed();
ajaxResult.setMsg("参数错误");
}
return JSON.toJSONString(ajaxResult);
}
Aggregations