package com.trade.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import com.trade.model.Custom;
import com.trade.model.Page;
import com.trade.model.Sales;
import com.trade.service.CustomService;
import com.trade.service.SalesService;
import com.trade.util.PageUtils;
@Controller
public class CustomController {
@Autowired
private CustomService customService;
@Autowired
private SalesService salesService;
@RequestMapping("queryCustomBypage.do")
public String queryCustomBypage(Custom custom,Page page,ModelMap model){
page.setMaxRows(5);
List<Custom> list = customService.queryByCustom(custom);
page.setStart(PageUtils.getPage(page.getPageNumber(), page.getTotalPage(), list.size(), page.getMaxRows()));
page.setTotalPage(PageUtils.getTotalPage(page.getPageNumber(), page.getTotalPage(), list.size(), page.getMaxRows()));
List<Custom> customList = customService.queryByList(page, custom);
model.put("page", page);
model.put("customList", customList);
model.put("custom", custom);
return "/customList";
}
@RequestMapping("queryCustomBypage1.do")
public String queryCustomBypage1(Page page,ModelMap model){
Custom custom = new Custom();
page.setMaxRows(5);
List<Custom> list = customService.queryByCustom(custom);
page.setStart(PageUtils.getPage(page.getPageNumber(), page.getTotalPage(), list.size(), page.getMaxRows()));
page.setTotalPage(PageUtils.getTotalPage(page.getPageNumber(), page.getTotalPage(), list.size(), page.getMaxRows()));
List<Custom> customList = customService.queryByList(page, custom);
model.put("page", page);
model.put("customList", customList);
model.put("custom", custom);
return "/customList";
}
@RequestMapping("addCustom.do")
public String addCustom(Custom custom,HttpServletRequest request){
customService.save(custom);
return "redirect:/queryCustomBypage.do";
}
@RequestMapping("editCustom.do")
public String editCustom(Custom custom,ModelMap model){
custom = customService.queryById(custom.getCustomid());
model.put("custom", custom);
return "/custom_edit";
}
@RequestMapping("updateCustom.do")
public String updateCustom(Custom custom,HttpServletRequest request){
customService.update(custom);
return "redirect:/queryCustomBypage.do";
}
@RequestMapping("deleteCustomByid.do")
public String deleteCustomByid(Custom custom, ModelMap model){
Sales sales = new Sales();
sales.setCustomid(custom.getCustomid());
List<Sales> salesList = salesService.queryBySales(sales);
if(salesList.size() != 0){
model.put("resultMessage", "客户有关联的销售订单,不能删除");
}else{
customService.deleteById(custom.getCustomid());
model.put("resultMessage", "删除成功");
}
return "forward:/queryCustomBypage1.do";
}
}
最近下载更多
最近浏览更多
筱洋1616 LV9
11月2日
奋斗的小蚂蚁 LV16
10月17日
微信网友_7727975685132288
10月15日
暂无贡献等级
dddding yang LV6
9月15日
yuyuhshbbja
9月15日
暂无贡献等级
vincemokea LV9
9月14日
是数据库 LV3
8月7日
一行白鹭 LV10
7月14日
ttg2025 LV3
7月12日
雷久治 LV2
6月16日

