diff --git a/src/main/java/com/phy/ebuy/EbuyApplication.java b/src/main/java/com/phy/ebuy/EbuyApplication.java index ef46c33..cae107e 100644 --- a/src/main/java/com/phy/ebuy/EbuyApplication.java +++ b/src/main/java/com/phy/ebuy/EbuyApplication.java @@ -3,6 +3,8 @@ package com.phy.ebuy; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + @MapperScan(basePackages = {"com.phy.ebuy.dao"}) @SpringBootApplication public class EbuyApplication { diff --git a/src/main/java/com/phy/ebuy/controller/EbuyController.java b/src/main/java/com/phy/ebuy/controller/EbuyController.java index 4b5436e..a4d3d4d 100644 --- a/src/main/java/com/phy/ebuy/controller/EbuyController.java +++ b/src/main/java/com/phy/ebuy/controller/EbuyController.java @@ -31,7 +31,7 @@ public class EbuyController { parameter.put("userName",userName); parameter.put("passWord",passWord); //返回结果 - Map result = null; + Map result = new HashMap<>(); try { result = ebuyService.verifyLogin(parameter); } catch (Exception e) { @@ -39,4 +39,33 @@ public class EbuyController { } return result; } + + //跳转到注册页面 + @RequestMapping("/register") + public String register() { + return "register.html"; + } + + //注册提交 + @RequestMapping("/registerSub") + @ResponseBody + public Map registerSub(@RequestParam("mobile") String mobile, + @RequestParam("userName") String userName, + @RequestParam("passWord") String passWord) { + //返回结果 + Map result = new HashMap<>(); + //参数 + Map parameter = new HashMap<>(); + parameter.put("mobile",mobile); + parameter.put("userName",userName); + parameter.put("passWord",passWord); + result = ebuyService.registerSub(parameter); + return result; + } + + //跳转到主页面 + @RequestMapping("/index") + public String index() { + return "index.html"; + } } diff --git a/src/main/java/com/phy/ebuy/dao/EbuyMapper.java b/src/main/java/com/phy/ebuy/dao/EbuyMapper.java index 8aa0dfc..9137406 100644 --- a/src/main/java/com/phy/ebuy/dao/EbuyMapper.java +++ b/src/main/java/com/phy/ebuy/dao/EbuyMapper.java @@ -4,11 +4,16 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; import java.util.Map; - @Mapper public interface EbuyMapper { /** * 验证登录 */ +// @Select(value = "select * from ebuy_user where (user_name = #{userName} and pass_word = #{passWord}) or (mobile = #{userName} and pass_word = #{passWord})") Map verifyLogin(Map map); + + /** + * 注册提交 + */ + int registerSub(Map map); } diff --git a/src/main/java/com/phy/ebuy/dao/mapping/EbuyMapper.xml b/src/main/java/com/phy/ebuy/dao/mapping/EbuyMapper.xml new file mode 100644 index 0000000..561ddf7 --- /dev/null +++ b/src/main/java/com/phy/ebuy/dao/mapping/EbuyMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + INSERT INTO ebuy_user + VALUES + ( + ( SELECT RIGHT ( RAND( ), 16 ) ), + #{userName}, + #{passWord}, + '', + '', + '', + #{mobile}, + '', + '00', + now( ), + '', + '00', + '0', + ( SELECT RIGHT ( RAND( ), 16 ) ) + ); + + \ No newline at end of file diff --git a/src/main/java/com/phy/ebuy/service/EbuyService.java b/src/main/java/com/phy/ebuy/service/EbuyService.java index 1e82831..7762f41 100644 --- a/src/main/java/com/phy/ebuy/service/EbuyService.java +++ b/src/main/java/com/phy/ebuy/service/EbuyService.java @@ -8,4 +8,10 @@ public interface EbuyService{ * 验证登录 */ Map verifyLogin(Map parameter); + + /** + * 注册提交 + */ + Map registerSub(Map parameter); + } diff --git a/src/main/java/com/phy/ebuy/service/impl/EbuyServiceImpl.java b/src/main/java/com/phy/ebuy/service/impl/EbuyServiceImpl.java index 16dfa7c..c1168ee 100644 --- a/src/main/java/com/phy/ebuy/service/impl/EbuyServiceImpl.java +++ b/src/main/java/com/phy/ebuy/service/impl/EbuyServiceImpl.java @@ -5,6 +5,7 @@ import com.phy.ebuy.service.EbuyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.HashMap; import java.util.Map; @Service @@ -13,10 +14,32 @@ public class EbuyServiceImpl implements EbuyService { * 验证登录 */ @Autowired - private EbuyMapper ebuyMapper; + public EbuyMapper ebuyMapper; public Map verifyLogin(Map parameter) { //返回结果 Map result = ebuyMapper.verifyLogin(parameter); + if (result == null){ + //返回结果 + Map result1 = new HashMap<>(); + result1.put("msg","你输入的密码和账户名不匹配!"); + return result1; + } else { + result.put("msg","登录成功!"); + return result; + } + } + + @Override + public Map registerSub(Map parameter) { + //返回结果 + Map result = new HashMap<>(); + int count = 0; + try { + count = ebuyMapper.registerSub(parameter); + } catch (Exception e) { + result.put("count","0"); + } + result.put("count",count); return result; } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d713458..7f37d29 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -40,38 +40,38 @@ spring: ############################## spring配置 结束 ############################## ############################## mybatis-plus配置 开始 ############################## -mybatis-plus: +mybatis: mapper-locations: classpath*:com/phy/ebuy/dao/mapping/*.xml typeAliasesPackage: com.phy.ebuy.model - global-config: - id-type: 3 # 0:数据库ID自增 1:用户输入id 2:全局唯一id(IdWorker) 3:全局唯一ID(uuid) - db-column-underline: false - refresh-mapper: true - logic-delete-value: 0 - logic-not-delete-value: 1 - sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector - configuration: - map-underscore-to-camel-case: false - cache-enabled: true # 配置的缓存的全局开关 - lazyLoadingEnabled: true # 延时加载的开关 - multipleResultSetsEnabled: true # 开启的话,延时加载一个属性时会加载该对象全部属性,否则按需加载属性 - #jdbc-type-for-null: 'null' #Oracle数据库开启,否则使用updateAllColumnById()这种方法,如果列值为空,就会报错 - #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印sql语句,调试用 +# global-config: +# id-type: 3 # 0:数据库ID自增 1:用户输入id 2:全局唯一id(IdWorker) 3:全局唯一ID(uuid) +# db-column-underline: false +# refresh-mapper: true +# logic-delete-value: 0 +# logic-not-delete-value: 1 +# sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector +# configuration: +# map-underscore-to-camel-case: false +# cache-enabled: true # 配置的缓存的全局开关 +# lazyLoadingEnabled: true # 延时加载的开关 +# multipleResultSetsEnabled: true # 开启的话,延时加载一个属性时会加载该对象全部属性,否则按需加载属性 +# jdbc-type-for-null: 'null' #Oracle数据库开启,否则使用updateAllColumnById()这种方法,如果列值为空,就会报错 +# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印sql语句,调试用 ############################## mybatis-plus配置 结束 ############################## ############################## quartz配置 结束 ############################## -org: - quartz: - jobStore: - class: org.quartz.impl.jdbcjobstore.JobStoreTX # 持久化 - dataSource: hussar # 定时任务数据源别名,非数据库别名 - misfireThreshold: 5000 # 容许的最大作业延长时 - tablePrefix: SYS_QRTZ_ # 表的前缀 - threadPool: - threadCount: 5 # 并发个数 - threadPriority: 5 # 优先级 - threadsInheritContextClassLoaderOfInitializingThread: true # 自创建父线程 +#org: +# quartz: +# jobStore: +# class: org.quartz.impl.jdbcjobstore.JobStoreTX # 持久化 +# dataSource: hussar # 定时任务数据源别名,非数据库别名 +# misfireThreshold: 5000 # 容许的最大作业延长时 +# tablePrefix: SYS_QRTZ_ # 表的前缀 +# threadPool: +# threadCount: 5 # 并发个数 +# threadPriority: 5 # 优先级 +# threadsInheritContextClassLoaderOfInitializingThread: true # 自创建父线程 ############################## quartz配置 结束 ############################## ############################## 日志配置 开始 ############################## @@ -82,24 +82,24 @@ org: ############################## 日志配置 结束 ############################## ############################## hussar配置 开始 ############################## -hussar: - spring-session-open: false # 是否开启spring session,如果是多机环境需要开启(true/false) - stand-alone: true # true 为单机环境 false 是集群环境 - welcome-page: / # 配置项目访问路径 - login-upper-open: true # 是否区分登录账号大小写 (true/false) - download-path: g:/GXDownload +#hussar: +# spring-session-open: false # 是否开启spring session,如果是多机环境需要开启(true/false) +# stand-alone: true # true 为单机环境 false 是集群环境 +# welcome-page: / # 配置项目访问路径 +# login-upper-open: true # 是否区分登录账号大小写 (true/false) +# download-path: g:/GXDownload ############## 登录密码传输加密的加密方式 默认提供三种加密方式 非对称RSA、对称AES 、Base64;存储加密方式默认提供SM4(国密4算法)、MD5哈希算法,可自行扩展其他算法 - encrypt-type: - type: RSA # 登录传输加密的加密方式 不区分大小写 - db-encrypt-type: SM4 # 存储加密的加密方式 不区分大小写 默认提供国密4算法;!!!!!!!! 修改该配置,需要重置数据库中密码所有密码!!!!! - secret-free-ip: 192.168.1.1 # 这里配置一个有登录权限的IP +# encrypt-type: +# type: RSA # 登录传输加密的加密方式 不区分大小写 +# db-encrypt-type: SM4 # 存储加密的加密方式 不区分大小写 默认提供国密4算法;!!!!!!!! 修改该配置,需要重置数据库中密码所有密码!!!!! +# secret-free-ip: 192.168.1.1 # 这里配置一个有登录权限的IP ############################## 外部接口配置 ############################## - open-orgservice: false #是否启用组织机构外部接口 +# open-orgservice: false #是否启用组织机构外部接口 ############## JWT认证所需参数 - jwt: - auth-path: /auth # 认证请求的路径 +# jwt: +# auth-path: /auth # 认证请求的路径 ############################## 以下配置为系统默认配置 ############################## # header: Authorization # http请求头所需要的字段 # secret: mySecret # jwt秘钥 @@ -121,8 +121,8 @@ hussar: # - /notice/update # - /notice/add # login-html: /login.html # 登录页html - index-config: true #是否开启欢迎页配置 true开启 false不开启 - default-index: /gxswJcsjInfo/view #默认欢迎页访问路径 +# index-config: true #是否开启欢迎页配置 true开启 false不开启 +# default-index: /gxswJcsjInfo/view #默认欢迎页访问路径 # shiro: # shiro 通用配置 # login-url: /login # 登录页面URL # unauthorized-url: /global/403 # 授权失败跳转地址 diff --git a/src/main/webapp/WEB-INF/view/index.html b/src/main/webapp/WEB-INF/view/index.html index d6d40cf..0afadad 100644 --- a/src/main/webapp/WEB-INF/view/index.html +++ b/src/main/webapp/WEB-INF/view/index.html @@ -3,8 +3,29 @@ E-BUY - 买你想买 + + + + +
+
+
+
+
+
+ +
+ +
+
+ +
+ + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/view/register.html b/src/main/webapp/WEB-INF/view/register.html new file mode 100644 index 0000000..34aed93 --- /dev/null +++ b/src/main/webapp/WEB-INF/view/register.html @@ -0,0 +1,62 @@ + + + + + 注册页面 + + + + + + + + +
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + +
+
+
+ +
+ + + + + + \ No newline at end of file diff --git a/src/main/webapp/static/css/index.css b/src/main/webapp/static/css/index.css new file mode 100644 index 0000000..5ee98b1 --- /dev/null +++ b/src/main/webapp/static/css/index.css @@ -0,0 +1,38 @@ +*{ + margin: 0; + padding: 0; +} +html{ + width: 100%; + height: 100%; +} +body{ + width: 100%; + height: 100%; + display: flex; + flex-direction:column; +} +.head{ + background: rgb(245,245,245); + flex: 1; + width: 100%; +} +.head .content{ + width: 80%; + height: 100%; + margin: 0 auto; +} +.middle{ + background: url("../img/background2.jpg") no-repeat; + background-size:100% 100%; + flex: 15; + display: flex; + overflow: auto; +} +.middle .box{ + width: 80%; + background: white; + margin: 0 auto; +} + + diff --git a/src/main/webapp/static/css/login.css b/src/main/webapp/static/css/login.css index 46400ee..0d3237b 100644 --- a/src/main/webapp/static/css/login.css +++ b/src/main/webapp/static/css/login.css @@ -125,7 +125,7 @@ body{ line-height: 42px; font-weight: 700; color: #fff; - background: #f40; + background: rgb(80,206,194); border-radius: 3px; cursor: pointer; zoom: 1; @@ -139,9 +139,11 @@ body{ float: right; } .middle .login-box .function .forget-password{ + cursor:pointer; flex: 1; } .middle .login-box .function .register{ + cursor:pointer; flex: 1; } .bottom{ diff --git a/src/main/webapp/static/css/register.css b/src/main/webapp/static/css/register.css new file mode 100644 index 0000000..56b72a2 --- /dev/null +++ b/src/main/webapp/static/css/register.css @@ -0,0 +1,43 @@ +.middle-register{ + flex: 8; + background: url(../img/timg.jpg) no-repeat; + background-size:100% 100%; + width: 100%; + height: 90%; +} +.middle-register .register-info{ + height: 20em; + width: 30em; + background: white; + margin: auto; + margin-top: 5%; + border-radius: 10px; + padding: 3% 2% 2% 2%; +} +.middle-register .register-info .btu-register{ + height: 3em; + width: 90%; + margin: 0 auto; + margin-top: 2em; + letter-spacing: 15px; + border: 0; + display: block; + overflow: hidden; + vertical-align: middle; + line-height: 42px; + font-weight: 700; + color: #fff; + background: rgb(80,206,194); + border-radius: 3px; + cursor: pointer; + zoom: 1; +} +.layui-form-label{ + width: 60px; +} +.layui-input-block { + margin-left: 100px; +} +.layui-input, .layui-textarea { + width: 93%; +} \ No newline at end of file diff --git a/src/main/webapp/static/img/background2.jpg b/src/main/webapp/static/img/background2.jpg new file mode 100644 index 0000000..5810133 Binary files /dev/null and b/src/main/webapp/static/img/background2.jpg differ diff --git a/src/main/webapp/static/js/index.js b/src/main/webapp/static/js/index.js new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/static/js/login.js b/src/main/webapp/static/js/login.js index f9f5758..9616069 100644 --- a/src/main/webapp/static/js/login.js +++ b/src/main/webapp/static/js/login.js @@ -2,22 +2,61 @@ layui.use(['layer',"jquery"], function() { const layer = layui.layer ,$ = layui.jquery; $(".login-btu").on("click", function () { - //登录验证 - $.ajax({ - url: "/ebuy/verifyLogin", - type: "post", - data: { - userName: $("#userName").val(), - passWord: $("#passWord").val() - }, - dataType: "json", - success: function (data) { - console.log(data); + if ($("#userName").val() == '' || $("#userName").val()== null) { + layer.msg("用户名不能为空!"); + } else if ($("#passWord").val() == '' || $("#passWord").val() == null) { + layer.msg("密码不能为空!"); + } else { + //登录验证 + $.ajax({ + url: "/ebuy/verifyLogin", + type: "post", + data: { + userName: $("#userName").val(), + passWord: $("#passWord").val() + }, + dataType: "json", + success: function (data) { + let msg = data.msg; + if (msg == "登录成功!") { + //登录成功 + console.log(msg); + window.location.href = "/ebuy/index"; + } else { + //登录失败 + layer.msg(msg) + } - }, - error: function () { - layer.msg("你输入的密码和账户名不匹配!") - } - }) + }, + error: function () { + layer.msg("登录异常! \n 请联系管理员:15006732580") + } + }) + } + + }) + + //注册 + $(".register").on("click",function () { + window.location.href = "/ebuy/register"; + }) + + //忘记密码 + $(".forget-password").on("click",function () { + layer.msg("功能正在完善,请联系管理员:15006732580!") + }) + + //回车登录 + $("body").keydown(function () { + + if (window.event.keyCode==13) { + //如果发生了按下回车键事件,回车键对应的编号是13 + + $(".login-btu").trigger("click"); //则激活登录按钮的click事件 + } + }); + + $(".log").on("click",function () { + window.location.href="/ebuy/index"; }) }) \ No newline at end of file diff --git a/src/main/webapp/static/js/register.js b/src/main/webapp/static/js/register.js new file mode 100644 index 0000000..167c591 --- /dev/null +++ b/src/main/webapp/static/js/register.js @@ -0,0 +1,61 @@ +layui.use(['layer',"jquery"], function() { + const layer = layui.layer + , $ = layui.jquery; + + //注册 + $(".btu-register").on("click",function () { + //获取表单数据 + let mobile = $("#mobile").val(); + let userName = $("#userName").val(); + let passWord = $("#passWord").val(); + let againPassWord = $("#againPassWord").val(); + if (mobile == '' || mobile == null) { + layer.msg("请输入手机号!") + } else if (userName == '' || userName == null) { + layer.msg("请输入用户名!") + } else if (passWord == '' || passWord == null) { + layer.msg("请输入密码!") + } else if (againPassWord == '' || againPassWord == null) { + layer.msg("请确认密码!") + } else if (againPassWord != passWord) { + layer.msg("两次密码不一致!") + } else + layer.confirm('确认提交?', function(index){ + $.ajax({ + url:"/ebuy/registerSub", + type:"post", + data:{ + mobile:mobile, + userName:userName, + passWord:passWord + }, + dataType:"json", + success:function (data) { + if (data.count > 0) { + layer.msg("注册成功"); + window.location.href="/ebuy/login"; + } else { + layer.msg("手机号已被注册或用户名重复!"); + } + + }, + error:function () { + layer.msg("注册出现异常! \n 请联系管理员:15006732580"); + } + }) + + layer.close(index); + }); + + }) + + //回车登录 + $("body").keydown(function () { + + if (window.event.keyCode==13) { + //如果发生了按下回车键事件,回车键对应的编号是13 + + $(".btu-register").trigger("click"); //则激活登录按钮的click事件 + } + }); +}) \ No newline at end of file