当前位置: 首页 > news >正文

基于SSM+Vue的咖啡销售系统

末尾获取源码
开发语言:Java
Java开发工具:JDK1.8
后端框架:SSM
前端:Vue
数据库:MySQL5.7和Navicat管理工具结合
服务器:Tomcat8.5
开发软件:IDEA / Eclipse
是否Maven项目:是


目录

一、项目简介

二、系统功能

三、系统项目截图

登录模块详细设计

用户注册模块

在线客服模块的实现

个人中心管理模块

咖啡信息管理模块的实现

系统管理模块的实现

下单流程模块的实现

订单管理模块设计

用户前台界面模块

四、核心代码

登录相关

文件上传

封装


一、项目简介

现代社会是计算机技术普遍发展与应用的社会,甚至无网不成行,由此可见信息网络已经在商家活动或者人们生活中占据非常重要的地位,成为各行业不可割舍的重要组成。而随着网络地位的越来越突出,网络平台已经超越电视、报纸等传统媒体,成为商家宣传与发展的重要平台。网络费用低廉,只要商家建立网站、或者利用其它大众平台,就能够实现网上购物、信息更新与查询等等功能,所有这些都是在与时俱进的过程中,为商家争取更多的效益,所以对于商家来说,拥有一个属于自己的网站平台是非常重要的。

近年来,由于电子商务和网上商城的快速发展,越来越多的人在网上商城进行商品的交易,取代了传统的当面交易,这无非使交易更安全更快捷。本文以咖啡销售系统为题,进行系统开发,主要解决人们在线购物的流畅,实现计算机化管理。

本文是针对web技术进行相应研究,并在其基础之上制定了一套基于SSM三层体系结构,采用JAVA技术结合Mysql数据库来实现咖啡商品管理系统。


二、系统功能

前台功能有查看咖啡资讯、咖啡商品等信息,进行用户注册,登录后进行在线咨询,商品购买等。用户后台功能有个人资料管理、购物车结算管理、我的订单管理;管理员功能有系统管理员(管理员添加、管理员查询、注册用户管理、修改密码)、咖啡资讯管理(咖啡资讯添加、咖啡资讯查询)、咖啡商品信息管理(商品类别添加、商品类别查询)、所有订单管理、系统管理(在线客服、轮播图)。



三、系统项目截图

登录模块详细设计

本系统角色有两类,管理员、注册用户,他们都属于系统的用户,用户登录实现的过程主要有几个步骤,首先对用户输入的信息进行保存然后利用JAVA程序从数据库中进行检索看是不是有用户输入的信息在数据库中是否存在如果存在就返回正确的结果,如果不正确就返回错误的结果。如果结果数据库中存在就显示登录成功,如果数据库不存在就显示失败请重新登录。

用户注册模块

用户需要注册登录才能进行购买商品。所以网站提供了一个用户注册和登陆的模块,用户需要正确输入账号和密码才能登录系统。

 

在线客服模块的实现

在线客服需要用户登录后才可以实现。 

个人中心管理模块

管理员登入系统,可以添加新的管理员用户,删除现有的管理员,也可以对自己的密码进行修改。修改密码,添加删除管理员实现的过程主要是将填写的数据写入数据库中即可。

 

咖啡信息管理模块的实现

管理员登录系统后,可以添加上传咖啡信息,管理员可以对咖啡信息进行增删改查,用户在前台登录后可以查询咖啡信息。

系统管理模块的实现

管理员登录系统后,可以管理咖啡资讯和在线客服以及轮播图。 

 

下单流程模块的实现

首先,用户经过注册登录系统前台,进行商品购买,用户选择商品和购买数量,进行添加购物车,用户进入个人后台,进行购物车结算,生成订单,商家登录后台进行用户订单审核,审核通过,进行商品发货,用户购买成功。

 

订单管理模块设计

订单管理模块分为两部分:用户的订单管理和管理员的订单管理,用户在前台进行商品的在线下单,登录个人后台之后,选择购物车的订单,生成有最终订单,付款成功后,这样在管理员后台就可以看到该单子。

 

用户前台界面模块

用户前台功能有查看咖啡资讯、商品、个人中心、购物车、在线客服等信息,进行用户注册,登录后进行在线咨询,商品购买等。用户后台功能有个人资料管理、我的收藏管理、我的订单管理等,主要是将在前台添加进行购物车的商品进行生成订单。


四、核心代码

登录相关


