Commit f4b145f8 authored by ysongq's avatar ysongq

commit

parent 8633e41d
...@@ -4,6 +4,7 @@ package com.jz.dm.mall.moduls.controller.customer; ...@@ -4,6 +4,7 @@ package com.jz.dm.mall.moduls.controller.customer;
import com.jz.common.bean.MallCustomerApiDto; import com.jz.common.bean.MallCustomerApiDto;
import com.jz.common.constant.RedisMessageConstant; import com.jz.common.constant.RedisMessageConstant;
import com.jz.common.utils.Result; import com.jz.common.utils.Result;
import com.jz.common.utils.SessionUtils;
import com.jz.common.utils.StatusCode; import com.jz.common.utils.StatusCode;
import com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto; import com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto;
import com.jz.dm.mall.moduls.entity.MallCustomer; import com.jz.dm.mall.moduls.entity.MallCustomer;
...@@ -47,7 +48,8 @@ public class LoginController { ...@@ -47,7 +48,8 @@ public class LoginController {
*/ */
@PostMapping(value = "/login") @PostMapping(value = "/login")
@ApiOperation(value = "登录功能", notes = "登录功能") @ApiOperation(value = "登录功能", notes = "登录功能")
public Result<CustomerDto> login(String username, String password, HttpServletRequest request) throws Exception { public Result<CustomerDto> login(@RequestParam(value = "username") String username,
@RequestParam(value = "password") String password, HttpServletRequest request) throws Exception {
// 手机 // 手机
String ph = "^[1][34578]\\d{9}$"; String ph = "^[1][34578]\\d{9}$";
// 如果是手机验证 // 如果是手机验证
...@@ -78,7 +80,7 @@ public class LoginController { ...@@ -78,7 +80,7 @@ public class LoginController {
* @return * @return
*/ */
@PostMapping(value = "/getCode") @PostMapping(value = "/getCode")
public Result loginCheck(@RequestParam(required = false) Map<String, String> paramMap) { public Result loginCheck(@RequestParam(required = true) 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;
...@@ -105,7 +107,7 @@ public class LoginController { ...@@ -105,7 +107,7 @@ public class LoginController {
*/ */
@GetMapping(value = "/phoneCheck") @GetMapping(value = "/phoneCheck")
@ApiOperation(value = "手机号码校验接口", notes = "手机号码是否已注册") @ApiOperation(value = "手机号码校验接口", notes = "手机号码是否已注册")
public Result phoneCheck(String telephone) { public Result phoneCheck(@RequestParam("telephone") String telephone) {
if (telephone == null) { if (telephone == null) {
return new Result(false, "请重新输入手机号!"); return new Result(false, "请重新输入手机号!");
} }
...@@ -127,7 +129,8 @@ public class LoginController { ...@@ -127,7 +129,8 @@ public class LoginController {
*/ */
@GetMapping(value = "/phoneUserCheck") @GetMapping(value = "/phoneUserCheck")
@ApiOperation(value = "手机号用户名重复校验接口", notes = "手机号用户名是否重复") @ApiOperation(value = "手机号用户名重复校验接口", notes = "手机号用户名是否重复")
public Result phoneCheck(String username, String telephone, HttpServletRequest request) { public Result phoneCheck(@RequestParam(value = "username") String username ,
@RequestParam(value = "password") String telephone, HttpServletRequest request) {
String ph = "^[1][34578]\\d{9}$"; String ph = "^[1][34578]\\d{9}$";
if (telephone.matches(ph)) { if (telephone.matches(ph)) {
MallCustomer mallCustomer = mallCustomerService.selectByPhone(telephone); MallCustomer mallCustomer = mallCustomerService.selectByPhone(telephone);
......
...@@ -3,6 +3,7 @@ package com.jz.dm.mall.moduls.controller.customer; ...@@ -3,6 +3,7 @@ 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.base.CurrentUser;
import com.jz.common.bean.MallCustomerApiDto;
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;
...@@ -13,6 +14,7 @@ import com.jz.common.utils.Result; ...@@ -13,6 +14,7 @@ import com.jz.common.utils.Result;
import com.jz.common.utils.StatusCode; import com.jz.common.utils.StatusCode;
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 io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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;
...@@ -50,7 +52,7 @@ public class MallCustomerController extends BaseController { ...@@ -50,7 +52,7 @@ public class MallCustomerController extends BaseController {
*/ */
@PostMapping("/saveCustomer") @PostMapping("/saveCustomer")
@ApiOperation(value = "注册用户", notes = "添加用户") @ApiOperation(value = "注册用户", notes = "添加用户")
public Result saveCustomer(@RequestParam(required = false) Map<String, String> paramMap, HttpServletRequest request) { public Result saveCustomer(@RequestParam(required = true) Map<String, String> paramMap, HttpServletRequest request) {
if (paramMap != null) { if (paramMap != null) {
String username = paramMap.get("username"); String username = paramMap.get("username");
String telephone = paramMap.get("telephone"); String telephone = paramMap.get("telephone");
...@@ -82,13 +84,13 @@ public class MallCustomerController extends BaseController { ...@@ -82,13 +84,13 @@ public class MallCustomerController extends BaseController {
* @return * @return
*/ */
@GetMapping("/getLoginUserName") @GetMapping("/getLoginUserName")
@ApiOperation(value = "注册用户", notes = "添加用户") @ApiOperation(value = "获取用户信息")
public Result getLoginUserName (HttpServletRequest request) { public Result getLoginUserName (HttpServletRequest request) {
// 从session中获取id // 从session中获取id
try { try {
MallCustomer mallCustomer = (MallCustomer) SessionUtils.getUserCurrent(request,"mallCustomer"); MallCustomerApiDto mallCustomer = (MallCustomerApiDto) SessionUtils.getUserCurrent(request,"mallCustomer");
Long customerId = 1L; // Long customerId = 1L;
// Long customerId = mallCustomer.getCustomerId(); Long customerId = mallCustomer.getCustomerId();
MallCustomer user = mallCustomerService.selectByUser(customerId); MallCustomer user = mallCustomerService.selectByUser(customerId);
return new Result(true, "获取用户信息成功!", StatusCode.OK, user); return new Result(true, "获取用户信息成功!", StatusCode.OK, user);
}catch (Exception e) { }catch (Exception e) {
...@@ -98,7 +100,9 @@ public class MallCustomerController extends BaseController { ...@@ -98,7 +100,9 @@ public class MallCustomerController extends BaseController {
} }
@PostMapping(value = "/updatePassword") @PostMapping(value = "/updatePassword")
public Result updatePassword(String oldPassword, String newPassword,HttpServletRequest request) throws Exception { @ApiModelProperty(value = "密码修改")
public Result updatePassword(@RequestParam(value = "oldPassWard") String oldPassword,
@RequestParam(value = "newPassword")String newPassword,HttpServletRequest request) throws Exception {
// 获取用户信息 // 获取用户信息
MallCustomer mallCustomer = (MallCustomer) getLoginUserName(request).getData(); MallCustomer mallCustomer = (MallCustomer) getLoginUserName(request).getData();
// 如果密码一致 // 如果密码一致
......
...@@ -5,6 +5,7 @@ import com.jz.common.bean.MallCustomerApiDto; ...@@ -5,6 +5,7 @@ import com.jz.common.bean.MallCustomerApiDto;
import com.jz.common.constant.RedisMessageConstant; import com.jz.common.constant.RedisMessageConstant;
import com.jz.common.enums.UserTypeEnum; import com.jz.common.enums.UserTypeEnum;
import com.jz.common.utils.DateUtils; import com.jz.common.utils.DateUtils;
import com.jz.common.utils.SessionUtils;
import com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto; import com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto;
import com.jz.dm.mall.moduls.entity.MallCustomer; import com.jz.dm.mall.moduls.entity.MallCustomer;
import com.jz.dm.mall.moduls.mapper.MallCustomerDao; import com.jz.dm.mall.moduls.mapper.MallCustomerDao;
...@@ -52,6 +53,7 @@ public class MallCustomerServiceImpl implements MallCustomerService { ...@@ -52,6 +53,7 @@ public class MallCustomerServiceImpl implements MallCustomerService {
mallCustomerApiDto.setUserTypeEnum(UserTypeEnum.COMPANY_ROLE); mallCustomerApiDto.setUserTypeEnum(UserTypeEnum.COMPANY_ROLE);
mallCustomerApiDto.setCustomerAccount(mallCustomer.getCustomerAccount()); mallCustomerApiDto.setCustomerAccount(mallCustomer.getCustomerAccount());
mallCustomerApiDto.setCustomerName(mallCustomer.getCustomerName()); mallCustomerApiDto.setCustomerName(mallCustomer.getCustomerName());
mallCustomerApiDto.setAssetsId(mallCustomer.getAssetsId());
// 存入到session // 存入到session
request.getSession().setAttribute("mallCustomer", mallCustomerApiDto); request.getSession().setAttribute("mallCustomer", mallCustomerApiDto);
// 存入到redis // 存入到redis
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment