Ejemplo n.º 1
0
  @RequestMapping("/checkPrice")
  public String checkPrice(Model model, Achat ac, HttpSession session) {
    User user = (User) session.getAttribute("user");
    achatService.update(ac);
    ac = achatService.get(ac.getId());
    // 将同意的那条流程更新之后,将另外两个供应商的数据删掉
    Achat ac2 = new Achat();
    ac2.setTitle(ac.getTitle());
    ac2.setContent(ac.getContent());
    ac2.setState("2");
    List<Achat> others = achatService.findAll(ac2);
    for (Achat ac3 : others) {
      achatService.delete(ac3.getId());
    }

    return "redirect:/user/achatDetail/" + user.getId();
  }
Ejemplo n.º 2
0
 @RequestMapping("/getNotification")
 public void getNotification(HttpServletResponse response, HttpSession session) {
   User user = (User) session.getAttribute("user");
   Achat at = new Achat();
   at.setSupport_id(user.getId() + "");
   List<Achat> list = achatService.findAll(at);
   for (Achat a : list) {
     String category_id = a.getCategory_id();
     Category c = categoryService.get(Integer.parseInt(category_id));
     a.setCategory_name(c.getName());
     String state = a.getState();
     a.setState(StringUtil.getState(state));
   }
   String json = JSON.toJSONString(list);
   try {
     response.getWriter().println(json);
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Ejemplo n.º 3
0
  /**
   * @Description: TODO
   *
   * @param @param user
   * @param @param response
   * @param @param page 第几页
   * @param @param rows 一页显示多少条
   * @return void
   * @throws
   * @author work
   * @date 2016年4月11日 上午12:58:32
   */
  @RequestMapping("/getUserList")
  public void getUserList(
      @ModelAttribute User user, String type, HttpServletResponse response, int page, int rows) {
    response.setCharacterEncoding("utf-8");
    if ("1".equals(type)) {
      user.setRole_id("2");
    } else if ("2".equals(type)) {
      int id = user.getId();
      if (id != 0) {
        User u = userService.get(id);
        String province = u.getProvince();
        if (province != null) {
          user.setProvince(province);
        }
      }
      user.setRole_id("3");
    } else {
      user.setRole_id("4");
    }
    Page<User> users = userService.findByParams(user, page, rows);
    for (User u : users.getRows()) {
      Date date = u.getLogin_date();
      String parseDate = "";

      if (date != null) {
        SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        parseDate = sm.format(date);
        u.setParseDate(parseDate);
      }
      String role_id = u.getRole_id();
      String role_name = "";
      if (role_id != null) {
        role_name = roleService.get(Integer.parseInt(role_id)).getRole_name();
      }
      u.setRole_name(role_name);
    }

    String json = JSON.toJSONString(users);
    System.out.println(json);
    try {
      response.getWriter().print(json);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }