Java项目:ssm+jsp实现手机WAP版外卖订餐系统

news2024/11/17 16:27:08

作者主页:源码空间站2022

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

这是一款由jsp+ssm框架(spring、springMVC、mybaits)实现的手机WAP版外卖订餐系统。

本系统前台页面是手机端的,跟目前主流的饿了么、美团外卖等一样的界面风格,前台实现了用户登录注册、查看菜品信息、添加到购物车、提交订单、查看个人订单、修改个人资料等,后台管理实现了菜品分类管理、菜品管理、客户管理、订单管理等功能。

前端访问地址:
http://localhost:8080/front/mainindex
用户名:13212345678
密码:123456

后端访问地址:http://localhost:8080/admin/login.html
用户名:admin

密码:123456

运行截图

前台界面

后台界面

 

相关代码 

管理员控制类

package com.mealorder.action;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mealorder.model.AdminUser;
import com.mealorder.model.PageBean;
import com.mealorder.util.GetIPUtil;
import com.mealorder.util.PageUtil;
import com.mealorder.util.ResponseUtil;
import com.mealorder.util.StringUtil;
import com.mealorder.dao.AdminUserDao;

import net.sf.json.JSONObject;

/**
 * 管理员控制类
 * @author gongwei
 *
 */
@Controller
public class AdminUserAction {
	@Resource
	private AdminUserDao adminuserDao;
	
	/**
	 * 登录页
	 * @return
	 * @throws IOException 
	 * @throws Exception
	 */
	@RequestMapping(value = "/admin/login")
	public String login(Model model, HttpServletRequest request, HttpServletResponse response) throws IOException {
		return "login.html";
	}
	
