首页>代码>基于SSM框架的B/S项目开发—学校班级回忆录网站管理系统>/ClassManage/src/com/demo/controller/NoticeController.java
package com.demo.controller;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.demo.entity.Notice;
import com.demo.services.INoticeService;
import com.demo.services.IStudentService;
import com.demo.util.JsonView;

@Controller
@Scope("prototype")
@RequestMapping("/notice.do")

public class NoticeController {
	@Autowired
	private INoticeService service;
	@Autowired
	private IStudentService Sservice;

	@RequestMapping(params = "action=notice")
	public ModelAndView notice(HttpServletRequest request,ModelMap map,int login_id) throws IOException{
		 ArrayList<Notice> noticeLists =  service.findAllNotice();
		 map.put("noticeList", noticeLists);  
		 int manager=Sservice.findStudentById(login_id).getManager();
		 map.put("manager", manager);
		 map.put("login_id", login_id);
	     return new ModelAndView("notice");  
	}
	
	@RequestMapping(params = "action=toAdd")
	public ModelAndView toAdd(HttpServletRequest request,ModelMap map,int login_id) throws IOException{
		System.out.println("toAdd");
		 map.put("login_id", login_id);
	     return new ModelAndView("addNotice");  
	}
	
	@RequestMapping(params = "action=toModify")
	public ModelAndView toModify(HttpServletRequest request,ModelMap map,int login_id,Notice notice) throws IOException{
		System.out.println("toModify");
		 notice=service.findAllNoticeByid(login_id);
		map.put("notice", notice);
	    return new ModelAndView("modify_Notice");  
	}
	
	@RequestMapping(params = "action=addOneNotice")
	public JsonView addOneStudent(HttpServletRequest request,ModelMap model,Notice notice)throws Exception{
		System.out.println("add start");
		JsonView view =new JsonView();
		try {
			java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
			java.util.Date currentTime = new java.util.Date();//得到当前系统时间  
			String str_date1 = formatter.format(currentTime); //将日期时间格式化
			notice.setCreateTime(str_date1.toString());
			service.addOneNotice( notice);
			System.out.println("*****addNotice ok******");
			view.setProperty("result", "ok");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			view.setProperty("result","error");
		}
		return view;
		
	}
	
	@RequestMapping(params = "action=modifyNotice")
	public JsonView modifyOne(HttpServletRequest request,ModelMap model,Notice notice)throws Exception{
		JsonView view =new JsonView();
		try {
			service.modifyNotice(notice);
			System.out.println("*****modifyNotice ok******");
			view.setProperty("result", "ok");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			view.setProperty("result","error");
		}
		return view;
		
	}
	
	@RequestMapping(params = "action=deleteNotice")
	public JsonView deleteAllNotice(HttpServletRequest request,int id)throws Exception{
		System.out.println("id"+id);
		JsonView view = new JsonView();
		try{
			service.deleteNotice(id);
			System.out.println("*****deleteNotice ok******");
			view.setProperty("result", "ok");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			view.setProperty("result","error");
		}
		return view;
	}
	
}
最近下载更多
hjjhhhh  LV4 2023年2月28日
asd521531  LV9 2022年12月14日
lilong007  LV20 2022年10月21日
akbar2020  LV9 2022年8月27日
34385135  LV2 2022年4月19日
找找找找找  LV4 2022年3月17日
qlpqlp  LV7 2022年3月13日
wanglinddad  LV54 2022年2月17日
曹思辰  LV6 2022年1月17日
Lin一点  LV4 2021年12月30日
最近浏览更多
WaZiN7  LV6 9小时前
WBelong  LV7 2023年12月27日
钝感力  LV1 2023年10月28日
iloveyou66  LV2 2023年9月3日
cunbie  LV4 2023年6月13日
yangbulx  LV3 2023年6月7日
6389181  LV7 2023年6月1日
一口深井  LV1 2023年5月23日
苏拉德666  LV4 2023年5月15日
可是不知道么  LV23 2023年3月25日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友