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


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


    目录

    一、项目简介

    二、系统功能

    三、系统项目截图

    登录模块详细设计

    用户注册模块

    在线客服模块的实现

    个人中心管理模块

    咖啡信息管理模块的实现

    系统管理模块的实现

    下单流程模块的实现

    订单管理模块设计

    用户前台界面模块

    四、核心代码

    登录相关

    文件上传

    封装


    一、项目简介

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

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

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


    二、系统功能

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



    三、系统项目截图

    登录模块详细设计

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

    用户注册模块

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

     

    在线客服模块的实现

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

    个人中心管理模块

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

     

    咖啡信息管理模块的实现

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

    系统管理模块的实现

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

     

    下单流程模块的实现

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

     

    订单管理模块设计

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

     

    用户前台界面模块

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


    四、核心代码

    登录相关

    1. package com.controller;
    2. import java.util.Arrays;
    3. import java.util.Calendar;
    4. import java.util.Date;
    5. import java.util.Map;
    6. import javax.servlet.http.HttpServletRequest;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.stereotype.Controller;
    9. import org.springframework.web.bind.annotation.GetMapping;
    10. import org.springframework.web.bind.annotation.PathVariable;
    11. import org.springframework.web.bind.annotation.PostMapping;
    12. import org.springframework.web.bind.annotation.RequestBody;
    13. import org.springframework.web.bind.annotation.RequestMapping;
    14. import org.springframework.web.bind.annotation.RequestParam;
    15. import org.springframework.web.bind.annotation.ResponseBody;
    16. import org.springframework.web.bind.annotation.RestController;
    17. import com.annotation.IgnoreAuth;
    18. import com.baomidou.mybatisplus.mapper.EntityWrapper;
    19. import com.entity.TokenEntity;
    20. import com.entity.UserEntity;
    21. import com.service.TokenService;
    22. import com.service.UserService;
    23. import com.utils.CommonUtil;
    24. import com.utils.MD5Util;
    25. import com.utils.MPUtil;
    26. import com.utils.PageUtils;
    27. import com.utils.R;
    28. import com.utils.ValidatorUtils;
    29. /**
    30. * 登录相关
    31. */
    32. @RequestMapping("users")
    33. @RestController
    34. public class UserController{
    35. @Autowired
    36. private UserService userService;
    37. @Autowired
    38. private TokenService tokenService;
    39. /**
    40. * 登录
    41. */
    42. @IgnoreAuth
    43. @PostMapping(value = "/login")
    44. public R login(String username, String password, String captcha, HttpServletRequest request) {
    45. UserEntity user = userService.selectOne(new EntityWrapper().eq("username", username));
    46. if(user==null || !user.getPassword().equals(password)) {
    47. return R.error("账号或密码不正确");
    48. }
    49. String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
    50. return R.ok().put("token", token);
    51. }
    52. /**
    53. * 注册
    54. */
    55. @IgnoreAuth
    56. @PostMapping(value = "/register")
    57. public R register(@RequestBody UserEntity user){
    58. // ValidatorUtils.validateEntity(user);
    59. if(userService.selectOne(new EntityWrapper().eq("username", user.getUsername())) !=null) {
    60. return R.error("用户已存在");
    61. }
    62. userService.insert(user);
    63. return R.ok();
    64. }
    65. /**
    66. * 退出
    67. */
    68. @GetMapping(value = "logout")
    69. public R logout(HttpServletRequest request) {
    70. request.getSession().invalidate();
    71. return R.ok("退出成功");
    72. }
    73. /**
    74. * 密码重置
    75. */
    76. @IgnoreAuth
    77. @RequestMapping(value = "/resetPass")
    78. public R resetPass(String username, HttpServletRequest request){
    79. UserEntity user = userService.selectOne(new EntityWrapper().eq("username", username));
    80. if(user==null) {
    81. return R.error("账号不存在");
    82. }
    83. user.setPassword("123456");
    84. userService.update(user,null);
    85. return R.ok("密码已重置为:123456");
    86. }
    87. /**
    88. * 列表
    89. */
    90. @RequestMapping("/page")
    91. public R page(@RequestParam Map params,UserEntity user){
    92. EntityWrapper ew = new EntityWrapper();
    93. PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
    94. return R.ok().put("data", page);
    95. }
    96. /**
    97. * 列表
    98. */
    99. @RequestMapping("/list")
    100. public R list( UserEntity user){
    101. EntityWrapper ew = new EntityWrapper();
    102. ew.allEq(MPUtil.allEQMapPre( user, "user"));
    103. return R.ok().put("data", userService.selectListView(ew));
    104. }
    105. /**
    106. * 信息
    107. */
    108. @RequestMapping("/info/{id}")
    109. public R info(@PathVariable("id") String id){
    110. UserEntity user = userService.selectById(id);
    111. return R.ok().put("data", user);
    112. }
    113. /**
    114. * 获取用户的session用户信息
    115. */
    116. @RequestMapping("/session")
    117. public R getCurrUser(HttpServletRequest request){
    118. Long id = (Long)request.getSession().getAttribute("userId");
    119. UserEntity user = userService.selectById(id);
    120. return R.ok().put("data", user);
    121. }
    122. /**
    123. * 保存
    124. */
    125. @PostMapping("/save")
    126. public R save(@RequestBody UserEntity user){
    127. // ValidatorUtils.validateEntity(user);
    128. if(userService.selectOne(new EntityWrapper().eq("username", user.getUsername())) !=null) {
    129. return R.error("用户已存在");
    130. }
    131. userService.insert(user);
    132. return R.ok();
    133. }
    134. /**
    135. * 修改
    136. */
    137. @RequestMapping("/update")
    138. public R update(@RequestBody UserEntity user){
    139. // ValidatorUtils.validateEntity(user);
    140. userService.updateById(user);//全部更新
    141. return R.ok();
    142. }
    143. /**
    144. * 删除
    145. */
    146. @RequestMapping("/delete")
    147. public R delete(@RequestBody Long[] ids){
    148. userService.deleteBatchIds(Arrays.asList(ids));
    149. return R.ok();
    150. }
    151. }

    文件上传

    1. package com.controller;
    2. import java.io.File;
    3. import java.io.FileNotFoundException;
    4. import java.io.IOException;
    5. import java.util.Arrays;
    6. import java.util.Date;
    7. import java.util.HashMap;
    8. import java.util.List;
    9. import java.util.Map;
    10. import java.util.Random;
    11. import java.util.UUID;
    12. import org.apache.commons.io.FileUtils;
    13. import org.apache.commons.lang3.StringUtils;
    14. import org.springframework.beans.factory.annotation.Autowired;
    15. import org.springframework.http.HttpHeaders;
    16. import org.springframework.http.HttpStatus;
    17. import org.springframework.http.MediaType;
    18. import org.springframework.http.ResponseEntity;
    19. import org.springframework.util.ResourceUtils;
    20. import org.springframework.web.bind.annotation.PathVariable;
    21. import org.springframework.web.bind.annotation.RequestBody;
    22. import org.springframework.web.bind.annotation.RequestMapping;
    23. import org.springframework.web.bind.annotation.RequestParam;
    24. import org.springframework.web.bind.annotation.RestController;
    25. import org.springframework.web.multipart.MultipartFile;
    26. import com.annotation.IgnoreAuth;
    27. import com.baomidou.mybatisplus.mapper.EntityWrapper;
    28. import com.entity.ConfigEntity;
    29. import com.entity.EIException;
    30. import com.service.ConfigService;
    31. import com.utils.R;
    32. /**
    33. * 上传文件映射表
    34. */
    35. @RestController
    36. @RequestMapping("file")
    37. @SuppressWarnings({"unchecked","rawtypes"})
    38. public class FileController{
    39. @Autowired
    40. private ConfigService configService;
    41. /**
    42. * 上传文件
    43. */
    44. @RequestMapping("/upload")
    45. public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
    46. if (file.isEmpty()) {
    47. throw new EIException("上传文件不能为空");
    48. }
    49. String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
    50. File path = new File(ResourceUtils.getURL("classpath:static").getPath());
    51. if(!path.exists()) {
    52. path = new File("");
    53. }
    54. File upload = new File(path.getAbsolutePath(),"/upload/");
    55. if(!upload.exists()) {
    56. upload.mkdirs();
    57. }
    58. String fileName = new Date().getTime()+"."+fileExt;
    59. File dest = new File(upload.getAbsolutePath()+"/"+fileName);
    60. file.transferTo(dest);
    61. FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
    62. if(StringUtils.isNotBlank(type) && type.equals("1")) {
    63. ConfigEntity configEntity = configService.selectOne(new EntityWrapper().eq("name", "faceFile"));
    64. if(configEntity==null) {
    65. configEntity = new ConfigEntity();
    66. configEntity.setName("faceFile");
    67. configEntity.setValue(fileName);
    68. } else {
    69. configEntity.setValue(fileName);
    70. }
    71. configService.insertOrUpdate(configEntity);
    72. }
    73. return R.ok().put("file", fileName);
    74. }
    75. /**
    76. * 下载文件
    77. */
    78. @IgnoreAuth
    79. @RequestMapping("/download")
    80. public ResponseEntity<byte[]> download(@RequestParam String fileName) {
    81. try {
    82. File path = new File(ResourceUtils.getURL("classpath:static").getPath());
    83. if(!path.exists()) {
    84. path = new File("");
    85. }
    86. File upload = new File(path.getAbsolutePath(),"/upload/");
    87. if(!upload.exists()) {
    88. upload.mkdirs();
    89. }
    90. File file = new File(upload.getAbsolutePath()+"/"+fileName);
    91. if(file.exists()){
    92. /*if(!fileService.canRead(file, SessionManager.getSessionUser())){
    93. getResponse().sendError(403);
    94. }*/
    95. HttpHeaders headers = new HttpHeaders();
    96. headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
    97. headers.setContentDispositionFormData("attachment", fileName);
    98. return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
    99. }
    100. } catch (IOException e) {
    101. e.printStackTrace();
    102. }
    103. return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
    104. }
    105. }

    封装

    1. package com.utils;
    2. import java.util.HashMap;
    3. import java.util.Map;
    4. /**
    5. * 返回数据
    6. */
    7. public class R extends HashMap {
    8. private static final long serialVersionUID = 1L;
    9. public R() {
    10. put("code", 0);
    11. }
    12. public static R error() {
    13. return error(500, "未知异常,请联系管理员");
    14. }
    15. public static R error(String msg) {
    16. return error(500, msg);
    17. }
    18. public static R error(int code, String msg) {
    19. R r = new R();
    20. r.put("code", code);
    21. r.put("msg", msg);
    22. return r;
    23. }
    24. public static R ok(String msg) {
    25. R r = new R();
    26. r.put("msg", msg);
    27. return r;
    28. }
    29. public static R ok(Map map) {
    30. R r = new R();
    31. r.putAll(map);
    32. return r;
    33. }
    34. public static R ok() {
    35. return new R();
    36. }
    37. public R put(String key, Object value) {
    38. super.put(key, value);
    39. return this;
    40. }
    41. }

  • 相关阅读:
    微服务组件
    Netty 的整体架构是怎样的?
    CentOS7安装maven3.8.6
    数字安全实操AG网址漏洞扫描原理与技术手段分析
    线性调频Z变换(CZT)
    毕业设计|基于stm32单片机的app视频遥控抽水灭火小车设计
    grafana的前端二次开发初体验
    【 Tkinter界面-练习05】 event和bind
    细数 GameFi 模型发展 ,未来仍可期?
    vue3新特性 Ⅱ
  • 原文地址:https://blog.csdn.net/weixin_52721608/article/details/133895692