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
d336d472
Commit
d336d472
authored
Dec 04, 2020
by
ysongq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
密码修改
parent
58e75822
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
20 deletions
+78
-20
MallCustomerController.java
...ll/moduls/controller/customer/MallCustomerController.java
+33
-6
MallCustomerDao.java
...in/java/com/jz/dm/mall/moduls/mapper/MallCustomerDao.java
+4
-7
MallCustomerService.java
...va/com/jz/dm/mall/moduls/service/MallCustomerService.java
+9
-2
MallCustomerServiceImpl.java
.../dm/mall/moduls/service/impl/MallCustomerServiceImpl.java
+20
-4
application-test.yml
jz-dm-mall/src/main/resources/application-test.yml
+1
-1
MallCustomerDao.xml
jz-dm-mall/src/main/resources/mapperconf/MallCustomerDao.xml
+11
-0
No files found.
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/customer/MallCustomerController.java
View file @
d336d472
...
@@ -2,9 +2,11 @@ package com.jz.dm.mall.moduls.controller.customer;
...
@@ -2,9 +2,11 @@ package com.jz.dm.mall.moduls.controller.customer;
import
com.baomidou.mybatisplus.extension.api.R
;
import
com.baomidou.mybatisplus.extension.api.R
;
import
com.jz.common.base.BaseController
;
import
com.jz.common.base.BaseController
;
import
com.jz.common.base.CurrentUser
;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.common.constant.ResultCode
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.constant.ResultMsg
;
import
com.jz.common.utils.SessionUtils
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.StatusCode
;
import
com.jz.common.utils.StatusCode
;
...
@@ -18,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -18,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.servlet.http.HttpServletRequest
;
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
;
/**
/**
...
@@ -73,13 +76,37 @@ public class MallCustomerController extends BaseController {
...
@@ -73,13 +76,37 @@ public class MallCustomerController extends BaseController {
}
}
/**
* 获取用户信息
* @return
*/
@GetMapping
(
"/getLoginUserName"
)
@ApiOperation
(
value
=
"注册用户"
,
notes
=
"添加用户"
)
public
Result
getLoginUserName
(
HttpServletRequest
request
)
{
// 从session中获取id
try
{
MallCustomer
mallCustomer
=
(
MallCustomer
)
SessionUtils
.
getUserCurrent
(
request
,
"mallCustomer"
);
Long
customerId
=
1L
;
// Long customerId = mallCustomer.getCustomerId();
MallCustomer
user
=
mallCustomerService
.
selectByUser
(
customerId
);
return
new
Result
(
true
,
"获取用户信息成功!"
,
StatusCode
.
OK
,
user
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
new
Result
(
false
,
"获取用户信息失败"
);
}
}
@PostMapping
(
value
=
"/updatePassword"
)
@PostMapping
(
value
=
"/updatePassword"
)
public
Result
updatePassword
(
String
username
,
String
password
)
throws
Exception
{
public
Result
updatePassword
(
String
oldPassword
,
String
newPassword
,
HttpServletRequest
request
)
throws
Exception
{
if
(
username
!=
null
&&
password
!=
null
)
{
// 获取用户信息
mallCustomerService
.
updatePassword
(
username
,
password
);
MallCustomer
mallCustomer
=
(
MallCustomer
)
getLoginUserName
(
request
).
getData
();
return
new
Result
(
true
,
"密码修改成功!"
);
// 如果密码一致
if
(
mallCustomer
.
getPassword
().
equals
(
oldPassword
))
{
// 修改密码
Long
customerId
=
mallCustomer
.
getCustomerId
();
mallCustomerService
.
updatePassword
(
customerId
,
newPassword
);
return
new
Result
(
true
,
"密码修改成功"
);
}
}
return
new
Result
(
false
,
"密码修改失败!
"
);
return
new
Result
(
false
,
"密码修改失败
"
);
}
}
}
}
\ No newline at end of file
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/mapper/MallCustomerDao.java
View file @
d336d472
...
@@ -2,14 +2,10 @@ package com.jz.dm.mall.moduls.mapper;
...
@@ -2,14 +2,10 @@ 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
;
<<<<<<<
HEAD
import
org.apache.ibatis.annotations.*
;
import
org.apache.ibatis.annotations.*
;
=======
import
org.apache.ibatis.annotations.Insert
;
import
org.apache.ibatis.annotations.Insert
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.ResultType
;
import
org.apache.ibatis.annotations.Select
;
>>>>>>>
4
f2273addb37e5eb2f1b255fb4f521ccb462856f
import
java.util.Map
;
import
java.util.Map
;
...
@@ -59,6 +55,7 @@ public interface MallCustomerDao extends BaseMapper<MallCustomer> {
...
@@ -59,6 +55,7 @@ public interface MallCustomerDao extends BaseMapper<MallCustomer> {
MallCustomer
findById
(
@Param
(
"customerId"
)
Long
customerId
);
MallCustomer
findById
(
@Param
(
"customerId"
)
Long
customerId
);
@Update
(
" update t_mall_customer set password = #{password} where customer_account = #{customer_account}"
)
void
updatePassword
(
Map
map
);
void
updatePassword
(
@Param
(
"customer_account"
)
String
username
,
@Param
(
"password"
)
String
password
);
MallCustomer
selectByCustomerId
(
Long
customerId
);
}
}
\ No newline at end of file
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/service/MallCustomerService.java
View file @
d336d472
...
@@ -43,8 +43,15 @@ public interface MallCustomerService {
...
@@ -43,8 +43,15 @@ public interface MallCustomerService {
/**
/**
* 修改密码
* 修改密码
* @param
username
* @param
customerId
* @param password
* @param password
*/
*/
void
updatePassword
(
@Param
(
"customer_account"
)
String
username
,
@Param
(
"password"
)
String
password
);
void
updatePassword
(
Long
customerId
,
String
password
);
/**
* 通过id查找用户信息
* @param customerId
* @return
*/
MallCustomer
selectByUser
(
Long
customerId
);
}
}
\ No newline at end of file
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/service/impl/MallCustomerServiceImpl.java
View file @
d336d472
...
@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
...
@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -133,15 +134,30 @@ public class MallCustomerServiceImpl implements MallCustomerService {
...
@@ -133,15 +134,30 @@ public class MallCustomerServiceImpl implements MallCustomerService {
/**
/**
* 修改密码
* 修改密码
*
*
* @param
username
* @param
customerId
* @param password
* @param password
*/
*/
@Override
@Override
public
void
updatePassword
(
String
username
,
String
password
)
{
public
void
updatePassword
(
Long
customerId
,
String
password
)
{
MallCustomer
mallCustomer
=
tMallCustomerDao
.
selectBy
Phone
(
username
);
MallCustomer
mallCustomer
=
tMallCustomerDao
.
selectBy
CustomerId
(
customerId
);
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
!=
null
)
{
tMallCustomerDao
.
updatePassword
(
username
,
password
);
Map
map
=
new
HashMap
();
map
.
put
(
"password"
,
password
);
map
.
put
(
"customerId"
,
customerId
);
tMallCustomerDao
.
updatePassword
(
map
);
}
}
}
/**
* 通过id查找用户信息
*
* @param customerId
* @return
*/
@Override
public
MallCustomer
selectByUser
(
Long
customerId
)
{
MallCustomer
mallCustomer
=
tMallCustomerDao
.
selectByCustomerId
(
customerId
);
return
mallCustomer
;
}
}
...
...
jz-dm-mall/src/main/resources/application-test.yml
View file @
d336d472
...
@@ -66,4 +66,4 @@ mybatis:
...
@@ -66,4 +66,4 @@ mybatis:
logging
:
logging
:
level
:
level
:
com.jz.
manage
:
debug
com.jz.
dm.mall
:
debug
jz-dm-mall/src/main/resources/mapperconf/MallCustomerDao.xml
View file @
d336d472
...
@@ -194,4 +194,15 @@
...
@@ -194,4 +194,15 @@
WHERE customer_id =#{customerId}
WHERE customer_id =#{customerId}
AND del_flag ='N'"
AND del_flag ='N'"
</select>
</select>
<select
id=
"selectByCustomerId"
resultMap=
"TMallCustomerMap"
>
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_id = #{customerId};
</select>
<update
id=
"updatePassword"
parameterType=
"map"
>
update t_mall_customer set password =#{password} where customer_id = #{customerId};
</update>
</mapper>
</mapper>
\ No newline at end of file
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