深圳公司网站建设公司,网站开发前端跟后端的区别,青岛东八区创意做网站,网上商城建网站末尾获取源码 开发语言#xff1a;Java Java开发工具#xff1a;JDK1.8 后端框架#xff1a;SSM 前端#xff1a;Vue 数据库#xff1a;MySQL5.7和Navicat管理工具结合 服务器#xff1a;Tomcat8.5 开发软件#xff1a;IDEA / Eclipse 是否Maven项目#xff1a;是 目录… 末尾获取源码 开发语言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;/*** 登录*/IgnoreAuthPostMapping(value /login)public R login(String username, String password, String captcha, HttpServletRequest request) {UserEntity user userService.selectOne(new EntityWrapperUserEntity().eq(username, username));if(usernull || !user.getPassword().equals(password)) {return R.error(账号或密码不正确);}String token tokenService.generateToken(user.getId(),username, users, user.getRole());return R.ok().put(token, token);}/*** 注册*/IgnoreAuthPostMapping(value /register)public R register(RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);if(userService.selectOne(new EntityWrapperUserEntity().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(退出成功);}/*** 密码重置*/IgnoreAuthRequestMapping(value /resetPass)public R resetPass(String username, HttpServletRequest request){UserEntity user userService.selectOne(new EntityWrapperUserEntity().eq(username, username));if(usernull) {return R.error(账号不存在);}user.setPassword(123456);userService.update(user,null);return R.ok(密码已重置为123456);}/*** 列表*/RequestMapping(/page)public R page(RequestParam MapString, Object params,UserEntity user){EntityWrapperUserEntity ew new EntityWrapperUserEntity();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){EntityWrapperUserEntity ew new EntityWrapperUserEntity();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 EntityWrapperUserEntity().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 EntityWrapperConfigEntity().eq(name, faceFile));if(configEntitynull) {configEntity new ConfigEntity();configEntity.setName(faceFile);configEntity.setValue(fileName);} else {configEntity.setValue(fileName);}configService.insertOrUpdate(configEntity);}return R.ok().put(file, fileName);}/*** 下载文件*/IgnoreAuthRequestMapping(/download)public ResponseEntitybyte[] 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 ResponseEntitybyte[](FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);}} catch (IOException e) {e.printStackTrace();}return new ResponseEntitybyte[](HttpStatus.INTERNAL_SERVER_ERROR);}}封装
package com.utils;import java.util.HashMap;
import java.util.Map;/*** 返回数据*/
public class R extends HashMapString, 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(MapString, 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;}
}