【524】基于java springboot在线彩妆商城交易平台源码和论文
摘 要
伴随着互联网技术的进步,各种电商平台也如雨后 春笋不断涌现。一个好的电商平台应该具有用户体验度高,用户信息安全等特点, 从而可以满足更多的用户需求。现有的电商平台虽然在不断完善,但仍然存在着 不少问题。本设计是一个基于springboot框架开发的彩妆销售商城项目,在较好地实现传 统电商平台的基础上又有创新和改善之处,比如分层搭建的设计思想,md5加密 算法的改进以及设计更为友好的操作界面等,以更好地服务大众。
本彩妆销售商城网站以IDEA+mysql为开发环境,JSP+CSS+JavaScript为页面编辑语言,springboot+mybatis为后台编辑语言来设计开发,开发一个彩妆销售商城正是为了企业独立开发的目的。J2EE体系的彩妆销售商城 具备很高的安全性和稳定性,以及更加出色的可扩展性和跨平台特点。在国外 J2EE 已经成为开发电子商务平台的主流技术,本文研发的彩妆销售商城系统使消费者进行购物时,不但商品推荐更为符合消费者的消 费习惯,且商品的质量安全以及用户个人信息能够得到有效保障,提升了消费者的购物体验,本系统主要设计用户选购,加入购物车,下单等功能,当然对应的有一个后台系统管理,主要是对前端即用户端的一个数据的支持管理,只有管理员角色才可以登陆。
本文基于springboot mybatis框架完整的实现了一个彩妆销售商城系统,可以为用户提供购买商品、等多个功能。从测试结果来看,系统完整实现了所需功能,而且具有一定的 稳定性和可靠性,并能够为用户提供良好的用户体验。总之,本系统基本符合客户的 需求,并达到了预期的目标。
关键词:彩妆销售商城 Idea mysql springboot
Abstract
With the progress of Internet technology, various e-commerce platforms have sprung up. A good e-commerce platform should have the characteristics of high user experience and user information security, so as to meet more user needs. Although the existing e-commerce platform is constantly improving, there are still many problems. This design is an e-mall project developed based on SSM framework. On the basis of better realizing the traditional e-commerce platform, there are also innovations and improvements, such as the design idea of layered construction, the improvement of MD5 encryption algorithm and the design of a more friendly operation interface, so as to better serve the public.
This online mall website is designed and developed with idea + MySQL as the development environment, JSP + CSS + JavaScript as the page editing language and springboot + mybatis as the background editing language. Developing an electronic mall is just for the purpose of independent development of enterprises. The e-mall based on J2EE system has high security and stability, as well as better scalability and cross platform characteristics. In foreign countries, J2EE has become the mainstream technology for developing e-commerce platform. The online mall system developed in this paper not only makes consumers' commodity recommendation more in line with consumers' consumption habits, but also effectively ensures the quality and safety of commodities and users' personal information, and improves consumers' shopping experience. This system is mainly designed for users to purchase, Add shopping cart, order and other functions. Of course, there is a background system management corresponding to it, which mainly supports and manages the data of the front end, that is, the user end. Only the administrator role can log in。
Based on the framework of springboot mybatis, this paper completely implements an online mall system, which can provide users with many functions, such as purchasing goods and so on. From the test results, the system has completely realized the required functions, has certain stability and reliability, and can provide users with a good user experience. In short, the system basically meets the needs of customers and achieves the expected goal。
Key words: shop Idea mysql springboot
package com.shop.controller.front;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shop.entity.*;
import com.shop.entity.*;
import com.shop.service.AddressService;
import com.shop.service.GoodsService;
import com.shop.service.OrderService;
import com.shop.service.UserService;
import com.shop.util.Md5Util;
import com.shop.util.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Controller
public class CustomerController {
@RequestMapping("/login")
public String loginView() {
return "login";
}
@Autowired
private UserService userService;
@RequestMapping("/register")
public String register() {
return "register";
}
@RequestMapping("/registerresult")
public String registerResult(User user, Model registerResult) {
List<User> userList = new ArrayList<>();
user.setPassword(Md5Util.MD5Encode(user.getPassword(), "utf-8"));
UserExample userExample = new UserExample();
userExample.or().andUsernameLike(user.getUsername());
userList = userService.selectByExample(userExample);
if (!userList.isEmpty()) {
registerResult.addAttribute("errorMsg", "用户名被占用");
return "register";
} else {
Date RegTime = new Date();
user.setRegtime(RegTime);
userService.insertSelective(user);
return "redirect:/login";
}
}
@RequestMapping("/loginconfirm")
public String loginConfirm(User user, Model loginResult, HttpServletRequest request, @RequestParam("confirmlogo") String confirmlogo) {
System.out.println("传进来的用户帐号和密码为:" + user);
//进行用户密码MD5加密验证
user.setPassword(Md5Util.MD5Encode(user.getPassword(), "UTF-8"));
HttpSession session = request.getSession();
String verificationCode = (String) session.getAttribute("certCode");
if (!confirmlogo.equals(verificationCode)) {
loginResult.addAttribute("errorMsg", "验证码错误");
return "login";
}
List<User> userList = new ArrayList<User>();
UserExample userExample = new UserExample();
userExample.or().andUsernameEqualTo(user.getUsername()).andPasswordEqualTo(user.getPassword());
userList = userService.selectByExample(userExample);
if (!userList.isEmpty()) {
session.setAttribute("user", userList.get(0));
return "redirect:/main";
} else {
loginResult.addAttribute("errorMsg", "用户名与密码不匹配");
return "login";
}
}
@RequestMapping("/information")
public String information(Model userModel, HttpServletRequest request) {
HttpSession session = request.getSession();
User user;
Integer userId;
user = (User) session.getAttribute("user");
if (user == null) {
return "redirect:/login";
}
userId = user.getUserid();
user = userService.selectByPrimaryKey(userId);
userModel.addAttribute("user", user);
return "information";
}
@RequestMapping("/saveInfo")
@ResponseBody
public Msg saveInfo(String name, String email, String telephone, HttpServletRequest request) {
try {
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
Integer userid = user.getUserid();
User user1 = userService.selectByPrimaryKey(userid);
user1.setEmail(email);
user1.setTelephone(telephone);
userService.updateByPrimaryKeySelective(user1);
return Msg.success("更新成功");
} catch (Exception e) {
e.printStackTrace();
return Msg.fail("更新失败");
}
}
@Autowired
private AddressService addressService;
@RequestMapping("/info/address")
public String address(HttpServletRequest request, Model addressModel) {
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
if (user == null) {
return "redirect:/login";
}
AddressExample addressExample = new AddressExample();
addressExample.or().andUseridEqualTo(user.getUserid());
List<Address> addressList = addressService.getAllAddressByExample(addressExample);
addressModel.addAttribute("addressList", addressList);
return "address";
}
@RequestMapping("/saveAddr")
@ResponseBody
public Msg saveAddr(Address address) {
addressService.updateByPrimaryKeySelective(address);
return Msg.success("修改成功");
}
@RequestMapping("/deleteAddr")
@ResponseBody
public Msg deleteAddr(Address address) {
addressService.deleteByPrimaryKey(address.getAddressid());
return Msg.success("删除成功");
}
@RequestMapping("/insertAddr")
@ResponseBody
public Msg insertAddr(Address address, HttpServletRequest request) {
HttpSession session = request.getSession();
User user = new User();
user = (User) session.getAttribute("user");
address.setUserid(user.getUserid());
addressService.insertSelective(address);
return Msg.success("添加成功");
}
@Autowired
private OrderService orderService;
@Autowired
private GoodsService goodsService;
@RequestMapping("/info/list")
public String list(HttpServletRequest request, Model orderModel) {
HttpSession session = request.getSession();
User user;
user = (User) session.getAttribute("user");
if (user == null) {
return "redirect:/login";
}
OrderExample orderExample = new OrderExample();
orderExample.or().andUseridEqualTo(user.getUserid());
List<Order> orderList = orderService.selectOrderByExample(orderExample);
orderModel.addAttribute("orderList", orderList);
Order order;
OrderItem orderItem;
List<OrderItem> orderItemList = new ArrayList<>();
Goods goods;
Address address;
for (Integer i = 0; i < orderList.size(); i++) {
order = orderList.get(i);
OrderItemExample orderItemExample = new OrderItemExample();
orderItemExample.or().andOrderidEqualTo(order.getOrderid());
orderItemList = orderService.getOrderItemByExample(orderItemExample);
List<Goods> goodsList = new ArrayList<>();
List<Integer> goodsIdList = new ArrayList<>();
for (Integer j = 0; j < orderItemList.size(); j++) {
orderItem = orderItemList.get(j);
Goods good = goodsService.selectById(orderItem.getGoodsid());
good.setCategory(orderItem.getNum());
goodsList.add(good);
}
order.setGoodsInfo(goodsList);
address = addressService.selectByPrimaryKey(order.getAddressid());
order.setAddress(address);
orderList.set(i, order);
}
orderModel.addAttribute("orderList", orderList);
return "list";
}
@RequestMapping("/deleteList")
@ResponseBody
public Msg deleteList(Order order) {
orderService.deleteById(order.getOrderid());
return Msg.success("删除成功");
}
/**
* 收藏商品
* @param pn
* @param request
* @param model
* @return
*/
@RequestMapping("/info/favorite")
public String showFavorite(@RequestParam(value = "page", defaultValue = "1") Integer pn, HttpServletRequest request, Model model) {
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
if (user == null) {
return "redirect:/login";
}
//一页显示几个数据
PageHelper.startPage(pn, 16);
FavoriteExample favoriteExample = new FavoriteExample();
favoriteExample.or().andUseridEqualTo(user.getUserid());
List<Favorite> favoriteList = goodsService.selectFavByExample(favoriteExample);
List<Integer> goodsIdList = new ArrayList<Integer>();
for (Favorite tmp : favoriteList) {
goodsIdList.add(tmp.getGoodsid());
}
List<Goods> goodsList = new ArrayList<>();
if(goodsIdList!=null && goodsIdList.size()>0){
for (Integer id:goodsIdList) {
goodsList.add( goodsService.selectById(id)) ;
}
}
//获取图片地址
for (int i = 0; i < goodsList.size(); i++) {
Goods goods = goodsList.get(i);
List<ImagePath> imagePathList = goodsService.findImagePath(goods.getGoodsid());
goods.setImagePaths(imagePathList);
//判断是否收藏
goods.setFav(true);
goodsList.set(i, goods);
}
//显示几个页号
PageInfo page = new PageInfo(goodsList, 5);
model.addAttribute("pageInfo", page);
return "favorite";
}
@RequestMapping("/savePsw")
@ResponseBody
public Msg savePsw(String Psw, HttpServletRequest request) {
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
user.setPassword(Md5Util.MD5Encode(Psw, "UTF-8"));
userService.updateByPrimaryKeySelective(user);
return Msg.success("修改密码成功");
}
@RequestMapping("/finishList")
@ResponseBody
public Msg finishiList(Integer orderid) {
Order order = orderService.selectByPrimaryKey(orderid);
order.setIsreceive(true);
order.setIscomplete(true);
orderService.updateOrderByKey(order);
return Msg.success("完成订单成功");
}
@RequestMapping("/logout")
public String logout(HttpServletRequest request) {
HttpSession session = request.getSession();
session.removeAttribute("user");
return "redirect:/login";
}
}