@TOC
ssm203基于vue的线上点餐系统+vue
系统概述
1.1 研究背景
如今互联网高速发展,网络遍布全球,国内移动信息领域独树一帜,通过微信发布的消息能快而方便的传播到世界每个角落,并且互联网上能传播的信息也很广,比如文字、图片、声音、视频等。从而,这种种好处使得互联网成了信息传播的主要途径,社会上各种各样的信息都想尽办法通过互联网进行传播,互联网对社会产生的影响越来越大。
因此,开发合适的线上点餐系统,可以方便管理人员对线上点餐系统的管理,提高信息管理工作效率及查询效率,用户可以在手机上通过来订餐,更加的方便,有利于更好的为人们服务。
1.2研究目的
随着互联网技术的快速发展,网络时代的到来,网络信息也将会改变当今社会。各行各业在日常企业经营管理等方面也在慢慢的向规范化和网络化趋势汇合。线上点餐系统的信息化程度体现在将互联网与信息技术应用于经营与管理,以现代化工具代替传统手工作业。无疑,使用网络信息化管理使信息管理更先进、更高效、更科学,信息交流更迅速。
对于之前点餐系统的管理,大部分都是使用传统的人工方式去管理,这样导致了管理效率低下、出错频率高。而且,时间一长的话,积累下来的数据信息不容易保存,对于查询、更新还有维护会带来不少问题。对于数据交接也存在很大的隐患。如果采用电子化的存储方式就会带来很大的改善,而且给用户的查询带来了很大便利,因此设计一个线上点餐系统刻不容缓,能够提高信息的管理水平。
1.3系统设计思想
一个成功的网站应明确建设网站的目的,确定网站的功能,确定网站规模、投入费用,进行必要的市场分析等。只有详细的策划,才能避免在网站建设中出现的很多问题,使网站建设能顺利进行。同时,一个大型的计算机网站系统,必须有一个正确的设计指导思想,通过合理选择数据结构、网络结构、操作系统以及开发环境,构成一个完善的网络体系结构,才能充分发挥计算机信息管理的优势。根据现实生活中网民的实际需求,本系统的设计按照下述原则进行。
- 有效性:实际上这里的有效性包括两个方面的意思:有用性和可用性。有用性是指站点潜在的能满足用户需求的功能,而可用性是指能够通过站点的操作实现特定的目标。可以看出一个站点如果不能恰当运行或设计得非常槽糕就不是一个好站点。可用站点的效益应该非常高,并易于学习,在实现用户目标时令人满意而不出错。
- 高可靠性:一个实用的网站同时必须是可靠的,本设计通过合理而先进的网络设计以及软、硬件的优化选型,可保证网站的可靠性与容错性。
- 高安全性:在设计中,将充分利用网络软、硬件提供的各种安全措施,既可以保证用户共享资源,充分考虑系统及数据资源的容灾、备份、恢复的要求。为系统提供强大的数据库备份工具。可以保证关键数据的安全性。操作权限级,设置不同的角色确保每一步的操作权限,可以由管理员进行设置。
- 先进性:采用目前国际上最先进的开发技术,使用JSP开发技术,MYSQL作为网站后台数据库。采用这些技术降低了以后的系统运营成本,提高了系统的稳定性和易维护性。
- 采用标准技术:本网站的所有设计遵循国际上现行的标准进行,以提高系统的开放性。
- 外观和技术平衡:系统采用Web风格的界面设计,界面友好、美观,使用方便,易学易用。网站设计的关键问题是外观和技术的平衡。外现不好的网站令人厌烦,站点可以运行很好,但却不能带动用户积极性,相反,如果外观非常有表现力,但技术有限,用户则会感到非常失望。在外观与技术之间需要确定一个清晰而连续的关系,即外观与站点的意图相关,对不同类型的网站处理方法不同。
2相关技术
2.1 MYSQL数据库
MySQL是一个真正的多用户、多线程SQL数据库服务器。 是基于SQL的客户/服务器模式的关系数据库管理系统,它的有点有有功能强大、使用简单、管理方便、安全可靠性高、运行速度快、多线程、跨平台性、完全网络化、稳定性等,非常适用于Web站点或者其他应用软件的数据库后端的开发工作。此外,用户可利用许多语言编写访问MySQL数据库的程序。作为开放源代码运动的产物之一,MySQL关系数据库管理系统越来越受到人们的青睐,应用范围也越来越广。速度和易用性使MySQL特别适用于Web站点或应用软件的数据库后端的开发工作。
MYSQL数据库具有以下特点:
1、C和C ++中使用和测试,以确保源代码的编译器的便携性和灵活性。
2、支持多种操作系统AIX的,FreeBSD下,HP-UX,Linux和Mac OS中,Novell公司的Netware,OpenBSD系统,OS/2裹时,Solaris,Windows等。
3、提供了用于不同的编程语言的API。编程语言,如C,, C ++,Python和Java的,的Perl,PHP,埃菲尔铁塔,Ruby和Tcl的。
4、以及使用的CPU资源来支持多线程。
5、算法优化查询SQL,切实提高搜索速度。
6、网络上的客户端和服务器可以用来编程任何独立的编程环境,也有中国,GB2312,BIG5,日文写作,一般基金,用于支持多国语言,并且可以嵌入在数据表和其他软件shift_jis访问柱可以用作的名称。
7、TCP / IP,ODBC和JDBC数据库,并提供连接到其他。
8、管理工具的管理,控制和优化数据库的操作。
9、可以数以千万计的记录在一个大的数据库。
2.2 VUE框架简介
Vue.js(读音 /vjuː/, 类似于 view) 是一套构建用户界面的渐进式框架。
Vue 只关注视图层, 采用自底向上增量开发的设计。
Vue 的目标是通过尽可能简单的 API 实现响应的数据绑定和组合的视图组件。
2.3 SSM框架简介
SSM框架,是Spring+Spring MVC+MyBatis的缩写,这个是继SSH之后,目前比较主流的Java EE企业级框架,适用于搭建各种大型的企业级应用系统。
1.Spring简介
Spring是一个开源框架,Spring是于2003年兴起的一个轻量级的Java开发框架,由Rod Johnson在其著作Expert One-On-One J2EE Development and Design中阐述的部分理念和原型衍生而来。它是为了解决企业应用开发的复杂性而创建的。Spring使用基本的JavaBean来完成以前只可能由EJB完成的事情。然而,Spring的用途不仅限于服务器端的开发。从简单性、可测试性和松耦合的角度而言,任何Java应用都可以从Spring中受益。简单来说,Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架。
A.控制反转(IOC)是什么呢?
IOC:控制反转也叫依赖注入。利用了工厂模式将对象交给容器管理,你只需要在spring配置文件总配置相应的bean,以及设置相关的属性,让spring容器来生成类的实例对象以及管理对象。在spring容器启动的时候,spring会把你在配置文件中配置的bean都初始化好,然后在你需要调用的时候,就把它已经初始化好的那些bean分配给你需要调用这些bean的类(假设这个类名是A),分配的方法就是调用A的setter方法来注入,而不需要你在A里面new这些bean了。
B.面向切面(AOP)又是什么呢?
首先,需要说明的一点,AOP只是Spring的特性,它就像OOP一样是一种编程思想,并不是某一种技术,AOP可以说是对OOP的补充和完善。OOP引入封装、继承和多态性等概念来建立一种对象层次结构,用以模拟公共行为的一个集合。当我们需要为分散的对象引入公共行为的时候,OOP则显得无能为力。也就是说,OOP允许你定义从上到下的关系,但并不适合定义从左到右的关系。例如日志功能。日志代码往往水平地散布在所有对象层次中,而与它所散布到的对象的核心功能毫无关系。在OOP设计中,它导致了大量代码的重复,而不利于各个模块的重用。将程序中的交叉业务逻辑(比如安全,日志,事务等),封装成一个切面,然后注入到目标对象(具体业务逻辑)中去。
实现AOP的技术,主要分为两大类:一是采用动态代理技术,利用截取消息的方式,对该消息进行装饰,以取代原有对象行为的执行;二是采用静态织入的方式,引入特定的语法创建“方面”,从而使得编译器可以在编译期间织入有关“方面”的代码。
2.Spring MVC简介
Spring MVC属于Spring Framework的后续产品,已经融合在Spring Web Flow里面,它原生支持的Spring特性,让开发变得非常简单规范。Spring MVC分离了控制器、模型对象、分派器以及处理程序对象的角色,这种分离让它们更容易进行定制。
3.MyBatis简介
MyBatis本是apache的一个开源项目iBatis,2010年这个项目由apache software foundation迁移到了google code,并且改名为MyBatis。MyBatis是一个基于Java的持久层框架。iBATIS提供的持久层框架包括SQL Maps和Data Access Objects(DAO)MyBatis消除了几乎所有的JDBC代码和参数的手工设置以及结果集的检索。MyBatis使用简单的XML或注解用于配置和原始映射,将接口和Java的POJOs(Plain Old Java Objects,普通的Java对象)映射成数据库中的记录。可以这么理解,MyBatis是一个用来帮你管理数据增删改查的框架。
3系统分析
3.1可行性分析
通过对本线上点餐系统实行的目的初步调查和分析,提出可行性方案并对其一一进行论证。我们在这里主要从技术可行性、经济可行性、操作可行性等方面进行分析。
3.1.1技术可行性
本线上点餐系统后端采用SSM框架进行开发,是一种成熟的框架,开发有很多教程的,微信开发也有很多教程,并且网络上很多免费的教程。
因此,线上点餐系统在开发技术上具有很高可行性,且开发人员掌握了一定的开发技术,所以此系统的开发技术具有可行性。
3.1.2经济可行性
本线上点餐系统采用的软件都是开源的,这样能够削减很多的精力和资源,降低开发成本。同时对计算机的配置要求也极低,即使是淘汰下来的计算机也能够满足需要,因此,本系统在经济上是完全具有可行性的,所以在经济上是十分可行的。
3.1.3操作可行性
本线上点餐系统的界面简单易操作,用户只要平时有在用过电脑,都能进行访问和操作。本系统具有易操作、易管理、交互性好的特点,在操作上是非常简单的,因此在操作上具有很高的可行性。
综上所述,此系统开发目标已明确,在技术、经济和操作方面都具有很高的可行性,并且投入少、功能完善、管理方便,因此系统的开发是完全可行的。
3.2系统性能分析
3.2.1 系统安全性
此线上点餐系统要严格控制管理权限,具体要求如下:
(1)要想对线上点餐系统进行管理,首先要依靠用户名和密码在系统中登陆,无权限的用户不可以通过任何方式登录系统和对系统的任何信息和数据进行查看,这样可以保证系统的安全可靠性和准确性。
(2)在具体实现中对不同的权限进行设定,不同权限的用户在系统中登陆后,不可以越级操作。
3.2.2 数据完整性
(1)所有记录信息要保持全面,信息记录内容不可以是空。
(2)各种数据间相互联系要保持正确。
(3)相同数据在不同记录中要保持一致。
3.3系统界面分析
目前,界面设计已经成为对软件质量进行评价的一条关键指标,一个好的用户界面可以使用户使用系统的信心和兴趣增加,从而使工作效率提高。页面尽量简洁,让页面清爽,访问速度能提升上去,访问服务端接口的时候相应更快更迅捷。
1.输出设计
输出是由电脑对输入的基本信息进行解决,生成高质量的有效信息,并使之具有一定的格式,提供给管理者使用,这是输出设计的主要责任和目标。
系统开发的过程与实施过程相反,并不是从输入设计到输出设计,而是从输出设计到输入设计。这是由于输出表格与使用者直接相联系,设计的目的应当是确保使用者可以很方便的使用输出表格,并且可以将各部门的有用信息及时的反映出来。输出设计的准绳是既要整体琢磨不同管理层的所有需要,又要简洁,不要提供给用户不需要的信息。
2.输入设计
输入数据的收集和录入是比较麻烦的,需要非常多的人力和一定设备,而且经常出错。一旦输入系统的数据不正确,那么处理后的输出就会扩大这些错误,因此输入的数据的准确性对整个系统的性能起着决定性意义。
输入设计有以下几点原则:
1)输入量应尽量保持在能够满足处理要求的最低限度。输入量越少,错误率就会越少,数据的准备时间也越少。
2)应尽可能的使输入的准备以及输入的过程进行时比较方便,这样使错误的发生率降低。
3)应尽量早检查输入数据(尽量接近原数据发生点),以便使错误更正比较及时。
4)输入数据尽早地记录成其处理所需的形式,以防止数据由一种介质转移到另一种介质时需要转录而可能发生的错误。
3.4系统流程和逻辑
图3-3登录流程图
图3-4修改密码流程图
4系统概要设计
4.1概述
本系统后台采用B/S结构(Browser/Server,浏览器/服务器结构)和基于Web服务两种模式,是一个适用于Internet环境下的模型结构。只要用户能连上Internet,便可以在任何时间、任何地点使用。系统工作原理图如图4-1所示:
图4-1系统工作原理图
4.2系统结构
设计的管理员主要是为用户提供的一些信息进行服务的。设计的管理员功能结构图如下图所示:
图4-2管理员功能结构图
用户主要是订餐购买这些情景,设计的用户功能结构图如下图所示:
4.3.数据库设计
4.3.1数据库实体
概念设计的目标是设计出反映某个组织部门信息需求的数据库系统概念模式,数据库系统的概念模式独立于数据库系统的逻辑结构、独立于数据库管理系统(DBMS)、独立于计算机系统。
概念模式的设计方法是在需求分析的基础上,用概念数据模型(例如E-R模型)表示数据及数据之间的相互联系,设计出反映用户信息需求和处理需求的数据库系统概念模式。概念设计的目标是准确描述应用领域的信息模式,支持用户的各种应用,这样既容易转换为数据库系统逻辑模式,又容易为用户理解。数据库系统概念模式是面向现实世界的数据模型,不能直接用于数据库系统的实现。在此阶段,用户可以参与和评价数据库系统的设计,从而有利于保证数据库系统的设计与用户的需求相吻合。在概念模式的设计中,E-R模型法是最常见的设计方法。本系统的E-R图如下图所示:
(1)菜品信息的实体属性图如下:
图4.12 菜品信息实体属性图
(2)美食资讯实体属性图如图4.13所示:
图4.13 美食资讯实体属性图
(3)菜品类别信息实体属性图如图4.14所示:
图4.14 菜品类别信息实体属性图
4.3.2数据库设计表
线上点餐系统需要后台数据库,下面介绍数据库中的各个表的详细信息:
表4.1 菜品类别信息表
字段 | 类型 | 空 | 默认 | 注释 |
---|---|---|---|---|
id (主键) | bigint(20) | 否 | 主键 | |
addtime | timestamp | 否 | CURRENT_TIMESTAMP | 创建时间 |
leibie | varchar(200) | 是 | NULL | 类别 |
表4.2 菜品信息
字段 | 类型 | 空 | 默认 | 注释 |
---|---|---|---|---|
id (主键) | bigint(20) | 否 | 主键 | |
addtime | timestamp | 否 | CURRENT_TIMESTAMP | 创建时间 |
caipinbianhao | varchar(200) | 是 | NULL | 菜品编号 |
caipinmingcheng | varchar(200) | 是 | NULL | 菜品名称 |
caipinleibie | varchar(200) | 是 | NULL | 菜品类别 |
jiage | int(11) | 是 | NULL | 价格 |
shuliang | int(11) | 是 | NULL | 数量 |
tupian | varchar(200) | 是 | NULL | 图片 |
yuancailiao | longtext | 是 | NULL | 原材料 |
pengrenfangfa | longtext | 是 | NULL | 烹饪方法 |
caipintese | longtext | 是 | NULL | 菜品特色 |
caipinjieshao | longtext | 是 | NULL | 菜品介绍 |
thumbsupnum | int(11) | 是 | 0 | 赞 |
crazilynum | int(11) | 是 | 0 | 踩 |
clicktime | datetime | 是 | NULL | 最近点击时间 |
clicknum | int(11) | 是 | 0 | 点击次数 |
表4.3 订单信息表
字段 | 类型 | 空 | 默认 | 注释 |
---|---|---|---|---|
id (主键) | bigint(20) | 否 | 主键 | |
addtime | timestamp | 否 | CURRENT_TIMESTAMP | 创建时间 |
caipinbianhao | varchar(200) | 是 | NULL | 菜品编号 |
caipinmingcheng | varchar(200) | 是 | NULL | 菜品名称 |
caipinleibie | varchar(200) | 是 | NULL | 菜品类别 |
jiage | int(11) | 是 | NULL | 价格 |
shuliang | int(11) | 否 | 数量 | |
heji | varchar(200) | 是 | NULL | 合计 |
tupian | varchar(200) | 是 | NULL | 图片 |
yuancailiao | varchar(200) | 是 | NULL | 原材料 |
pengrenfangfa | varchar(200) | 是 | NULL | 烹饪方法 |
caipintese | varchar(200) | 是 | NULL | 菜品特色 |
caipinjieshao | varchar(200) | 是 | NULL | 菜品介绍 |
zhanghao | varchar(200) | 是 | NULL | 账号 |
xingming | varchar(200) | 是 | NULL | 姓名 |
sfsh | varchar(200) | 是 | 否 | 是否审核 |
shhf | longtext | 是 | NULL | 审核回复 |
ispay | varchar(200) | 是 | 未支付 | 是否支付 |
表4.4 订单评论表
字段 | 类型 | 空 | 默认 | 注释 |
---|---|---|---|---|
id (主键) | bigint(20) | 否 | 主键 | |
addtime | timestamp | 否 | CURRENT_TIMESTAMP | 创建时间 |
refid | bigint(20) | 否 | 关联表id | |
userid | bigint(20) | 否 | 用户id | |
nickname | varchar(200) | 是 | NULL | 用户名 |
content | longtext | 否 | 评论内容 | |
reply | longtext | 是 | NULL | 回复内容 |
表4.5 美食资讯信息表
字段 | 类型 | 空 | 默认 | 注释 |
---|---|---|---|---|
id (主键) | bigint(20) | 否 | 主键 | |
addtime | timestamp | 否 | CURRENT_TIMESTAMP | 创建时间 |
title | varchar(200) | 否 | 标题 | |
introduction | longtext | 是 | NULL | 简介 |
picture | varchar(200) | 否 | 图片 | |
content | longtext | 否 | 内容 |
表4.6 收藏表
字段 | 类型 | 空 | 默认 | 注释 |
---|---|---|---|---|
id (主键) | bigint(20) | 否 | 主键 | |
addtime | timestamp | 否 | CURRENT_TIMESTAMP | 创建时间 |
userid | bigint(20) | 否 | 用户id | |
refid | bigint(20) | 是 | NULL | 收藏id |
tablename | varchar(200) | 是 | NULL | 表名 |
name | varchar(200) | 否 | 收藏名称 | |
picture | varchar(200) | 否 | 收藏图片 |
表4.7 管理员信息表
字段 | 类型 | 空 | 默认 | 注释 |
---|---|---|---|---|
id (主键) | bigint(20) | 否 | 主键 | |
username | varchar(100) | 否 | 用户名 | |
password | varchar(100) | 否 | 密码 | |
role | varchar(100) | 是 | 管理员 | 角色 |
addtime | timestamp | 否 | CURRENT_TIMESTAMP | 新增时间 |
表4.8 用户信息表
字段 | 类型 | 空 | 默认 | 注释 |
---|---|---|---|---|
id (主键) | bigint(20) | 否 | 主键 | |
addtime | timestamp | 否 | CURRENT_TIMESTAMP | 创建时间 |
zhanghao | varchar(200) | 否 | 账号 | |
mima | varchar(200) | 否 | 密码 | |
xingming | varchar(200) | 否 | 姓名 | |
xingbie | varchar(200) | 是 | NULL | 性别 |
shouji | varchar(200) | 是 | NULL | 手机 |
youxiang | varchar(200) | 是 | NULL | 邮箱 |
shenfenzheng | varchar(200) | 是 | NULL | 身份证 |
zhaopian | varchar(200) | 是 | NULL | 照片 |
beizhu | longtext | 是 | NULL | 备注 |
5系统详细实现
5.1 管理员模块的实现
5.1.1 菜品信息管理
管理员可以管理菜品信息,可以对菜品信息添加修改删除。具体界面的展示如图5.1所示。
图5.1 菜品信息界面
5.1.2 用户信息管理
管理员可以对用户进行查询修改,删除操作。具体界面如图5.2所示。
图5.3 用户信息管理界面
5.1.3 订单信息管理
系统管理员可以对订单进行查询,审核以及查看评价信息,。界面如下图所示:
图5.4 订单信息管理界面
5.1.4 菜品类别管理
系统管理员可以对菜品类别进行添加修改删除操作。界面如下图所示:
图5.4 菜品类别管理界面
5.2 用户模块的实现
5.2.1 系统首页
系统首页上面有导航,可以看到菜品信息,美食资讯以及个人中心之类的点击操作,首页可以显示美食信息。界面如下图所示:
图5.5 系统首页
5.2.2 我的订单
用户登录后,在我的后台里面可以看到自己的订单,可以对订单进行支付操作。界面如下图所示:
图5.6 我的订单
5.2.2 收藏与加购
在商品详情界面,可以对商品进行收藏和下单操作,点击菜品图片右上角的五角星,是收藏操作,双击是取消,点击页面右下角的加购按钮,会进行下单操作。界面如下图所示:
图5.6 收藏与加购
StoreupServiceImpl.java
package com.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.List;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.utils.PageUtils;
import com.utils.Query;
import com.dao.StoreupDao;
import com.entity.StoreupEntity;
import com.service.StoreupService;
import com.entity.vo.StoreupVO;
import com.entity.view.StoreupView;
@Service("storeupService")
public class StoreupServiceImpl extends ServiceImpl<StoreupDao, StoreupEntity> implements StoreupService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
Page<StoreupEntity> page = this.selectPage(
new Query<StoreupEntity>(params).getPage(),
new EntityWrapper<StoreupEntity>()
);
return new PageUtils(page);
}
@Override
public PageUtils queryPage(Map<String, Object> params, Wrapper<StoreupEntity> wrapper) {
Page<StoreupView> page =new Query<StoreupView>(params).getPage();
page.setRecords(baseMapper.selectListView(page,wrapper));
PageUtils pageUtil = new PageUtils(page);
return pageUtil;
}
@Override
public List<StoreupVO> selectListVO(Wrapper<StoreupEntity> wrapper) {
return baseMapper.selectListVO(wrapper);
}
@Override
public StoreupVO selectVO(Wrapper<StoreupEntity> wrapper) {
return baseMapper.selectVO(wrapper);
}
@Override
public List<StoreupView> selectListView(Wrapper<StoreupEntity> wrapper) {
return baseMapper.selectListView(wrapper);
}
@Override
public StoreupView selectView(Wrapper<StoreupEntity> wrapper) {
return baseMapper.selectView(wrapper);
}
}
StoreupController.java
package com.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
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 com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.StoreupEntity;
import com.entity.view.StoreupView;
import com.service.StoreupService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 收藏表
* 后端接口
* @author
* @email
* @date 2021-04-18 01:00:26
*/
@RestController
@RequestMapping("/storeup")
public class StoreupController {
@Autowired
private StoreupService storeupService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,StoreupEntity storeup,
HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
storeup.setUserid((Long)request.getSession().getAttribute("userId"));
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,StoreupEntity storeup, HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
storeup.setUserid((Long)request.getSession().getAttribute("userId"));
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( StoreupEntity storeup){
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
ew.allEq(MPUtil.allEQMapPre( storeup, "storeup"));
return R.ok().put("data", storeupService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(StoreupEntity storeup){
EntityWrapper< StoreupEntity> ew = new EntityWrapper< StoreupEntity>();
ew.allEq(MPUtil.allEQMapPre( storeup, "storeup"));
StoreupView storeupView = storeupService.selectView(ew);
return R.ok("查询收藏表成功").put("data", storeupView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
StoreupEntity storeup = storeupService.selectById(id);
return R.ok().put("data", storeup);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
StoreupEntity storeup = storeupService.selectById(id);
return R.ok().put("data", storeup);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody StoreupEntity storeup, HttpServletRequest request){
storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(storeup);
storeup.setUserid((Long)request.getSession().getAttribute("userId"));
storeupService.insert(storeup);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody StoreupEntity storeup, HttpServletRequest request){
storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(storeup);
storeup.setUserid((Long)request.getSession().getAttribute("userId"));
storeupService.insert(storeup);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody StoreupEntity storeup, HttpServletRequest request){
//ValidatorUtils.validateEntity(storeup);
storeupService.updateById(storeup);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
storeupService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<StoreupEntity> wrapper = new EntityWrapper<StoreupEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
wrapper.eq("userid", (Long)request.getSession().getAttribute("userId"));
}
int count = storeupService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
TokenServiceImpl.java
package com.service.impl;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dao.TokenDao;
import com.entity.TokenEntity;
import com.entity.TokenEntity;
import com.service.TokenService;
import com.utils.CommonUtil;
import com.utils.PageUtils;
import com.utils.Query;
/**
* token
*/
@Service("tokenService")
public class TokenServiceImpl extends ServiceImpl<TokenDao, TokenEntity> implements TokenService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
Page<TokenEntity> page = this.selectPage(
new Query<TokenEntity>(params).getPage(),
new EntityWrapper<TokenEntity>()
);
return new PageUtils(page);
}
@Override
public List<TokenEntity> selectListView(Wrapper<TokenEntity> wrapper) {
return baseMapper.selectListView(wrapper);
}
@Override
public PageUtils queryPage(Map<String, Object> params,
Wrapper<TokenEntity> wrapper) {
Page<TokenEntity> page =new Query<TokenEntity>(params).getPage();
page.setRecords(baseMapper.selectListView(page,wrapper));
PageUtils pageUtil = new PageUtils(page);
return pageUtil;
}
@Override
public String generateToken(Long userid,String username, String tableName, String role) {
TokenEntity tokenEntity = this.selectOne(new EntityWrapper<TokenEntity>().eq("userid", userid).eq("role", role));
String token = CommonUtil.getRandomString(32);
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.HOUR_OF_DAY, 1);
if(tokenEntity!=null) {
tokenEntity.setToken(token);
tokenEntity.setExpiratedtime(cal.getTime());
this.updateById(tokenEntity);
} else {
this.insert(new TokenEntity(userid,username, tableName, role, token, cal.getTime()));
}
return token;
}
@Override
public TokenEntity getTokenEntity(String token) {
TokenEntity tokenEntity = this.selectOne(new EntityWrapper<TokenEntity>().eq("token", token));
if(tokenEntity == null || tokenEntity.getExpiratedtime().getTime()<new Date().getTime()) {
return null;
}
return tokenEntity;
}
}
register.vue
<template>
<div>
<div class="container">
<div class="login-form" style="backgroundColor:rgba(255, 255, 255, 0.17);borderRadius:10px">
<h1 class="h1" style="color:rgba(36, 194, 205, 1);fontSize:28px;">线上点餐系统注册</h1>
<el-form ref="rgsForm" class="rgs-form" :model="rgsForm" label-width="120px">
<!-- <div v-if="tableName=='yonghu'" class="input-group">
<div class="label">账号</div>
<div class="input-container">
<input v-model="ruleForm.zhanghao" class="input" type="text" placeholder="账号">
</div>
</div> -->
<el-form-item label="账号" class="input" v-if="tableName=='yonghu'">
<el-input v-model="ruleForm.zhanghao" autocomplete="off" placeholder="账号" />
</el-form-item>
<!-- <div v-if="tableName=='yonghu'" class="input-group">
<div class="label">密码</div>
<div class="input-container">
<input v-model="ruleForm.mima" class="input" type="text" placeholder="密码">
</div>
</div> -->
<el-form-item label="密码" class="input" v-if="tableName=='yonghu'">
<el-input v-model="ruleForm.mima" autocomplete="off" placeholder="密码" type="password"#elsetype="text" />
</el-form-item>
<!-- <div v-if="tableName=='yonghu'" class="input-group">
<div class="label">姓名</div>
<div class="input-container">
<input v-model="ruleForm.xingming" class="input" type="text" placeholder="姓名">
</div>
</div> -->
<el-form-item label="姓名" class="input" v-if="tableName=='yonghu'">
<el-input v-model="ruleForm.xingming" autocomplete="off" placeholder="姓名" />
</el-form-item>
<!-- <div v-if="tableName=='yonghu'" class="input-group">
<div class="label">手机</div>
<div class="input-container">
<input v-model="ruleForm.shouji" class="input" type="text" placeholder="手机">
</div>
</div> -->
<el-form-item label="手机" class="input" v-if="tableName=='yonghu'">
<el-input v-model="ruleForm.shouji" autocomplete="off" placeholder="手机" />
</el-form-item>
<!-- <div v-if="tableName=='yonghu'" class="input-group">
<div class="label">邮箱</div>
<div class="input-container">
<input v-model="ruleForm.youxiang" class="input" type="text" placeholder="邮箱">
</div>
</div> -->
<el-form-item label="邮箱" class="input" v-if="tableName=='yonghu'">
<el-input v-model="ruleForm.youxiang" autocomplete="off" placeholder="邮箱" />
</el-form-item>
<!-- <div v-if="tableName=='yonghu'" class="input-group">
<div class="label">身份证</div>
<div class="input-container">
<input v-model="ruleForm.shenfenzheng" class="input" type="text" placeholder="身份证">
</div>
</div> -->
<el-form-item label="身份证" class="input" v-if="tableName=='yonghu'">
<el-input v-model="ruleForm.shenfenzheng" autocomplete="off" placeholder="身份证" />
</el-form-item>
<div style="display: flex;flex-wrap: wrap;width: 100%;justify-content: center;">
<el-button class="btn" type="primary" @click="login()">注册</el-button>
<el-button class="btn close" type="primary" @click="close()">取消</el-button>
</div>
</el-form>
</div>
<!-- <div class="nk-navigation">
<a href="#">
<div @click="login()">注册</div>
</a>
</div> -->
</div>
</div>
</template>
<script>
export default {
data() {
return {
ruleForm: {
},
tableName:"",
rules: {}
};
},
mounted(){
let table = this.$storage.get("loginTable");
this.tableName = table;
},
methods: {
// 获取uuid
getUUID () {
return new Date().getTime();
},
close(){
this.$router.push({ path: "/login" });
},
// 注册
login() {
if((!this.ruleForm.zhanghao) && `yonghu` == this.tableName){
this.$message.error(`账号不能为空`);
return
}
if((!this.ruleForm.mima) && `yonghu` == this.tableName){
this.$message.error(`密码不能为空`);
return
}
if((!this.ruleForm.xingming) && `yonghu` == this.tableName){
this.$message.error(`姓名不能为空`);
return
}
if(`yonghu` == this.tableName && this.ruleForm.shouji&&(!this.$validate.isMobile(this.ruleForm.shouji))){
this.$message.error(`手机应输入手机格式`);
return
}
if(`yonghu` == this.tableName && this.ruleForm.youxiang&&(!this.$validate.isEmail(this.ruleForm.youxiang))){
this.$message.error(`邮箱应输入邮件格式`);
return
}
if(`yonghu` == this.tableName && this.ruleForm.shenfenzheng&&(!this.$validate.checkIdCard(this.ruleForm.shenfenzheng))){
this.$message.error(`身份证应输入身份证格式`);
return
}
this.$http({
url: `${this.tableName}/register`,
method: "post",
data:this.ruleForm
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: "注册成功",
type: "success",
duration: 1500,
onClose: () => {
this.$router.replace({ path: "/login" });
}
});
} else {
this.$message.error(data.msg);
}
});
}
}
};
</script>
<style lang="scss" scoped>
.el-radio__input.is-checked .el-radio__inner {
border-color: #00c292;
background: #00c292;
}
.el-radio__input.is-checked .el-radio__inner {
border-color: #00c292;
background: #00c292;
}
.el-radio__input.is-checked .el-radio__inner {
border-color: #00c292;
background: #00c292;
}
.el-radio__input.is-checked+.el-radio__label {
color: #00c292;
}
.el-radio__input.is-checked+.el-radio__label {
color: #00c292;
}
.el-radio__input.is-checked+.el-radio__label {
color: #00c292;
}
.h1 {
margin-top: 10px;
}
body {
padding: 0;
margin: 0;
}
// .container {
// min-height: 100vh;
// text-align: center;
// // background-color: #00c292;
// padding-top: 20vh;
// background-image: url(../assets/img/bg.jpg);
// background-size: 100% 100%;
// opacity: 0.9;
// }
// .login-form:before {
// vertical-align: middle;
// display: inline-block;
// }
// .login-form {
// max-width: 500px;
// padding: 20px 0;
// width: 80%;
// position: relative;
// margin: 0 auto;
// .label {
// min-width: 60px;
// }
// .input-group {
// max-width: 500px;
// padding: 20px 0;
// width: 80%;
// position: relative;
// margin: 0 auto;
// display: flex;
// align-items: center;
// .input-container {
// display: inline-block;
// width: 100%;
// text-align: left;
// margin-left: 10px;
// }
// .icon {
// width: 30px;
// height: 30px;
// }
// .input {
// position: relative;
// z-index: 2;
// float: left;
// width: 100%;
// margin-bottom: 0;
// box-shadow: none;
// border-top: 0px solid #ccc;
// border-left: 0px solid #ccc;
// border-right: 0px solid #ccc;
// border-bottom: 1px solid #ccc;
// padding: 0px;
// resize: none;
// border-radius: 0px;
// display: block;
// width: 100%;
// height: 34px;
// padding: 6px 12px;
// font-size: 14px;
// line-height: 1.42857143;
// color: #555;
// background-color: #fff;
// }
// }
// }
.nk-navigation {
margin-top: 15px;
a {
display: inline-block;
color: #fff;
background: rgba(255, 255, 255, .2);
width: 100px;
height: 50px;
border-radius: 30px;
text-align: center;
display: flex;
align-items: center;
margin: 0 auto;
justify-content: center;
padding: 0 20px;
}
.icon {
margin-left: 10px;
width: 30px;
height: 30px;
}
}
.register-container {
margin-top: 10px;
a {
display: inline-block;
color: #fff;
max-width: 500px;
height: 50px;
border-radius: 30px;
text-align: center;
display: flex;
align-items: center;
margin: 0 auto;
justify-content: center;
padding: 0 20px;
div {
margin-left: 10px;
}
}
}
.container {
background-image: url("http://codegen.caihongy.cn/20201124/b960a45e1acf4bc2b364a1664aad3fdb.jpg");
height: 100vh;
background-position: center center;
background-size: cover;
background-repeat: no-repeat;
.login-form {
right: 50%;
top: 50%;
height: auto;
transform: translate3d(50%, -50%, 0);
border-radius: 10px;
background-color: rgba(255,255,255,.5);
width: 420px;
padding: 30px 30px 40px 30px;
font-size: 14px;
font-weight: 500;
.h1 {
margin: 0;
text-align: center;
line-height: 54px;
font-size: 24px;
color: #000;
}
.rgs-form {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.input {
width: 100%;
& /deep/ .el-form-item__label {
line-height: 40px;
color: rgba(0, 0, 0, 1);
font-size: #606266;
}
& /deep/ .el-input__inner {
height: 40px;
color: #606266;
font-size: 14px;
border-width: 1px;
border-style: solid;
border-color: #606266;
border-radius: 4px;
background-color: #fff;
}
}
.btn {
margin: 0 10px;
width: 88px;
height: 44px;
color: #fff;
font-size: 14px;
border-width: 1px;
border-style: solid;
border-color: rgba(36, 194, 205, 1);
border-radius: 4px;
background-color: rgba(36, 194, 205, 1);
}
.close {
margin: 0 10px;
width: 88px;
height: 44px;
color: #409EFF;
font-size: 14px;
border-width: 1px;
border-style: solid;
border-color: #409EFF;
border-radius: 5px;
background-color: #FFF;
}
}
}
}
</style>
声明
本博客适用于广泛的学术和教育用途,包括但不限于个人学习、开发设计,产品设计。仅供学习参考,旨在为读者提供深入理解和学术研究的材料。