基于javaweb+mysql的springboot家政服务网站系统设计和实现(java+springboot+ssm+mysql+jsp+maven)

基于javaweb+mysql的springboot家政服务网站系统设计和实现(java+springboot+ssm+mysql+jsp+maven)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot家政服务网站系统设计和实现(java+springboot+ssm+mysql+jsp+maven)

一、项目简述

本系统主要实现的功能有: 项目功能较多,包括用户的注册登录,家政0员务的查看, 分类,预订,以及支付,订单信息的查看,后台管理员的 人员管理,服务类别管理,订单分配,数据统计,家政维 护等等功能。

二、项目运行

1运行环境:

环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持) 项目技术: Springboot+ SpringMVC + MyBatis + ThymeLeaf + JavaScript + JQuery + Ajax + maven

        this.getRequest().setAttribute("goods", goods);
        Topic topic = new Topic();
        topic.setGoodsid(id);
        List<Topic> topicList = this.topicService.getTopicByCond(topic);
        this.getRequest().setAttribute("topicList", topicList);
        this.getRequest().setAttribute("tnum", topicList.size());
        return "users/detail";
    }
}

@Controller
@RequestMapping("/ali")
public class AliPayController {
    @Autowired
    private Orders order;
    @Autowired
    private OrdersService ordersService;
    private String serverUrl = "https://openapi.alipaydev.com/gateway.do"; // 支付宝的网关地址
    private String APP_ID = "2016101000656227";
    private String APP_PRIVATE_KEY = "MIIEuwIBADANBgkqhkiG9w0BAQEFAASCBKUwggShAgEAAoIBAQCQ0XDs0oV54+TwyNJkCZxoZa/bXmK0SvIC9+reKRJRcUqSpe9JpTBD2E2UNstBPxJlreUhJrT23K2IsvnMixaBpvQ6CI82k0iCKanYqkQ/gyNeWvCjRRogdr9zbzxHiB1pYAqRzrtp0rZ0eN+6RSuZ0qsPtcSaAY+6wEqQRRvxHiXvJunnF+tln4UgO+mUlxWdskmlML1bjqv8hXvLDotytzVEx3A0TiSUQWBUNAToqRAtx8aAaM/bPTLMFOmRHVQ6Kxb+FaByq2WqI6+lZXmVZuvhUiEzN2ThyDE+uFdEF8OvIOabgOsJViUgzUk8WHR/G1T29PIvKQbJAxLpaVBJAgMBAAECggEACE1JaPoklrk+zaLllMCMS9vQegXuKKHHP+5Qc43tM+gHu2Jx1kn2+1yyDdYaTtI7zsJqST070I8UD6sa8OPkVWhpxc3pz9ofpP6YcwhHw1BUPbt+4g07EzNbhFWTIhKmhPzxfixYyBdBSGoJgVcnybiu/8aOz7lZMP6HB8A+etMGa1FldB37pSF/4y4FpNLCLEECtZ9OjhqOxwIiaR2WGlqqNkTYlHO8TKsUmfajyORhuiLfvU/vpv5XGeBXh4I5CzFJAHx1McUfMeVx7+rHgukQoQq+RjsCJCTXMk30D0HNgbd9CFm7aaFGUqUkV9Abnb4uY04O5nXg3eR+0FIqdQKBgQDWd2VH2VS8xiXXxL3EUUFWHbFQqQKReEZz3PFWvf0zHaSSTzgl+YZUUo5XbUL+qTgfdU/6pR4s3W2OW8yNKQIJ6Xxso4DKwPFkS2Z25yscEQTZS/RYEP4e2QE8kHeHlslzF+e4q8/wAaENF5pDNJm/jrBjiblUi4+sFJgjvyEd+wKBgQCs3Rej/qyCBJWc9SdHnakVN/fGuSFH7u0f9qIEQkjulXr81vYN+VhasEOKS8WAHPOFgHwHiLqGLFnSn1Y72J8rsTaomQixkJbZB7/j8/DzLCvdbWlHmjK09HkMlnZYE+7vhlM5zbStHzygY3PTM4ck1ZWoWRnw3sJaG2t/1njLiwJ/L8BlzJmXRHDZ/DDSD+QHqCT0VgFLkRg2l5WaJrYmqjrvaaQ53DqyrhOzncO2Jv2GgXqdVDFvho3G1uuZn9SBn7NdANNm2b4cATjIl7Dg6F7htYAz52fhLP0kSVfhRU9Ni1LHRVb79XRnZ4LZ1hzgHsamf4MqwKhSVP5A4bSsqwKBgQCgjxsOL9Z7TVbJ2ssJMd+C3eE+q2XGMp39Ok9yNT8Ym68IeYFBqX/vfBi/s3FWdY2bSqPpO45EYZ1sjKLEI4h0RL3IC5yPkQULwK7zQ/lhZH25xY4r+4VtnkVw87AoTxt3TwSug+p1grYFI1rJqOq1w8yl+Vym5cEPgLhwnPzF0QKBgAJkpELf0KjazwUdo4dkiLsX9VDYROfNudfn2cps9yzteb6gW9q+wRuXLfc86Vtej+ctl8G8XmbQv1B/Xr7xAhoNZhthtbbazw1mBsaiEFOKJdFTwytwitZimyeEqAbf6jCtMv9Km9XiO3+KUZJLzOEuaYFDP6Ai8Gai0U4aFqYi";
    private String FORMAT = "JSON"; // 数据传输的格式
    private String CHARSET = "utf-8"; // 数据的编码
    private String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArC+n7jVK2EtqhtynNGDxdFVYrwT8jP2gu3VsRu7CSfdsAfuDTrwmeuKeaQCBQ19gSAslwTzfip8ebIsiA6jnhRrpNbd+c3FxBxHR6tB6pG2tvBPB6EtQAStRTjPWkiTF1laTbcynuKsiW8X4dgX92PxPfW/Fx8bHgDgxrEBhrURUtZHuQh6VBdUyLHAnpVKU+zQ06p+h4H4O/Ch+fv0KAzAHe9Z1XVot2hswa+UJM1H2am5y2DU5K1gw3s8anGoOMnc4tFsXW4yDEZQrspxbhtLiU7tWc4fvd4GEQ7Ye7OoPIWtUZq1iyra8TMtT2KIhyYRqj+1K21HyMsJkmf0cvwIDAQAB"; // 支付宝的公钥
    private String SINGTYP = "RSA2"; // 签名算法

