Search in sources :

Example 56 with AjaxResult

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

the class RemoteGraController method getLoadList.

@RequestMapping(value = "/RGra/{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<RemoteGraduateWorkload> list = graService.getList(years, teacher, page, limit);
    AjaxResult ajaxResult = new AjaxResult();
    ajaxResult.setCount(graService.getCount(years, teacher));
    ajaxResult.ok();
    ajaxResult.setData(list);
    String json = JSON.toJSONString(ajaxResult);
    return json;
}
Also used : AjaxResult(com.hfut.entity.AjaxResult) RemoteGraduateWorkload(com.hfut.entity.RemoteGraduateWorkload) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 57 with AjaxResult

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

the class TotalController method getLocalTotal.

@RequestMapping(value = "/total/count/{years}/{location}/{college}/{teacher}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf8")
@ResponseBody
public String getLocalTotal(@PathVariable("years") Integer years, @PathVariable("location") Integer location, /*1落地0异地*/
@PathVariable("teacher") String teacher, @PathVariable("college") String college) {
    AjaxResult result = new AjaxResult();
    logger.info(years + "," + location + "," + teacher + "," + college);
    System.out.println(college);
    if (location == 1) {
        result.setData(totalService.getTotalByName(years, teacher, college, TotalService.LOCAL));
    } else {
        result.setData(totalService.getTotalByName(years, teacher, college, TotalService.REMOTE));
    }
    result.ok();
    return JSON.toJSONString(result);
}
Also used : AjaxResult(com.hfut.entity.AjaxResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 58 with AjaxResult

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

the class RoleController method addUser.

@RequestMapping(value = "/user/add", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String addUser(User account) throws Exception {
    Subject subject = SecurityUtils.getSubject();
    if (!subject.hasRole("超级管理员")) {
        account.setLevel(0);
    }
    AjaxResult result = new AjaxResult();
    account.setPassword(ToolKit.psw2pwd(account.getPassword()));
    if (!userService.register(account)) {
        result.failed();
        result.setMsg("注册失败");
    } else {
        result.ok();
    }
    return result.toString();
}
Also used : AjaxResult(com.hfut.entity.AjaxResult) Subject(org.apache.shiro.subject.Subject) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 59 with AjaxResult

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

the class RoleController method deleteTeacher.

@RequestMapping(value = "/user/delete/list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String deleteTeacher(@RequestParam(name = "data") String s) {
    ArrayList<Integer> list = (ArrayList<Integer>) JSON.parseArray(s, Integer.class);
    AjaxResult result = new AjaxResult();
    if (userService.removeUser(list)) {
        result.ok();
    } else {
        result.failed();
        result.setMsg("用户不存在");
    }
    return result.toString();
}
Also used : AjaxResult(com.hfut.entity.AjaxResult) ArrayList(java.util.ArrayList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 60 with AjaxResult

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

the class UserController method getDetail.

@RequestMapping(value = "/zone/getDetail", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8", method = { RequestMethod.GET })
@ResponseBody
public // 获取当前用户信息
String getDetail() throws Exception {
    Subject currentUser = SecurityUtils.getSubject();
    AjaxResult ajaxResult = new AjaxResult();
    User user = userService.findByName(currentUser.getPrincipal().toString());
    if (user != null) {
        List list = new ArrayList();
        user.setPassword(user.getPassword().replaceAll("\\S", "*"));
        user.setAnswer(user.getAnswer().replaceAll("\\S", "*"));
        list.add(user);
        ajaxResult.setData(list);
        ajaxResult.ok();
    } else {
        ajaxResult.failed();
        ajaxResult.setMsg("请重新登录重试。");
    }
    return JSON.toJSONString(ajaxResult);
}
Also used : AjaxResult(com.hfut.entity.AjaxResult) User(com.hfut.entity.User) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Subject(org.apache.shiro.subject.Subject) 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