コード例 #1
0
ファイル: AdminController.java プロジェクト: XST-Group/xst
  @ResponseBody
  @RequestMapping(value = "/login", method = RequestMethod.POST)
  public StatusMessage login(String username, String password, HttpSession session) {

    String message = "";
    StatusMessage statusMessage = null;

    if (username == "") {
      message = "请输入用户名!";
      statusMessage = new StatusMessage(0, message);

    } else if (!adminDao.isUsernameExit(username)) {
      message = "用户名不存在!";
      statusMessage = new StatusMessage(0, message);

    } else {
      V9Admin admin = adminDao.getByName(username);
      System.out.println(admin.getUsername() + "   " + admin.getPassword());
      if (password == "") {
        message = "请输入密码!";
        statusMessage = new StatusMessage(0, message);
      } else if (!admin.getPassword().equals(password)) {
        message = "密码错误!";
        statusMessage = new StatusMessage(0, message);
      } else {

        message = "管理员登陆成功!";
        session.setAttribute("loginUser", admin);
        statusMessage = new StatusMessage(1, message);
        System.out.println("message1 : " + message);
        // redirectAttributes.addFlashAttribute("loginMsg",message);
        // return "redirect:index";
      }
    }

    //        System.out.println("message : "+message);
    // statusMessage.setStatus(status);
    // statusMessage.setMessage(message);
    // redirectAttributes.addFlashAttribute("loginMsg",message);
    // return "redirect:/admin/login";
    return statusMessage;
  }
コード例 #2
0
ファイル: AdminController.java プロジェクト: XST-Group/xst
  /**
   * 添加资讯
   *
   * @param title
   * @param description
   * @param redirectAttributes
   * @return
   */
  @RequestMapping(value = "/news/add", method = RequestMethod.POST)
  public String addNews(
      String title,
      String description,
      String content,
      RedirectAttributes redirectAttributes,
      String arr_group_id,
      String type,
      HttpSession session) {

    V9Admin admin = (V9Admin) session.getAttribute("loginUser");
    String username = null;
    if (admin != null) {
      username = admin.getUsername();
    }

    if (username == null) {
      username = "******";
    }
    newsDao.addNews(title, description, content, arr_group_id, type, username);
    redirectAttributes.addFlashAttribute("Msg", "添加成功!"); // session在跳到页面后马上移除对象
    return "redirect:/admin/news/list";
  }
コード例 #3
0
ファイル: AdminController.java プロジェクト: XST-Group/xst
  /**
   * 编辑之后进行更新
   *
   * @param model
   * @param newsId
   * @param title
   * @param description
   * @param content
   * @param redirectAttributes
   * @param arr_group_id
   * @param type
   * @param session
   * @return
   */
  @RequestMapping(value = "/news/update/{newsId}", method = RequestMethod.POST)
  public String update(
      Model model,
      @PathVariable("newsId") int newsId,
      String title,
      String description,
      String content,
      RedirectAttributes redirectAttributes,
      String arr_group_id,
      String type,
      HttpSession session) {

    String username = null;
    V9Admin admin = (V9Admin) session.getAttribute("loginUser");
    if (admin != null) {
      username = admin.getUsername();
    }
    if (username == null) {
      username = "******";
    }
    newsDao.updateNews(newsId, title, description, content, arr_group_id, type, username);
    redirectAttributes.addFlashAttribute("Msg", "编辑成功!!");
    return "redirect:/admin/news/list";
  }