基于javaweb+mysql的springboot网上电商项目(前后端分离+java+vue+springboot+ssm+mysql+maven+redis)

基于javaweb+mysql的springboot网上电商项目(前后端分离+java+vue+springboot+ssm+mysql+maven+redis)

运行环境

Java≥8、MySQL≥5.7、Node.js≥10

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行

前端:WebStorm/VSCode/HBuilderX等均可

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot网上电商项目(前后端分离+java+vue+springboot+ssm+mysql+maven+redis)

一、项目简述

本系统功能包括: 一款基于Springboot+Vue的电商项目,前后端分离项目,前台后台都有,前台商品展示购买,购物车分类,订 单查询等等,后台商品管理,订单管理,信息维护,用户管理等等。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX (Webstorm也 行)+ Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts都支 持)。

项目技术: Springboot + Maven + Mybatis + Vue + Redis, B/S 模式+ Maven等等,附带支付宝沙箱环境以及支付环节代码。

            return CommonResult.success("注册信息发送成功");
        } catch (Exception e) {
            return CommonResult.error("注册信息发送失败");
        }
    }

    @RequestMapping(value = "/allow/sendHtmlRole")
    public CommonResult sendRoleInfo(String sendTo, String userName, String roleInfo) {
        try {
            Map<String, Object> data = new HashMap<>();
            data.put("userName", userName);
            data.put("roleInfo", roleInfo);
            data.put("year", Calendar.getInstance().get(Calendar.YEAR));
            mailService.sendTemplateMail(sendTo, "权限管理", "role", data);
            return CommonResult.success("授权信息发送成功");
        } catch (Exception e) {
            return CommonResult.error("授权信息发送失败");
        }
    }

    @RequestMapping(value = "/allow/sendHtmlResetPwd")
    public CommonResult sendResetPwd(String sendTo, String pwd) {
        try {
            Map<String, Object> data = new HashMap<>();
            data.put("password", pwd);
            data.put("year", Calendar.getInstance().get(Calendar.YEAR));
            mailService.sendTemplateMail(sendTo, "重置密码", "resetpwd", data);
            return CommonResult.success("新密码信息发送成功");
        } catch (Exception e) {
            return CommonResult.error("新密码信息发送失败");
        }
    }

    /**
     * 发送一个邮箱附件
     *
     * @param sendTo 收件人
     */
    @RequestMapping(value = "/util/sendFile")
    public String sendmailFile(String sendTo, String content) {
        try {
            String filePath = "F:\\IDEA\\JAVA_Program\\Springboot-Mall\\src\\main\\resources\\static\\1.zip";
            mailService.sendAttachmentsMail(sendTo, "文件操作", content, filePath);
        List<Map<String, Object>> lineData = orderService.selectChartDATE(startTime,endTime);
        List<Map<String, Object>> ringData = orderService.selectProductTypeChart(startTime, endTime);
        Map<String, Object> countData = orderService.selectCountAndAmount(startTime,endTime);
        if(lineData.size()!=0){
            data.put("lineData",lineData);
        }
        if(ringData.size()!=0){
            data.put("ringData",ringData);
        }
        if(countData.size()!=0){
            data.put("countData",countData);
        }
        if(data.size()!=0){
            return CommonResult.success("查询成功",data);
        }else{
            return CommonResult.error("查询失败");
        }
    }

}

/**
 * @email qiudb.top@aliyun.com
 * @description 描述
 */
@RestController
@CrossOrigin
public class BannerController {
    final BannerService bannerService;
    public BannerController(BannerService bannerService){
        this.bannerService = bannerService;
    }

