From a5b282e1c85ea498377215e43ff475054bf2e4e2 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Mon, 18 May 2020 20:34:20 +0800
Subject: [PATCH] finish login interface and modify some issue
---
src/main/java/com/xcong/excoin/utils/SSLClient.java | 49 +++
src/main/java/com/xcong/excoin/common/system/controller/CommonController.java | 70 +++++
src/main/java/com/xcong/excoin/common/system/bean/LoginUserBean.java | 2
pom.xml | 9
src/main/java/com/xcong/excoin/modules/member/entity/MemberAuthenticationEntity.java | 56 ++++
src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java | 88 ++++++
src/main/java/com/xcong/excoin/common/contants/AppContants.java | 10
src/main/java/com/xcong/excoin/configurations/properties/ApplicationProperties.java | 2
src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java | 13 +
src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletCoinEntity.java | 61 ++++
src/main/java/com/xcong/excoin/common/system/base/BaseEntity.java | 2
src/main/java/com/xcong/excoin/modules/member/controller/MemberController.java | 15 +
src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletAgentEntity.java | 53 ++++
src/main/java/com/xcong/excoin/configurations/GlobalExceptionHandler.java | 17
src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletContractEntity.java | 33 ++
src/main/java/com/xcong/excoin/common/system/service/UserDetailsServiceImpl.java | 24 +
src/main/java/com/xcong/excoin/common/exception/GlobalException.java | 17 +
src/main/resources/mapper/member/MemberDao.xml | 8
src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java | 8
src/main/java/com/xcong/excoin/modules/test/entity/TestUserEntity.java | 4
src/main/java/com/xcong/excoin/utils/SmsUtils.java | 96 +++++++
src/main/java/com/xcong/excoin/common/system/controller/LoginController.java | 33 ++
src/main/resources/application.yml | 3
src/main/java/com/xcong/excoin/common/system/dto/RegisterDto.java | 38 ++
src/main/java/com/xcong/excoin/modules/member/dao/MemberDao.java | 13 +
src/main/java/com/xcong/excoin/modules/member/service/MemberService.java | 11
26 files changed, 714 insertions(+), 21 deletions(-)
diff --git a/pom.xml b/pom.xml
index 4431a55..dbdfbfe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -165,6 +165,15 @@
<version>${fastjson.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <version>1.6.1</version>
+ </dependency>
</dependencies>
diff --git a/src/main/java/com/xcong/excoin/common/contants/AppContants.java b/src/main/java/com/xcong/excoin/common/contants/AppContants.java
index 7a27f94..08660f1 100644
--- a/src/main/java/com/xcong/excoin/common/contants/AppContants.java
+++ b/src/main/java/com/xcong/excoin/common/contants/AppContants.java
@@ -27,4 +27,14 @@
*/
public static final String TOKEN_START_WITH = "Bearer ";
+ /**
+ * 账号类型-手机号
+ */
+ public static final String ACCOUNT_TYPE_MOBILE = "1";
+
+ /**
+ * 账号类型-邮箱
+ */
+ public static final String ACCOUNT_TYPE_EMAIL = "2";
+
}
diff --git a/src/main/java/com/xcong/excoin/common/exception/GlobalException.java b/src/main/java/com/xcong/excoin/common/exception/GlobalException.java
new file mode 100644
index 0000000..938cd36
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/common/exception/GlobalException.java
@@ -0,0 +1,17 @@
+package com.xcong.excoin.common.exception;
+
+import lombok.Getter;
+
+/**
+ * 统一异常处理
+ *
+ * @author wzy
+ * @date 2020-05-18
+ **/
+@Getter
+public class GlobalException extends RuntimeException {
+
+ public GlobalException(String msg) {
+ super(msg);
+ }
+}
diff --git a/src/main/java/com/xcong/excoin/common/system/base/BaseEntity.java b/src/main/java/com/xcong/excoin/common/system/base/BaseEntity.java
index f9eecfa..79c0ff1 100644
--- a/src/main/java/com/xcong/excoin/common/system/base/BaseEntity.java
+++ b/src/main/java/com/xcong/excoin/common/system/base/BaseEntity.java
@@ -28,4 +28,6 @@
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
+
+ private Integer version;
}
diff --git a/src/main/java/com/xcong/excoin/common/system/bean/LoginUserBean.java b/src/main/java/com/xcong/excoin/common/system/bean/LoginUserBean.java
index a2e10cf..0924317 100644
--- a/src/main/java/com/xcong/excoin/common/system/bean/LoginUserBean.java
+++ b/src/main/java/com/xcong/excoin/common/system/bean/LoginUserBean.java
@@ -32,7 +32,7 @@
@JsonIgnore
@Override
public String getUsername() {
- return memberEntity.getUsername();
+ return "";
}
@JsonIgnore
diff --git a/src/main/java/com/xcong/excoin/common/system/controller/CommonController.java b/src/main/java/com/xcong/excoin/common/system/controller/CommonController.java
new file mode 100644
index 0000000..db35bd2
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/common/system/controller/CommonController.java
@@ -0,0 +1,70 @@
+package com.xcong.excoin.common.system.controller;
+
+import com.xcong.excoin.common.contants.AppContants;
+import com.xcong.excoin.common.response.Result;
+import com.xcong.excoin.utils.RedisUtils;
+import com.xcong.excoin.utils.SmsUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 公共请求类
+ *
+ * @author wzy
+ * @date 2020-05-18
+ **/
+@Slf4j
+@Api(value = "公共请求类", tags = "公共请求类")
+@RestController
+@RequestMapping(value = "/common")
+public class CommonController {
+
+ private static final String SUCCESS = "Success";
+
+ @Resource
+ private RedisUtils redisUtils;
+
+ @ApiOperation(value = "获取验证码接口", notes = "获取验证码通用接口")
+ @GetMapping(value = "/verifyCode")
+ public Result verifyCode(String account, String type) {
+ log.info("#账号:{}, 类型:{}#", account, type);
+
+ int code = (int) ((Math.random() * 9 + 1) * 100000);
+ if (AppContants.ACCOUNT_TYPE_MOBILE.equals(type)) {
+ Map<String, Object> result = SmsUtils.sendVerifyCode(account, code);
+
+ if (SUCCESS.equals(result.get("resultstatus"))) {
+ Map<String, Object> map = new HashMap<>();
+ boolean flag = redisUtils.set("SMS_" + account, code, 120);
+ map.put("code", flag);
+ return Result.ok("success", map);
+ }
+ } else if (AppContants.ACCOUNT_TYPE_EMAIL.equals(type)) {
+ return Result.ok("success");
+ } else {
+ log.info("未定义账号类型");
+ return Result.fail("fail");
+ }
+ return Result.fail("fail");
+ }
+
+ @ApiOperation(value = "验证验证码是否正确", notes = "验证验证码是否正确")
+ @GetMapping(value = "/checkVerify")
+ public Result checkVerify() {
+ return null;
+ }
+
+ @ApiOperation(value = "文件上次接口", notes = "文件上传")
+ @GetMapping(value = "/uploadFile")
+ public Result uploadFile() {
+ return null;
+ }
+}
diff --git a/src/main/java/com/xcong/excoin/common/system/controller/LoginController.java b/src/main/java/com/xcong/excoin/common/system/controller/LoginController.java
index e10dc75..8e2d3d2 100644
--- a/src/main/java/com/xcong/excoin/common/system/controller/LoginController.java
+++ b/src/main/java/com/xcong/excoin/common/system/controller/LoginController.java
@@ -1,17 +1,23 @@
package com.xcong.excoin.common.system.controller;
import cn.hutool.core.util.IdUtil;
+import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;
+import cn.hutool.crypto.asymmetric.Sign;
+import cn.hutool.crypto.asymmetric.SignAlgorithm;
import com.alibaba.fastjson.JSONObject;
import com.xcong.excoin.common.contants.AppContants;
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.common.system.bean.LoginUserBean;
import com.xcong.excoin.common.system.dto.LoginDto;
+import com.xcong.excoin.common.system.dto.RegisterDto;
import com.xcong.excoin.configurations.properties.ApplicationProperties;
import com.xcong.excoin.configurations.properties.SecurityProperties;
+import com.xcong.excoin.modules.member.service.MemberService;
import com.xcong.excoin.utils.RedisUtils;
import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@@ -31,10 +37,13 @@
* @Version V1.0
**/
@Slf4j
-@Api(value = "登陆类", tags = "登陆类")
+@Api(value = "登陆注册类", tags = "登陆注册类")
@RestController
@RequestMapping(value = "/")
public class LoginController {
+
+ @Resource
+ private MemberService memberservice;
@Resource
private ApplicationProperties applicationProperties;
@@ -48,14 +57,25 @@
@Resource
private RedisUtils redisUtils;
+ @ApiOperation(value = "登陆接口", notes = "登陆接口")
@PostMapping("/login")
public Result login(@RequestBody @Validated LoginDto loginDto) {
+ // 使用md5加密前端传来的密码
+ Sign sign = SecureUtil.sign(SignAlgorithm.MD5withRSA);
+ byte[] pwdByte = sign.sign(loginDto.getPassword().getBytes());
+
+ // 将账号密码交给spring security验证,并调用userServiceDetails
UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(loginDto.getUsername(), loginDto.getPassword());
Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authToken);
- String token = IdUtil.simpleUUID();
+
+ // 获取当前验证过后的用户
LoginUserBean loginUserBean = (LoginUserBean) authentication.getPrincipal();
- redisUtils.set(AppContants.APP_LOGIN_PREFIX + token, JSONObject.toJSONString(loginUserBean), 300000);
+
+ // 生成UUID作为token
+ String token = IdUtil.simpleUUID();
+ redisUtils.set(AppContants.APP_LOGIN_PREFIX + token, JSONObject.toJSONString(loginUserBean), applicationProperties.getRedisExpire());
Map<String, Object> authInfo = new HashMap<>();
+ // 开启debug模式,则将加密后的token返回
if (applicationProperties.isDebug()) {
authInfo.put("token", token);
authInfo.put("rsaToken", generateAsaToken(token));
@@ -71,4 +91,11 @@
RSA rsa = new RSA(null, securityProperties.getPublicKey());
return rsa.encryptBase64(token + "_" +System.currentTimeMillis(), KeyType.PublicKey);
}
+
+ @ApiOperation(value = "app注册接口", notes = "app注册接口,验证码必须输入可默认为123456")
+ @PostMapping(value = "/register")
+ public Result register(@RequestBody @Validated RegisterDto registerDto) {
+ return null;
+ }
+
}
diff --git a/src/main/java/com/xcong/excoin/common/system/dto/RegisterDto.java b/src/main/java/com/xcong/excoin/common/system/dto/RegisterDto.java
new file mode 100644
index 0000000..230d52e
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/common/system/dto/RegisterDto.java
@@ -0,0 +1,38 @@
+package com.xcong.excoin.common.system.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * 注册用户接收类
+ *
+ * @author wzy
+ * @date 2020-05-18
+ **/
+@Data
+@ApiModel(value = "注册接口参数类", description = "注册接口参数类")
+public class RegisterDto {
+
+ @ApiModelProperty(value = "账号", example = "13412341234")
+ @NotBlank(message = "账号不能为空")
+ private String account;
+
+ @ApiModelProperty(value = "密码", example = "123456")
+ @NotBlank(message = "密码不能为空")
+ private String password;
+
+ @ApiModelProperty(value = "账号类型", notes = "1-手机 2-邮箱", example = "1")
+ @NotBlank(message = "账号类型不能为空")
+ private String type;
+
+ @ApiModelProperty(value = "验证码", example = "123456")
+ @NotBlank(message = "验证码不能为空")
+ private String code;
+
+ @ApiModelProperty(value = "推荐人id", example = "rxadr3")
+ private String refererId;
+}
diff --git a/src/main/java/com/xcong/excoin/common/system/service/UserDetailsServiceImpl.java b/src/main/java/com/xcong/excoin/common/system/service/UserDetailsServiceImpl.java
index c33fc4b..508dff9 100644
--- a/src/main/java/com/xcong/excoin/common/system/service/UserDetailsServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/common/system/service/UserDetailsServiceImpl.java
@@ -1,6 +1,11 @@
package com.xcong.excoin.common.system.service;
+import cn.hutool.crypto.SecureUtil;
+import cn.hutool.crypto.asymmetric.Sign;
+import cn.hutool.crypto.asymmetric.SignAlgorithm;
+import com.xcong.excoin.common.exception.GlobalException;
import com.xcong.excoin.common.system.bean.LoginUserBean;
+import com.xcong.excoin.modules.member.dao.MemberDao;
import com.xcong.excoin.modules.member.entity.MemberEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.GrantedAuthority;
@@ -9,6 +14,7 @@
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@@ -22,16 +28,26 @@
@Service("userDetailsService")
public class UserDetailsServiceImpl implements UserDetailsService {
+ @Resource
+ private MemberDao memberDao;
+
@Override
public LoginUserBean loadUserByUsername(String username) throws UsernameNotFoundException {
+ log.info("#登陆账号:{}#", username);
List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
// GrantedAuthority grantedAuthority = new SimpleGrantedAuthority("ROLE_ADMIN");
// grantedAuthorities.add(grantedAuthority);
- MemberEntity memberEntity = new MemberEntity();
- memberEntity.setId(1L);
- memberEntity.setUsername("11111");
- memberEntity.setPassword(new BCryptPasswordEncoder().encode("123456"));
+ MemberEntity memberEntity = memberDao.selectMemberInfoByAccount(username);
+ if (memberEntity != null) {
+ memberEntity.setPassword(new BCryptPasswordEncoder().encode(memberEntity.getPassword()));
+ } else {
+ throw new UsernameNotFoundException("");
+ }
+
+ if (MemberEntity.ACCOUNT_STATUS_DISABLED == memberEntity.getAccountStatus()) {
+ throw new GlobalException("账号已被禁用");
+ }
return new LoginUserBean(memberEntity, null, null);
}
diff --git a/src/main/java/com/xcong/excoin/configurations/GlobalExceptionHandler.java b/src/main/java/com/xcong/excoin/configurations/GlobalExceptionHandler.java
index 97ed2d9..99efc56 100644
--- a/src/main/java/com/xcong/excoin/configurations/GlobalExceptionHandler.java
+++ b/src/main/java/com/xcong/excoin/configurations/GlobalExceptionHandler.java
@@ -1,5 +1,6 @@
package com.xcong.excoin.configurations;
+import com.xcong.excoin.common.exception.GlobalException;
import com.xcong.excoin.common.response.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DuplicateKeyException;
@@ -49,11 +50,6 @@
return null;
}
- @ExceptionHandler(value = {Exception.class})
- public Result handleException(Exception e) {
- log.error(e.getMessage(), e);
- return Result.fail("系统异常");
- }
/**
* spring security 账户密码验证异常
@@ -67,4 +63,15 @@
return Result.fail("用户名或密码错误");
}
+ @ExceptionHandler(value = {GlobalException.class})
+ public Result handleException(GlobalException e) {
+ return Result.fail(e.getMessage());
+ }
+
+ @ExceptionHandler(value = {Exception.class})
+ public Result handleException(Exception e) {
+ log.error(e.getMessage(), e);
+ return Result.fail("系统异常");
+ }
+
}
diff --git a/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java b/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java
index b60a5a3..f7b0c87 100644
--- a/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java
+++ b/src/main/java/com/xcong/excoin/configurations/interceptor/MybatisInterceptor.java
@@ -79,8 +79,9 @@
if (o instanceof BaseEntity) {
BaseEntity baseEntity = (BaseEntity) o;
if (member != null) {
- baseEntity.setCreateBy(member.getUsername());
- baseEntity.setUpdateBy(member.getUsername());
+ String by = member.getPhone() != null ? member.getPhone() : member.getEmail();
+ baseEntity.setCreateBy(by);
+ baseEntity.setUpdateBy(by);
} else {
baseEntity.setCreateBy(AppContants.SYSTEM_USER);
baseEntity.setUpdateBy(AppContants.SYSTEM_USER);
@@ -95,7 +96,8 @@
if (o instanceof BaseEntity) {
BaseEntity baseEntity = (BaseEntity) o;
if (member != null) {
- baseEntity.setUpdateBy(member.getUsername());
+ String by = member.getPhone() != null ? member.getPhone() : member.getEmail();
+ baseEntity.setUpdateBy(by);
} else {
baseEntity.setUpdateBy(AppContants.SYSTEM_USER);
}
diff --git a/src/main/java/com/xcong/excoin/configurations/properties/ApplicationProperties.java b/src/main/java/com/xcong/excoin/configurations/properties/ApplicationProperties.java
index cdacf9b..9e877ec 100644
--- a/src/main/java/com/xcong/excoin/configurations/properties/ApplicationProperties.java
+++ b/src/main/java/com/xcong/excoin/configurations/properties/ApplicationProperties.java
@@ -15,4 +15,6 @@
@ConfigurationProperties(prefix = "app")
public class ApplicationProperties {
private boolean debug;
+
+ private Long redisExpire;
}
diff --git a/src/main/java/com/xcong/excoin/modules/member/controller/MemberController.java b/src/main/java/com/xcong/excoin/modules/member/controller/MemberController.java
new file mode 100644
index 0000000..a5c5fdf
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/member/controller/MemberController.java
@@ -0,0 +1,15 @@
+package com.xcong.excoin.modules.member.controller;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 用户类
+ *
+ * @author wzy
+ * @date 2020-05-18
+ **/
+@RestController
+@RequestMapping(value = "/api/member")
+public class MemberController {
+}
diff --git a/src/main/java/com/xcong/excoin/modules/member/dao/MemberDao.java b/src/main/java/com/xcong/excoin/modules/member/dao/MemberDao.java
new file mode 100644
index 0000000..31545ba
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/member/dao/MemberDao.java
@@ -0,0 +1,13 @@
+package com.xcong.excoin.modules.member.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xcong.excoin.modules.member.entity.MemberEntity;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * @author wzy
+ */
+public interface MemberDao extends BaseMapper<MemberEntity> {
+
+ public MemberEntity selectMemberInfoByAccount(@Param("account") String account);
+}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberAuthenticationEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberAuthenticationEntity.java
new file mode 100644
index 0000000..03af297
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/member/entity/MemberAuthenticationEntity.java
@@ -0,0 +1,56 @@
+package com.xcong.excoin.modules.member.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.xcong.excoin.common.system.base.BaseEntity;
+import lombok.Data;
+
+/**
+ * 用户实名认证信息实体
+ *
+ * @author wzy
+ * @date 2020-05-18
+ **/
+@Data
+@TableName("member_authentication")
+public class MemberAuthenticationEntity extends BaseEntity {
+
+ /**
+ * 用户ID
+ */
+ private Long memberId;
+
+ /**
+ * 真实姓名
+ */
+ private String realName;
+
+ /**
+ * 姓
+ */
+ private String firstName;
+
+ /**
+ * 名
+ */
+ private String secondName;
+
+ /**
+ * 国家
+ */
+ private String nation;
+
+ /**
+ * 身份证正面
+ */
+ private String idcardImageFront;
+
+ /**
+ * 身份证背面
+ */
+ private String idcardImageBack;
+
+ /**
+ * 手持身份证
+ */
+ private String idcardImageInHand;
+}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java
index 11eff4b..66c6c9a 100644
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java
+++ b/src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java
@@ -1,5 +1,6 @@
package com.xcong.excoin.modules.member.entity;
+import com.baomidou.mybatisplus.annotation.TableName;
import com.xcong.excoin.common.system.base.BaseEntity;
import lombok.Data;
@@ -12,12 +13,91 @@
* @date 2020-05-12
**/
@Data
-public class MemberEntity extends BaseEntity implements Serializable {
- private static final long serialVersionUID = -1L;
+@TableName("member")
+public class MemberEntity extends BaseEntity {
- private Long id;
+ /**
+ * 账号状态 - 禁用
+ */
+ public static final Integer ACCOUNT_STATUS_DISABLED = 0;
- private String username;
+ /**
+ * 账号状态 - 启用
+ */
+ public static final Integer ACCOUNT_STATUS_ENABLE = 1;
+ /**
+ * 手机号(包含国际手机号)
+ */
+ private String phone;
+
+ /**
+ * 邮箱
+ */
+ private String email;
+
+ /**
+ * 登陆密码
+ */
private String password;
+
+ /**
+ * 交易密码
+ */
+ private String tradePassword;
+
+ /**
+ * 交易密码时效性设置
+ */
+ private Integer tradeAgingSetting;
+
+ /**
+ * 邀请码
+ */
+ private String inviteId;
+
+ /**
+ * 账号状态 0-禁用 1-启用
+ */
+ private int accountStatus;
+
+ /**
+ * 上级推荐人id
+ */
+ private String refererId;
+
+ /**
+ * 上级推荐人ID链
+ */
+ private String refererIds;
+
+ /**
+ * 账号类型 1-正常账号 2-测试账号
+ */
+ private Integer accountType;
+
+ /**
+ * 代理级别
+ */
+ private Integer agentLevel;
+
+ /**
+ * 实名认证状态 0-审核未通过 1-审核通过 2-等待审核
+ */
+ private Integer certifyStatus;
+
+ /**
+ * 身份证号
+ */
+ private String idcardNo;
+
+ /**
+ * 是否设置盈亏难度系数 0-否1-是
+ */
+ private Integer isProfit;
+
+ /**
+ * 是否设置预估强平价系数 0-否1-是
+ */
+ private Integer isForce;
}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletAgentEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletAgentEntity.java
new file mode 100644
index 0000000..5c87492
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletAgentEntity.java
@@ -0,0 +1,53 @@
+package com.xcong.excoin.modules.member.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.xcong.excoin.common.system.base.BaseEntity;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 代理用户钱包
+ *
+ * @author wzy
+ * @date 2020-05-18
+ **/
+@Data
+@TableName("member_wallet_agent")
+public class MemberWalletAgentEntity extends BaseEntity {
+
+ /**
+ * 用户Id
+ */
+ private Long memberId;
+
+ /**
+ * 可用余额
+ */
+ private BigDecimal availableBalance;
+
+ /**
+ * 总金额
+ */
+ private BigDecimal totalBalance;
+
+ /**
+ * 冻结金额
+ */
+ private BigDecimal frozenBalance;
+
+ /**
+ * 借入资产金额
+ */
+ private BigDecimal borrowedFund;
+
+ /**
+ * 钱包标识
+ */
+ private String walletCode;
+
+ /**
+ * 钱包地址
+ */
+ private String walletAddress;
+}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletCoinEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletCoinEntity.java
new file mode 100644
index 0000000..cab2390
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletCoinEntity.java
@@ -0,0 +1,61 @@
+package com.xcong.excoin.modules.member.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.xcong.excoin.common.system.base.BaseEntity;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wzy
+ * @date 2020-05-18
+ **/
+@Data
+@TableName("member_wallet_coin")
+public class MemberWalletCoinEntity extends BaseEntity {
+
+ /**
+ * 用户Id
+ */
+ private Long memberId;
+
+ /**
+ * 可用余额
+ */
+ private BigDecimal availableBalance;
+
+ /**
+ * 总金额
+ */
+ private BigDecimal totalBalance;
+
+ /**
+ * 冻结金额
+ */
+ private BigDecimal frozenBalance;
+
+ /**
+ * 借入资产金额
+ */
+ private BigDecimal borrowedFund;
+
+ /**
+ * 钱包标识
+ */
+ private String walletCode;
+
+ /**
+ * 钱包地址
+ */
+ private String walletAddress;
+
+ /**
+ * 上次余额
+ */
+ private BigDecimal earlyBalance;
+
+ /**
+ * 区块编号
+ */
+ private int blockNumber;
+}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletContractEntity.java b/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletContractEntity.java
new file mode 100644
index 0000000..533425d
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/member/entity/MemberWalletContractEntity.java
@@ -0,0 +1,33 @@
+package com.xcong.excoin.modules.member.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.xcong.excoin.common.system.base.BaseEntity;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wzy
+ * @date 2020-05-18
+ **/
+@Data
+@TableName("member_wallet_contract")
+public class MemberWalletContractEntity extends BaseEntity {
+ private Long memberId;
+
+ private BigDecimal availableBalance;
+
+ private BigDecimal totalBalance;
+
+ private BigDecimal frozenBalance;
+
+ private BigDecimal borrowedFund;
+
+ private BigDecimal earlyBalance;
+
+ private int blockNumber;
+
+ private String walletCode;
+
+ private String walletAddress;
+}
diff --git a/src/main/java/com/xcong/excoin/modules/member/service/MemberService.java b/src/main/java/com/xcong/excoin/modules/member/service/MemberService.java
new file mode 100644
index 0000000..612ebee
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/member/service/MemberService.java
@@ -0,0 +1,11 @@
+package com.xcong.excoin.modules.member.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.xcong.excoin.modules.member.entity.MemberEntity;
+import com.xcong.excoin.modules.test.entity.TestUserEntity;
+
+/**
+ * @author wzy
+ */
+public interface MemberService extends IService<MemberEntity> {
+}
diff --git a/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java b/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java
new file mode 100644
index 0000000..5d93e06
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java
@@ -0,0 +1,13 @@
+package com.xcong.excoin.modules.member.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xcong.excoin.modules.member.dao.MemberDao;
+import com.xcong.excoin.modules.member.entity.MemberEntity;
+import com.xcong.excoin.modules.member.service.MemberService;
+
+/**
+ * @author wzy
+ * @date 2020-05-18
+ **/
+public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> implements MemberService {
+}
diff --git a/src/main/java/com/xcong/excoin/modules/test/entity/TestUserEntity.java b/src/main/java/com/xcong/excoin/modules/test/entity/TestUserEntity.java
index d4373d5..13a3879 100644
--- a/src/main/java/com/xcong/excoin/modules/test/entity/TestUserEntity.java
+++ b/src/main/java/com/xcong/excoin/modules/test/entity/TestUserEntity.java
@@ -1,5 +1,6 @@
package com.xcong.excoin.modules.test.entity;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xcong.excoin.common.system.base.BaseEntity;
import lombok.Data;
@@ -19,4 +20,7 @@
private String account;
private String password;
+
+ @TableField(exist = false)
+ private String aaaaa;
}
diff --git a/src/main/java/com/xcong/excoin/utils/SSLClient.java b/src/main/java/com/xcong/excoin/utils/SSLClient.java
new file mode 100644
index 0000000..0b26d23
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/utils/SSLClient.java
@@ -0,0 +1,49 @@
+package com.xcong.excoin.utils;
+
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+
+@SuppressWarnings("deprecation")
+class SSLClient extends DefaultHttpClient {
+ public SSLClient() throws Exception {
+ super();
+ SSLContext ctx = SSLContext.getInstance("TLS");
+ X509TrustManager tm = new X509TrustManager() {
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ };
+ ctx.init(null, new TrustManager[] { tm }, null);
+
+ SSLSocketFactory ssf = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+ ClientConnectionManager ccm = this.getConnectionManager();
+ SchemeRegistry sr = ccm.getSchemeRegistry();
+ sr.register(new Scheme("https", 443, ssf));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/xcong/excoin/utils/SmsUtils.java b/src/main/java/com/xcong/excoin/utils/SmsUtils.java
new file mode 100644
index 0000000..4adc0ee
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/utils/SmsUtils.java
@@ -0,0 +1,96 @@
+package com.xcong.excoin.utils;
+
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.util.EntityUtils;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 短信发送工具
+ *
+ * @author wzy
+ * @date 2020-05-18
+ **/
+public class SmsUtils {
+
+
+ private static HttpClient httpclient;
+
+ @SuppressWarnings("deprecation")
+ public static Map<String, Object> hxSmsSend(String mobile, String sendContent) {
+ Map<String, Object> map = new HashMap<String, Object>();
+ try {
+ httpclient = new SSLClient();
+ //TFT001
+ String url = "https://dx.ipyy.net/sms.aspx";
+ //excoin DX001 //ctcoin:OT00028 //改为实际账号名
+ String accountName = "DX001";
+ //excoin 1qaz2wsx //ctcoin: atvckt //改为实际发送密码
+ String password = "1qaz2wsx";
+ String text = sendContent;
+ HttpPost post = new HttpPost(url);
+ post.setHeader("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
+ List<NameValuePair> nvps = new ArrayList<NameValuePair>();
+ nvps.add(new BasicNameValuePair("action", "send"));
+ nvps.add(new BasicNameValuePair("userid", ""));
+ nvps.add(new BasicNameValuePair("account", accountName));
+ nvps.add(new BasicNameValuePair("password", password));
+ //多个手机号用逗号分隔
+ nvps.add(new BasicNameValuePair("mobile", mobile));
+ nvps.add(new BasicNameValuePair("content", text));
+ nvps.add(new BasicNameValuePair("sendTime", ""));
+ nvps.add(new BasicNameValuePair("extno", ""));
+
+ post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
+
+ HttpResponse response = httpclient.execute(post);
+ HttpEntity entity = response.getEntity();
+ // 将字符转化为XML
+ String returnString = EntityUtils.toString(entity, "UTF-8");
+ Document doc = DocumentHelper.parseText(returnString);
+ // 获取根节点
+ Element rootElt = doc.getRootElement();
+ // 获取根节点下的子节点的值
+ String returnstatus = rootElt.elementText("returnstatus").trim();
+ String message = rootElt.elementText("message").trim();
+ String remainpoint = rootElt.elementText("remainpoint").trim();
+ String taskID = rootElt.elementText("taskID").trim();
+ String successCounts = rootElt.elementText("successCounts").trim();
+
+ map.put("returnstatus", returnstatus);
+ map.put("message", message);
+ map.put("remainpoint", remainpoint);
+ map.put("taskID", taskID);
+ map.put("successCounts", successCounts);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return map;
+ }
+
+ /**
+ * 短信验证码
+ *
+ * @param phone 手机号
+ * @param code 验证码
+ * @return
+ */
+ public static Map<String, Object> sendVerifyCode(String phone, int code) {
+ String smsContent = "【Excoin】您的验证码为:"+code+",该验证码有效期为2分钟,请勿泄露于他人。";
+ return hxSmsSend(phone, smsContent);
+ }
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index e418a9f..7e1d602 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -70,11 +70,12 @@
## 连接超时时间(毫秒)
timeout: 30000
mybatis-plus:
- mapper-locations: classpath:mapper/*.xml
+ mapper-locations: classpath:mapper/**/*.xml
app:
debug: true
+ redis_expire: 3000
rsa:
public_key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCCf8UFZK54AiK4PRu7tNd+Z8qZ77o/QXCnk25DRmygVpOEu5mGNSAvfnWmKp2pEV2RljeXq3Rid/+LQkonaebMJeXKSF0yxL/VgyeT8JaQ5gNbOrdfdlc+mFkXJyzyJt8YkvApEdPRNSU2ENBn7mgRfD0BYPM4vZ6/rv+de38FJwIDAQAB
diff --git a/src/main/resources/mapper/member/MemberDao.xml b/src/main/resources/mapper/member/MemberDao.xml
new file mode 100644
index 0000000..0a0c8b1
--- /dev/null
+++ b/src/main/resources/mapper/member/MemberDao.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xcong.excoin.modules.member.dao.MemberDao">
+
+ <select id="selectMemberInfoByAccount" resultType="com.xcong.excoin.modules.member.entity.MemberEntity">
+ select * from member where phone=#{account} or email=#{account}
+ </select>
+</mapper>
\ No newline at end of file
--
Gitblit v1.9.1