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"; } }
最近下载更多
王愉悦 LV2
4月30日
genyuan2014 LV6
4月27日
adminstort LV3
4月13日
ssw11111 LV2
4月9日
微信网友_6512020493586432 LV2
4月8日
wanglinddad LV55
4月6日
xiongM LV4
4月4日
wangsheng818 LV4
4月3日
ifeng11111 LV1
4月1日
2131234536546 LV7
3月31日
最近浏览更多
李俊雄 LV3
昨天
多吃多占 LV12
5月6日
l193512
4月30日
暂无贡献等级
王愉悦 LV2
4月30日
kenhomeliu LV29
4月30日
微信网友_6972105052114944
4月29日
暂无贡献等级
dubersky LV1
4月29日
xunzhen245 LV1
4月28日
genyuan2014 LV6
4月27日
getset LV8
4月24日