Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dm_project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姚本章
dm_project
Commits
a5de1461
Commit
a5de1461
authored
Dec 02, 2020
by
ysongq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
85e41fe9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
92 additions
and
12 deletions
+92
-12
pom.xml
jz-dm-common/pom.xml
+12
-0
UserContextUtil.java
...on/src/main/java/com/jz/common/utils/UserContextUtil.java
+35
-0
LoginController.java
...z/dm/mall/moduls/controller/customer/LoginController.java
+15
-2
MallCustomerController.java
...ll/moduls/controller/customer/MallCustomerController.java
+1
-7
MallCustomerDao.java
...in/java/com/jz/dm/mall/moduls/mapper/MallCustomerDao.java
+13
-1
MallCustomerService.java
...va/com/jz/dm/mall/moduls/service/MallCustomerService.java
+3
-0
MallCustomerServiceImpl.java
.../dm/mall/moduls/service/impl/MallCustomerServiceImpl.java
+4
-0
LoginController.java
.../com/jz/manage/moduls/controller/sys/LoginController.java
+9
-2
No files found.
jz-dm-common/pom.xml
View file @
a5de1461
...
@@ -74,5 +74,17 @@
...
@@ -74,5 +74,17 @@
<version>
RELEASE
</version>
<version>
RELEASE
</version>
<scope>
compile
</scope>
<scope>
compile
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.tomcat.embed
</groupId>
<artifactId>
tomcat-embed-core
</artifactId>
<version>
9.0.39
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-web
</artifactId>
<version>
5.3.1
</version>
<scope>
compile
</scope>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
jz-dm-common/src/main/java/com/jz/common/utils/UserContextUtil.java
0 → 100644
View file @
a5de1461
package
com
.
jz
.
common
.
utils
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
/**
* @ClassName: 将数据从session存储/取出
* @Author: Carl
* @Date: 2020/12/2
* @Version:
*/
public
class
UserContextUtil
{
/**
* 从session中获取数据
* @param objName 存储到session中的对象的变量名
*/
public
static
Object
pop
(
String
objName
)
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
return
request
.
getSession
().
getAttribute
(
objName
);
}
/**
* 把数据存储到session中
* @param objName 存储到session中的对象的变量名
* @param o 存储的任意数据
*/
public
static
void
push
(
String
objName
,
Object
o
)
{
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
request
.
getSession
().
setAttribute
(
objName
,
o
);
}
}
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/customer/LoginController.java
View file @
a5de1461
...
@@ -2,15 +2,21 @@ package com.jz.dm.mall.moduls.controller.customer;
...
@@ -2,15 +2,21 @@ package com.jz.dm.mall.moduls.controller.customer;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.StatusCode
;
import
com.jz.common.utils.StatusCode
;
import
com.jz.common.utils.UserContextUtil
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
com.jz.dm.mall.moduls.service.MallCustomerService
;
import
com.jz.dm.mall.moduls.service.MallCustomerService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.http.HttpRequest
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpSession
;
/**
/**
* @ClassName:
* @ClassName:
* @Author: Carl
* @Author: Carl
...
@@ -35,15 +41,18 @@ public class LoginController {
...
@@ -35,15 +41,18 @@ public class LoginController {
* @param password 密码
* @param password 密码
* @return
* @return
*/
*/
@
Ge
tMapping
(
value
=
"/login"
)
@
Pos
tMapping
(
value
=
"/login"
)
public
Result
<
MallCustomer
>
login
(
String
username
,
String
password
)
{
public
Result
<
MallCustomer
>
login
(
String
username
,
String
password
,
HttpServletRequest
request
)
{
// 手机
// 手机
String
ph
=
"^[1][34578]\\d{9}$"
;
String
ph
=
"^[1][34578]\\d{9}$"
;
HttpSession
session
=
request
.
getSession
();
// 如果是手机验证
// 如果是手机验证
if
(
username
.
matches
(
username
))
{
if
(
username
.
matches
(
username
))
{
MallCustomer
mallCustomer
=
mallCustomerService
.
selectByPhone
(
username
);
MallCustomer
mallCustomer
=
mallCustomerService
.
selectByPhone
(
username
);
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
.
getCustomerPhone
().
equals
(
username
)
&&
mallCustomer
.
getPassword
().
equals
(
password
)){
if
(
mallCustomer
.
getCustomerPhone
().
equals
(
username
)
&&
mallCustomer
.
getPassword
().
equals
(
password
)){
session
.
setAttribute
(
"customer_id"
,
mallCustomer
.
getCustomerId
());
session
.
setAttribute
(
"customer_account"
,
mallCustomer
.
getCustomerAccount
());
return
new
Result
<>(
true
,
"登录成功!"
,
StatusCode
.
OK
);
return
new
Result
<>(
true
,
"登录成功!"
,
StatusCode
.
OK
);
}
}
return
new
Result
<>(
false
,
"用户名或密码错误!"
,
StatusCode
.
ERROR
);
return
new
Result
<>(
false
,
"用户名或密码错误!"
,
StatusCode
.
ERROR
);
...
@@ -52,9 +61,13 @@ public class LoginController {
...
@@ -52,9 +61,13 @@ public class LoginController {
MallCustomer
mallCustomer
=
mallCustomerService
.
selectByAccount
(
username
);
MallCustomer
mallCustomer
=
mallCustomerService
.
selectByAccount
(
username
);
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
.
getCustomerAccount
().
equals
(
username
)
&&
mallCustomer
.
getPassword
().
equals
(
password
)){
if
(
mallCustomer
.
getCustomerAccount
().
equals
(
username
)
&&
mallCustomer
.
getPassword
().
equals
(
password
)){
session
.
setAttribute
(
"customer_id"
,
mallCustomer
.
getCustomerId
());
session
.
setAttribute
(
"customer_account"
,
mallCustomer
.
getCustomerAccount
());
return
new
Result
<>(
true
,
"登录成功!"
,
StatusCode
.
OK
);
return
new
Result
<>(
true
,
"登录成功!"
,
StatusCode
.
OK
);
}
}
}
}
return
new
Result
<>(
false
,
"用户名或密码错误!"
,
StatusCode
.
ERROR
);
return
new
Result
<>(
false
,
"用户名或密码错误!"
,
StatusCode
.
ERROR
);
}
}
}
}
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/customer/MallCustomerController.java
View file @
a5de1461
...
@@ -32,20 +32,14 @@ public class MallCustomerController extends BaseController {
...
@@ -32,20 +32,14 @@ public class MallCustomerController extends BaseController {
@Autowired
@Autowired
private
RedisTemplate
redisTemplate
;
private
RedisTemplate
redisTemplate
;
@PostMapping
(
value
=
"/saveCustomer"
)
public
Result
saveCustomer
(
Map
<
String
,
String
>
paramMap
)
{
return
null
;
}
/**
/**
* 手机号码校验
* 手机号码校验
* @param paramMap
* @param paramMap
* @param res
* @return
* @return
*/
*/
@PostMapping
(
value
=
"/check"
)
@PostMapping
(
value
=
"/check"
)
public
Result
loginCheck
(
@RequestBody
Map
<
String
,
String
>
paramMap
,
HttpServletResponse
res
)
{
public
Result
loginCheck
(
@RequestBody
Map
<
String
,
String
>
paramMap
)
{
// 获取手机号码
// 获取手机号码
String
telephone
=
paramMap
.
get
(
"telephone"
);
String
telephone
=
paramMap
.
get
(
"telephone"
);
String
key
=
RedisMessageConstant
.
SENDTYPE_LOGIN
+
"_"
+
telephone
;
String
key
=
RedisMessageConstant
.
SENDTYPE_LOGIN
+
"_"
+
telephone
;
...
...
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/mapper/MallCustomerDao.java
View file @
a5de1461
...
@@ -3,6 +3,8 @@ package com.jz.dm.mall.moduls.mapper;
...
@@ -3,6 +3,8 @@ package com.jz.dm.mall.moduls.mapper;
import
com.jz.common.base.BaseMapper
;
import
com.jz.common.base.BaseMapper
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
java.util.Map
;
/**
/**
* 商城用户(TMallCustomer)表数据库访问层
* 商城用户(TMallCustomer)表数据库访问层
*
*
...
@@ -10,8 +12,18 @@ import com.jz.dm.mall.moduls.entity.MallCustomer;
...
@@ -10,8 +12,18 @@ import com.jz.dm.mall.moduls.entity.MallCustomer;
* @since 2020-12-01 10:41:39
* @since 2020-12-01 10:41:39
*/
*/
public
interface
MallCustomerDao
extends
BaseMapper
<
MallCustomer
>
{
public
interface
MallCustomerDao
extends
BaseMapper
<
MallCustomer
>
{
/**
* 根据账号查询用户信息
* @param username
* @return
*/
MallCustomer
selectByAccount
(
String
username
);
MallCustomer
selectByAccount
(
String
username
);
/**
* 根据手机号查询用户信息
* @param username
* @return
*/
MallCustomer
selectByPhone
(
String
username
);
MallCustomer
selectByPhone
(
String
username
);
}
}
\ No newline at end of file
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/service/MallCustomerService.java
View file @
a5de1461
...
@@ -2,6 +2,8 @@ package com.jz.dm.mall.moduls.service;
...
@@ -2,6 +2,8 @@ package com.jz.dm.mall.moduls.service;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
java.util.Map
;
/**
/**
* 商城用户(TMallCustomer)表服务接口
* 商城用户(TMallCustomer)表服务接口
*
*
...
@@ -24,4 +26,5 @@ public interface MallCustomerService {
...
@@ -24,4 +26,5 @@ public interface MallCustomerService {
*/
*/
MallCustomer
selectByPhone
(
String
username
);
MallCustomer
selectByPhone
(
String
username
);
}
}
\ No newline at end of file
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/service/impl/MallCustomerServiceImpl.java
View file @
a5de1461
...
@@ -7,6 +7,8 @@ import com.jz.dm.mall.moduls.service.MallCustomerService;
...
@@ -7,6 +7,8 @@ import com.jz.dm.mall.moduls.service.MallCustomerService;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Map
;
/**
/**
* 商城用户(TMallCustomer)表服务实现类
* 商城用户(TMallCustomer)表服务实现类
*
*
...
@@ -40,4 +42,6 @@ public class MallCustomerServiceImpl implements MallCustomerService {
...
@@ -40,4 +42,6 @@ public class MallCustomerServiceImpl implements MallCustomerService {
public
MallCustomer
selectByPhone
(
String
username
)
{
public
MallCustomer
selectByPhone
(
String
username
)
{
return
tMallCustomerDao
.
selectByPhone
(
username
);
return
tMallCustomerDao
.
selectByPhone
(
username
);
}
}
}
}
\ No newline at end of file
jz-dm-manage/src/main/java/com/jz/manage/moduls/controller/sys/LoginController.java
View file @
a5de1461
...
@@ -13,7 +13,9 @@ import org.springframework.util.StringUtils;
...
@@ -13,7 +13,9 @@ import org.springframework.util.StringUtils;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.security.auth.Subject
;
import
javax.security.auth.Subject
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
java.util.Map
;
import
java.util.Map
;
@RestController
@RestController
...
@@ -32,15 +34,18 @@ public class LoginController extends BaseController {
...
@@ -32,15 +34,18 @@ public class LoginController extends BaseController {
* @param password 密码
* @param password 密码
* @return
* @return
*/
*/
@
Ge
tMapping
(
value
=
"login"
)
@
Pos
tMapping
(
value
=
"login"
)
public
Result
login
(
String
username
,
String
password
)
{
public
Result
login
(
String
username
,
String
password
,
HttpServletRequest
request
)
{
// 手机
// 手机
String
ph
=
"^[1][34578]\\d{9}$"
;
String
ph
=
"^[1][34578]\\d{9}$"
;
HttpSession
session
=
request
.
getSession
();
// 如果是手机验证
// 如果是手机验证
if
(
username
.
matches
(
username
))
{
if
(
username
.
matches
(
username
))
{
SysUser
sysUser
=
sysUserService
.
selectByPhone
(
username
);
SysUser
sysUser
=
sysUserService
.
selectByPhone
(
username
);
if
(
sysUser
!=
null
)
{
if
(
sysUser
!=
null
)
{
if
(
sysUser
.
getTelephone
().
equals
(
username
)
&&
sysUser
.
getPassword
().
equals
(
password
)){
if
(
sysUser
.
getTelephone
().
equals
(
username
)
&&
sysUser
.
getPassword
().
equals
(
password
)){
session
.
setAttribute
(
"account"
,
sysUser
.
getAccount
());
session
.
setAttribute
(
"password"
,
sysUser
.
getPassword
());
return
new
Result
<>(
true
,
"登录成功!"
,
StatusCode
.
OK
);
return
new
Result
<>(
true
,
"登录成功!"
,
StatusCode
.
OK
);
}
}
return
new
Result
<>(
false
,
"用户名或密码错误!"
,
StatusCode
.
ERROR
);
return
new
Result
<>(
false
,
"用户名或密码错误!"
,
StatusCode
.
ERROR
);
...
@@ -49,6 +54,8 @@ public class LoginController extends BaseController {
...
@@ -49,6 +54,8 @@ public class LoginController extends BaseController {
SysUser
sysUser
=
sysUserService
.
selectByUsername
(
username
);
SysUser
sysUser
=
sysUserService
.
selectByUsername
(
username
);
if
(
sysUser
!=
null
)
{
if
(
sysUser
!=
null
)
{
if
(
sysUser
.
getAccount
().
equals
(
username
)
&&
sysUser
.
getPassword
().
equals
(
password
)){
if
(
sysUser
.
getAccount
().
equals
(
username
)
&&
sysUser
.
getPassword
().
equals
(
password
)){
session
.
setAttribute
(
"account"
,
sysUser
.
getAccount
());
session
.
setAttribute
(
"password"
,
sysUser
.
getPassword
());
return
new
Result
<>(
true
,
"登录成功!"
,
StatusCode
.
OK
);
return
new
Result
<>(
true
,
"登录成功!"
,
StatusCode
.
OK
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment