Search in sources :

Example 26 with AjaxResult

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

the class RemoteNonLessonController method updataRecord.

@RequestMapping(value = "/nonLesson/save", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String updataRecord(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]));
        RemoteNonLesson workload;
        workload = JSON.parseObject(String.valueOf(jsonObject), RemoteNonLesson.class);
        logger.info(workload.toString());
        if (service.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) RemoteNonLesson(com.hfut.entity.RemoteNonLesson) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 27 with AjaxResult

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

the class RoleController method searchUser.

@RequestMapping(value = "/user/search", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8")
@ResponseBody
public String searchUser(@RequestParam(name = "s") String s, @RequestParam(name = "page") Integer page, @RequestParam(name = "limit") Integer limit) throws Exception {
    AjaxResult result = new AjaxResult();
    List<User> list = userService.selectLike(s, page, limit);
    result.setData(list);
    result.setCount(userService.countLike(s));
    result.ok();
    return result.toString();
}
Also used : AjaxResult(com.hfut.entity.AjaxResult) User(com.hfut.entity.User) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 28 with AjaxResult

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

the class UserController method password.

@RequestMapping(value = "/user/password", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=utf-8", method = { RequestMethod.POST })
@ResponseBody
public // 修改密码
String password(@RequestParam(name = "name") String name, @RequestParam(name = "oldPsw") String old, @RequestParam(name = "newPsw") String newpsw) throws Exception {
    Subject currentUser = SecurityUtils.getSubject();
    old = ToolKit.psw2pwd(old);
    newpsw = ToolKit.psw2pwd(newpsw);
    AjaxResult result = new AjaxResult();
    String username = currentUser.getPrincipal().toString();
    User user = userService.findByName(username);
    if (null == user || !username.equals(name)) {
        result.failed();
        result.setMsg("修改用户名与当前用户名不匹配。");
        return JSON.toJSONString(result);
    } else if (!user.getPassword().equals(old)) {
        result.failed();
        result.setMsg("旧密码不正确。");
        return JSON.toJSONString(result);
    }
    try {
        user.setPassword(newpsw);
        System.out.println(user);
        userService.alterPassword(user);
        result.ok();
        result.setMsg("修改成功,重新登录。");
        return JSON.toJSONString(result);
    } catch (Exception e) {
        throw new CustomException("请检查数据是否正确");
    }
}
Also used : AjaxResult(com.hfut.entity.AjaxResult) User(com.hfut.entity.User) CustomException(com.hfut.exception.CustomException) Subject(org.apache.shiro.subject.Subject) CustomException(com.hfut.exception.CustomException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 29 with AjaxResult

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

the class DesignController method getLoadList.

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

Example 30 with AjaxResult

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

the class DesignController method saveLoad.

@RequestMapping(value = "/saveLocalDesign", 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]));
        LocalDesignWorkload workload;
        workload = JSON.parseObject(String.valueOf(jsonObject), LocalDesignWorkload.class);
        if (designService.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) LocalDesignWorkload(com.hfut.entity.LocalDesignWorkload) 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