Commit 39dab40a authored by ysongq's avatar ysongq

Merge branch 'dm_dev' of http://gitlab.ioubuy.cn/yaobenzhang/dm_project into dm_dev

parents dc4f8a71 8b903186
package com.jz.common.base;
import com.jz.common.bean.MallCustomerApiDto;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
/**
......@@ -9,20 +11,22 @@ import javax.servlet.http.HttpServletRequest;
* @Date: 2020/12/3
* @Version:
*/
public class CurrentUser {
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 Long getDepartmentId(HttpServletRequest request) {
public static String 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;
}
}
......@@ -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;
}
}
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;
}
}
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;
}
}
package com.jz.dm.mall.moduls.controller.customer;
import com.jz.common.base.CurrentUser;
import com.jz.common.bean.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
......
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;
}
}
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);
/**
* 根据手机号查询是否已注册
......
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);
/**
* 注册账号
......
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;
}
......
......@@ -172,11 +172,19 @@
where customer_account = #{username};
</select>
<select id="selectByPhone" 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_phone = #{username};
<select id="selectByPhone" resultType="com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto">
select
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">
......
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