作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本项目包含管理员与普通用户两种角色;
管理员角色包含以下功能:
管理员登录,查看销售报表,餐桌管理,菜式管理,菜品管理,点餐明细管理,修改密码等功能。
用户角色包含以下功能:
用户登录,点餐,提交订单,修改密码等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
6.是否Maven项目:否;
技术栈
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+jQuery+bootstrap
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中WebContent/WEB-INF/config/config.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入 http://localhost:8080/ssm_restaurentsys/
运行截图
管理员角色
用户角色
相关代码
BaseController
public abstract class BaseController {
protected Map<String, Object> getWhereMap(HttpServletRequest request)
{
Map<String, Object> map = new HashMap<String, Object>();
int start = StringUtil.parseToInt(request.getParameter("start"), 0);
int limit = StringUtil.parseToInt(request.getParameter("limit"), 50);
map.put("start", start);
map.put("limit", limit);
return map;
}
protected Map<String, Object> getMessageMap(boolean success, String message) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("success", success);
map.put("message", message);
return map;
}
}
DishController
@Controller
@RequestMapping(value="/dish")
public class DishController extends BaseController {
@Autowired
DishService dishService;
@Autowired
DishTypeService dishTypeService;
@RequestMapping(value = "/list", method = RequestMethod.GET)
public String get(SearchVO searchVO, HttpServletRequest request, ModelMap modelMap) {
String pageNow = request.getParameter("pageNow");
Page page = null;
Map<String, Object> whereMap = new HashMap<String, Object>();
if (!StringUtil.isEmpty(searchVO.getName())) {
whereMap.put("name", " name like '%" + searchVO.getName() + "%'");
}
int totalCount = (int) dishService.getCount(whereMap);
if (pageNow != null) {
page = new Page(totalCount, Integer.parseInt(pageNow));
} else {
page = new Page(totalCount, 1);
}
whereMap.put("startPos", page.getStartPos());
whereMap.put("pageSize", page.getPageSize());
List<Dishes> dishes = dishService.getAll(whereMap);
modelMap.addAttribute("dishes", dishes);
modelMap.addAttribute("page", page);
return "restaurent/dishes";
}
@RequestMapping(value="/save", method = RequestMethod.POST)
public String save(@RequestParam(required=false, value="file")MultipartFile file, Dishes dish, ModelMap modelMap, HttpSession session) {
String path = dish.getPic();
if (file != null && !file.isEmpty()) {
String fileName = file.getOriginalFilename();
String ext = fileName.substring(fileName.lastIndexOf("."));
path = "/pic/" + System.currentTimeMillis() + ext;
String dir = session.getServletContext().getRealPath(path);
try {
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(dir));
} catch (IOException e) {
e.printStackTrace();
}
} else if (StringUtil.isEmpty(path)){
path = "/pic/default.jpg";
}
dish.setPic(path);
DishType dishType = dishTypeService.getDishTypeById(dish.getDishType());
dish.setTypeName(dishType.getName());
if(dish.getId() == null) {
dishService.insert(dish);
} else {
dishService.update(dish);
}
return "redirect:list.html";
}
@RequestMapping(value="/add", method = RequestMethod.GET)
public String add(ModelMap modelMap) {
List<DishType> dishtypes = dishTypeService.getAll();
modelMap.put("dishtypes", dishtypes);
return "restaurent/adddish";
}
@RequestMapping(value="/update", method = RequestMethod.GET)
public String update(int id, ModelMap modelMap) {
Dishes dish = dishService.getDishesById(id);
List<DishType> dishtypes = dishTypeService.getAll();
modelMap.put("dishtypes", dishtypes);
modelMap.put("dish", dish);
return "restaurent/adddish";
}
@RequestMapping(value="/delete", method = RequestMethod.GET)
public String delete(int id, ModelMap modelMap) {
dishService.deleteById(id);
return "redirect:list.html";
}
}
如果也想学习本系统,下面领取。回复:200ssm