首页>代码>基于SSM实现的仓库管理系统>/源代码/TradeManage/src/com/trade/controller/CustomController.java
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";
	}
}
最近下载更多
bankroll  LV5 2024年12月16日
WanLiuYun  LV12 2024年11月11日
zouzou123  LV3 2024年10月10日
月灬兆离  LV1 2024年9月9日
初心不负丶方得始终  LV11 2024年8月22日
aholian  LV2 2024年7月1日
血羽如风  LV6 2024年6月17日
sweetlove  LV20 2024年6月13日
wubinbin  LV11 2024年5月22日
不一样的心情  LV5 2024年5月21日
最近浏览更多
雷久治  LV2 6月16日
ES大兵  LV11 6月12日
11999333  LV3 6月9日
浅影阿 6月6日
暂无贡献等级
luhong  LV4 6月5日
梁小贤  LV1 5月22日
1139975809 5月18日
暂无贡献等级
ljy050925 5月13日
暂无贡献等级
小浩030629  LV1 5月8日
无念27149 2024年12月24日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友