package com.hhtc.controller;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.hhtc.po.Page;
import com.hhtc.po.Student;
import com.hhtc.po.Teacher;
import com.hhtc.service.AdminService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Controller
public class AdminController {
@Autowired
private AdminService adminService;
@RequestMapping("/welcome")
public ModelAndView welcome(Model model) {
ModelAndView mav = new ModelAndView("admin/welcome");
return mav;
}
//学生
//学生数据分页
@RequestMapping(value = "/liststudent",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
@ResponseBody
public String liststudent(Page page) {
List<Student> list=adminService.stumanage();
page.caculatestart();
List<Student> list2=adminService.liststudent(page);
JSONObject jsonobj=new JSONObject();
jsonobj.put("code", 0);
jsonobj.put("msg", "成功");
jsonobj.put("count",list.size());
JSONArray jsonobj2=new JSONArray();
JSONObject jsonobj3=new JSONObject();
for(Student student:list2) {
jsonobj3.put("id",student.getId());
jsonobj3.put("username",student.getUsername());
jsonobj3.put("password",student.getPassword());
jsonobj3.put("stuclass",student.getStuclass());
jsonobj3.put("stuname",student.getStuname());
jsonobj3.put("stuno",student.getStuno());
jsonobj2.add(jsonobj3);
}
jsonobj.put("data", jsonobj2);
return jsonobj.toString();
}
@RequestMapping("/addstudent")
public ModelAndView addstu(Student student,Model model) {
adminService.addStudent(student);
ModelAndView mav = new ModelAndView("admin/stumanage");
return mav;
}
@RequestMapping("/delstu")
public ModelAndView delstu(String id,Model model) {
adminService.delstudnet(id);
ModelAndView mav = new ModelAndView("admin/stumanage");
return mav;
}
@RequestMapping("/updatestu")
public ModelAndView updatestu(String id,Student student,Model model) {
student.setId(Integer.parseInt(id));
adminService.updatestu(student);
ModelAndView mav = new ModelAndView("admin/stumanage");
return mav;
}
@RequestMapping(value = "/mohuname",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
@ResponseBody
public String mohuname(HttpSession session) {
@SuppressWarnings("unchecked")
List<Student> list=(List<Student>) session.getAttribute("list");
JSONObject jsonobj=new JSONObject();
jsonobj.put("code", 0);
jsonobj.put("msg", "成功");
jsonobj.put("count",list.size());
JSONArray jsonobj2=new JSONArray();
JSONObject jsonobj3=new JSONObject();
for(Student student:list) {
jsonobj3.put("id",student.getId());
jsonobj3.put("username",student.getUsername());
jsonobj3.put("password",student.getPassword());
jsonobj3.put("stuclass",student.getStuclass());
jsonobj3.put("stuname",student.getStuname());
jsonobj3.put("stuno",student.getStuno());
jsonobj2.add(jsonobj3);
}
jsonobj.put("data", jsonobj2);
return jsonobj.toString();
}
//老师
@RequestMapping("/addtea")
public ModelAndView addteacher(Teacher teacher,Model model) {
adminService.addteacher(teacher);
ModelAndView mav = new ModelAndView("admin/teamanage");
return mav;
}
@RequestMapping(value = "/teamanage",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
@ResponseBody
public String teamanage(Model model) {
List<Teacher> list=adminService.teamanage();
JSONObject jsonobj=new JSONObject();
jsonobj.put("code", 0);
jsonobj.put("msg", "成功");
jsonobj.put("count",list.size());
JSONArray jsonobj2=new JSONArray();
JSONObject jsonobj3=new JSONObject();
for(Teacher teacher:list) {
jsonobj3.put("id",teacher.getId());
jsonobj3.put("username",teacher.getUsername());
jsonobj3.put("password",teacher.getPassword());
jsonobj3.put("teaname",teacher.getTeaname());
jsonobj2.add(jsonobj3);
}
jsonobj.put("data", jsonobj2);
return jsonobj.toString();
}
@RequestMapping("/deltea")
public ModelAndView deltea(String id,Model model) {
adminService.delteacher(id);
ModelAndView mav = new ModelAndView("admin/teamanage");
return mav;
}
@RequestMapping("/updatetea")
public ModelAndView updatetea(String id,Teacher teacher,Model model) {
teacher.setId(Integer.parseInt(id));
adminService.updatetea(teacher);
ModelAndView mav = new ModelAndView("admin/teamanage");
return mav;
}
@RequestMapping(value = "/mohunametea",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
@ResponseBody
public String mohunametea(HttpSession session) {
@SuppressWarnings("unchecked")
List<Teacher> list=(List<Teacher>) session.getAttribute("tealist");
JSONObject jsonobj=new JSONObject();
jsonobj.put("code", 0);
jsonobj.put("msg", "成功");
jsonobj.put("count",list.size());
JSONArray jsonobj2=new JSONArray();
JSONObject jsonobj3=new JSONObject();
for(Teacher teacher:list) {
jsonobj3.put("id",teacher.getId());
jsonobj3.put("username",teacher.getUsername());
jsonobj3.put("password",teacher.getPassword());
jsonobj3.put("teaname",teacher.getTeaname());
jsonobj2.add(jsonobj3);
}
jsonobj.put("data", jsonobj2);
return jsonobj.toString();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
SSM(spring+spring MVC+mybatis)学生成绩管理系统源码 (243个子文件)
AdminController.class 7KB
TeachController.class 4KB
HrefController.class 3KB
LoginController.class 3KB
AdminService.class 3KB
Student.class 2KB
StudentController.class 2KB
CustomerController.class 1KB
Customer.class 1KB
LoginService.class 1KB
Teacher.class 1KB
AdminDao.class 979B
GeneraService.class 971B
Page.class 922B
Admin.class 913B
CustomerServiceImpl.class 873B
LoginDao.class 335B
GeneraDao.class 227B
CustomerService.class 207B
CustomerDao.class 195B
.classpath 1KB
org.eclipse.wst.common.component 461B
org.eclipse.wst.jsdt.ui.superType.container 49B
layui.css 73KB
layer.css 14KB
xadmin.css 10KB
layui.mobile.css 10KB
laydate.css 7KB
code.css 1KB
font.css 505B
iconfont.eot 48KB
iconfont.eot 46KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
48.gif 3KB
43.gif 3KB
30.gif 2KB
61.gif 2KB
33.gif 2KB
69.gif 2KB
14.gif 2KB
47.gif 2KB
36.gif 2KB
49.gif 2KB
58.gif 2KB
6.gif 2KB
54.gif 2KB
53.gif 2KB
56.gif 2KB
62.gif 2KB
31.gif 2KB
55.gif 2KB
共 243 条
- 1
- 2
- 3
资源评论
沐路
- 粉丝: 3
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于SimPy和贝叶斯优化的流程仿真系统.zip
- (源码)基于Java Web的个人信息管理系统.zip
- (源码)基于C++和OTL4的PostgreSQL数据库连接系统.zip
- (源码)基于ESP32和AWS IoT Core的室内温湿度监测系统.zip
- (源码)基于Arduino的I2C协议交通灯模拟系统.zip
- coco.names 文件
- (源码)基于Spring Boot和Vue的房屋租赁管理系统.zip
- (源码)基于Android的饭店点菜系统.zip
- (源码)基于Android平台的权限管理系统.zip
- (源码)基于CC++和wxWidgets框架的LEGO模型火车控制系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功