文章目录

  • 1、数据库设计
    • 1.1 数据库表关系
    • 1.2 表的建立
  • 2、前后端接口设计
    • 2.1 用户登录
    • 2.2 用户注册
    • 2.3 查询抽奖设置
    • 2.4 修改抽奖人数
    • 2.5 新增奖项
    • 2.6 修改奖项
    • 2.7 删除奖项
    • 2.8 新增抽奖人员
    • 2.9 修改抽奖人员
    • 2.10 删除抽奖人员
    • 2.11 抽奖
    • 2.12 删除当前奖项某个获奖人员
    • 2.13 删除当前奖项全部获奖人员
  • 3、开发环境准备
    • 3.1 配置项目pom.xml
    • 3.2 Springboot配置文件
    • 3.3 SpringBoot启动类

1、数据库设计

1.1 数据库表关系

1.2 表的建立

drop database if exists lucky_draw;
create database lucky_draw character set utf8mb4;use lucky_draw;drop table if exists user;
create table user(id int primary key auto_increment,username varchar(20) not null unique comment '用户账号',password varchar(20) not null comment '密码',nickname varchar(20) comment '用户昵称',email varchar(50) comment '邮箱',age int comment '年龄',head varchar(255) comment '头像url',create_time timestamp default NOW() comment '创建时间'
) comment '用户表';drop table if exists setting;
create table setting(id int primary key auto_increment,user_id int not null comment '用户id',batch_number int not null comment '每次抽奖人数',create_time timestamp default NOW() comment '创建时间',foreign key (user_id) references user(id)
) comment '抽奖设置';drop table if exists award;
create table award(id int primary key auto_increment,name varchar(20) not null comment '奖项名称',count int not null comment '奖项人数',award varchar(20) not null comment '奖品',setting_id int not null comment '抽奖设置id',create_time timestamp default NOW() comment '创建时间',foreign key (setting_id) references setting(id)
) comment '奖项';drop table if exists member;
create table member(id int primary key auto_increment,name varchar(20) not null comment '姓名',no varchar(20) not null comment '工号',setting_id int not null comment '抽奖设置id',create_time timestamp default NOW() comment '创建时间',foreign key (setting_id) references setting(id)
) comment '抽奖人员';drop table if exists record;
create table record(id int primary key auto_increment,member_id int not null comment '中奖人员id',award_id int not null comment '中奖奖项id',create_time timestamp default NOW() comment '创建时间',foreign key (member_id) references member(id),foreign key (award_id) references award(id)
) comment '中奖记录';

2、前后端接口设计

2.1 用户登录

请求:POST api/user/login

Content-Type: application/json
{username: "abc", password: "123"}

响应:

{ "success" : true }

2.2 用户注册

请求:POST api/user/register

Content-Type: multipart/form-data; boundary=---- WebKitFormBoundarypOUwkGIMUyL0aOZT
username: abc
password: 123
nickname: 权志龙
email: 666@163.com
age: 66
headFile: (binary)

响应:

{ "success" : true }

2.3 查询抽奖设置

请求:GET api/setting/query
响应:

{"success" : true,"data" : {"id" : 1,"userId" : 1,"batchNumber" : 8,"createTime" : "2020-08-14 08:16:31","user" : {"id" : 1,"username" : "123","password" : "123","nickname" : "蜡笔小新","email" : "1111@163.com","age" : 18,"head" : "img/test-head.jpg","createTime" : "2020-08-14 08:16:31","settingId" : 1},"awards" : [ {"id" : 1,"name" : "一等奖","count" : 1,"award" : "火箭","settingId" : 1,"createTime" : "2020-08-14 08:16:31","luckyMemberIds" : [ 5 ]}, {"id" : 2,"name" : "二等奖","count" : 5,"award" : "红旗 H5","settingId" : 1,"createTime" : "2020-08-14 08:16:31","luckyMemberIds" : [ 56, 40, 32, 65, 81 ]}, {"id" : 3,"name" : "三等奖","count" : 20,"award" : "国内任意游","settingId" : 1,"createTime" : "2020-08-14 08:16:31","luckyMemberIds" : [ 48, 68, 43, 73, 13, 83, 63, 25 ]} ],"members" : [ {"id" : 1,"name" : "李寻欢","no" : "水果刀","userId" : 1,"createTime" : "2020-08-14 08:16:31"}, {"id" : 2,"name" : "郭靖","no" : "降猪十八掌","userId" : 1,"createTime" : "2020-08-14 08:16:31"}, {"id" : 3,"name" : "韦小宝","no" : "龙爪手","userId" : 1,"createTime" : "2020-08-14 08:16:31"} ]}
}

