作者主页:夜未央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+easyui+echarts+h-ui
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ssm_zxmarketsys 登录



- /**
- * 前台首页控制器
- * @author Administrator
- *
- */
- @RequestMapping("/home")
- @Controller
- public class IndexController {
-
- @Autowired
- private AccountService accountService;
- @Autowired
- private ProductCategoryService productCategoryService;
- @Autowired
- private ProductService productService;
- /**
- * 前台首页页面
- * @param model
- * @return
- */
- @RequestMapping(value = "/index",method = RequestMethod.GET)
- public ModelAndView index(ModelAndView model){
- model.addObject("productCategoryList", MenuUtil.getTreeCategory(productCategoryService.findList(new HashMap<String, Object>())));
- Map<String, Object> queryMap = new HashMap<String, Object>();
- queryMap.put("offset", 0);
- queryMap.put("pageSize", 5);
- queryMap.put("orderBy", "createTime");
- queryMap.put("sort", "desc");
- model.addObject("lastProductList", productService.findList(queryMap));
- queryMap.put("orderBy", "sellNum");
- model.addObject("sellProductList", productService.findList(queryMap));
- model.addObject("allCategoryClass","shop_hd_menu_hover");
- model.addObject("currentHome", "current_");
- model.setViewName("home/index/index");
- return model;
- }
-
- /**
- * 用户登录页面
- * @param model
- * @return
- */
- @RequestMapping(value = "/login",method = RequestMethod.GET)
- public ModelAndView login(ModelAndView model){
- model.addObject("title", "用户登录");
- model.setViewName("home/index/login");
- return model;
- }
-
- /**
- * 用户登录页面
- * @param model
- * @return
- */
- @RequestMapping(value = "/register",method = RequestMethod.GET)
- public ModelAndView register(ModelAndView model){
- model.addObject("title", "用户注册");
- model.setViewName("home/index/register");
- return model;
- }
-
- /**
- * 提交注册信息
- * @param account
- * @return
- */
- @RequestMapping(value = "/register",method = RequestMethod.POST)
- @ResponseBody
- public Map<String, String> register(Account account,String code,HttpServletRequest request){
- Map<String, String> ret = new HashMap<String, String>();
- ret.put("type", "error");
- if(account == null){
- ret.put("msg", "请填写正确的用户信息");
- return ret;
- }
- if(StringUtils.isEmpty(account.getName())){
- ret.put("msg", "请填写用户名");
- return ret;
- }
- if(StringUtils.isEmpty(account.getPassword())){
- ret.put("msg", "请填写密码");
- return ret;
- }
- if(StringUtils.isEmpty(account.getEmail())){
- ret.put("msg", "请填写邮箱");
- return ret;
- }
- if(StringUtils.isEmpty(code)){
- ret.put("msg", "请填写验证码");
- return ret;
- }
- Object codeObject = request.getSession().getAttribute("userRegisterCpacha");
- if(codeObject == null){
- ret.put("msg", "验证码已过期,请刷新页面后重试!");
- return ret;
- }
- if(!code.equalsIgnoreCase((String)codeObject)){
- ret.put("msg", "验证码错误!");
- return ret;
- }
- Account findByName = accountService.findByName(account.getName());
- if(findByName != null){
- ret.put("msg", "该用户名已存在!");
- return ret;
- }
- account.setStatus(1);
- account.setCreateTime(new Date());
- if(accountService.add(account) <= 0){
- ret.put("msg", "注册失败,请联系管理员!");
- return ret;
- }
- ret.put("type", "success");
- return ret;
- }
-
- /**
- * 提交注册信息
- * @param account
- * @return
- */
- @RequestMapping(value = "/login",method = RequestMethod.POST)
- @ResponseBody
- public Map<String, String> login(Account account,String code,HttpServletRequest request){
- Map<String, String> ret = new HashMap<String, String>();
- ret.put("type", "error");
- if(account == null){
- ret.put("msg", "请填写正确的用户信息");
- return ret;
- }
- if(StringUtils.isEmpty(account.getName())){
- ret.put("msg", "请填写用户名");
- return ret;
- }
- if(StringUtils.isEmpty(account.getPassword())){
- ret.put("msg", "请填写密码");
- return ret;
- }
- if(StringUtils.isEmpty(code)){
- ret.put("msg", "请填写验证码");
- return ret;
- }
- Object codeObject = request.getSession().getAttribute("userLoginCpacha");
- if(codeObject == null){
- ret.put("msg", "验证码已过期,请刷新页面后重试!");
- return ret;
- }
- if(!code.equalsIgnoreCase((String)codeObject)){
- ret.put("msg", "验证码错误!");
- return ret;
- }
- Account findByName = accountService.findByName(account.getName());
- if(findByName == null){
- ret.put("msg", "该用户名不存在!");
- return ret;
- }
- if(!account.getPassword().equals(findByName.getPassword())){
- ret.put("msg", "密码错误!");
- return ret;
- }
- if(findByName.getStatus() == 0){
- ret.put("msg", "该用户已被冻结,请联系管理员!");
- return ret;
- }
- request.getSession().setAttribute("userLoginCpacha", null);
- request.getSession().setAttribute("account", findByName);
- ret.put("type", "success");
- return ret;
- }
-
- }
- /**
- * 前台用户中心控制器
- * @author Administrator
- *
- */
- @RequestMapping("/user")
- @Controller
- public class HomeUserController {
-
- @Autowired
- private AccountService accountService;
- @Autowired
- private ProductCategoryService productCategoryService;
- @Autowired
- private ProductService productService;
- @Autowired
- private OrderService orderService;
- @Autowired
- private CartService cartService;
- @Autowired
- private AddressService addressService;
- /**
- * 用户中心页面
- * @param model
- * @return
- */
- @RequestMapping(value = "/info",method = RequestMethod.GET)
- public ModelAndView info(ModelAndView model,HttpServletRequest request){
- model.addObject("productCategoryList", MenuUtil.getTreeCategory(productCategoryService.findList(new HashMap<String, Object>())));
- model.addObject("allCategoryId","shop_hd_menu_all_category");
- Account onlineAccount = (Account)request.getSession().getAttribute("account");
- model.addObject("user", onlineAccount);
- model.addObject("currentUser", "current_");
- model.setViewName("home/user/info");
- return model;
- }
-
- /**
- * 修改密码页面
- * @param model
- * @return
- */
- @RequestMapping(value = "/update_pwd",method = RequestMethod.GET)
- public ModelAndView updatePwd(ModelAndView model){
- model.addObject("productCategoryList", MenuUtil.getTreeCategory(productCategoryService.findList(new HashMap<String, Object>())));
- model.addObject("allCategoryId","shop_hd_menu_all_category");
- model.addObject("currentUser", "current_");
- model.setViewName("home/user/update_pwd");
- return model;
- }
-
- /**
- * 修改密码提交
- * @param password
- * @param newPassword
- * @param request
- * @return
- */
- @RequestMapping(value = "/update_pwd",method = RequestMethod.POST)
- @ResponseBody
- public Map<String, String> updatePassword(String password,String newPassword,
- HttpServletRequest request){
- Map<String, String> ret = new HashMap<String, String>();
- Account onlineAccount = (Account)request.getSession().getAttribute("account");
- ret.put("type", "error");
- if(StringUtils.isEmpty(password)){
- ret.put("msg", "旧密码不能为空!");
- return ret;
- }
- if(StringUtils.isEmpty(newPassword)){
- ret.put("msg", "新密码不能为空!");
- return ret;
- }
- if(!onlineAccount.getPassword().equals(password)){
- ret.put("msg", "旧密码错误!");
- return ret;
- }
- onlineAccount.setPassword(newPassword);
- if(accountService.edit(onlineAccount) <= 0){
- ret.put("msg", "修改失败,请联系管理员!");
- return ret;
- }
- ret.put("type", "success");
- return ret;
- }
-
- /**
- * 更新资料
- * @param account
- * @return
- */
- @RequestMapping(value = "/update_info",method = RequestMethod.POST)
- @ResponseBody
- public Map<String, String> updateInfo(Account account,
- HttpServletRequest request){
- Map<String, String> ret = new HashMap<String, String>();
- Account onlineAccount = (Account)request.getSession().getAttribute("account");
- ret.put("type", "error");
- if(account == null){
- ret.put("msg", "请填写正确的信息");
- return ret;
- }
- if(StringUtils.isEmpty(account.getEmail())){
- ret.put("msg", "邮箱地址不能为空!");
- return ret;
- }
- if(StringUtils.isEmpty(account.getTrueName())){
- ret.put("msg", "真实姓名不能为空!");
- return ret;
- }
- onlineAccount.setEmail(account.getEmail());
- onlineAccount.setTrueName(account.getTrueName());
- onlineAccount.setSex(account.getSex());
- if(accountService.edit(onlineAccount) <= 0){
- ret.put("msg", "修改失败,请联系管理员!");
- return ret;
- }
- ret.put("type", "success");
- return ret;
- }
-
- /**
- * 下单成功展示页面
- * @param model
- * @param request
- * @return
- */
- @RequestMapping(value = "/order_success",method = RequestMethod.GET)
- public ModelAndView orderSuccess(ModelAndView model,Long orderId,HttpServletRequest request){
- model.addObject("productCategoryList", MenuUtil.getTreeCategory(productCategoryService.findList(new HashMap<String, Object>())));
- model.addObject("allCategoryId","shop_hd_menu_all_category");
- model.addObject("currentCart", "current_");
- model.addObject("order", orderService.findById(orderId));
- model.setViewName("home/cart/order_success");
- return model;
- }
-
-
- }
如果也想学习本系统,下面领取。回复:114ssm