You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.6 KiB
106 lines
2.6 KiB
package com.liuyanzhao.ssm.blog.controller.admin;
|
|
|
|
|
|
import com.liuyanzhao.ssm.blog.entity.Notice;
|
|
import com.liuyanzhao.ssm.blog.enums.NoticeStatus;
|
|
import com.liuyanzhao.ssm.blog.service.NoticeService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
|
|
@Controller
|
|
@RequestMapping("/admin/notice")
|
|
public class BackNoticeController {
|
|
|
|
@Autowired
|
|
private NoticeService noticeService;
|
|
|
|
/**
|
|
* 后台公告列表显示
|
|
*
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "")
|
|
public String index(Model model) {
|
|
List<Notice> noticeList = noticeService.listNotice(null);
|
|
model.addAttribute("noticeList", noticeList);
|
|
return "Admin/Notice/index";
|
|
|
|
}
|
|
|
|
/**
|
|
* 添加公告显示
|
|
*
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/insert")
|
|
public String insertNoticeView() {
|
|
return "Admin/Notice/insert";
|
|
}
|
|
|
|
/**
|
|
* 添加公告提交
|
|
*
|
|
* @param notice
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/insertSubmit", method = RequestMethod.POST)
|
|
public String insertNoticeSubmit(Notice notice) {
|
|
notice.setNoticeCreateTime(new Date());
|
|
notice.setNoticeUpdateTime(new Date());
|
|
notice.setNoticeStatus(NoticeStatus.NORMAL.getValue());
|
|
notice.setNoticeOrder(1);
|
|
noticeService.insertNotice(notice);
|
|
return "redirect:/admin/notice";
|
|
}
|
|
|
|
/**
|
|
* 删除公告
|
|
*
|
|
* @param id
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/delete/{id}")
|
|
public String deleteNotice(@PathVariable("id") Integer id) {
|
|
noticeService.deleteNotice(id);
|
|
|
|
return "redirect:/admin/notice";
|
|
}
|
|
|
|
/**
|
|
* 编辑公告页面显示
|
|
*
|
|
* @param id
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/edit/{id}")
|
|
public String editNoticeView(@PathVariable("id") Integer id, Model model) {
|
|
Notice notice = noticeService.getNoticeById(id);
|
|
model.addAttribute("notice", notice);
|
|
return "Admin/Notice/edit";
|
|
}
|
|
|
|
|
|
/**
|
|
* 编辑公告页面显示
|
|
*
|
|
* @param notice
|
|
* @return
|
|
*/
|
|
@RequestMapping(value = "/editSubmit", method = RequestMethod.POST)
|
|
public String editNoticeSubmit(Notice notice) {
|
|
notice.setNoticeUpdateTime(new Date());
|
|
noticeService.updateNotice(notice);
|
|
return "redirect:/admin/notice";
|
|
}
|
|
|
|
|
|
}
|