首页>代码>SSM(spring+spring MVC+mybatis)学生成绩管理系统>/ssm/src/com/hhtc/controller/TeachController.java
package com.hhtc.controller;
import java.util.List;

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 com.hhtc.service.GeneraService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Controller
public class TeachController {
	@Autowired
	private AdminService adminService;
	@Autowired
	private GeneraService generaService;
	@RequestMapping("/hrefaddscore")
	public ModelAndView hrefaddscore(Model model) {
		ModelAndView mav = new ModelAndView("teacher/addscore");
		return mav;
	}
	@RequestMapping("/hrefupdatepw")
	public ModelAndView hrefupdatepw(Model model) {
		ModelAndView mav = new ModelAndView("teacher/updatepw");
		return mav;
	}
	@RequestMapping(value = "/stuscore",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
	@ResponseBody
	public String stuscoree(Page page,Model model) {
		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("stuno", student.getStuno());
	    	jsonobj3.put("stuname",student.getStuname());
	    	jsonobj3.put("stuclass",student.getStuclass());
	    	jsonobj3.put("score",student.getScore());    	
	    	jsonobj2.add(jsonobj3);
	    }
	    jsonobj.put("data", jsonobj2);		
		return jsonobj.toString();
	}
	@RequestMapping("/updatepw")
	public ModelAndView updatepw(Teacher teacher,Model model) {
		this.generaService.updatepw(teacher);
		ModelAndView mav = new ModelAndView("success");
		return mav;
	}
	@RequestMapping("/updatescore")
	public ModelAndView updatescore(String id,String score,Model model) {
		Student student=new Student();
		student.setId(Integer.parseInt(id));
		student.setScore(score);
		this.generaService.updatescore(student);
		ModelAndView mav = new ModelAndView("teacher/addscore");
		return mav;
	}
}
最近下载更多
pangzhihui  LV12 4月17日
自由吃柚子  LV2 3月26日
3090754224  LV2 1月7日
李朝磊  LV18 2023年12月30日
xiongwei11231  LV8 2023年12月12日
liuxiao2  LV16 2023年11月7日
蹇金金  LV7 2023年11月6日
wwewww  LV4 2023年11月3日
wcheng  LV2 2023年10月18日
李亮  LV19 2023年8月28日
最近浏览更多
fkjafjkkfo  LV2 前天
自由吃柚子  LV2 3月26日
XJH939  LV1 3月14日
xinnnnn  LV1 2月26日
admin_z  LV22 1月29日
周青松5  LV2 1月15日
3090754224  LV2 1月7日
minjing123  LV8 1月4日
李朝磊  LV18 2023年12月30日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友