2.4 修改抽奖人数

请求:GET api/setting/update?batchNumber=5
响应:

{ "success" : true }

2.5 新增奖项

请求:POST api/award/add

Content-Type: application/json
{name: "牛哄哄", count: 3, award: "华为手机"}

响应:

{ "success" : true }

2.6 修改奖项

请求:POST api/award/update

Content-Type: application/json
{name: "牛哄哄", count: 3, award: "小米手机", id: 4}

响应:

{ "success" : true }

2.7 删除奖项

请求:GET api/award/delete/4
响应:

{ "success" : true }

2.8 新增抽奖人员

请求:POST api/member/add

Content-Type: application/json
{name: "羞羞的粉拳", no: "007"}

响应:

{ "success" : true }

2.9 修改抽奖人员

请求:POST api/member/update

Content-Type: application/json
{name: "泰山", no: "000", id: 96}

响应:

{ "success" : true }

2.10 删除抽奖人员

请求:GET api/member/delete/97
响应:

{ "success" : true }

2.11 抽奖

请求:POST api/record/add/3

Content-Type: application/json
[92, 22, 43, 76]

响应:

{ "success" : true }

2.12 删除当前奖项某个获奖人员

请求:GET api/record/delete/member?id=22
响应:

{ "success" : true }

2.13 删除当前奖项全部获奖人员

请求:GET api/record/delete/award?id=3
响应:

{ "success" : true }

3、开发环境准备

3.1 配置项目pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><!-- 默认使用的Spring Framework版本为5.2.10.RELEASE --><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.5.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>org.example</groupId><artifactId>lucky-draw</artifactId><version>1.0-SNAPSHOT</version><properties><java.version>1.8</java.version></properties><dependencies><!-- spring-boot-starter-web: 基于SpringBoot开发的依赖包,会再次依赖spring-framework中基本依赖包,aop相关依赖包,web相关依赖包,还会引入其他如json,tomcat,validation等依赖 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><!-- 排除tomcat依赖 --><exclusions><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId></exclusion></exclusions></dependency><!-- 添加 Undertow 依赖 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-undertow</artifactId></dependency><!--引入AOP依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-aop</artifactId></dependency><!-- mybatis-spring-boot-starter: Mybatis框架在SpringBoot中集成的依赖包,Mybatis是一种数据库对象关系映射Object-Relationl Mapping(ORM)框架,其他还有如Hibernate等 --><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.1.3</version></dependency><!-- Mybatis代码生成工具 --><dependency><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-core</artifactId><version>1.3.5</version></dependency><!-- druid-spring-boot-starter: 阿里Druid数据库连接池,同样的运行时需要 --><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>1.2.3</version></dependency><!-- JDBC:mysql驱动包 --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.49</version><scope>runtime</scope></dependency><!-- spring-boot-devtools: SpringBoot的热部署依赖包 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><scope>runtime</scope><!-- 不能被其它模块继承,如果多个子模块可以去掉 --><optional>true</optional></dependency><!-- lombok: 简化bean代码的框架 --><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><!-- spring-boot-starter-test: SpringBoot测试框架 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><plugins><!-- SpringBoot的maven打包插件 --><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin><!-- 明确指定一些插件的版本,以免受到 maven 版本的影响 --><plugin><artifactId>maven-clean-plugin</artifactId><version>3.1.0</version></plugin><plugin><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version></plugin><plugin><artifactId>maven-deploy-plugin</artifactId><version>2.8.2</version></plugin><plugin><artifactId>maven-install-plugin</artifactId><version>2.5.2</version></plugin><plugin><artifactId>maven-jar-plugin</artifactId><version>3.2.0</version></plugin><plugin><artifactId>maven-resources-plugin</artifactId><version>3.1.0</version></plugin><plugin><artifactId>maven-site-plugin</artifactId><version>3.3</version></plugin><plugin><artifactId>maven-surefire-plugin</artifactId><version>2.22.2</version></plugin></plugins></build></project>

