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
39dab40a
Commit
39dab40a
authored
Dec 09, 2020
by
ysongq
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dm_dev' of
http://gitlab.ioubuy.cn/yaobenzhang/dm_project
into dm_dev
parents
dc4f8a71
8b903186
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
318 additions
and
32 deletions
+318
-32
CurrentUser.java
...-common/src/main/java/com/jz/common/base/CurrentUser.java
+28
-5
MallCustomerApiDto.java
.../src/main/java/com/jz/common/bean/MallCustomerApiDto.java
+14
-0
OrderMethodEnum.java
...on/src/main/java/com/jz/common/enums/OrderMethodEnum.java
+68
-0
PaymentMethodEnum.java
.../src/main/java/com/jz/common/enums/PaymentMethodEnum.java
+68
-0
LoginController.java
...z/dm/mall/moduls/controller/customer/LoginController.java
+16
-8
CustomerDto.java
.../dm/mall/moduls/controller/customer/bean/CustomerDto.java
+100
-0
MallCustomerDao.java
...in/java/com/jz/dm/mall/moduls/mapper/MallCustomerDao.java
+2
-2
MallCustomerService.java
...va/com/jz/dm/mall/moduls/service/MallCustomerService.java
+2
-2
MallCustomerServiceImpl.java
.../dm/mall/moduls/service/impl/MallCustomerServiceImpl.java
+7
-10
MallCustomerDao.xml
jz-dm-mall/src/main/resources/mapperconf/MallCustomerDao.xml
+13
-5
No files found.
jz-dm-common/src/main/java/com/jz/common/base/CurrentUser.java
View file @
39dab40a
package
com
.
jz
.
common
.
base
;
import
com.jz.common.bean.MallCustomerApiDto
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.servlet.http.HttpServletRequest
;
/**
...
...
@@ -13,16 +15,18 @@ public class CurrentUser {
/**
* 获取用户信息
*
* @param req
* @return
*/
public
static
MallCustomerApiDto
getCurrentUser
(
HttpServletRequest
req
){
MallCustomerApiDto
mallCustomerApiDto
=(
MallCustomerApiDto
)
req
.
getAttribute
(
"mallCustomer"
);
public
static
MallCustomerApiDto
getCurrentUser
(
HttpServletRequest
req
)
{
MallCustomerApiDto
mallCustomerApiDto
=
(
MallCustomerApiDto
)
req
.
getAttribute
(
"mallCustomer"
);
return
mallCustomerApiDto
;
}
/**
* 用户id
*
* @param request
* @return
*/
...
...
@@ -33,12 +37,31 @@ public class CurrentUser {
/**
* 企业id
*
* @param request
* @return
*/
public
static
Lo
ng
getDepartmentId
(
HttpServletRequest
request
)
{
public
static
Stri
ng
getDepartmentId
(
HttpServletRequest
request
)
{
Long
departmentId
=
getCurrentUser
(
request
).
getDepartmentId
();
return
departmentId
;
if
(
departmentId
!=
null
)
{
String
id
=
String
.
valueOf
(
departmentId
);
return
id
;
}
return
null
;
}
/**
* 用户资产id
* @Author Bellamy
* @param request
* @return
*/
public
static
String
getAssetsId
(
HttpServletRequest
request
)
{
String
assetsId
=
getCurrentUser
(
request
).
getAssetsId
();
if
(
StringUtils
.
isNotEmpty
(
assetsId
))
{
return
assetsId
;
}
return
null
;
}
}
jz-dm-common/src/main/java/com/jz/common/bean/MallCustomerApiDto.java
View file @
39dab40a
...
...
@@ -38,6 +38,12 @@ public class MallCustomerApiDto implements Serializable {
@ApiModelProperty
(
value
=
"用户真实姓名"
)
private
String
customerName
;
/**
* 资产账户id
*/
@ApiModelProperty
(
value
=
"资产账户id"
)
private
String
assetsId
;
public
static
long
getSerialVersionUID
()
{
return
serialVersionUID
;
}
...
...
@@ -81,4 +87,12 @@ public class MallCustomerApiDto implements Serializable {
public
void
setCustomerName
(
String
customerName
)
{
this
.
customerName
=
customerName
;
}
public
String
getAssetsId
()
{
return
assetsId
;
}
public
void
setAssetsId
(
String
assetsId
)
{
this
.
assetsId
=
assetsId
;
}
}
jz-dm-common/src/main/java/com/jz/common/enums/OrderMethodEnum.java
0 → 100644
View file @
39dab40a
package
com
.
jz
.
common
.
enums
;
/**
* 订单方式
*
* @author Bellamy
* @since 2020-12-09 14:30:23
*/
public
enum
OrderMethodEnum
{
/**
* 年
*/
YEAR
(
"YEAR"
,
"01"
),
/**
* 季
*/
SEASON
(
"SEASON"
,
"02"
),
/**
* 月
*/
MONTH
(
"MONTH"
,
"03"
),
/**
* 月
*/
SECOND
(
"SECOND"
,
"04"
),
;
private
String
code
;
private
String
value
;
OrderMethodEnum
(
String
code
,
String
value
)
{
this
.
code
=
code
;
this
.
value
=
value
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
public
static
OrderMethodEnum
get
(
String
code
)
{
if
(
code
==
null
)
{
return
null
;
}
for
(
OrderMethodEnum
status
:
values
())
{
if
(
status
.
getCode
().
equalsIgnoreCase
(
code
))
{
return
status
;
}
}
return
null
;
}
}
jz-dm-common/src/main/java/com/jz/common/enums/PaymentMethodEnum.java
0 → 100644
View file @
39dab40a
package
com
.
jz
.
common
.
enums
;
/**
* 支付方式
*
* @author Bellamy
* @since 2020-12-09 14:30:23
*/
public
enum
PaymentMethodEnum
{
/**
* 余额
*/
YE
(
"YE"
,
"01"
),
/**
* 支付宝
*/
ZFB
(
"ZFB"
,
"02"
),
/**
* 微信
*/
WX
(
"WX"
,
"03"
),
/**
* 其他
*/
OTHER
(
"OTHER"
,
"04"
),
;
private
String
code
;
private
String
value
;
PaymentMethodEnum
(
String
code
,
String
value
)
{
this
.
code
=
code
;
this
.
value
=
value
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
public
static
PaymentMethodEnum
get
(
String
code
)
{
if
(
code
==
null
)
{
return
null
;
}
for
(
PaymentMethodEnum
status
:
values
())
{
if
(
status
.
getCode
().
equalsIgnoreCase
(
code
))
{
return
status
;
}
}
return
null
;
}
}
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/customer/LoginController.java
View file @
39dab40a
package
com
.
jz
.
dm
.
mall
.
moduls
.
controller
.
customer
;
import
com.jz.common.b
ase.CurrentUser
;
import
com.jz.common.b
ean.MallCustomerApiDto
;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.StatusCode
;
import
com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
com.jz.dm.mall.moduls.service.MallCustomerService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.catalina.servlet4preview.http.HttpServletRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.apache.catalina.servlet4preview.http.HttpServletRequest
;
import
java.util.Map
;
...
...
@@ -37,21 +37,26 @@ public class LoginController {
@Autowired
private
RedisTemplate
redisTemplate
;
/**
* 登录功能
*
* @param username 账号
* @param password 密码
* @return
*/
@PostMapping
(
value
=
"/login"
)
public
Result
<
MallCustomer
>
login
(
String
username
,
String
password
,
HttpServletRequest
request
)
throws
Exception
{
@ApiOperation
(
value
=
"登录功能"
,
notes
=
"登录功能"
)
public
Result
<
MallCustomer
>
login
(
String
username
,
String
password
,
HttpServletRequest
request
)
throws
Exception
{
// 手机
String
ph
=
"^[1][34578]\\d{9}$"
;
// 如果是手机验证
if
(
username
.
matches
(
username
))
{
MallCustomer
mallCustomer
=
mallCustomerService
.
selectByPhone
(
username
,
request
);
CustomerDto
mallCustomer
=
mallCustomerService
.
selectByPhone
(
username
,
request
);
MallCustomerApiDto
mallCustomerApiDto
=
(
MallCustomerApiDto
)
request
.
getSession
().
getAttribute
(
"mallCustomer"
);
System
.
out
.
print
(
mallCustomerApiDto
.
getAssetsId
());
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
.
getCustomerPhone
().
equals
(
username
)
&&
mallCustomer
.
getPassword
().
equals
(
password
)){
if
(
mallCustomer
.
getCustomerPhone
().
equals
(
username
)
&&
mallCustomer
.
getPassword
().
equals
(
password
))
{
return
new
Result
<>(
true
,
"登录成功!"
,
StatusCode
.
OK
);
}
return
new
Result
<>(
false
,
"用户名或密码错误!"
,
StatusCode
.
ERROR
);
...
...
@@ -59,7 +64,7 @@ public class LoginController {
}
MallCustomer
mallCustomer
=
mallCustomerService
.
selectByAccount
(
username
,
request
);
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
.
getCustomerAccount
().
equals
(
username
)
&&
mallCustomer
.
getPassword
().
equals
(
password
)){
if
(
mallCustomer
.
getCustomerAccount
().
equals
(
username
)
&&
mallCustomer
.
getPassword
().
equals
(
password
))
{
return
new
Result
<>(
true
,
"登录成功!"
,
StatusCode
.
OK
);
}
}
...
...
@@ -69,6 +74,7 @@ public class LoginController {
/**
* 手机获取验证码
*
* @param paramMap
* @return
*/
...
...
@@ -94,6 +100,7 @@ public class LoginController {
/**
* 手机号码校验
*
* @param telephone
* @return
*/
...
...
@@ -113,6 +120,7 @@ public class LoginController {
/**
* 手机号码及用户名重复校验
*
* @param username
* @param telephone
* @param request
...
...
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/customer/bean/CustomerDto.java
0 → 100644
View file @
39dab40a
package
com
.
jz
.
dm
.
mall
.
moduls
.
controller
.
customer
.
bean
;
import
io.swagger.annotations.ApiModel
;
/**
* @ClassName: CustomerDto
* @Description: 商城用户返回对象参数
* @Author Bellamy
* @Date 2020/12/9
* @Version 1.0
*/
@ApiModel
(
value
=
"商城用户--返回参数对象"
,
description
=
"返回参数对象"
)
public
class
CustomerDto
{
/**
* 用户id
*/
private
Long
customerId
;
/**
* 企业id
*/
private
Long
departmentId
;
/**
* 密码
*/
private
String
password
;
/**
* 账户
*/
private
String
customerAccount
;
/**
* 用户真实姓名
*/
private
String
customerName
;
/**
* 联系电话
*/
private
String
customerPhone
;
/**
* 资产账户id
*/
private
String
assetsId
;
public
Long
getCustomerId
()
{
return
customerId
;
}
public
void
setCustomerId
(
Long
customerId
)
{
this
.
customerId
=
customerId
;
}
public
Long
getDepartmentId
()
{
return
departmentId
;
}
public
void
setDepartmentId
(
Long
departmentId
)
{
this
.
departmentId
=
departmentId
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getCustomerAccount
()
{
return
customerAccount
;
}
public
void
setCustomerAccount
(
String
customerAccount
)
{
this
.
customerAccount
=
customerAccount
;
}
public
String
getCustomerName
()
{
return
customerName
;
}
public
void
setCustomerName
(
String
customerName
)
{
this
.
customerName
=
customerName
;
}
public
String
getCustomerPhone
()
{
return
customerPhone
;
}
public
void
setCustomerPhone
(
String
customerPhone
)
{
this
.
customerPhone
=
customerPhone
;
}
public
String
getAssetsId
()
{
return
assetsId
;
}
public
void
setAssetsId
(
String
assetsId
)
{
this
.
assetsId
=
assetsId
;
}
}
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/mapper/MallCustomerDao.java
View file @
39dab40a
package
com
.
jz
.
dm
.
mall
.
moduls
.
mapper
;
import
com.jz.common.base.BaseMapper
;
import
com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
org.apache.ibatis.annotations.*
;
import
org.apache.ibatis.annotations.Insert
;
import
org.apache.ibatis.annotations.Param
;
...
...
@@ -28,7 +28,7 @@ public interface MallCustomerDao extends BaseMapper<MallCustomer> {
* @param username
* @return
*/
MallCustomer
selectByPhone
(
String
username
);
CustomerDto
selectByPhone
(
String
username
);
/**
* 根据手机号查询是否已注册
...
...
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/service/MallCustomerService.java
View file @
39dab40a
package
com
.
jz
.
dm
.
mall
.
moduls
.
service
;
import
com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
org.apache.ibatis.annotations.Param
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Map
;
...
...
@@ -26,7 +26,7 @@ public interface MallCustomerService {
* @param username
* @return
*/
MallCustomer
selectByPhone
(
String
username
,
HttpServletRequest
request
);
CustomerDto
selectByPhone
(
String
username
,
HttpServletRequest
request
);
/**
* 注册账号
...
...
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/service/impl/MallCustomerServiceImpl.java
View file @
39dab40a
package
com
.
jz
.
dm
.
mall
.
moduls
.
service
.
impl
;
import
com.jz.common.bean.MallCustomerApiDto
;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.enums.UserTypeEnum
;
import
com.jz.common.utils.DateUtils
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.SessionUtils
;
import
com.jz.common.bean.MallCustomerApiDto
;
import
com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
com.jz.dm.mall.moduls.mapper.MallCustomerDao
;
import
com.jz.dm.mall.moduls.service.MallCustomerService
;
import
freemarker.template.utility.DateUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -59,7 +55,7 @@ public class MallCustomerServiceImpl implements MallCustomerService {
// 存入到session
request
.
getSession
().
setAttribute
(
"mallCustomer"
,
mallCustomerApiDto
);
// 存入到redis
redisTemplate
.
opsForValue
().
set
(
"user_"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_CUSTOMER
,
mallCustomerApiDto
,
3
,
TimeUnit
.
DAYS
);
redisTemplate
.
opsForValue
().
set
(
"user_"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_CUSTOMER
,
mallCustomerApiDto
,
3
,
TimeUnit
.
DAYS
);
}
return
mallCustomer
;
}
...
...
@@ -71,8 +67,8 @@ public class MallCustomerServiceImpl implements MallCustomerService {
* @return
*/
@Override
public
MallCustomer
selectByPhone
(
String
username
,
HttpServletRequest
request
)
{
MallCustomer
mallCustomer
=
tMallCustomerDao
.
selectByPhone
(
username
);
public
CustomerDto
selectByPhone
(
String
username
,
HttpServletRequest
request
)
{
CustomerDto
mallCustomer
=
tMallCustomerDao
.
selectByPhone
(
username
);
if
(
mallCustomer
!=
null
)
{
MallCustomerApiDto
mallCustomerApiDto
=
new
MallCustomerApiDto
();
// 赋值
...
...
@@ -81,10 +77,11 @@ public class MallCustomerServiceImpl implements MallCustomerService {
mallCustomerApiDto
.
setUserTypeEnum
(
UserTypeEnum
.
COMPANY_ROLE
);
mallCustomerApiDto
.
setCustomerAccount
(
mallCustomer
.
getCustomerAccount
());
mallCustomerApiDto
.
setCustomerName
(
mallCustomer
.
getCustomerName
());
mallCustomerApiDto
.
setAssetsId
(
mallCustomer
.
getAssetsId
());
// 存入到session
request
.
getSession
().
setAttribute
(
"mallCustomer"
,
mallCustomerApiDto
);
// 存入到redis
redisTemplate
.
opsForValue
().
set
(
"user_"
+
RedisMessageConstant
.
SENDTYPE_LOGIN_CUSTOMER
,
mallCustomerApiDto
,
3
,
TimeUnit
.
DAYS
);
//redisTemplate.opsForValue().set("user_" + RedisMessageConstant.SENDTYPE_LOGIN_CUSTOMER
, mallCustomerApiDto, 3, TimeUnit.DAYS);
}
return
mallCustomer
;
}
...
...
jz-dm-mall/src/main/resources/mapperconf/MallCustomerDao.xml
View file @
39dab40a
...
...
@@ -172,11 +172,19 @@
where customer_account = #{username};
</select>
<select
id=
"selectByPhone"
result
Map=
"TMallCustomerMap
"
>
<select
id=
"selectByPhone"
result
Type=
"com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto
"
>
select
customer_id, department_id, password, customer_account, customer_name, customer_phone, customer_email, customer_address, customer_point, register_time, customer_level, identity_card, cre_time, upt_time, del_flag
from t_mall_customer
where customer_phone = #{username};
t1.customer_id as customerId,
t1.department_id as departmentId,
t1.password,
t1.customer_account as customerAccount,
t1.customer_name as customerName,
t1.customer_phone as customerPhone,
t3.assets_id as assetsId
from t_mall_customer t1
left join t_department t2 on t1.department_id=t2.department_id
left join t_finance_customer_assets t3 on t3.department_id=t2.department_id
where 1=1 and t1.del_flag='N' and customer_phone = #{username}
</select>
<select
id=
"selectByPhoneExist"
resultMap=
"TMallCustomerMap"
>
...
...
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