package com.controller;import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;/*** 登录相关*/
@RequestMapping("users")
@RestController
public class UserController{@Autowiredprivate UserService userService;@Autowiredprivate TokenService tokenService;/*** 登录*/@IgnoreAuth@PostMapping(value = "/login")public R login(String username, String password, String captcha, HttpServletRequest request) {UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));if(user==null || !user.getPassword().equals(password)) {return R.error("账号或密码不正确");}String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());return R.ok().put("token", token);}/*** 注册*/@IgnoreAuth@PostMapping(value = "/register")public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {return R.error("用户已存在");}userService.insert(user);return R.ok();}/*** 退出*/@GetMapping(value = "logout")public R logout(HttpServletRequest request) {request.getSession().invalidate();return R.ok("退出成功");}/*** 密码重置*/@IgnoreAuth@RequestMapping(value = "/resetPass")public R resetPass(String username, HttpServletRequest request){UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));if(user==null) {return R.error("账号不存在");}user.setPassword("123456");userService.update(user,null);return R.ok("密码已重置为:123456");}/*** 列表*/@RequestMapping("/page")public R page(@RequestParam Map<String, Object> params,UserEntity user){EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));return R.ok().put("data", page);}/*** 列表*/@RequestMapping("/list")public R list( UserEntity user){EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();ew.allEq(MPUtil.allEQMapPre( user, "user")); return R.ok().put("data", userService.selectListView(ew));}/*** 信息*/@RequestMapping("/info/{id}")public R info(@PathVariable("id") String id){UserEntity user = userService.selectById(id);return R.ok().put("data", user);}/*** 获取用户的session用户信息*/@RequestMapping("/session")public R getCurrUser(HttpServletRequest request){Long id = (Long)request.getSession().getAttribute("userId");UserEntity user = userService.selectById(id);return R.ok().put("data", user);}/*** 保存*/@PostMapping("/save")public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {return R.error("用户已存在");}userService.insert(user);return R.ok();}/*** 修改*/@RequestMapping("/update")public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);userService.updateById(user);//全部更新return R.ok();}/*** 删除*/@RequestMapping("/delete")public R delete(@RequestBody Long[] ids){userService.deleteBatchIds(Arrays.asList(ids));return R.ok();}
}

文件上传

package com.controller;import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;/*** 上传文件映射表*/
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{@Autowiredprivate ConfigService configService;/*** 上传文件*/@RequestMapping("/upload")public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {if (file.isEmpty()) {throw new EIException("上传文件不能为空");}String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);File path = new File(ResourceUtils.getURL("classpath:static").getPath());if(!path.exists()) {path = new File("");}File upload = new File(path.getAbsolutePath(),"/upload/");if(!upload.exists()) {upload.mkdirs();}String fileName = new Date().getTime()+"."+fileExt;File dest = new File(upload.getAbsolutePath()+"/"+fileName);file.transferTo(dest);FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));if(StringUtils.isNotBlank(type) && type.equals("1")) {ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));if(configEntity==null) {configEntity = new ConfigEntity();configEntity.setName("faceFile");configEntity.setValue(fileName);} else {configEntity.setValue(fileName);}configService.insertOrUpdate(configEntity);}return R.ok().put("file", fileName);}/*** 下载文件*/@IgnoreAuth@RequestMapping("/download")public ResponseEntity<byte[]> download(@RequestParam String fileName) {try {File path = new File(ResourceUtils.getURL("classpath:static").getPath());if(!path.exists()) {path = new File("");}File upload = new File(path.getAbsolutePath(),"/upload/");if(!upload.exists()) {upload.mkdirs();}File file = new File(upload.getAbsolutePath()+"/"+fileName);if(file.exists()){/*if(!fileService.canRead(file, SessionManager.getSessionUser())){getResponse().sendError(403);}*/HttpHeaders headers = new HttpHeaders();headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    headers.setContentDispositionFormData("attachment", fileName);    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);}} catch (IOException e) {e.printStackTrace();}return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);}}

封装

package com.utils;import java.util.HashMap;
import java.util.Map;/*** 返回数据*/
public class R extends HashMap<String, Object> {private static final long serialVersionUID = 1L;public R() {put("code", 0);}public static R error() {return error(500, "未知异常,请联系管理员");}public static R error(String msg) {return error(500, msg);}public static R error(int code, String msg) {R r = new R();r.put("code", code);r.put("msg", msg);return r;}public static R ok(String msg) {R r = new R();r.put("msg", msg);return r;}public static R ok(Map<String, Object> map) {R r = new R();r.putAll(map);return r;}public static R ok() {return new R();}public R put(String key, Object value) {super.put(key, value);return this;}
}

http://www.lryc.cn/news/196423.html

相关文章:

  • L2-026 小字辈
  • linux 查看系统版本
  • Python实现PDF转换文件格式
  • 【Ceph Cluster】完全删除Ceph集群
  • 4.Vue-Vue调用第三方接口
  • 大语言模型在推荐系统的实践应用
  • 第三章 交换技术及应用
  • 地震勘探原理部分问题解答
  • 两个步骤轻松搞定批量合并视频
  • VR虚拟现实在室内设计仿真教学中的应用演示
  • Python操作串口通信
  • 图详解第四篇:单源最短路径--Dijkstra算法
  • CRMEB多商户商城系统阿里云集群部署教程
  • Java第三方登录封装工具类
  • BUUCTF学习(四): 文件包含tips
  • 德国人工智能公司【Kodex AI】完成160万欧元融资
  • LeetCode 2 两数相加
  • springboot项目启动失败,不打印报错详细信息(启动打印日记问题)
  • MyBatis (where、set、foreach)标签
  • flutter开发之安装dart
  • 向量召回:深入评估离线体系,探索优质召回方法
  • 播放器缓存队列bug解决方案
  • React拖拽实践
  • Stable Diffusion绘图,lora选择
  • kube-controller-manager和kube-scheduler不能正常启动
  • Mac OS m1 下安装Gradle5.1
  • JUC并发编程面试题(自用)
  • Redis分布式会话
  • 程序员大厂之鹅厂探秘
  • 【Java 进阶篇】深入理解 JavaScript DOM Node 对象