	public String getOrdersById(String id) {
		Orders orders = this.ordersService.getOrdersById(id);
		this.getRequest().setAttribute("orders", orders);
		List<Users> usersList = this.usersService.getAllUsers();
		this.getRequest().setAttribute("usersList", usersList);
		return "admin/editorders";
	}

	public OrdersService getOrdersService() {
		return ordersService;
	}

	public void setOrdersService(OrdersService ordersService) {
		this.ordersService = ordersService;
	}

}

//定义为控制器
@Controller
// 设置路径
		fileName = name + "." + type;
		File targetFile = new File(path, fileName);
		if (!targetFile.exists()) {
			targetFile.mkdirs();
		}

		// 保存
		try {
			file.transferTo(targetFile);
		} catch (Exception e) {
			e.printStackTrace();
		}
		model.addAttribute("imageFileName", fileName);
		return "savefile";
	}
}
//package com.interceptor;
//
//
//
//@Component
//public class LoginInterceptor implements HandlerInterceptor {
//    @Autowired
//    private UsersService usersService;
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        HttpSession session = request.getSession();
//        String userid= (String) session.getAttribute("userid");
//        Users user=usersService.getUsersById(userid);
//        System.out.println(user);
//        if (user==null){
//            return false;
//        }else {
//            return true;
//        }
//    }
//
//
//    @Override
//    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//        System.out.println("postHandle...");
//    }
//
		File targetFile = new File(path, fileName);
		if (!targetFile.exists()) {
			targetFile.mkdirs();
		}

		// 保存
		try {
			file.transferTo(targetFile);
		} catch (Exception e) {
			e.printStackTrace();
		}
		model.addAttribute("imageFileName", fileName);
		return "savefile";
	}
}
//package com.interceptor;
//
//
//
//@Component
//public class LoginInterceptor implements HandlerInterceptor {
//    @Autowired
//    private UsersService usersService;
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        HttpSession session = request.getSession();
//        String userid= (String) session.getAttribute("userid");
//        Users user=usersService.getUsersById(userid);
//        System.out.println(user);
//        if (user==null){
//            return false;
//        }else {
//            return true;
//        }
//    }
//
//
//    @Override
//    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//        System.out.println("postHandle...");
//    }