	/**
	 * 后台管理员登陆
	 */
	@RequestMapping(value = "/admin/loginAdmin")
	public String loginAdmin(Model model, HttpServletRequest request, HttpServletResponse response) {
		JSONObject resultJson = new JSONObject();
		
		String adminuser_username = request.getParameter("adminuser_username");
		String adminuser_password = request.getParameter("adminuser_password");
		String imageCode = request.getParameter("imageCode");
		
		HttpSession session = request.getSession();
		String sesstionCode = (String) session.getAttribute("imageCode");
		
		if (StringUtil.isNotEmpty(sesstionCode)) {
			if (sesstionCode.equals(imageCode)) {
				AdminUser adminUser = adminuserDao.adminLogin(adminuser_username, adminuser_password);
				if (adminUser.getAdminuser_username() == null || adminUser.getAdminuser_username() == "") {
					resultJson.put("message", "用户名或密码错误");
					resultJson.put("result", "failthree");//用户名或密码错误
				} else if (adminUser.getAdminuser_status() == 2) {//用户被锁定了
					resultJson.put("message", "该用户已被锁定");
					resultJson.put("result", "failfour");//该用户已被锁定
				} else {
					//获取当前系统时间
					Date date = new Date();
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					String adminuser_lastertime = formatter.format(date);
					
					String adminuser_lasterip = GetIPUtil.getIp(request);
					
					//根据管理员id修改该管理员的登陆时间和登陆IP
					adminuserDao.updateAdminUserLasterTimeAndLasterIp(adminUser.getAdminuser_id(), adminuser_lastertime,adminuser_lasterip);
					
					session.setAttribute("currentAdminUser", adminUser);
					//setMaxInactiveInterval设置的是当前会话的失效时间,不是整个web的时间,单位为以秒计算。如果设置的值为零或负数,则表示会话将永远不会超时。
					session.setMaxInactiveInterval(0);
					resultJson.put("message", "登录成功");
					resultJson.put("result", "success");//登录成功
				}
			} else {
				resultJson.put("message", "验证码错误");
				resultJson.put("result", "failtwo");//验证码错误
			}
		} else {
			resultJson.put("message", "系统繁忙,请稍后再试");
			resultJson.put("result", "failone");//系统繁忙,请稍后再试
		}
		try {
			ResponseUtil.write(resultJson, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	
	/**
	 * 后台主界面
	 * @return
	 * @throws IOException 
	 * @throws Exception
	 */
	@RequestMapping(value = "/admin/main")
	public String main(HttpServletRequest request, HttpServletResponse response) throws IOException {
		return "main.jsp";
	}
	
	/**
	 * 管理员退出后台
	 * @return
	 * @throws IOException 
	 * @throws Exception
	 */
	@RequestMapping(value = "/admin/logout")
	public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
		request.getSession().invalidate();
		String url = "login.html";
		response.sendRedirect(url);
	}

	/**
	 * 管理员列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/admin/adminuserlist")
	public String adminuserlist(String page, String type, String searchType, String searchvalue, Model model, HttpServletRequest request, HttpServletResponse response) {
		if (StringUtil.isEmpty(page)) {
			page = "1";
		}
		PageBean pageBean = new PageBean(Integer.parseInt(page), 10);
		int total = 0;
		List<AdminUser> adminuserList = null;
		if (type != null) {
			if (type.equals("search")) {
				adminuserList = adminuserDao.findAdminUserBySearchPage(searchType, searchvalue, pageBean);
				total = adminuserDao.AdminUserCountBySearch(searchType, searchvalue);
			}
		} else {
			adminuserList = adminuserDao.findAdminUserByPage(null, pageBean);
			total = adminuserDao.AdminUserCount(null);
		}
		String pageCode = PageUtil.genPagination(request.getContextPath()
				+ "/admin/adminuserlist?1=1", total, Integer.parseInt(page), 10);
		model.addAttribute("adminuserList", adminuserList);
		model.addAttribute("pageCode", pageCode);
		return "adminuser/adminuser_list.jsp";
	}
	
	/**
	 * 添加修改管理员信息管理
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/admin/adminuserpreSave")
	public String adminuserpreSave(AdminUser adminuser, String adminuserId, Model model, HttpServletRequest request, HttpServletResponse response) {
		String title;
		if (StringUtil.isNotEmpty(adminuserId)) {
			adminuser = adminuserDao.getAdminUserById(Integer.valueOf(adminuserId));
			model.addAttribute("adminuserId", adminuserId);
			model.addAttribute("adminuser", adminuser);
			title = "修改管理员信息";
		} else {
			title = "新增管理员信息";
		}
		int adminuser_sn_max = adminuserDao.getAdminUserSnToMax()+1;//获取最大的管理员编号,再加1赋值到管理员添加页面和修改页面
		model.addAttribute("adminuser_sn_max", adminuser_sn_max);
		model.addAttribute("title", title);
		return "adminuser/adminuser_add.jsp";
	}
	
	/**
	 * 管理员添加修改操作实现
	 * @return
	 */
	@RequestMapping(value = "/admin/adminusersave")
	public void adminusersave(Model model, HttpServletRequest request, HttpServletResponse response) throws IOException {
		JSONObject resultJson = new JSONObject();
		AdminUser adminuser = new AdminUser();
		String adminuser_sn = request.getParameter("adminuser_sn");//获取用户编号
		adminuser.setAdminuser_sn(adminuser_sn);//设置用户编号
		
		String adminuser_username = request.getParameter("adminuser_username");//获取用户名姓名
		
		adminuser.setAdminuser_username(adminuser_username);//设置管理员姓名
		
		String adminuser_password = request.getParameter("adminuser_password");//获取管理员密码
		adminuser.setAdminuser_password(adminuser_password);//设置用户密码
		
		String adminuser_iphone = request.getParameter("adminuser_iphone");//获取管理员手机号码
		adminuser.setAdminuser_iphone(adminuser_iphone);//设置管理员手机号码
		
		String adminuser_email = request.getParameter("adminuser_email");//获取管理员电子邮箱
		adminuser.setAdminuser_email(adminuser_email);//设置管理员电子邮箱
		
		//获取当前系统时间
		Date date = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String adminuser_registertime = formatter.format(date);
		adminuser.setAdminuser_registertime(adminuser_registertime);//设置管理员添加时间
		
		adminuser.setAdminuser_status(1);//设置管理员的状态为正常
		
		adminuser.setRole_id(1);//设置用户角色 1、管理员 2、用户
		
		String adminuserId = request.getParameter("adminuserId");//获取管理员id
		if (StringUtil.isNotEmpty(adminuserId)) {//不为空,则是修改管理员信息
			adminuser.setAdminuser_id(Integer.parseInt(adminuserId));//设置管理员id
			int a = adminuserDao.updateAdminUser(adminuser);
			if (a > 0) {
				resultJson.put("result", "successone");//修改管理员信息成功
			} else {
				resultJson.put("result", "failtwo");//修改管理员信息失败
			}
		} else {
			//根据用户名查询用户是否存在
			List<AdminUser> adminuserlist = adminuserDao.findAdminUserByAdminusername(adminuser_username);
			if (adminuserlist.size() > 0) {
				resultJson.put("result", "failone");//用户名已存在
			} else {
				int a = adminuserDao.addAdminUser(adminuser);
				if (a > 0) {
					resultJson.put("result", "successtwo");//添加管理员信息成功
				} else {
					resultJson.put("result", "failthree");//添加管理员信息失败
				}	
			}
		}
		try {
			ResponseUtil.write(resultJson, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 用户删除操作
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/admin/adminuserdelete")
	public String adminuserdelete(String adminuserId, HttpServletRequest request, HttpServletResponse response) {
		adminuserDao.deleteAdminUser(Integer.parseInt(adminuserId));
		JSONObject resultJson = new JSONObject();
		resultJson.put("success", true);
		try {
			ResponseUtil.write(resultJson, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 设置用户为锁定状态
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/admin/updateadminusertoclose")
	public String updateadminusertoclose(Model model,String adminuser_id, HttpServletRequest request, HttpServletResponse response) throws Exception {
		JSONObject resultJson = new JSONObject();

		int a = adminuserDao.updateadminusertoclose(Integer.parseInt(adminuser_id));

		if (a > 0) {
			resultJson.put("result", "success");
		} else {
			resultJson.put("result", "fail");
		}

		ResponseUtil.write(resultJson, response);
		return null;
	}
	
	/**
	 * 设置用户为解锁状态
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/admin/updateadminusertoopen")
	public String updateadminusertoopen(Model model,String adminuser_id, HttpServletRequest request, HttpServletResponse response) throws Exception {
		JSONObject resultJson = new JSONObject();

		int a = adminuserDao.updateadminusertoopen(Integer.parseInt(adminuser_id));

		if (a > 0) {
			resultJson.put("result", "success");
		} else {
			resultJson.put("result", "fail");
		}

		ResponseUtil.write(resultJson, response);
		return null;
	}
	
	/**
	 * 修改管理员密码页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/admin/adminuserupdatepassword")
	public String adminuserupdatepassword(String adminuserId, Model model, HttpServletRequest request, HttpServletResponse response) {
		HttpSession session = request.getSession();
		AdminUser adminUser = (AdminUser) session.getAttribute("currentAdminUser");
		AdminUser adminuser = adminuserDao.getAdminUserById(adminUser.getAdminuser_id());//获取管理员对象
		model.addAttribute("adminuser", adminuser);
		return "adminuser/update_password.jsp";
	}
	
	/**
	 * 修改管理员密码
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/admin/updateadminuserpassowrd")
	public String updateadminuserpassowrd(Model model, HttpServletRequest request, HttpServletResponse response) throws Exception {
		JSONObject resultJson = new JSONObject();
		String adminuser_id = request.getParameter("adminuser_id");
		
		String older_password = request.getParameter("older_password");
		
		String new_password = request.getParameter("new_password");

		//根据管理员id和原密码查询该管理员原密码是否正确
		List<AdminUser> adminuserlist = adminuserDao.findOlderPasswordByAdminuserId(Integer.parseInt(adminuser_id), older_password);
		if (adminuserlist.size() > 0) {//原密码正确
			int a = adminuserDao.updateadminuserpassword(Integer.parseInt(adminuser_id),new_password);
			if (a > 0) {
				resultJson.put("result", "success");
			} else {
				resultJson.put("result", "updatefalse");
			}
		} else {
			resultJson.put("result", "false");
		}
		ResponseUtil.write(resultJson, response);
		return null;
	}
	
	/**
	 * 用户列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/admin/userlist")
	public String userlist(String page, String type, String searchType, String searchvalue, Model model, HttpServletRequest request, HttpServletResponse response) {
		if (StringUtil.isEmpty(page)) {
			page = "1";
		}
		PageBean pageBean = new PageBean(Integer.parseInt(page), 10);
		int total = 0;
		List<AdminUser> adminuserList = null;
		if (type != null) {
			if (type.equals("search")) {
				adminuserList = adminuserDao.findUserBySearchPage(searchType, searchvalue, pageBean);
				total = adminuserDao.UserCountBySearch(searchType, searchvalue);
			}
		} else {
			adminuserList = adminuserDao.findUserByPage(null, pageBean);
			total = adminuserDao.UserCount(null);
		}
		String pageCode = PageUtil.genPagination(request.getContextPath()
				+ "/admin/userlist?1=1", total, Integer.parseInt(page), 10);
		model.addAttribute("adminuserList", adminuserList);
		model.addAttribute("pageCode", pageCode);
		return "adminuser/user_list.jsp";
	}
	
	/**
	 * 添加修改用户信息管理
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/admin/userpreSave")
	public String userpreSave(AdminUser adminuser, String adminuserId, Model model, HttpServletRequest request, HttpServletResponse response) {
		String title;
		if (StringUtil.isNotEmpty(adminuserId)) {
			adminuser = adminuserDao.getAdminUserById(Integer.valueOf(adminuserId));
			model.addAttribute("adminuserId", adminuserId);
			model.addAttribute("adminuser", adminuser);
			title = "修改用户信息";
		} else {
			title = "新增用户信息";
		}
		int adminuser_sn_max = adminuserDao.getAdminUserSnToMax()+1;//获取最大的管理员编号,再加1赋值到管理员添加页面和修改页面
		model.addAttribute("adminuser_sn_max", adminuser_sn_max);
		model.addAttribute("title", title);
		return "adminuser/user_add.jsp";
	}
	
	/**
	 * 用户添加修改操作实现
	 * @return
	 */
	@RequestMapping(value = "/admin/usersave")
	public void usersave(Model model, HttpServletRequest request, HttpServletResponse response) throws IOException {
		JSONObject resultJson = new JSONObject();
		AdminUser adminuser = new AdminUser();
		String adminuser_sn = request.getParameter("adminuser_sn");//获取用户编号
		adminuser.setAdminuser_sn(adminuser_sn);//设置用户编号
		
		String adminuser_username = request.getParameter("adminuser_username");//获取用户名姓名
		
		adminuser.setAdminuser_username(adminuser_username);//设置管理员姓名
		
		String adminuser_password = request.getParameter("adminuser_password");//获取管理员密码
		adminuser.setAdminuser_password(adminuser_password);//设置用户密码
		
		String adminuser_iphone = request.getParameter("adminuser_iphone");//获取管理员手机号码
		adminuser.setAdminuser_iphone(adminuser_iphone);//设置管理员手机号码
		
		String adminuser_email = request.getParameter("adminuser_email");//获取管理员电子邮箱
		adminuser.setAdminuser_email(adminuser_email);//设置管理员电子邮箱
		
		//获取当前系统时间
		Date date = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String adminuser_registertime = formatter.format(date);
		adminuser.setAdminuser_registertime(adminuser_registertime);//设置管理员添加时间
		
		adminuser.setAdminuser_status(1);//设置管理员的状态为正常
		
		adminuser.setRole_id(2);//设置用户角色 1、管理员 2、用户
		
		String adminuserId = request.getParameter("adminuserId");//获取管理员id
		if (StringUtil.isNotEmpty(adminuserId)) {//不为空,则是修改管理员信息
			adminuser.setAdminuser_id(Integer.parseInt(adminuserId));//设置管理员id
			int a = adminuserDao.updateAdminUser(adminuser);
			if (a > 0) {
				resultJson.put("result", "successone");//修改管理员信息成功
			} else {
				resultJson.put("result", "failtwo");//修改管理员信息失败
			}
		} else {
			//根据用户名查询用户是否存在
			List<AdminUser> adminuserlist = adminuserDao.findAdminUserByAdminusername(adminuser_username);
			if (adminuserlist.size() > 0) {
				resultJson.put("result", "failone");//用户名已存在
			} else {
				int a = adminuserDao.addAdminUser(adminuser);
				if (a > 0) {
					resultJson.put("result", "successtwo");//添加管理员信息成功
				} else {
					resultJson.put("result", "failthree");//添加管理员信息失败
				}	
			}
		}
		try {
			ResponseUtil.write(resultJson, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 店长列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/admin/shopuserlist")
	public String shopuserlist(String page, String type, String searchType, String searchvalue, Model model, HttpServletRequest request, HttpServletResponse response) {
		if (StringUtil.isEmpty(page)) {
			page = "1";
		}
		PageBean pageBean = new PageBean(Integer.parseInt(page), 10);
		int total = 0;
		List<AdminUser> adminuserList = null;
		if (type != null) {
			if (type.equals("search")) {
				adminuserList = adminuserDao.findShopuserBySearchPage(searchType, searchvalue, pageBean);
				total = adminuserDao.ShopuserCountBySearch(searchType, searchvalue);
			}
		} else {
			adminuserList = adminuserDao.findShopuserByPage(null, pageBean);
			total = adminuserDao.ShopuserCount(null);
		}
		String pageCode = PageUtil.genPagination(request.getContextPath()
				+ "/admin/shopuserlist?1=1", total, Integer.parseInt(page), 10);
		model.addAttribute("adminuserList", adminuserList);
		model.addAttribute("pageCode", pageCode);
		return "adminuser/shopuser_list.jsp";
	}
	
	/**
	 * 添加修改店长信息管理
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/admin/shopuserpreSave")
	public String shopuserpreSave(AdminUser adminuser, String adminuserId, Model model, HttpServletRequest request, HttpServletResponse response) {
		String title;
		if (StringUtil.isNotEmpty(adminuserId)) {
			adminuser = adminuserDao.getAdminUserById(Integer.valueOf(adminuserId));
			model.addAttribute("adminuserId", adminuserId);
			model.addAttribute("adminuser", adminuser);
			title = "修改店长信息";
		} else {
			title = "新增店长信息";
		}
		int adminuser_sn_max = adminuserDao.getAdminUserSnToMax()+1;//获取最大的管理员编号,再加1赋值到管理员添加页面和修改页面
		model.addAttribute("adminuser_sn_max", adminuser_sn_max);
		model.addAttribute("title", title);
		return "adminuser/shopuser_add.jsp";
	}
	
	/**
	 * 店长用户添加修改操作实现
	 * @return
	 */
	@RequestMapping(value = "/admin/shopusersave")
	public void shopusersave(Model model, HttpServletRequest request, HttpServletResponse response) throws IOException {
		JSONObject resultJson = new JSONObject();
		AdminUser adminuser = new AdminUser();
		String adminuser_sn = request.getParameter("adminuser_sn");//获取店长编号
		adminuser.setAdminuser_sn(adminuser_sn);//设置店长编号
		
		String adminuser_username = request.getParameter("adminuser_username");//获取店长姓名
		
		adminuser.setAdminuser_username(adminuser_username);//设置店长姓名
		
		String adminuser_password = request.getParameter("adminuser_password");//获取店长密码
		adminuser.setAdminuser_password(adminuser_password);//设置店长密码
		
		String adminuser_iphone = request.getParameter("adminuser_iphone");//获取店长手机号码
		adminuser.setAdminuser_iphone(adminuser_iphone);//设置店长手机号码
		
		String adminuser_email = request.getParameter("adminuser_email");//获取店长电子邮箱
		adminuser.setAdminuser_email(adminuser_email);//设置店长电子邮箱
		
		//获取当前系统时间
		Date date = new Date();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String adminuser_registertime = formatter.format(date);
		adminuser.setAdminuser_registertime(adminuser_registertime);//设置店长添加时间
		
		adminuser.setAdminuser_status(1);//设置店长的状态为正常
		
		adminuser.setRole_id(3);//设置用户角色 1、管理员 2、用户 3、店长
		
		String adminuserId = request.getParameter("adminuserId");//获取店长id
		if (StringUtil.isNotEmpty(adminuserId)) {//不为空,则是修改店长信息
			adminuser.setAdminuser_id(Integer.parseInt(adminuserId));//设置店长id
			int a = adminuserDao.updateAdminUser(adminuser);
			if (a > 0) {
				resultJson.put("result", "successone");//修改店长信息成功
			} else {
				resultJson.put("result", "failtwo");//修改店长信息失败
			}
		} else {
			//根据用户名查询用户是否存在
			List<AdminUser> adminuserlist = adminuserDao.findAdminUserByAdminusername(adminuser_username);
			if (adminuserlist.size() > 0) {
				resultJson.put("result", "failone");//用户名已存在
			} else {
				int a = adminuserDao.addAdminUser(adminuser);
				if (a > 0) {
					resultJson.put("result", "successtwo");//添加店长信息成功
				} else {
					resultJson.put("result", "failthree");//添加店长信息失败
				}	
			}
		}
		try {
			ResponseUtil.write(resultJson, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

店铺控制类

package com.mealorder.action;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mealorder.dao.AdminUserDao;
import com.mealorder.dao.ShopDao;
import com.mealorder.model.Shop;
import com.mealorder.model.AdminUser;
import com.mealorder.model.PageBean;
import com.mealorder.util.PageUtil;
import com.mealorder.util.ResponseUtil;
import com.mealorder.util.StringUtil;

import net.sf.json.JSONObject;

/**
 * 店铺控制类
 * @author gongwei
 *
 */
@Controller
public class ShopAction {
	@Resource
	private ShopDao shopDao;
	@Resource
	private AdminUserDao adminuserDao;
	
	/**
	 * 店铺列表
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/admin/shoplist")
	public String shoplist(String page, String type, String searchType, String searchvalue, Model model, HttpServletRequest request, HttpServletResponse response) {
		if (StringUtil.isEmpty(page)) {
			page = "1";
		}
		PageBean pageBean = new PageBean(Integer.parseInt(page), 10);
		int total = 0;
		List<Shop> shoplist = null;
		shoplist = shopDao.findShopByPage(null, pageBean);
		total = shopDao.ShopCount(null);
		String pageCode = PageUtil.genPagination(request.getContextPath()
				+ "/admin/shoplist?1=1", total, Integer.parseInt(page), 10);
		model.addAttribute("shoplist", shoplist);
		model.addAttribute("pageCode", pageCode);
		return "shop/shop_list.jsp";
	}
	
	/**
	 * 添加修改店铺信息管理
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/admin/shoppreSave")
	public String shoppreSave(Shop shop, String shopId, Model model, HttpServletRequest request, HttpServletResponse response) {
		String title;
		if (StringUtil.isNotEmpty(shopId)) {
			shop = shopDao.getShopById(Integer.valueOf(shopId));
			model.addAttribute("shopId", shopId);
			title = "修改店铺";
		} else {
			title = "新增店铺";
		}
		model.addAttribute("title", title);
		model.addAttribute("shop", shop);
		List<AdminUser> adminuserlist = adminuserDao.findAdminUserForShop();
		model.addAttribute("adminuserlist", adminuserlist);
		return "shop/shop_add.jsp";
	}
	
	/**
	 * 店铺添加修改操作实现
	 * @return
	 */
	@RequestMapping(value = "/admin/shopsave")
	public void shopsave(String shopId, Shop shop, Model model, HttpServletRequest request, HttpServletResponse response) throws IOException {
		shop.setAdminuser_id(shop.getAdminuser_id());//设置店长id
		if(StringUtil.isNotEmpty(shopId)){
			shop.setShop_id(Integer.parseInt(shopId));
			shopDao.updateShop(shop);
		}else{
			if (shop.getShop_name() != null) {
				shop.setShop_name(shop.getShop_name());//设置店铺名称
			}
			if (shop.getShop_images() != null) {
				shop.setShop_images(shop.getShop_images());//设置店铺图片
			}
			if (shop.getShop_content() != null) {
				shop.setShop_content(shop.getShop_content());//设置店铺介绍
			}
			if (shop.getShop_opentime() != null) {
				shop.setShop_opentime(shop.getShop_opentime());//设置营业时间
			}
			if (shop.getShop_address() != null) {
				shop.setShop_address(shop.getShop_address());//设置店铺地址
			}
			if (shop.getShop_iphone() != null) {
				shop.setShop_iphone(shop.getShop_iphone());//设置联系电话
			}
			//获取当前系统时间
			Date date = new Date();
			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String shop_addtime = formatter.format(date);
			shop.setShop_addtime(shop_addtime);//设置添加时间
			shop.setShop_iftj(1);//设置是否推荐 1、不推荐 2、推荐
			shopDao.addShop(shop);
		}
		response.sendRedirect("shoplist");//重定向到店铺列表页面
	}

	/**
	 * 店铺删除操作
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/admin/shopdelete")
	public String shopdelete(String shopId, HttpServletRequest request, HttpServletResponse response) {
		shopDao.deleteShop(Integer.parseInt(shopId));
		JSONObject resultJson = new JSONObject();
		resultJson.put("success", true);
		try {
			ResponseUtil.write(resultJson, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 设置店铺为推荐状态
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/admin/updateshoptotuijian")
	public String updateshoptotuijian(Model model,String shop_id, HttpServletRequest request, HttpServletResponse response) throws Exception {
		JSONObject resultJson = new JSONObject();

		int a = shopDao.updateShopToTuijian(Integer.parseInt(shop_id));

		if (a > 0) {
			resultJson.put("result", "success");
		} else {
			resultJson.put("result", "fail");
		}

		ResponseUtil.write(resultJson, response);
		return null;
	}
	
	/**
	 * 设置店铺为不推荐状态
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/admin/updateshoptonotuijian")
	public String updateshoptonotuijian(Model model,String shop_id, HttpServletRequest request, HttpServletResponse response) throws Exception {
		JSONObject resultJson = new JSONObject();

		int a = shopDao.updateShopToNoTuijian(Integer.parseInt(shop_id));

		if (a > 0) {
			resultJson.put("result", "success");
		} else {
			resultJson.put("result", "fail");
		}

		ResponseUtil.write(resultJson, response);
		return null;
	}
	
}

如果也想学习本系统,下面领取。关注并回复:021ssm 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/55296.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

如何发布一个 npm 包

前言 npm&#xff08;node package manager&#xff09;作为 Node.js 的包管理工具&#xff0c;让世界各地的 JavaScript 开发者方便复用、分享代码以及造轮子&#xff1b;本文将介绍如何发布一个 npm 包&#xff0c;以及使用工具来自动化管理发布 npm 包&#xff1b;本文总览…

Java代码审计——WebGoat CSRF (上)

目录 前言&#xff1a; &#xff08;一&#xff09;CSRF 0x01、简单介绍 0x02、实际案例 1&#xff0e;对 Referer 过滤不严导致的 CSRF 漏洞 2&#xff0e;token 可重用导致 CSRF 漏洞 3、webGoat中的CSRF 0x03 防御 3.1 STP 3.2 检查 Referer 字段 3.3 检查 Referer…

GMO Research 2022年旅游调查:旅游业有望强劲增长

GMO Research (TOKYO: 3695)最近进行的一项旅行调查显示&#xff0c;随着边境再次开放&#xff0c;亚洲正在逐渐恢复正常的旅行模式。尽管该地区仍没有达到疫情前水平&#xff0c;旅行者仍持谨慎态度&#xff0c;但他们对海外旅行的兴趣显著增加。 为了解旅行模式和旅行意愿&a…

Intel OpenVINO 安装显卡驱动

背景&#xff1a; 使用集合诚KMDA-3301 OpenVINO CPU和GPU 算法加速&#xff0c;用GPU加速时&#xff0c;调动不起来。写下解决过程&#xff0c;以备后用。 过程&#xff1a; 调动GPU 报错&#xff1a; terminate called after throwing an instance of InferenceEngine::G…

2023最新SSM计算机毕业设计选题大全(附源码+LW)之java高校师生党建管理系统4d8du

最近大四学弟学妹们开始准备设计了&#xff0c;有一些问题问我&#xff0c;比如设计怎么做&#xff0c;有没有模板等等吧&#xff0c;大家都没有去学校&#xff0c;老师都是通过远程指导的&#xff0c;答辩也是远程答辩&#xff0c;这种情况下同学们不在一起&#xff0c;可能碰…

day13【代码随想录】环形链表II、环形链表、快乐数、各位相加、丑数、丑数||

文章目录一、环形链表 II&#xff08;力扣142&#xff09;二、环形链表&#xff08;力扣141&#xff09;三、快乐数&#xff08;力扣202&#xff09;四、各位相加&#xff08;力扣258&#xff09;五、丑数&#xff08;力扣263&#xff09;六、丑数||&#xff08;力扣264&#x…

JavaScript:File API和Blob API

web应用的痛点就是不能操作计算机上的文件。File API和Blob API可以安全访问到客户端上的文件。 File类型 现在我们可以在html表单中直接访问文件&#xff0c;比如&#xff1a; <!DOCTYPE html> <html lang"en"> <head><meta charset"U…

PaddleOCR服务部署-并通过Java进行调用

上一篇讲了PaddleOCR的简单使用&#xff0c;但是最终的目的肯定是要将它进行服务部署方便我们调用的&#xff0c;这里介绍一下他的服务部署方式 选择部署方式 官方推荐有以下几种&#xff1a; Python 推理 C 推理 Serving 服务化部署&#xff08;Python/C&#xff09; Paddle…

电影寒冬之下,票房靠“主旋律”能撑住场吗?《扫黑行动》仍在重播

春节将近&#xff0c;各大院线陆陆续续公布了春节档将要上映的影片档期&#xff0c;小伙伴们是不是也对近期热门的影片有了兴趣&#xff0c;想要一饱眼福了呢。下面是小编根据网络公布的数据进行报表数据处理分析后得到的数据可视化图&#xff0c;展示了近期一些热门影片的情况…

数据库专辑--WITH CHECK OPTION的用法

系列文章 C#底层库–数据库访问帮助类&#xff08;MySQL版&#xff09; 本文链接&#xff1a;https://blog.csdn.net/youcheng_ge/article/details/126886379 文章目录系列文章前言一、概念介绍二、测试用例2.1 数据准备2.2 数据查询2.3 修改视图&#xff0c;加上WITH CHECK O…

IDEA 优质 插件 Translation 跟随 IDEA 2022.3 版 更新翻译引擎啦

IDEA 优质 插件 Translation 跟随 IDEA 2022.3 版 更新翻译引擎啦 文章目录IDEA 优质 插件 Translation 跟随 IDEA 2022.3 版 更新翻译引擎啦特征安装使用 IDE 内置插件系统安装&#xff1a;手动安装&#xff1a;使用1. 注册翻译服务&#xff08;可选&#xff09;2. 开始翻译3.…

BGP学习笔记

概念 动态路由协议按照按照工作范围可以分为IGP和EGP&#xff0c;IGP工作在一个AS之内&#xff0c;主要用来发现和计算路由&#xff0c;常见的IGP包括OSPF&#xff0c;RIP&#xff0c;ISIS等。EGP工作在AS与AS之间&#xff0c;在AS之间提供无环路的路由信息交换。BGP&#xff…

[附源码]Python计算机毕业设计Django基于Web的软考题库平台

项目运行 环境配置&#xff1a; Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术&#xff1a; django python Vue 等等组成&#xff0c;B/S模式 pychram管理等等。 环境需要 1.运行环境&#xff1a;最好是python3.7.7&#xff0c;…

ActiveMQ window安装、修改密码、启动一闪而过、设置8161端口仅本地访问

目录 1.ActiveMQ下载 2.ActiveMQ目录说明 3.启动activemq 4.修改activemq默认密码 5.设置8161端口仅本地访问。 1.ActiveMQ下载 官网下载ActiveMQhttps://activemq.apache.org/ window版本直接解压就可以。 2.ActiveMQ目录说明 apache-activemq-5.16.5 activemq目录结构…

这几款文档笔记工具,你习惯用哪个?

前言 俗话说的好&#xff1a;“好记性不如烂笔头”&#xff0c;平时工作记录笔记的确是一个良好的习惯&#xff0c;做文档笔记可以在我们遗忘时进行回看&#xff0c;方便查找&#xff0c;代替人的大脑。有时程序写多了&#xff0c;很不愿意去强制记忆一些东西&#xff0c;那么…

【高度预估】基于matlab卡尔曼滤波和粒子滤波无人机离地高度估计【含Matlab源码 2255期】

⛄一、卡尔曼滤波和粒子滤波无人机离地高度估计 1 无人机离地高度估计算法 1.1 离地高度估计基本方案 无人机安装两路距离测量传感器, 传感器能在小型无人机飞行的一般高度正常工作, 且两个传感器的安装位置保证它们能够测量相同的离地高度信息。 两路距离测量传感器以1s的频…

单源最短路径(贪心算法)

最近在研究算法设计与分析&#xff0c;看到了单源最短路劲&#xff0c;特发文一篇。 下面代码就是实现这个有向联通图 废话不说直接上代码 #include<stdio.h> #define m 5000 int c[5][5] {m,10,m,30,100,m,m,50,m,m,m,m,m,m,10,m,m,20,m,60,m,m,m,m,m, }; int dist[5]…

现在市面跑步耳机哪款好用、分享五款适合跑步用的耳机推荐

近这两年来&#xff0c;运动健身风潮一直都非常火&#xff0c;但是一个人运动健身&#xff0c;难免无聊&#xff0c;如果有音乐的陪伴&#xff0c;时间都能过得快很多&#xff0c;这时候就需要一款运动蓝牙耳机了。不过购买运动蓝牙耳机&#xff0c;比挑选普通的耳机还更需要花…

[附源码]Python计算机毕业设计Django架构的博客平台设计

项目运行 环境配置&#xff1a; Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术&#xff1a; django python Vue 等等组成&#xff0c;B/S模式 pychram管理等等。 环境需要 1.运行环境&#xff1a;最好是python3.7.7&#xff0c;…

节约软件开发成本,关键在这儿。

​1、节省软件开发成本的核心在减少返工&#xff01; 软件企业利润 销售额 - 成本。企业的利润少&#xff0c;可能是销售额太少&#xff0c;也可能是成本太高。而增加销售额&#xff0c;取决于销售人员、客户、市场、产品等众多不可控因素&#xff0c;可遇而不可求。相反&…