Пример #1
0
 /**
  * 查看一条新闻
  *
  * @param model
  * @param newsId
  * @return
  */
 @RequestMapping(value = "/news/view/{newsId}", method = RequestMethod.GET)
 public String viewNews(Model model, @PathVariable("newsId") int newsId) {
   V9News news = newsDao.getById(newsId);
   model.addAttribute("news", news);
   System.out.println(news);
   return "admin/news/viewnews";
 }
Пример #2
0
 @RequestMapping(value = "/news/delete/{newsId}", method = RequestMethod.GET)
 public String deleteOneNews(
     Model model, @PathVariable("newsId") int newsId, RedirectAttributes redirectAttributes) {
   newsDao.deleteAll(new int[] {newsId});
   redirectAttributes.addFlashAttribute("Msg", "删除成功!");
   return "redirect:/admin/news/list";
 }
Пример #3
0
 /**
  * 批量或删除新闻
  *
  * @param model
  * @param id
  * @return
  */
 @RequestMapping(value = "/news/delete", method = RequestMethod.POST)
 public String deleteNews(
     Model model, @RequestParam(value = "id") int id[], RedirectAttributes redirectAttributes) {
   newsDao.deleteAll(id);
   redirectAttributes.addFlashAttribute("Msg", "删除成功!");
   return "redirect:/admin/news/list";
 }
Пример #4
0
 /** Drops underlying database table using DAOs. */
 public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
   MenuDao.dropTable(db, ifExists);
   ChannelDao.dropTable(db, ifExists);
   NewsDao.dropTable(db, ifExists);
   NewsDetailDao.dropTable(db, ifExists);
   ImageDao.dropTable(db, ifExists);
   HeaderImageDao.dropTable(db, ifExists);
 }
Пример #5
0
 /** Creates underlying database table using DAOs. */
 public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
   MenuDao.createTable(db, ifNotExists);
   ChannelDao.createTable(db, ifNotExists);
   NewsDao.createTable(db, ifNotExists);
   NewsDetailDao.createTable(db, ifNotExists);
   ImageDao.createTable(db, ifNotExists);
   HeaderImageDao.createTable(db, ifNotExists);
 }
Пример #6
0
 /**
  * 分页显示资讯
  *
  * @param model
  * @param page
  * @return
  */
 @RequestMapping(value = "/news/list", method = RequestMethod.GET)
 public String listNews(Model model, String page) {
   int pageNum = page == null ? 1 : Integer.valueOf(page);
   Page<V9News> newsPage = newsDao.queryForNewsListByPage(pageNum, 15);
   model.addAttribute("page", newsPage);
   model.addAttribute("currentPage", pageNum);
   return "admin/news/newslist";
 }
Пример #7
0
  /**
   * 添加资讯
   *
   * @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";
  }
Пример #8
0
  /**
   * 编辑之后进行更新
   *
   * @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";
  }
Пример #9
0
 /**
  * 编辑资讯,获取待编辑的内容
  *
  * @param model
  * @param newsId
  * @return
  */
 @RequestMapping(value = "/news/edit/{newsId}", method = RequestMethod.GET)
 public String editNews(Model model, @PathVariable("newsId") int newsId) {
   V9News news = newsDao.getById(newsId);
   model.addAttribute("news", news);
   return "admin/news/editnews";
 }