多对一的增删改查-controller

package com.lzl.controller;

import java.util.List;


import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageInfo;
import com.lzl.pojo.Company;
import com.lzl.pojo.Pantent;
import com.lzl.service.PantentService;

@Controller
public class PantentController {

@Reference
PantentService service;

@RequestMapping("list")
public String list(Model m,@RequestParam(defaultValue = "1")Integer pageNum,@RequestParam(defaultValue = "5")Integer pageSize,Pantent pantent) {

PageInfo<Pantent> info = service.list(pageNum, pageSize,pantent);
Pantent pz = service.zong();

m.addAttribute("info", info);
m.addAttribute("pz", pz);
m.addAttribute("pantent", pantent);

return "list";
}

@RequestMapping("toadd")
public String toadd(Model m) {


List<Company> coms = service.coms();
m.addAttribute("coms", coms);

return "add";
}
@RequestMapping("add")
public String add(Pantent pantent) {
service.add(pantent);//执行添加

return "redirect:list";
}

@RequestMapping("tongji")
public String tongji(Model m) {
List<Pantent> list = service.tongji();
m.addAttribute("list", list);

return "tongji";
}
@RequestMapping("toupdate")
public String toupdate(Model m,Integer id) {
System.out.println(id);
Pantent pantent = service.selectOne(id);//查询单个数据
List<Company> coms = service.coms();//查询
m.addAttribute("coms", coms);
m.addAttribute("pantent", pantent);
return "update";

}
@RequestMapping("update")
public String update(Pantent pantent) {
service.update(pantent);//修改

return "redirect:list";
}

}

猜你喜欢

转载自www.cnblogs.com/liuzhaolong/p/12921351.html