//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/admin", produces = "text/plain;charset=utf-8")
public class AdminController extends BaseController {
	// 注入Service 由于标签的存在 所以不需要getter setter
	@Autowired
	@Resource
	private AdminService adminService;

	// 管理员登录 1 验证用户名是否存在 2 验证密码是否正确
	@RequestMapping("/login")
	public String login() {
		String username = this.getRequest().getParameter("username");
		String password = this.getRequest().getParameter("password");
		Admin adminpojo = new Admin();
		adminpojo.setUsername(username);
		List<Admin> adminlist = this.adminService.getAdminByCond(adminpojo);
		if (adminlist.size() == 0) {
			this.getRequest().setAttribute("message", "用户名不存在");
			return "admin/index";
		} else {
			Admin admin = adminlist.get(0);
			if (password.equals(admin.getPassword())) {
				this.getSession().setAttribute("adminid", admin.getAdminid());
				this.getSession().setAttribute("adminname", admin.getUsername());
				this.getSession().setAttribute("realname", admin.getRealname());
				this.getSession().setAttribute("role", admin.getRole());
			} else {
				this.getRequest().setAttribute("message", "密码错误");
				return "admin/index";
			}
		}
		return "admin/main";
	}

	// 修改密码
	@RequestMapping("/editpwd")
	public String editpwd() {
		String adminid = (String) this.getSession().getAttribute("adminid");
		String password = this.getRequest().getParameter("password");
		String repassword = this.getRequest().getParameter("repassword");
		Admin admin = this.adminService.getAdminById(adminid);
		if (password.equals(admin.getPassword())) {
			admin.setPassword(repassword);
			this.adminService.updateAdmin(admin);
		} else {
			this.getRequest().setAttribute("message", "旧密码错误");
		}
		return "admin/editpwd";
	}
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("上一页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) - 1) + "" + path + "\">上一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("下一页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) + 1) + "" + path + "\">下一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("尾页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=" + (maxPage - 1) + "" + path + "\">尾页</a>");
		}
		String html = buffer.toString();
		request.setAttribute("html", html);
		request.setAttribute(name + "List", objList);
	}

	public static void getUserPage(List<?> list, String name, String actionName, int pageSize, String number, HttpServletRequest request) {
		StringBuffer buffer = new StringBuffer();
		String path = "";
		String action = actionName + "";
		List<Object> objList = new ArrayList<Object>();
		int pageNumber = list.size();
		int maxPage = pageNumber;
		if (maxPage % pageSize == 0) {
			maxPage = maxPage / pageSize;
		} else {
			maxPage = maxPage / pageSize + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * pageSize;
		int over = (Integer.parseInt(number) + 1) * pageSize;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Object obj = list.get(i);
			objList.add(obj);
		}
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
	@RequestMapping("/queryItemsByCond")
	public String queryItemsByCond(String cond, String name, String number) {
		Items items = new Items();
		if (cond != null) {
			if ("ordercode".equals(cond)) {
				items.setOrdercode(name);
			}
			if ("goodsid".equals(cond)) {
				items.setGoodsid(name);
			}
			if ("price".equals(cond)) {
				items.setPrice(name);
			}
		}

		List<String> nameList = new ArrayList<String>();
		List<String> valueList = new ArrayList<String>();
		nameList.add(cond);
		valueList.add(name);
		PageHelper.getPage(this.itemsService.getItemsByLike(items), "items", nameList, valueList, 10, number, this.getRequest(), "query");
		name = null;
		cond = null;
		return "admin/queryitems";
	}

	// 按主键查询数据
	@RequestMapping("/getItemsById")
	public String getItemsById(String id) {
		Items items = this.itemsService.getItemsById(id);
		this.getRequest().setAttribute("items", items);
		List<Goods> goodsList = this.goodsService.getAllGoods();
		this.getRequest().setAttribute("goodsList", goodsList);
		return "admin/edititems";
	}

	public ItemsService getItemsService() {
		return itemsService;
	}

	public void setItemsService(ItemsService itemsService) {
		this.itemsService = itemsService;
	}

}

				goods.setImage(name);
			}
			if ("cateid".equals(cond)) {
				goods.setCateid(name);
			}
			if ("price".equals(cond)) {
				goods.setPrice(name);
			}
			if ("addtime".equals(cond)) {
				goods.setAddtime(name);
			}
			if ("hits".equals(cond)) {
				goods.setHits(name);
			}
			if ("sellnum".equals(cond)) {
				goods.setSellnum(name);
			}
			if ("contents".equals(cond)) {
				goods.setContents(name);
			}
		}

		List<String> nameList = new ArrayList<String>();
		List<String> valueList = new ArrayList<String>();
		nameList.add(cond);
		valueList.add(name);
		PageHelper.getPage(this.goodsService.getGoodsByLike(goods), "goods", nameList, valueList, 10, number, this.getRequest(), "query");
		name = null;
		cond = null;
		return "admin/querygoods";
	}

	// 按主键查询数据
	@RequestMapping("/getGoodsById")
	public String getGoodsById(String id) {
		Goods goods = this.goodsService.getGoodsById(id);
		this.getRequest().setAttribute("goods", goods);
		List<Cate> cateList = this.cateService.getAllCate();
		this.getRequest().setAttribute("cateList", cateList);
		return "admin/editgoods";
	}

