001 | package com.controller; |
002 |
003 |
004 | import com.po.Class; |
005 | import com.po.PageInfo; |
006 | import com.service.ClassService; |
007 | import org.springframework.beans.factory.annotation.Autowired; |
008 | import org.springframework.stereotype.Controller; |
009 | import org.springframework.ui.Model; |
010 | import org.springframework.web.bind.annotation.RequestBody; |
011 | import org.springframework.web.bind.annotation.RequestMapping; |
012 | import org.springframework.web.bind.annotation.RequestMethod; |
013 | import org.springframework.web.bind.annotation.ResponseBody; |
014 |
015 | import javax.servlet.http.HttpSession; |
016 | import java.util.List; |
017 |
018 | /** |
019 | * 用户控制器类 |
020 | */ |
021 | @Controller |
022 | public class ClassController { |
023 | // 依赖注入 |
024 | @Autowired |
025 | private ClassService classService; |
026 |
027 | /** |
028 | * 分页查询 |
029 | * pageIndex 当前页码 |
030 | * pageSize 显示条数 |
031 | */ |
032 | @RequestMapping (value = "/findClass" ) |
033 | public String findClass(Integer c_classid, String c_classname, String c_counsellor, |
034 | Integer pageIndex, Integer pageSize, Model model) { |
035 | PageInfo<Class> ci = classService.findPageInfo(c_classname,c_counsellor, |
036 | c_classid,pageIndex,pageSize); |
037 | model.addAttribute( "ci" ,ci); |
038 | model.addAttribute( "c_classid" ,c_classid); |
039 | return "class_list" ; |
040 | } |
041 |
042 | /** |
043 | * 导出Excel |
044 | */ |
045 | @RequestMapping (value = "/exportclasslist" , method = RequestMethod.POST) |
046 | @ResponseBody |
047 | public List<Class> exportClass(){ |
048 | List<Class> classList = classService.getAll(); |
049 | return classList; |
050 | } |
051 |
052 | /** |
053 | * 删除学生信息 |
054 | */ |
055 | @RequestMapping ( "/deleteClass" ) |
056 | @ResponseBody |
057 | public String deleteClass(Integer c_id) { |
058 | int c = classService.deleteClass(c_id); |
059 | return "class_list" ; |
060 | } |
061 |
062 | /** |
063 | * 添加班级信息 |
064 | */ |
065 | @RequestMapping (value = "/addClass" ,method = RequestMethod.POST) |
066 | @ResponseBody |
067 | public String addClass( @RequestBody Class uclass) { |
068 | boolean flag = classService.addClass(uclass); |
069 | if (flag) return "success" ; |
070 | return "fail" ; |
071 | } |
072 |
073 | @RequestMapping ( "/findClassById" ) |
074 | public String findClassById( Integer c_id,HttpSession session) { |
075 | Class c= classService.findClassById(c_id); |
076 | session.setAttribute( "c" ,c); |
077 | return "class_edit" ; |
078 | } |
079 |
080 | /** |
081 | * 修改班级信息 |
082 | */ |
083 | @RequestMapping (value = "/updateClass" ,method = RequestMethod.POST) |
084 |
085 | public String updateClass( Class uclass) { |
086 | int c = classService.updateClass(uclass); |
087 | return "redirect:/findClass" ; |
088 | } |
089 |
090 | /** |
091 | * 班级人员信息查询 |
092 | */ |
093 | @RequestMapping (value = "/findClassStudent" ) |
094 | public String findClassStudent(Class uclass,Model model) { |
095 | List<Class> c = classService.findClassStudent(uclass); |
096 | model.addAttribute( "cs" ,c); |
097 | return "class_Studentlist" ; |
098 | } |
099 |
100 | //采用Ajax来提交表单,并返回JSON数据 |
101 | // @RequestMapping(value = "/findClassStudentlist",method = RequestMethod.POST) |
102 | // @ResponseBody |
103 | // public List<Class> findClassStudentlist(@RequestBody Class uclass){ |
104 | // List<Class> c = classService.findClassStudent(uclass); |
105 | // return c; |
106 | // } |
107 | } |

SX520886 LV6
4月24日
最平凡的代码 LV1
1月3日
zolscy LV24
2024年11月26日
chn-lei LV2
2024年7月31日
sweetlove LV20
2024年6月19日
lilitu LV6
2024年5月30日
xyzzuidaima LV3
2023年10月1日
爱吃鱼的猫Vital LV6
2023年7月26日
刘洋66666 LV1
2023年7月14日
酷酷的轲 LV10
2023年6月29日

暂无贡献等级
helloworldsbsb LV8
6月25日
SX520886 LV6
4月24日
54188ytw
3月30日
暂无贡献等级
PLVAE_514 LV2
3月10日
哪里的完整版 LV8
3月1日
wpkm2008 LV13
1月17日
最平凡的代码 LV1
1月3日
3187611758
1月1日
暂无贡献等级
xiaoaitx LV8
1月1日