2020-08-27

layui 复选框选中学员推送给老师 controller代码

当前页面加载时传过去数据,多条件查询

@ResponseBody
	@RequestMapping("queryalllists")
	public Object queryalllists(Model model,Integer page,Integer limit,HttpServletRequest request,String username,Integer times) {
	//根据用户名字查询出teacher表中的id 再根据id查询出student
		CookieUtils cookieUtils = new CookieUtils();
		String teaid =(String) CookieUtils.getCookieValue(request, "teaid");
		long ttid = Long.parseLong(teaid);
		List<EduTeacher> tlist = eduTeacherMapper.querytyteacherByid(ttid);
		if(tlist.size()==0) {
			Map<String, Object> json = new HashMap<String, Object>();
			json.put("code", 0);
			json.put("msg", "");
			json.put("count",0);
			json.put("data", null);
			return json;
		}
		PageHelper.startPage(page, limit);
		List<Student> mm=new ArrayList<Student>();
		if(times==-1)
		{
			 mm = tystudentMapper.queryStudentByusername(ttid,username);
		}
		else{
			mm=tystudentMapper.queryStudentBytime(ttid, username, times);
		}
		PageInfo<Student> info=new PageInfo<Student>(mm);
		Map<String, Object> json = new HashMap<String, Object>();
		json.put("code", 0);
		json.put("msg", "");
		json.put("count",info.getTotal());
		json.put("data", info.getList());		
		return json;
	}

点击推送 调用存入cookie的老师id

	//推送
	@RequestMapping("/push")
	@ResponseBody
	public Object queryTyteacher(HttpServletRequest request,Integer page,Integer limit) {
		//点击推送时弹框
		//这是自己的ccookie方法
		CookieUtils cookieUtils = new CookieUtils();
		String  uname =(String) cookieUtils.getCookieValue(request, "uname");
		String teaid =(String) CookieUtils.getCookieValue(request, "teaid");
		long ttid = Long.parseLong(teaid);
		//根据父类id查询出它下面的子类tlist.get(0).getTid()
		PageHelper.startPage(page, limit);
		List<Tyteacher> tulist = tyteacherMapper.querytyeatherBytidAndtype(ttid, ttid);
		PageInfo<Tyteacher> info=new PageInfo<Tyteacher>(tulist);
		Map<String, Object> json = new HashMap<String, Object>();
		json.put("code", 0);
		json.put("msg", "");
		json.put("count",info.getTotal());
		json.put("data", info.getList());		
		return json;
	}

添加

@ResponseBody
	@RequestMapping("/insetteacherstudent")
	public Integer insetteacherstudent( String stuid,String teachid) {
	   //学员推送
		Integer ids=null;
		if(stuid!=null&&stuid!=""&&teachid!=null&&teachid!="") {
			String[] stuidarr=stuid.split(",");
			String[] teacheidarr=teachid.split(",");
		for (int i = 0; i < teacheidarr.length; i++) {   
			for (int j = 0; j < stuidarr.length; j++) {
				//如果已加入
				List<Tyteacherstudent> querylist = tyteacherstudentMapper.queryteacherstudentBystuid(stuidarr[j]);
				if(querylist.size()>0) {
					return 0;
				}
				else{
					//推送成功之后加入中间表
					ids = tyteacherstudentMapper.addteacherstudentBystuidAndteachid(stuidarr[j], teacheidarr[i]);
					//根据学生id查teachid
					List<Tyteacherstudent> tslist = tyteacherstudentMapper.queryteacherstudentBystuid(stuidarr[j]);
					long teach_id = tslist.get(0).getTeach_id();
					//根据teachid查询出分配到哪个老师下面 并添加到student表
					List<Tyteacher> teacherlist = tyteacherMapper.querytyteacherByiid(teach_id);
					String name = teacherlist.get(0).getTname();
					Student stu = new Student();
					stu.setId(Long.parseLong(stuidarr[j]));
					stu.setPush_teacher(name);
					tystudentMapper.updateByStudent(stu);
				}	
			}
		}
	}
	 return ids;
	}
	
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值