//	@GetMapping("/findPage")
//	public String getByPage(HttpServletRequest request){
//		String pageNow= request.getParameter("pageNow");
//		PageInfo<Goods> pageInfo=goodsService.findAll(Integer.valueOf(pageNow),3);
//		request.setAttribute("pageInfo",pageInfo);
//		return "users/list";
//	}

	public GoodsService getGoodsService() {
		return goodsService;
	}
                details.setItemsid(VeDate.getStringDatex() + (Math.random() * 9 + 1) * 1000);
                details.setGoodsid(cart.getGoodsid());
                details.setOrdercode(ordercode);
                details.setPrice(cart.getPrice());
                Goods goods = this.goodsService.getGoodsById(cart.getGoodsid());
                details.setGoodsname(goods.getGoodsname());
                this.itemsService.insertItems(details);
                goods.setSellnum("" + (Integer.parseInt(goods.getSellnum()) + 1));
                this.goodsService.updateGoods(goods);
                total += Double.parseDouble(cart.getPrice());
                this.cartService.deleteCart(cart.getCartid());
            }
            String workdate = this.getRequest().getParameter("workdate");
            String enddate = this.getRequest().getParameter("enddate");
            String worktime = this.getRequest().getParameter("worktime");
            long days = VeDate.getDays(enddate, workdate) + 1;
            Orders orders = new Orders();
            orders.setAddress(getRequest().getParameter("address"));
            orders.setAddtime(VeDate.getStringDateShort());
            orders.setContact(getRequest().getParameter("contact"));
            orders.setOrdercode(ordercode);
            orders.setStatus("已付款");
            orders.setTotal("" + VeDate.getDouble(total));
            orders.setUsersid(userid);
            orders.setEnddate(enddate);
            orders.setWorkdate(workdate);
            orders.setWorktime(worktime);
            this.ordersService.insertOrders(orders);
        }
        return "redirect:/index/showOrders";
    }

    // 查看订购
    @RequestMapping("/showOrders")
    public String showOrders(String number) {
        this.front();
        if (this.getSession().getAttribute("userid") == null) {
            return "redirect:/index/preLogin";
        }
        String userid = (String) this.getSession().getAttribute("userid");
        Orders orders = new Orders();
        orders.setUsersid(userid);
        List<Orders> ordersList = new ArrayList<Orders>();
        List<Orders> tempList = this.ordersService.getOrdersByCond(orders);
        int pageNumber = tempList.size();
        int maxPage = pageNumber;
        if (maxPage % 10 == 0) {
            maxPage = maxPage / 10;
        } else {
            maxPage = maxPage / 10 + 1;
		if (nameList != null && valueList != null) {
			for (int i = 0; i < nameList.size(); i++) {
				path += "&" + nameList.get(i) + "=" + valueList.get(i);
			}
		}
		int pageNumber = list.size();
		int maxPage = pageNumber;
		if (maxPage % pageSize == 0) {
			maxPage = maxPage / pageSize;
		} else {
			maxPage = maxPage / pageSize + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * pageSize;
		int over = (Integer.parseInt(number) + 1) * pageSize;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Object obj = list.get(i);
			objList.add(obj);
		}
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
		buffer.append((Integer.parseInt(number) + 1));
		buffer.append("页 &nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("首页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=0" + path + "\">首页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if ((Integer.parseInt(number) + 1) == 1) {
			buffer.append("上一页");
		} else {
			buffer.append("<a href=\"" + name + "/" + action + "?number=" + (Integer.parseInt(number) - 1) + "" + path + "\">上一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
		Goods goods = new Goods();
		if (cond != null) {
			if ("goodsname".equals(cond)) {
				goods.setGoodsname(name);
			}
			if ("image".equals(cond)) {
				goods.setImage(name);
			}
			if ("cateid".equals(cond)) {
				goods.setCateid(name);
			}
			if ("price".equals(cond)) {
				goods.setPrice(name);
			}
			if ("addtime".equals(cond)) {
				goods.setAddtime(name);
			}
			if ("hits".equals(cond)) {
				goods.setHits(name);
			}
			if ("sellnum".equals(cond)) {
				goods.setSellnum(name);
			}
			if ("contents".equals(cond)) {
				goods.setContents(name);
			}
		}

		List<String> nameList = new ArrayList<String>();
		List<String> valueList = new ArrayList<String>();
		nameList.add(cond);
		valueList.add(name);
		PageHelper.getPage(this.goodsService.getGoodsByLike(goods), "goods", nameList, valueList, 10, number, this.getRequest(), "query");
		name = null;
		cond = null;
		return "admin/querygoods";
	}

	// 按主键查询数据
	@RequestMapping("/getGoodsById")
	public String getGoodsById(String id) {
		Goods goods = this.goodsService.getGoodsById(id);
		this.getRequest().setAttribute("goods", goods);
		List<Cate> cateList = this.cateService.getAllCate();
		this.getRequest().setAttribute("cateList", cateList);
		return "admin/editgoods";
	}

//	@GetMapping("/findPage")
//	public String getByPage(HttpServletRequest request){
//		String pageNow= request.getParameter("pageNow");
//		PageInfo<Goods> pageInfo=goodsService.findAll(Integer.valueOf(pageNow),3);
//		request.setAttribute("pageInfo",pageInfo);
		return "admin/editcate";
	}

	public CateService getCateService() {
		return cateService;
	}

	public void setCateService(CateService cateService) {
		this.cateService = cateService;
	}

}

@Controller
public class SendCodeController {
    //短信平台相关参数
    //这个不用改
    private String apiUrl = "https://sms_developer.zhenzikj.com";
    //榛子云系统上获取
    private String appId = "108850";
    private String appSecret = "NzhmN2JhNGQtNmRmOC00MWIwLTk1OGEtOTEyYzFiYjFlY2Vk";
    @ResponseBody
    @RequestMapping("/sendCode")
    public boolean getCode(String memPhone, HttpSession httpSession){
        try {
            JSONObject json = null;
            //随机生成验证码
            String code = String.valueOf(new Random().nextInt(999999));
            String pcode=null;
            //将验证码通过榛子云接口发送至手机
            ZhenziSmsClient client = new ZhenziSmsClient(apiUrl, appId, appSecret);
            Map<String, Object> params = new HashMap<String, Object>();
            //前台输入的手机号
            params.put("number", memPhone);
            //这个模板id对应的是榛子云个人中心的模板id
		return "admin/main";
	}

	// 修改密码
	@RequestMapping("/editpwd")
	public String editpwd() {
		String adminid = (String) this.getSession().getAttribute("adminid");
		String password = this.getRequest().getParameter("password");
		String repassword = this.getRequest().getParameter("repassword");
		Admin admin = this.adminService.getAdminById(adminid);
		if (password.equals(admin.getPassword())) {
			admin.setPassword(repassword);
			this.adminService.updateAdmin(admin);
		} else {
			this.getRequest().setAttribute("message", "旧密码错误");
		}
		return "admin/editpwd";
	}

	// 管理员退出登录
	@RequestMapping("/exit")
	public String exit() {
		this.getSession().removeAttribute("adminid");
		this.getSession().removeAttribute("adminname");
		this.getSession().removeAttribute("realname");
		this.getSession().removeAttribute("role");
		return "admin/index";
	}

	// 准备添加数据
	@RequestMapping("/createAdmin")
	public String createAdmin() {
		return "admin/addadmin";
	}

	// 添加数据
	@RequestMapping("/addAdmin")
	public String addAdmin(Admin admin) {
		admin.setAddtime(VeDate.getStringDateShort());
		this.adminService.insertAdmin(admin);
		return "redirect:/admin/createAdmin";
	}

	// 通过主键删除数据
	@RequestMapping("/deleteAdmin")
	public String deleteAdmin(String id) {
		this.adminService.deleteAdmin(id);

//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/admin", produces = "text/plain;charset=utf-8")
public class AdminController extends BaseController {
	// 注入Service 由于标签的存在 所以不需要getter setter
	@Autowired
	@Resource
	private AdminService adminService;

	// 管理员登录 1 验证用户名是否存在 2 验证密码是否正确
	@RequestMapping("/login")
	public String login() {
		String username = this.getRequest().getParameter("username");
		String password = this.getRequest().getParameter("password");
		Admin adminpojo = new Admin();
		adminpojo.setUsername(username);
		List<Admin> adminlist = this.adminService.getAdminByCond(adminpojo);
		if (adminlist.size() == 0) {
			this.getRequest().setAttribute("message", "用户名不存在");
			return "admin/index";
		} else {
			Admin admin = adminlist.get(0);
			if (password.equals(admin.getPassword())) {
				this.getSession().setAttribute("adminid", admin.getAdminid());
				this.getSession().setAttribute("adminname", admin.getUsername());
				this.getSession().setAttribute("realname", admin.getRealname());
				this.getSession().setAttribute("role", admin.getRole());
			} else {
				this.getRequest().setAttribute("message", "密码错误");
				return "admin/index";
			}
		}
		return "admin/main";
	}

	// 修改密码
	@Resource
	private GoodsService goodsService;

	// 准备添加数据
	@RequestMapping("/createItems")
	public String createItems() {
		List<Goods> goodsList = this.goodsService.getAllGoods();
		this.getRequest().setAttribute("goodsList", goodsList);
		return "admin/additems";
	}

	// 添加数据
	@RequestMapping("/addItems")
	public String addItems(Items items) {
		this.itemsService.insertItems(items);
		return "redirect:/items/createItems";
	}

	// 通过主键删除数据
	@RequestMapping("/deleteItems")
	public String deleteItems(String id) {
		this.itemsService.deleteItems(id);
		return "redirect:/items/getAllItems";
	}

	// 批量删除数据
	@RequestMapping("/deleteItemsByIds")
	public String deleteItemsByIds() {
		String[] ids = this.getRequest().getParameterValues("itemsid");
		for (String itemsid : ids) {
			this.itemsService.deleteItems(itemsid);
		}
		return "redirect:/items/getAllItems";
	}

	// 更新数据
	@RequestMapping("/updateItems")
	public String updateItems(Items items) {
		this.itemsService.updateItems(items);
		return "redirect:/items/getAllItems";
	}

	// 显示全部数据
	@RequestMapping("/getAllItems")
	public String getAllItems(String number) {
		List<Items> itemsList = this.itemsService.getAllItems();
		PageHelper.getPage(itemsList, "items", null, null, 10, number, this.getRequest(), null);
        this.getRequest().setAttribute("html", html);
        this.getRequest().setAttribute("ordersList", ordersList);
        return "users/orderlist";
    }

    // 准备付款
    @RequestMapping("/prePay")
    public String prePay(String id) {
        this.front();
        if (this.getSession().getAttribute("userid") == null) {
            return "redirect:/index/preLogin";
        }
        this.getRequest().setAttribute("id", id);
        Orders order=ordersService.getOrdersById(id);
        this.getRequest().setAttribute("order",order);
        System.out.println(order);
        System.out.println(order.getTotal()+"==========");
        return "users/pay";
    }

    // 付款
    @RequestMapping("/pay")
    public String pay(String id) {
        this.front();
        if (this.getSession().getAttribute("userid") == null) {
            return "redirect:/index/preLogin";
        }
        String oid=getRequest().getParameter("id");
        Orders orders = this.ordersService.getOrdersById(oid);
        orders.setStatus("已付款");
        this.ordersService.updateOrders(orders);
        return "redirect:/index/showOrders";
    }
    // 确认收货
    @RequestMapping("/preTopic")
    public String preTopic(String id) {
        this.front();
        if (this.getSession().getAttribute("userid") == null) {
            return "redirect:/index/preLogin";
        }
        Orders orders = this.ordersService.getOrdersById(this.getRequest().getParameter("id"));
        Items items = new Items();
        items.setOrdercode(orders.getOrdercode());
        List<Items> itemsList = this.itemsService.getItemsByCond(items);
        this.getRequest().setAttribute("detailsList", itemsList);

//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/allot", produces = "text/plain;charset=utf-8")
public class AllotController extends BaseController {
	// 注入Service 由于标签的存在 所以不需要getter setter
	@Autowired
	@Resource
	private AllotService allotService;
	@Autowired
	@Resource
	private OrdersService ordersService;
	@Autowired
	@Resource
	private EmployService employService;

	// 准备添加数据
	@RequestMapping("/createAllot")
	public String createAllot() {
		Orders orders = new Orders();
		orders.setStatus("已付款");
		List<Orders> ordersList = this.ordersService.getOrdersByCond(orders);
		this.getRequest().setAttribute("ordersList", ordersList);
		List<Employ> employList = this.employService.getAllEmploy();
		this.getRequest().setAttribute("employList", employList);
		return "admin/addallot";
	}

	// 添加数据
	@RequestMapping("/addAllot")
	public String addAllot(Allot allot) {
		allot.setAddtime(VeDate.getStringDateShort());
		allot.setStatus("进行中");
		this.allotService.insertAllot(allot);
		Orders orders = this.ordersService.getOrdersById(allot.getOrdersid());
		orders.setStatus("进行中");

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值