Giter Site home page Giter Site logo

strawqqhat / miaosha Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 2368001770/miaosha

0.0 0.0 0.0 23.94 MB

SpringBoot快速搭建的前后端分离的电商基础秒杀项目

Java 0.91% HTML 14.88% CSS 15.89% JavaScript 67.51% PHP 0.67% Go 0.07% Python 0.06% ASP 0.01% Shell 0.01%

miaosha's Introduction

SpringBoot构建电商基础秒杀项目

项目简介

通过SpringBoot快速搭建的前后端分离的电商基础秒杀项目。项目通过应用领域驱动型的分层模型设计方式去完成:用户otp注册、登陆、查看、商品列表、进入商品详情以及倒计时秒杀开始后下单购买的基本流程。

项目要点

  • 使用配置mybatis自动生成器来生成文件,在mybatis-generator.xml配置文件中在对应生成表类名配置中加入 enableCountByExample="false"enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"selectByExampleQueryId="false" 避免生成不常用方法

  • 使用LocalDatTime、joda-time类库代替java.util.date

  • 前端 ajax 调用接口获取验证码 html/getotp.html,出现跨域请求问题 解决方法:@CrossOrigin(origins = {"*"}, allowCredentials = "true") allowedHeaders 允许前端将 token 放入 header 做 session 共享的跨域请求。 allowCredentials 授信后,需前端也设置 xhfFields 授信才能实现跨域 session 共享。 xhrFields: {withCredentials: true},

  • 统一前端返回格式CommonReturnType {status: xx ,object:xx} dataobject -> 与数据库对应的映射对象 model -> 用于业务逻辑service的领域模型对象 viewobject -> 用于前端交互的模型对象

  • 使用 hibernate-validator 通过注解来完成模型参数校验

  • insertSelective 中设置 keyProperty="id" useGeneratedKeys="true" 使得插入完后的 DO 生成自增 id 。 insertSelective与insert区别: insertSelective对应的sql语句加入了NULL校验,即只会插入数据不为null的字段值(null的字段依赖于数据库字段默认值)insert则会插入所有字段,会插入null。

  • 数据库设计规范,设计时字段要设置为not null,并设置默认值,避免唯一索引在null情况下失效等类似场景

  • 解决如果事务createorder下单如果回滚,该下单方法中获得流水号id回滚,使等到的id号可能再一次被使用 在generatorOrderNo方法前加注解: @Transactional(propagation = Propagation.REQUIRES_NEW)

  • 使用聚合模型在itemModel加入PromoModel promoModel,若不为空表示其有未结束的秒杀活动;在orderModel中加入promoId,若不为空,则以秒杀方式下单

miaosha's People

Contributors

2368001770 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.