3.2 Springboot配置文件

server.port=8085
debug=true
# 设置打印日志的级别,及打印sql语句
#日志级别:trace,debug,info,warn,error
#基本日志
logging.level.root=INFO
#扫描的包:druid.sql.Statement类和frank包
logging.level.druid.sql.Statement=DEBUG
logging.level.org.example=DEBUG# 美化JSON数据格式
spring.jackson.serialization.indent-output=true
# 设置JSON数据的日期格式
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
# JSON数据属性为null时不返回
spring.jackson.default-property-inclusion=non_null
# get请求参数及表单提交数据的日期格式
spring.mvc.format.date=yyyy-MM-dd HH:mm:ss#servlet上下文路径
#server.servlet.context-path=/lucky-draw
# 自定义属性:用户头像本地保存根路径
user.head.local-path=E:/TMP
user.head.remote-path=http://localhost:8080${server.servlet.context-path:}
#user.head.filename=head.jpg
# 静态资源映射:将路径映射为/,即/static/xxx,映射为/xxx,支持多个字符串,逗号间隔
# 默认为/META-INF/resources/, /resources/, /static/, /public/
# 指定外部web资源文件夹:访问的路径为/
spring.resources.static-locations=classpath:/static/,classpath:/public/,file:${user.head.local-path}#druid数据库连接池配置
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/lucky_draw?useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.druid.initial-size=1
spring.datasource.druid.min-idle=1
spring.datasource.druid.max-active=20
spring.datasource.druid.test-on-borrow=true#指定Mybatis表和实体映射关系xml配置文件,包含表与实体的映射,字段和属性的映射,及各个sql语句
mybatis.mapper-locations=classpath:mapper/**Mapper.xml

3.3 SpringBoot启动类

package org.example;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
public class Application {public static void main(String[] args) {SpringApplication.run(Application.class, args);}
}

基于SpringBoot实现在线抽奖系统相关推荐

  1. java项目:基于springboot+vue在线考试系统1013

    项目描述 springboot+vue在线考试系统: 使用目前较为流行的框架spring boot,前端部分采用了vue,项目的业务流程相对简单,该项目主要功能包括学生管理,教师管理,题库管理,成绩查 ...

  2. 基于SpringBoot+Vue在线考试系统【web端+小程序端】【附带源码】

    最近和不少大佬聊天,有的技术很牛,有的赚很多,有的已经是高管,有的有自己的公司. 通过聊天,我发现成功人的优点基本相同: 能吃苦,执行力强,自律性强. 喝了不少酒后,酒后吐真言,成功的人都不容易,说这 ...

  3. java基于springboot外卖在线订餐系统(厨艺论坛)有论文

    简介 本项目主要包括了外卖订餐系统(在线订餐和外卖配送).厨艺论坛系统.管理员后台.用户中心等功能.用户注册后可以选择餐桌在线点餐支付,也可以选择外卖配送到家的方式. 演示视频 https://www ...

  4. 基于SpringBoot的在线答疑系统的研究与实现

    社会的发展和科学技术的进步,互联网技术越来越受欢迎.网络计算机的生活方式逐渐受到广大师生的喜爱,也逐渐进入了每个学生的使用.互联网具有便利性,速度快,效率高,成本低等优点. 因此,构建符合自己要求的操 ...

  5. 【毕业设计】基于Springboot的在线汽车销售系统(论文+源码+ppt+视频)

    概述 效果图 在这里插入图片描述 47a4ead90e5fa23f36acf0d.png) 资源下载 免费下载 需要讲解源码和部署的请直接私信我则可以.联系方式在主页 第 1 章 绪论 1.1研究背景 ...

  6. (免费分享)基于springboot,vue在线考试系统

    该项目是一个前后端分离,后端使用 SpringBoot,前端使用 VUE 和 Element-UI 组件库配合完成开发. 开发工具:IDEA,数据库:mysql5.7 源码获取:下方gongzhong ...

  7. 基于springboot的在线零食系统

    文章目录 前言 一.前台部分页面展示 1.首页 2.个人中心管理页 3.查看商品详情页 4.购物车页面 5.支付页面 二.后台部分页面展示 1.后台登录页面 2.后台主页面 3.用户管理 4.订单管理 ...

  8. 基于springboot的在线考试系统的设计与实现 毕业设计毕设参考

    后台功能 (1)网站初始化:设置网站名称.关键字.描述等 (2)系统设置:设置关于我们.联系我们.加入我们.法律声明 (3)资讯录入:选择资讯分类.录入资讯标题.简介.内容等 (4)资讯管理:查看所有 ...

  9. java 面包屑导航_基于SpringBoot打造在线教育系统(7)-- 面包屑导航与子分类

    这一节我们来讲一下面包屑导航的问题. 先看思路,当我们点击左侧的一级课程,是不是可以拿到一个ID? 这个ID的作用可大了,我们有了这个ID,本意是通过它去寻找它所有的子节点. 看图,假设[JAVA基础 ...

  10. 基于SpringBoot的在线招聘网站

    你好呀,我是小邹. 今天给大家分享一个项目,基于SpringBoot的在线招聘系统. 软件架构:SpringBoot+MyBatisPlus+MyBatis+Layui+MySQL+Redis+Shi ...

最新文章

  1. 美国西北大学 计算机工程专业排名,美国西北大学优势专业排名榜单最新一览...
  2. 只看不说-CCTV的客户端关键字
  3. sqlserver连接和操作数据库
  4. MySQL优化(二):索引的类型、匹配原则、创建原则
  5. leetcode 实现 strStr()
  6. 推荐系统基础之介绍入门篇
  7. iOS 手势操作和事件传递响应链
  8. 知瓜数据丨月入过亿的品牌“李宁”,如何成为直播营销的领头羊
  9. 风险预测模型_只学有用的:贷后评分模型的三种细分应用
  10. 关于在谷歌浏览器,vue-video-player 实现断点续播,currentTime不生效问题
  11. Notepad++ json 插件 Jsonviewer2 无法使用问题
  12. unity实现简单游戏——井字棋
  13. 一个关于随机矩阵谱范数的不等式
  14. linux14.04设置DNS,Ubuntu 14.04.4 LTS设置DNS
  15. 缓存、缓存算法和缓存框架简介
  16. 语法解析错误: syntax error, unexpected ‘��‘ (T_STRING), expecting ‘,‘ or ‘;‘
  17. 笔记本Win7系统 设置WIFI热点共享无线网络
  18. 2023年,我们还需要一部游戏手机吗?
  19. 寻找突破口语学习技巧
  20. 2021年危险化学品经营单位主要负责人考试题库及危险化学品经营单位主要负责人考试内容

热门文章

  1. 2018人工智能发展盘点:国内各行业拥抱AI,总体呈现八大特点
  2. wince同步软件区别
  3. JAVA系列---项目打包部署
  4. PhotoshopCS5 第五篇 图层的应用
  5. 计算机老是蓝屏需要重新启动3,电脑蓝屏重启,教您电脑经常自动蓝屏重启怎么办...
  6. html flash mp3播放器,网页实用最简单的flash mp3播放器代码-多样式
  7. android 空气质量代码,Android-Json数据解析之空气质量检测
  8. ChromiumOS的分区格式
  9. u盘 固态硬盘 读写速度测试软件,超级U盘/SSD读写可靠性(扩容)测试工具urwtest v1.8...
  10. 神经网络简介及简单应用