package com.wjh.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.ResponseBody;
import com.wjh.dao.ConferenceMapper;
import com.wjh.dao.TowerMapper;
import com.wjh.dao.model.Conference;
import com.wjh.dao.model.Tower;
@Controller
public class ConferenceController {
@Autowired
ConferenceMapper cm;
@Autowired
TowerMapper tm;
//會議室列表查詢
@RequestMapping("list")
public String list(Model model) {
List<Conference> list = cm.listConference();
model.addAttribute("list", list);
List<Tower> Towerlist = tm.selectByExample(null);
model.addAttribute("tower", Towerlist);
return "list";
}
//會議室列表查詢
@RequestMapping("toadd")
public String toadd(Model model) {
List<Tower> Towerlist = tm.selectByExample(null);
model.addAttribute("tower", Towerlist);
return "add";
}
//會議室列表查詢
@RequestMapping("add")
@ResponseBody
public int add(Conference conf) {
cm.add(conf);
return 1;
}
//會議室列表查詢
@RequestMapping("toupdate")
public String toupdate(Model model,int id) {
Conference confList = cm.confList(id);
List<Tower> list = tm.selectByExample(null);
model.addAttribute("tower", list);
model.addAttribute("conf", confList);
return "update";
}
//會議室列表查詢
@RequestMapping("update")
@ResponseBody
public int update(Conference conf) {
cm.update(conf);
return 1;
}
//會議室列表刪除
@RequestMapping("del")
@ResponseBody
public int del(int id) {
cm.deleteByPrimaryKey(id);
return 1;
}
//會議室列表批刪
@ResponseBody
@RequestMapping("dels")
public int dels(String id) {
cm.dele(id);
return 1;
}
}