                    newProduct.setIsStockOut(newStock<product.getLowestStock());
                    // 如果库存小于等于0,自动下架
                    newProduct.setIsSale(newStock>0);
                    if(productService.updateById(newProduct)){
                        if(orderService.insertData(order)){
                            redisTemplate.opsForValue().set(order.getOrderNo(),order.getOrderNo(),24, TimeUnit.HOURS);
                            return CommonResult.success("创建订单成功",order);
                        }else{
                            return CommonResult.error("创建订单失败");
                        }
                    }else{
                        return CommonResult.error("创建订单失败");
                    }
                }else{
                    return CommonResult.error("商品库存不足");
                }
            }
        }else{
            return CommonResult.error("订单数据不完整");
        }
    }

    @RequestMapping(value = "/order/cartOrder")
    private CommonResult cartOrder(String orderNo,String ordersInfo) {
        JSONArray jsonArray = JSON.parseArray(ordersInfo);
        List<Order> orders = JSONObject.parseArray(jsonArray.toJSONString(), Order.class);
        if(orders!=null){
            ArrayList<String> orderInfo = new ArrayList<>();
            ArrayList<String> productInfo = new ArrayList<>();
            for (Order order : orders) {
                Product product = productService.selectByKey(order.getProductNo());
                Integer productStock = product.getProductStock();
                Integer payAmount = order.getPayAmount();
                boolean isOk =productStock >= payAmount;
                if(isOk){
                    Product newProduct = new Product();
                    newProduct.setProductId(product.getProductId());
                    int newStock = productStock - payAmount;
                    newProduct.setProductStock(newStock);
                    newProduct.setIsStockOut(newStock<product.getLowestStock());
                    // 如果库存小于等于0,自动下架
                    newProduct.setIsSale(newStock>0);
                    if(productService.updateById(newProduct)){
                        if(orderService.insertData(order)){
                            orderInfo.add(order.getOrderNo());
                            productInfo.add(order.getProductNo());
                        }
                    }
                }

/**
 * @email qiudb.top@aliyun.com
 * @description 数据分析,商品数量,订单数量等分析业务
 */
@CrossOrigin
@RestController
public class OverViewController {
    final OrderService orderService;
    final ProductService productService;
    final ReturnGoodsService returnGoodsService;
    public OverViewController(OrderService orderService,ProductService productService,ReturnGoodsService returnGoodsService) {
        this.orderService = orderService;
        this.productService = productService;
        this.returnGoodsService = returnGoodsService;
    }

    @RequestMapping(value = "/view/dataInfo")
    private CommonResult dataInfo() {
        Map<String, Object> resultMap = new HashMap<>();
        Map<String, Object> productMap = productService.productOverview();
        Map<String, Object> orderMap = orderService.orderOverview();
        Map<String, Object> returnGoodsMap = returnGoodsService.returnGoodsOverview();
        if(productMap!=null){
            resultMap.putAll(productMap);
        }
        if(orderMap!=null){
            resultMap.putAll(orderMap);
        }
        if(returnGoodsMap!=null){
            resultMap.putAll(returnGoodsMap);
        }
        if(resultMap.size()!=0){
            return CommonResult.success("查询成功",resultMap);
        }else{
            return CommonResult.error("查询失败");
        }
    }
 */

@RestController
@CrossOrigin
public class UserRoleController {

    final UserRoleService userRoleService;
    public UserRoleController(UserRoleService userRoleService) {
        this.userRoleService = userRoleService;
    }
    /*根据id查询用户*/
    @RequestMapping(value = "/userRole/findById")
    private CommonResult findById(Integer userId) {
        List<UserRole> userRoles = userRoleService.selectByUserId(userId);
        if(userRoles!=null){
            return CommonResult.success("查询成功",userRoles);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    @RequestMapping(value = "/userRole/findRoleById")
    private CommonResult findRoleById(Integer userId) {
        List<Map<String, Object>> maps = userRoleService.selectRoleByUserId(userId);
        if(maps!=null){
            return CommonResult.success("查询成功",maps);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    /*查询所有用户*/
    @RequestMapping(value = "/userRole/findAll")
    private CommonResult findAll() {
        List<UserRole> userRoles = userRoleService.selectAll();
        if(userRoles!=null){
            return CommonResult.success("查询成功",userRoles);
        }else{
            return CommonResult.error("查询失败");
        }

/**
 * @email qiudb.top@aliyun.com
 * @description 商品退回 业务控制层
 */
@RestController
@CrossOrigin
public class ReturnProductController {
    final ReturnReasonService returnReasonService;
    final ReturnGoodsService returnGoodsService;
    final LogisticsService logisticsService;
    final OrderService orderService;
    final ProductService productService;
    public ReturnProductController(ProductService productService,OrderService orderService,ReturnReasonService returnReasonService,ReturnGoodsService returnGoodsService,LogisticsService logisticsService){
        this.returnReasonService = returnReasonService;
        this.returnGoodsService = returnGoodsService;
        this.logisticsService = logisticsService;
        this.orderService = orderService;
        this.productService = productService;
    }
    /*退货原因*/
    @RequestMapping(value = "/returnReason/findReasonById")
    private CommonResult findReasonById(Integer reasonId) {
        ReturnReason returnReason = returnReasonService.selectById(reasonId);
        if(returnReason!=null){
            return CommonResult.success("退货原因查询成功",returnReason);
        }else{
            return CommonResult.error("退货原因查询失败");
        }
    }
    /*查询全部退货原因*/
    @RequestMapping(value = "/returnReason/findAllReason")
    private CommonResult findAllReason() {
        List<ReturnReason> returnReasons = returnReasonService.selectAll();
        if(returnReasons!=null){
            return CommonResult.success("退货原因查询成功",returnReasons);
        }else{
            return CommonResult.error("退货原因查询失败");
        }
    }
    /*查询全部退货原因名称*/
    @RequestMapping(value = "/returnReason/findReasonName")
    private CommonResult findReasonName() {
        if(maps!=null){
            return CommonResult.success("商品分类信息查询成功",maps);
        }else{
            return CommonResult.error("商品分类信息查询失败");
        }
    }

    @RequestMapping(value = "/product/add")
    private CommonResult add(Product product) {
        System.out.println(product);
        if(productService.insertData(product)){
            return CommonResult.success("添加商品成功",product);
        }else{
            return CommonResult.error("添加商品失败");
        }
    }

    @RequestMapping(value = "/product/update")
    private CommonResult update(Product product) {
        if(product.getIsNew()!=null && product.getIsNew()){
            product.setSaleTime(new Date());
        }
        if(productService.updateById(product)){
            return CommonResult.success("修改商品成功",product);
        }else{
            return CommonResult.error("修改商品失败");
        }
    }

    @RequestMapping(value = "/product/delete")
    private CommonResult delete(Integer productId) {
        if(productService.deleteById(productId)){
            return CommonResult.success("商品删除成功","productId:" + productId);
        }else{
            return CommonResult.error("商品删除失败");
        }
    }

    /*商品类别*/
    @RequestMapping(value = "/productType/add")
    private CommonResult addType(ProductType productType) {
        if(productTypeService.insertData(productType)){
            return CommonResult.success("商品分类添加成功",productType);
        }else{
            return CommonResult.error("商品分类添加失败");
        }
    }

    @RequestMapping(value = "/productType/update")
    private CommonResult updateType(ProductType productType) {
        if(productTypeService.updateById(productType)){
            return CommonResult.success("商品分类修改成功",productType);
        }else{

/**
 * @email qiudb.top@aliyun.com
 * @description 发送邮件、产生验证码图片、发送短信等工具类操作
 */

@RestController
@CrossOrigin
public class UtilController {
    private final RedisTemplate<String, String> redisTemplate;
    private final AliYunSmsService aliYunSmsService;
    private final IMailService mailService;
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    public UtilController(RedisTemplate<String, String> redisTemplate, IMailService mailService, AliYunSmsService aliYunSmsService) {
        this.mailService = mailService;
        this.aliYunSmsService = aliYunSmsService;
        this.redisTemplate = redisTemplate;
    }

    /**
     * 发送一个简单的文本邮件
     *
     * @param sendTo 收件人
     */
    @RequestMapping(value = "/util/send")
    public String sendmail(String sendTo) {
        mailService.sendSimpleMail(sendTo, "主题:你好普通邮件", "内容:第一封邮件");
        return "发送成功!";
    }

    /**
     * 发送一个邮箱随机验证码
     *
     * @param sendTo 收件人
     */
    @RequestMapping(value = "/allow/sendHtmlCode")
    public CommonResult sendHtmlCode(String sendTo) {
//        long startTime = System.currentTimeMillis(); //获取开始时间
        try {
            String code = MyUtils.getCode(6);
//            long oneTime = System.currentTimeMillis(); //获取第一阶段时间
            Map<String, Object> data = new HashMap<>();
        if(userRole!=null){
            if(userRoleService.insertData(userRole)){
                return CommonResult.success("添加成功",userRole);
            }else{
                return CommonResult.error("添加失败");
            }
        }
        return CommonResult.error("用户数据不存在");
    }

    @RequestMapping(value = "/userRole/delete")
    private CommonResult delete(Integer userId) {
        Boolean bool = userRoleService.deleteById(userId);
        System.out.println(bool);
        if(bool){
            return CommonResult.success("删除成功",userId);
        }else{
            return CommonResult.error("删除失败");
        }
    }

}

/**
 * @email qiudb.top@aliyun.com
 * @description 数据分析,商品数量,订单数量等分析业务
 */
@CrossOrigin
@RestController
public class OverViewController {
    final OrderService orderService;
    final ProductService productService;
    final ReturnGoodsService returnGoodsService;
    public OverViewController(OrderService orderService,ProductService productService,ReturnGoodsService returnGoodsService) {
        if(specs!=null){
            return CommonResult.success("查询成功",specs);
        }else{
            return CommonResult.error("查询失败");
        }
    }
    
    @RequestMapping(value = "/specs/existsSpecsName")
    private CommonResult existsSpecsName(Integer specsId, String specsName, String productType) {
        Boolean isExist = specsService.existsWithSpecsName(specsId,specsName,productType);
        if(isExist!=null){
            return CommonResult.success("查询成功",isExist);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    @RequestMapping(value = "/specs/findAllByType")
    private CommonResult findAllSpecsByType(String productType) {
        List<Specs> specs = specsService.selectAllByType(productType);
        if(specs!=null){
            return CommonResult.success("查询成功",specs);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    @RequestMapping(value = "/specs/add")
    private CommonResult addSpecs(Specs specs) {
        if(specs!=null){
            if(specsService.insertData(specs)){
                return CommonResult.success("添加成功",specs);
            }else{
                return CommonResult.error("添加失败");
            }
        }
        return CommonResult.error("数据不存在");
    }

    @RequestMapping(value = "/specs/update")
    private CommonResult updateSpecs(Specs specs) {
        if(specsService.updateById(specs)){
    @RequestMapping(value = "/product/findAllLikeName")
    private CommonResult findAllLikeName(String keyWord) {
        List<Product> products = productService.selectAllLikeName(keyWord);
        if(products!=null){
            return CommonResult.success("全部商品信息查询成功",products);
        }else{
            return CommonResult.error("全部商品信息查询失败");
        }
    }
    @RequestMapping(value = "/product/findAllLikeType")
    private CommonResult findAllLikeType(String keyWord) {
        List<Product> products = productService.selectAllLikeType(keyWord);
        if(products!=null){
            return CommonResult.success("全部商品信息查询成功",products);
        }else{
            return CommonResult.error("全部商品信息查询失败");
        }
    }
    @RequestMapping(value = "/product/findAllLikeBrand")
    private CommonResult findAllLikeBrand(String keyWord) {
        List<Product> products = productService.selectAllLikeBrand(keyWord);
        if(products!=null){
            return CommonResult.success("全部商品信息查询成功",products);
        }else{
            return CommonResult.error("全部商品信息查询失败");
        }
    }
    @RequestMapping(value = "/product/findAllByType")
    private CommonResult findAllByType() {
        List<Map<String, Object>> maps = productService.selectAllByType();
        if(maps!=null){
            return CommonResult.success("商品分类信息查询成功",maps);
        }else{
            return CommonResult.error("商品分类信息查询失败");
        }
    }

    @RequestMapping(value = "/product/add")
    private CommonResult add(Product product) {
        System.out.println(product);
        if(productService.insertData(product)){
            return CommonResult.success("添加商品成功",product);
        }else{
            return CommonResult.error("添加商品失败");
        }
    }

    @RequestMapping(value = "/product/update")
    private CommonResult update(Product product) {
        if(product.getIsNew()!=null && product.getIsNew()){
            product.setSaleTime(new Date());
        }
        }else{
            return CommonResult.error("vip信息插入失败");
        }
    }

    //更新vip信息
    @RequestMapping(value = "/vip/updateVip")
    private CommonResult updateVip(Vip vip) {
        if(vipService.updateById(vip)){
            return CommonResult.success("vip信息更新成功",vip);
        }else{
            return CommonResult.error("vip信息更新失败");
        }
    }

    //删除vip信息
    @RequestMapping(value = "/vip/deleteVip")
    private CommonResult deleteVip(Integer vipId) {
        if(vipService.deleteById(vipId)){
            return CommonResult.success("删除成功",vipId);
        }else{
            return CommonResult.error("删除失败");
        }
    }
}

@CrossOrigin
@RequestMapping("/alipay")
@Slf4j
@Controller
    public ProductReviewController(ProductReviewService ProductReviewService,OrderService orderService){
        this.ProductReviewService = ProductReviewService;
        this.orderService = orderService;
    }

    /*商品类别*/
    @RequestMapping(value = "/productReview/add")
    private CommonResult addProductReview(ProductReview productReview) {
        if(ProductReviewService.insertData(productReview)){
            Integer orderId = orderService.selectIdByKey(productReview.getOrderNo());
            Order order = new Order();
            order.setOrderId(orderId);
            order.setOrderState("已评价");
            orderService.updateById(order);
            return CommonResult.success("商品评论添加成功",productReview);
        }else{
            return CommonResult.error("商品评论添加失败");
        }
    }

    @RequestMapping(value = "/productReview/update")
    private CommonResult updateProductReview(ProductReview productReview) {
        if(ProductReviewService.updateById(productReview)){
            return CommonResult.success("商品评论修改成功",productReview);
        }else{
            return CommonResult.error("商品评论修改失败");
        }
    }

    @RequestMapping(value = "/productReview/deleteById")
    private CommonResult deleteProductReview(Integer reviewId) {
        if(ProductReviewService.deleteById(reviewId)){
            return CommonResult.success("商品评论删除成功","reviewId: "+reviewId);
        }else{
            return CommonResult.error("商品评论删除失败");
        }
    }

    @RequestMapping(value = "/productReview/findAll")
    private CommonResult findAllProductReview(String productNo) {
        List<Map<String, Object>> productReviewInfo = ProductReviewService.selectAll(productNo);

    @RequestMapping(value = "/order/receipt")
    private CommonResult updateOrder(Integer orderId) {
        Order order = new Order();
        order.setOrderId(orderId);
        order.setOrderState("已收货");
        if(orderService.updateById(order)){
            return CommonResult.success("商品收货成功",order);
        }else{
            return CommonResult.error("商品收货失败");
        }
    }

    @RequestMapping(value = "/orderDetail/orderInfo")
    private CommonResult orderInfo(String orderNo) {
        ArrayList<Object> resultList = new ArrayList<>();
        Order order = orderService.selectByKey(orderNo);
        Logistics logistics = logisticsService.selectOrderNo(orderNo);
        if(order!=null){
            resultList.add(order);
        }
        if(logistics!=null){
            resultList.add(logistics);
        }

        if(resultList.size()!=0){
            return CommonResult.success("订单详情查询成功",resultList);
        }else{
            return CommonResult.error("订单详情查询失败");
        }
    }
}

/**
            return CommonResult.error("物流信息查询失败");
        }
    }

    @RequestMapping(value = "/logistics/addInfo")
    private CommonResult addInfo(Logistics logistics) {
        if(logistics!=null){
            if(logisticsService.insertData(logistics)){
                return CommonResult.success("物流信息添加成功",logistics);
            }else{
                return CommonResult.error("物流信息添加失败");
            }
        }
        return CommonResult.error("物流信息数据不存在");
    }

    @RequestMapping(value = "/logistics/deleteInfo")
    private CommonResult deleteInfo(Integer logisticId) {
        if(logisticId!=null){
            if(logisticsService.deleteById(logisticId)){
                return CommonResult.success("物流信息删除成功",logisticId);
            }else{
                return CommonResult.error("物流信息删除失败");
            }
        }
        return CommonResult.error("物流信息数据不存在");
    }

    @RequestMapping(value = "/orderDetail/returnInfo")
    private CommonResult returnInfo(String orderNo) {
        ArrayList<Object> resultList = new ArrayList<>();
        Map<String, Object> returnGoods = returnGoodsService.selectOrderNo(orderNo);
        Logistics logistics = logisticsService.selectOrderNo(orderNo);
        if(returnGoods!=null){
            resultList.add(returnGoods);
        }
        if(logistics!=null){
            resultList.add(logistics);
        }

        if(resultList.size()!=0){
            return CommonResult.success("退货订单详情查询成功",resultList);
        }else{
            return CommonResult.error("退货订单详情查询失败");
        }
    }

}
            return CommonResult.error("商品库存更新失败");
        }
    }
}

/**
 * @email qiudb.top@aliyun.com
 * @description 用户相关业务
 */

@RestController
@CrossOrigin
public class UserController {
    final RoleService roleService;
    final UserService userService;
    final UserRoleService userRoleService;
    final VipService vipService;
    public UserController(UserService userService, RoleService roleService,VipService vipService, UserRoleService userRoleService) {
        this.userService = userService;
        this.roleService = roleService;
        this.userRoleService = userRoleService;
        this.vipService = vipService;
    }

    /*根据id查询用户*/
    @RequestMapping(value = "/user/findById")
    private CommonResult findById(Integer id) {
        User user = userService.selectById(id);
        if(user!=null){
            return CommonResult.success("查询成功",user);
        }else{
            return CommonResult.error("查询失败");
        }
    }
//            SimpleHash md5 = new SimpleHash("MD5", user.getPassword(), ByteSource.Util.bytes(user.getAccountNumber()), 2);
//            user.setPassword(md5.toHex());
            user.setUserState(true);
            user.setCreatTime(Timestamp.valueOf(LocalDateTime.now()));
            if(userService.insertData(user)){
                logger.info("成功添加了一个新用户");
                return CommonResult.success("注册成功",user);
            }else{
                return CommonResult.error("注册失败");
            }
        }
        return CommonResult.error("用户数据不存在");
    }

    //更新用户信息
    @RequestMapping(value = "/allow/update")
    private CommonResult update(User user) {
        System.out.println(user);
        if(userService.updateById(user)){
            return CommonResult.success("信息保存成功",user);
        }else{
            return CommonResult.error("信息保存失败");
        }
    }

}

/**
 * @email qiudb.top@aliyun.com
 * @description 用户相关业务
 */

@RestController
@CrossOrigin
public class UserController {
    final RoleService roleService;
    final UserService userService;
    final UserRoleService userRoleService;
    final VipService vipService;
    public UserController(UserService userService, RoleService roleService,VipService vipService, UserRoleService userRoleService) {
        this.userService = userService;
        this.roleService = roleService;
        this.userRoleService = userRoleService;
        this.vipService = vipService;
    }

    /*根据id查询用户*/
    @RequestMapping(value = "/user/findById")
    private CommonResult findById(Integer id) {
        User user = userService.selectById(id);
        if(user!=null){
            return CommonResult.success("查询成功",user);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    /*根据帐号查询用户*/
    @RequestMapping(value = "/user/findByKey")

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值