This commit is contained in:
裴浩宇 2020-01-07 18:19:42 +08:00
parent e05ad8a2e3
commit 327d8794a0
16 changed files with 424 additions and 61 deletions

View File

@ -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 {

View File

@ -31,7 +31,7 @@ public class EbuyController {
parameter.put("userName",userName);
parameter.put("passWord",passWord);
//返回结果
Map<String,Object> result = null;
Map<String,Object> 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<String,Object> registerSub(@RequestParam("mobile") String mobile,
@RequestParam("userName") String userName,
@RequestParam("passWord") String passWord) {
//返回结果
Map<String,Object> result = new HashMap<>();
//参数
Map<String,Object> 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";
}
}

View File

@ -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<String,Object> verifyLogin(Map<String,Object> map);
/**
* 注册提交
*/
int registerSub(Map<String,Object> map);
}

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.phy.ebuy.dao.EbuyMapper">
<!--验证登录-->
<select id="verifyLogin" parameterType="map" resultType="map" >
select * from ebuy_user where (user_name = #{userName} and pass_word = #{passWord})
or (mobile = #{userName} and pass_word = #{passWord})
</select>
<!--注册提交-->
<insert id="registerSub" parameterType="map">
INSERT INTO ebuy_user
VALUES
(
( SELECT RIGHT ( RAND( ), 16 ) ),
#{userName},
#{passWord},
'',
'',
'',
#{mobile},
'',
'00',
now( ),
'',
'00',
'0',
( SELECT RIGHT ( RAND( ), 16 ) )
);
</insert>
</mapper>

View File

@ -8,4 +8,10 @@ public interface EbuyService{
* 验证登录
*/
Map<String,Object> verifyLogin(Map<String,Object> parameter);
/**
* 注册提交
*/
Map<String,Object> registerSub(Map<String,Object> parameter);
}

View File

@ -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<String,Object> verifyLogin(Map<String,Object> parameter) {
//返回结果
Map<String, Object> result = ebuyMapper.verifyLogin(parameter);
if (result == null){
//返回结果
Map<String,Object> result1 = new HashMap<>();
result1.put("msg","你输入的密码和账户名不匹配!");
return result1;
} else {
result.put("msg","登录成功!");
return result;
}
}
@Override
public Map<String, Object> registerSub(Map<String, Object> parameter) {
//返回结果
Map<String, Object> result = new HashMap<>();
int count = 0;
try {
count = ebuyMapper.registerSub(parameter);
} catch (Exception e) {
result.put("count","0");
}
result.put("count",count);
return result;
}
}

View File

@ -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 # 授权失败跳转地址

View File

@ -3,8 +3,29 @@
<head>
<meta charset="UTF-8">
<title>E-BUY - 买你想买</title>
<link rel="shortcut icon" type="image/x-icon" href="../../static/img/favicon.ico" rel="external nofollow" />
<link rel="stylesheet" href="../../static/css/index.css">
<link rel="stylesheet" href="../../static/layui/css/layui.css">
</head>
<body>
<div class="head">
<div class="content">
</div>
</div>
<div class="middle">
<div class="box">
</div>
</div>
<div class="bottom">
</div>
</body>
<script src="../../static/js/jquery-1.12.2.js"></script>
<script src="../../static/js/index.js"></script>
<script src="../../static/layui/layui.js"></script>
<script src="../../static/layui/layui.all.js"></script>
</html>

View File

@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>注册页面</title>
<link rel="stylesheet" href="../../static/css/login.css">
<link rel="shortcut icon" type="image/x-icon" href="../../static/img/favicon.ico" rel="external nofollow" />
<link rel="stylesheet" href="../../static/layui/css/layui.css">
<link rel="stylesheet" href="../../static/css/register.css">
<script src="../../static/layui/layui.all.js"></script>
</head>
<body>
<div class="head">
<div class="log"></div>
<div class="login-msg error">
<p class="error">
为确保您账户的安全及正常使用依《网络安全法》相关要求6月1日起会员账户需绑定手机。如您还未绑定请尽快完成感谢您的理解及支持
</p>
</div>
</div>
<div class="middle-register">
<div class="register-info">
<div class="layui-form-item">
<label class="layui-form-label">手机号</label>
<div class="layui-input-block">
<input type="text" id="mobile" name="title" lay-verify="title" autocomplete="off" placeholder="请输入手机号" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">用户名</label>
<div class="layui-input-block">
<input type="text" id="userName" name="title" lay-verify="title" autocomplete="off" placeholder="请输入用户名" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">密码</label>
<div class="layui-input-block">
<input type="password" id="passWord" name="title" lay-verify="title" autocomplete="off" placeholder="请输入密码" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">确认密码</label>
<div class="layui-input-block">
<input type="password" id="againPassWord" name="title" lay-verify="title" autocomplete="off" placeholder="请确认密码" class="layui-input">
</div>
</div>
<button class="btu-register" type="submit">
注 册
</button>
</div>
</div>
<div class="bottom">
</div>
</body>
<script src="../../static/js/jquery-1.12.2.js"></script>
<script src="../../static/js/login.js"></script>
<script src="../../static/layui/layui.js"></script>
<script src="../../static/js/register.js"></script>
</html>

View File

@ -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;
}

View File

@ -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{

View File

@ -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%;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

View File

View File

@ -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";
})
})

View File

@ -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事件
}
});
})