package com.md.controller;
import com.md.entity.*;
import com.md.service.*;
import com.md.utils.MapControl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author md
* @Desc
* @date 2020/11/16 16:12
*/
@Controller
@RequestMapping("/section")
public class SectionController {
private final String LIST = "section/list";
private final String ADD = "section/add";
private final String UPDATE = "section/update";
@Autowired
private SectionService sectionService;
@Autowired
private SubjectService subjectService;
@Autowired
private ClazzService clazzService;
@Autowired
private TeacherService teacherService;
@Autowired
private CourseService courseService;
@Autowired
private StudentService studentService;
@Autowired
private ScoreService scoreService;
/**
* 插入一条新数据
* @param section
* @return
*/
@PostMapping("/create")
@ResponseBody
public Map<String, Object> create(@RequestBody Section section){
int result = sectionService.create(section);
if (result <= 0){
return MapControl.getInstance().error().getMap();
}
return MapControl.getInstance().success().getMap();
}
/**
* 根据id进行删除
* @param ids
* @return
*/
@PostMapping("/delete")
@ResponseBody
public Map<String, Object> delete(String ids){
int result = sectionService.delete(ids);
if (result <= 0){
return MapControl.getInstance().error().getMap();
}
return MapControl.getInstance().success().getMap();
}
/**
* 修改信息
* @param section
* @return
*/
@PostMapping("/update")
@ResponseBody
public Map<String, Object> update(@RequestBody Section section){
int result = sectionService.update(section);
if (result <= 0){
return MapControl.getInstance().error().getMap();
}
return MapControl.getInstance().success().getMap();
}
/**
* 获取一条详细的信息
* @param id
* @return
*/
@GetMapping("/detail/{id}")
public String detail(@PathVariable("id") Integer id, ModelMap modelMap){
Section section = sectionService.detail(id);
// 拿到所有的专业名称
List<Teacher> teacherList = teacherService.query(null);
List<Course> courseList = courseService.query(null);
modelMap.addAttribute("teacherList",teacherList);
modelMap.addAttribute("courseList",courseList);
modelMap.addAttribute("section",section);
return UPDATE;
}
/**
* 重点:查询,和专业班级一块查询
* @param section
* @return
*/
@PostMapping("/query")
@ResponseBody
public Map<String, Object> query(Section section){
List<Section> sectionList = sectionService.query(section);
// 查询所有的老师
List<Teacher> teacherList = teacherService.query(null);
// 查询所有的课程
List<Course> courseList = courseService.query(null);
// 循环赋值,两个表在一起进行查询
sectionList.forEach(entity ->{
teacherList.forEach(teacher -> {
if (entity.getTeacherId() == teacher.getId()){
entity.setTeacher(teacher);
}
});
courseList.forEach(course -> {
if (entity.getCourseId() == course.getId()){
entity.setCourse(course);
}
});
});
//
// // 总条数
Integer count = sectionService.count(section);
return MapControl.getInstance().success().put("data",sectionList).put("count",count).getMap();
}
/**
* 页面跳转
* @return
*/
@GetMapping("/list")
public String list(){
return LIST;
}
/**
* 添加的时候先查询专业,然后再查询班级,用于前端选择使用
*
* @return
*/
@GetMapping("/add")
public String add(Integer clazzId, ModelMap modelMap){
List<Teacher> teacherList = teacherService.query(null);
List<Course> courseList = courseService.query(null);
modelMap.addAttribute("teacherList",teacherList);
modelMap.addAttribute("courseList",courseList);
modelMap.addAttribute("clazzId",clazzId);
return ADD;
}
/**
* 节点树,利用ztree
* 父节点为专业,子节点为专业下面对应的具体班级
* 利用列表和map组合的形式
* 格式是根据ztree的api来写的
* [{"children":[{"name":"软件工程2020102","id":16,"parentId":17},
* {"name":"网络通信2020103","id":17,"parentId":17}],"name":"计算机应用","id":17,"parentId":0},
* {"children":[{"name":"英语2020201","id":18,"parentId":18},{"name":"日语2020202","id":19,"parentId":18},
* {"name":"文学","id":23,"parentId":18}],"name":"英语","id":18,"parentId":0},
* {"children":[{"name":"电子商务2020301","id":20,"parentId":19},{"name":"物流2020302","id":21,"parentId":19}],"name":"电子商务","id":19,"parentId":0},
* {"children":[],"name":"计算机","id":22,"parentId":0}]
* @return
*/
@PostMapping("/tree")
@ResponseBody
public List<Map<String,Object>> tree(){
List<Subject> subjectList = subjectService.query(null);
List<Clazz> clazzList = clazzService.query(null);
List<Map<String,Object>> list = new ArrayList<>();
subjectList.forEach(subject -> {
// 构造父节点
HashMap<String, Object> map = new HashMap<>();
map.put("id",subject.getId());
map.put("name",subject.getSubjectName());
map.put("parentId",0);
// 构造子节点
List<Map<String,Object>> childrenList = new ArrayList<>();
clazzList.forEach(clazz -> {
if (clazz.getSubjectId() == subject.getId()){
HashMap<String, Object> map1 = new HashMap<>();
map1.put("id",clazz.getId());
map1.put("name",clazz.getClazzName());
// 用来指定它的父节点
map1.put("parentId",subject.getId());
childrenList.add(map1);
}
});
map.put("children",childrenList);
list.add(map);
});
return list;
}
/**
* 用于页面的跳转
* @return
*/
@GetMapping("/student_section")
public String student_section(){
return "section/student_section";
}
/**
* 学生页面用于数据的显示
* @param session
* @return
*/
@PostMapping("/query_student_section")
@ResponseBody
public Map<String, Object> student_section(HttpSession session){
// 1. 获取当前登陆的信息
Student student = (Student)session.getAttribute("user");
// 2. 通过当前登录用户的id来获取课程信息,多表查询
List<Section> sections = sectionService.queryByStudent(student.getId());
for (Section section : sections) {
System.out.println(section);
}
// 3.查询班级,老师,课程的详细信息
List<Clazz> clazzList = clazzService.query(null);
List<Teacher> teacherList = teacherService.query(null);
List<Course> courseList = courseService.query(null);
// 4. 嵌套循环,设置对应的值
sections.forEach(section -> {
clazzList.forEach(clazz -> {
if (section.getClazzId() == c
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目是一个基于SSM的学生学籍管理系统设计源码,共包含432个文件,其中包括153个GIF文件、68个JavaScript文件等。系统采用了Java、JavaScript和CSS等技术,为用户提供了一个便捷的学生学籍管理解决方案。系统设计注重用户体验和响应速度,采用了模块化的开发方式,便于后续的扩展和维护。
资源推荐
资源详情
资源评论
收起资源包目录
基于SSM的学生学籍管理系统设计源码 (433个子文件)
layui.css 82KB
layui.css 71KB
font-awesome.css 37KB
font-awesome.min.css 30KB
layuimini.css 17KB
wangEditor.css 17KB
layer.css 15KB
wangEditor.min.css 15KB
layer.css 14KB
layui.mobile.css 11KB
layui.mobile.css 10KB
zyupload-1.0.0.min.css 9KB
laydate.css 8KB
laydate.css 7KB
zTreeStyle.css 6KB
default.css 4KB
step.css 1KB
code.css 1KB
code.css 1KB
public.css 942B
font.css 512B
style.css 499B
treetable.css 294B
fontawesome-webfont.eot 162KB
iconfont.eot 46KB
iconfont.eot 41KB
59.gif 10KB
59.gif 10KB
22.gif 10KB
22.gif 10KB
24.gif 8KB
24.gif 8KB
13.gif 7KB
13.gif 7KB
16.gif 7KB
16.gif 7KB
39.gif 6KB
39.gif 6KB
64.gif 6KB
64.gif 6KB
63.gif 6KB
63.gif 6KB
50.gif 6KB
50.gif 6KB
loading-0.gif 6KB
loading-0.gif 6KB
4.gif 6KB
4.gif 6KB
zTreeStandard.gif 5KB
1.gif 5KB
1.gif 5KB
42.gif 5KB
42.gif 5KB
71.gif 5KB
71.gif 5KB
21.gif 5KB
21.gif 5KB
20.gif 5KB
20.gif 5KB
29.gif 5KB
29.gif 5KB
70.gif 4KB
70.gif 4KB
5.gif 4KB
5.gif 4KB
17.gif 4KB
17.gif 4KB
27.gif 4KB
27.gif 4KB
9.gif 4KB
9.gif 4KB
44.gif 4KB
44.gif 4KB
11.gif 4KB
11.gif 4KB
8.gif 4KB
8.gif 4KB
3.gif 4KB
3.gif 4KB
23.gif 4KB
23.gif 4KB
34.gif 4KB
34.gif 4KB
41.gif 4KB
41.gif 4KB
38.gif 4KB
38.gif 4KB
65.gif 3KB
65.gif 3KB
32.gif 3KB
32.gif 3KB
45.gif 3KB
45.gif 3KB
7.gif 3KB
7.gif 3KB
12.gif 3KB
12.gif 3KB
26.gif 3KB
26.gif 3KB
60.gif 3KB
共 433 条
- 1
- 2
- 3
- 4
- 5
资源评论
沐知全栈开发
- 粉丝: 4767
- 资源: 3372
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 毕业设计基于深度强化学习的资源调度研究python源码.zip
- 2014年计算机一级Photoshop模拟试题及答案.doc
- I2C 总线控制器及读写 EEPROM实验内容,适合FPGA初学者
- (1949-2022年期间)中国教育统计年鉴
- (2005-2014期间)中国环境统计年鉴
- 2015高中信息技术excel操作题及素材(精品文档).xls
- SW3518S全协议快充USB Type-c接口电源模块硬件参考设计评估版硬件(原理图 +pcb)+封装库文件.zip
- 基于深度强化学习算法实现多星对区域目标观测的规划python源码+数据集+模型+超详细注释.zip
- RT1052+SDRAM(IS42S16160) +SIM7600CE(PCIE接口封装)控制板硬件(原理图+PCB)+封装库
- 2017大学英语四级词汇-excel-列表版(精品文档).xls
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功