use of com.hfut.entity.Teacher in project Workload by amoxu.
the class TeacherController method getTeacher.
@RequestMapping(value = "/teacher/{college}/{teacher}/{type}", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8", method = RequestMethod.GET)
@ResponseBody
public String getTeacher(HttpServletRequest request, @PathVariable("college") String college, @PathVariable("teacher") String teacher, @PathVariable("type") Integer type) {
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;
}
AjaxResult result;
result = new AjaxResult<Teacher>();
result.setData(teacherService.getTeacherList(college, teacher, type, page, limit));
return result.toString();
}
use of com.hfut.entity.Teacher in project Workload by amoxu.
the class TeacherController method getTeacher.
@RequestMapping(value = "/teacher/list/{type}", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8", method = RequestMethod.GET)
@ResponseBody
public String getTeacher(HttpServletRequest request, @PathVariable("type") String type) {
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;
}
AjaxResult result;
result = new AjaxResult<Teacher>();
result.setData(teacherService.getTeacherList(type, page, limit));
return result.toString();
}
use of com.hfut.entity.Teacher 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