zero 11 месяцев назад
Родитель
Сommit
457cfe20a5

+ 11 - 0
PCS/pom.xml

@@ -155,6 +155,17 @@
 <!--            <version>4.10.0</version>-->
 <!--        </dependency>-->
         <!--rabbitmq-->
+        <!-- 短信接口 -->
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-core</artifactId>
+            <version>4.5.16</version>
+        </dependency>
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
+            <version>1.1.0</version>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-amqp</artifactId>

+ 59 - 0
PCS/src/main/java/cn/cslg/permission/common/core/business/BaseProperties.java

@@ -0,0 +1,59 @@
+package cn.cslg.permission.common.core.business;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Component
+@ConfigurationProperties(prefix = "base")
+public class BaseProperties {
+
+	public String project;
+	public String distributedCacheTopic;
+	public String distributedCachePrefix;
+	public List<String> noAuthPath = new ArrayList<>();
+	public String sharedDistributedCacheTopic;
+	public String filePath;
+	
+	public String getProject() {
+		return project;
+	}
+	public void setProject(String project) {
+		this.project = project;
+	}
+	public String getDistributedCacheTopic() {
+		return distributedCacheTopic;
+	}
+	public void setDistributedCacheTopic(String distributedCacheTopic) {
+		this.distributedCacheTopic = distributedCacheTopic;
+	}
+	public List<String> getNoAuthPath() {
+		return noAuthPath;
+	}
+	public void setNoAuthPath(List<String> noAuthPath) {
+		this.noAuthPath = noAuthPath;
+	}
+	public String getDistributedCachePrefix() {
+		return distributedCachePrefix;
+	}
+	public void setDistributedCachePrefix(String distributedCachePrefix) {
+		this.distributedCachePrefix = distributedCachePrefix;
+	}
+	public String getSharedDistributedCacheTopic() {
+		return sharedDistributedCacheTopic;
+	}
+
+	public void setSharedDistributedCacheTopic(String sharedDistributedCacheTopic) {
+		this.sharedDistributedCacheTopic = sharedDistributedCacheTopic;
+	}
+
+	public String getFilePath() {
+		return filePath;
+	}
+
+	public void setFilePath(String filePath) {
+		this.filePath = filePath;
+	}
+}

+ 35 - 0
PCS/src/main/java/cn/cslg/permission/common/core/business/LoginCacheKeyUtil.java

@@ -0,0 +1,35 @@
+package cn.cslg.permission.common.core.business;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class LoginCacheKeyUtil {
+
+    //分隔符
+    public final static String SEPARATOR = ":";
+    //统一前缀
+    private static String prefix;
+
+    @Autowired
+    public LoginCacheKeyUtil(BaseProperties baseProperties) {
+        prefix = baseProperties.getProject();
+    }
+
+    public final static String PHONE_LOGIN = "PHONELOGIN";
+
+    public final static String LOGIN_CAPTCHA  = "LOGIN_CAPTCHA";
+
+    /*
+     * 获取用户手机号缓存key
+     * key:手机号
+     * value:验证码 类型:String
+     * */
+    public static String getLoginCaptcha(String phoneNo) {
+        StringBuilder builder = new StringBuilder(prefix + SEPARATOR + PHONE_LOGIN + SEPARATOR);
+        builder.append(LOGIN_CAPTCHA + SEPARATOR)
+                .append(phoneNo);
+        return builder.toString();
+    }
+
+}

+ 45 - 0
PCS/src/main/java/cn/cslg/permission/common/core/business/SmsService.java

@@ -0,0 +1,45 @@
+package cn.cslg.permission.common.core.business;
+
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.profile.DefaultProfile;
+import com.google.gson.Gson;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SmsService {
+
+    @Value("${SMS.regionId}")
+    private String regionId;
+
+    @Value("${SMS.accessKeyId}")
+    private String accessKeyId;
+
+    @Value("${SMS.secret}")
+    private String secret;
+
+    public void sendMessage(String phoneNum,String random){
+
+        DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, secret);
+        IAcsClient client = new DefaultAcsClient(profile);
+        SendSmsRequest request = new SendSmsRequest();
+//        String templateParam = "{\"code\":\"" + random + "\",\"message\":\"" + "为您的登陆验证码" + "\",\"validTime\":\"" + "5分钟" + "\"}";
+        String templateParam = "{\"code\":\"" + random + "\"}";
+        request.setPhoneNumbers(phoneNum);//接收短信的手机号码
+        request.setSignName("小世数字科技");//短信签名名称
+        request.setTemplateCode("SMS_296725687");//短信模板CODE
+        request.setTemplateParam(templateParam);//短信模板变量对应的实际值
+        try {
+            SendSmsResponse response = client.getAcsResponse(request);
+            System.out.println(new Gson().toJson(response));
+        } catch (ClientException e) {
+            System.out.println("ErrCode:" + e.getErrCode());
+            System.out.println("ErrMsg:" + e.getErrMsg());
+            System.out.println("RequestId:" + e.getRequestId());
+        }
+    }
+}

+ 34 - 0
PCS/src/main/java/cn/cslg/permission/common/model/dto/PhoneLoginDTO.java

@@ -0,0 +1,34 @@
+package cn.cslg.permission.common.model.dto;
+
+
+import lombok.Data;
+
+@Data
+public class PhoneLoginDTO {
+
+    //手机号
+    private String phoneNum;
+
+    //验证码
+    private String phoneCode;
+
+    /**
+     * 机器码
+     */
+    private String machineCode;
+
+    /**
+     * 请求的secret
+     */
+    private String sign;
+
+    /**
+     * 应用key
+     */
+    private String appKey;
+
+    /**
+     * 发起请求时的时间戳
+     */
+    private Long currentTimeMillis;
+}

+ 12 - 0
PCS/src/main/java/cn/cslg/permission/common/model/dto/SendCodeDTO.java

@@ -0,0 +1,12 @@
+package cn.cslg.permission.common.model.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+@Data
+public class SendCodeDTO {
+    //手机号
+    @NotBlank
+    private String phoneNum;
+}

+ 2 - 0
PCS/src/main/java/cn/cslg/permission/common/model/vo/EncryptionLoginVO.java

@@ -19,4 +19,6 @@ public class EncryptionLoginVO {
      * 登陆成功后生成的Token
      */
     private String token;
+    //个人配置
+    private String personnelConfig;
 }

+ 23 - 0
PCS/src/main/java/cn/cslg/permission/common/model/vo/PhoneLoginVO.java

@@ -0,0 +1,23 @@
+package cn.cslg.permission.common.model.vo;
+
+import lombok.Data;
+
+@Data
+public class PhoneLoginVO {
+
+    private String personnelUserName;
+
+    private Integer personId;
+
+    private String personnelName;
+
+    private String personnelPhone;
+
+    private String machineCode;
+
+    private String privateKey;
+
+    private String personnelConfig;
+
+    private String token;
+}

+ 30 - 0
PCS/src/main/java/cn/cslg/permission/common/utils/RandomUtil.java

@@ -0,0 +1,30 @@
+package cn.cslg.permission.common.utils;
+
+import java.util.Random;
+
+public class RandomUtil {
+
+    /**
+     * 随机验证码
+     * @return
+     */
+    public static String getSixRandom(){
+        return String.valueOf((int) ((Math.random() * 9 + 1) * Math.pow(10, 5)));
+    }
+    private static String[] STR_ARR = new String[] { "a", "b", "c", "d", "e",
+            "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
+            "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E",
+            "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
+            "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5",
+            "6", "7", "8", "9", "0" };
+    public static String generateRandomString(int length) {
+        StringBuilder sb = new StringBuilder();
+        Random rand = new Random();
+        for (int i = 0; i < length; i++) {
+            sb.append(STR_ARR[rand.nextInt(STR_ARR.length)]);
+        }
+        return sb.toString();
+    }
+
+
+}

+ 80 - 0
PCS/src/main/java/cn/cslg/permission/common/utils/RegexUtil.java

@@ -0,0 +1,80 @@
+package cn.cslg.permission.common.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+/**
+  * 正则工具类
+ */
+public class RegexUtil {
+
+    /**
+     * 大陆号码或香港号码均可
+     */
+    public static boolean isPhoneLegal(String str) throws PatternSyntaxException {
+        return isChinaPhoneLegal(str) || isHKPhoneLegal(str);
+    }
+
+    /**
+     * 手机号验证,1开头,后面10位随机0-9数字
+     */
+    public static boolean isChinaPhoneLegal(String str) throws PatternSyntaxException {
+        if (str == null) {
+            return false;
+        }
+        String regExp = "^[1][0-9]{10}$";
+        Pattern p = Pattern.compile(regExp);
+        Matcher m = p.matcher(str);
+        return m.matches();
+    }
+
+    /**
+     * 香港手机号码8位数,5|6|8|9开头+7位任意数
+     */
+    public static boolean isHKPhoneLegal(String str) throws PatternSyntaxException {
+        if (str == null) {
+            return false;
+        }
+        String regExp = "^(5|6|8|9)\\d{7}$";
+        Pattern p = Pattern.compile(regExp);
+        Matcher m = p.matcher(str);
+        return m.matches();
+    }
+
+    public static boolean isRegExpReplace(String str) throws PatternSyntaxException {
+        if (str == null) {
+            return false;
+        }
+        String regExp = "[,。、;,./;]";
+        Pattern p = Pattern.compile(regExp);
+        Matcher m = p.matcher(str);
+        return m.matches();
+    }
+
+    //split By分隔符忽略引号
+    public static List<String> splitByDelimiters(String input) {
+        List<String> result = new ArrayList<>();
+        // 正则表达式匹配分隔符,但忽略引号内的内容
+        // 注意:这里使用了Unicode转义序列来表示中文引号
+        Pattern pattern = Pattern.compile("\"([^\"]*)\"|’([^’]*)’|‘([^’]*)’|“([^\"]*)”|([^,。、;,./;\\s+]+)");
+        Matcher matcher = pattern.matcher(input);
+
+        while (matcher.find()) {
+            if (matcher.group(1) != null) { // 英文双引号
+                result.add(matcher.group(1));
+            } else if (matcher.group(2) != null) { // 中文单引号
+                result.add(matcher.group(2));
+            } else if (matcher.group(3) != null) { // 中文单引号(另一种可能的形式)
+                result.add(matcher.group(3));
+            } else if (matcher.group(4) != null) { // 中文双引号
+                result.add(matcher.group(4));
+            } else { // 其他内容(即分隔符外的部分)
+                result.add(matcher.group(5));
+            }
+        }
+        return result;
+    }
+}

+ 7 - 0
PCS/src/main/java/cn/cslg/permission/common/utils/ResponseEnum.java

@@ -30,6 +30,13 @@ public enum ResponseEnum {
     THE_SIGN_IS_NOT_SAME(500, "请求SIGN不一致,重新检查"),
     THE_MACHINE_CODE_IS_NULL(500, "机器码不可为空"),
     DO_NOT_LOG_IN_TO_MORE_THAN_TWO_NEW_MACHINES_WITH_THE_SAME_ACCOUNT(500, "同一账号新机登录不可超过两个"),
+    THE_PHONE_FORMAT_ERROR(500,"手机号格式错误"),
+    THE_PHONE_IS_NOT_EMPTY(500,"手机号不可为空"),
+    THE_PHONE_CODE_IS_INVALID(500,"手机验证码失效"),
+    THE_PHONE_CODE_IS_NOT_NULL(500,"手机验证码不可为空"),
+    THE_PHONE_CODE_IS_INCONFORMITY(500,"验证码不一致"),
+    THE_PERSONNEL_IS_NOT_EXIST(500,"用户不存在"),
+    THE_PERSONNEL_IS_FORBIDDEN(500,"该用户已停用"),
     THE_VERSION_IS_NULL(500, "版本号不可为空");
 
 

+ 16 - 0
PCS/src/main/java/cn/cslg/permission/controller/LoginController.java

@@ -3,6 +3,8 @@ package cn.cslg.permission.controller;
 import cn.cslg.permission.common.core.base.Constants;
 import cn.cslg.permission.common.model.dto.EncryptionFunctionDTO;
 import cn.cslg.permission.common.model.dto.EncryptionLoginDTO;
+import cn.cslg.permission.common.model.dto.PhoneLoginDTO;
+import cn.cslg.permission.common.model.dto.SendCodeDTO;
 import cn.cslg.permission.common.model.vo.LoginVO;
 import cn.cslg.permission.common.utils.Response;
 import cn.cslg.permission.common.utils.auth.checkAuth;
@@ -16,6 +18,8 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
+
 /**
  * @author 沈永艺
  * @date 2022-8-5
@@ -82,4 +86,16 @@ public class LoginController {
     public String functionByEncryption(@RequestBody EncryptionFunctionDTO vo) throws Exception {
         return loginService.functionByEncryption(vo);
     }
+
+//    @Operation(summary = "获取手机验证码")
+//    @PostMapping("/getPhoneCode")
+//    public String getPhoneCode(@RequestBody @Valid SendCodeDTO vo) {
+//        return loginService.getPhoneCode(vo);
+//    }
+//
+//    @Operation(summary = "手机号登录")
+//    @PostMapping(value = "/loginByPhone")
+//    public String loginByPhone(@Valid @RequestBody PhoneLoginDTO vo) throws Exception {
+//        return loginService.loginByPhone(vo);
+//    }
 }

+ 112 - 1
PCS/src/main/java/cn/cslg/permission/service/LoginService.java

@@ -1,8 +1,12 @@
 package cn.cslg.permission.service;
 
 import cn.cslg.permission.common.core.base.RedisConf;
+import cn.cslg.permission.common.core.business.LoginCacheKeyUtil;
+import cn.cslg.permission.common.core.business.SmsService;
 import cn.cslg.permission.common.model.dto.EncryptionFunctionDTO;
 import cn.cslg.permission.common.model.dto.EncryptionLoginDTO;
+import cn.cslg.permission.common.model.dto.PhoneLoginDTO;
+import cn.cslg.permission.common.model.dto.SendCodeDTO;
 import cn.cslg.permission.common.model.vo.*;
 import cn.cslg.permission.common.utils.*;
 import cn.cslg.permission.common.utils.message.MessageUtils;
@@ -24,6 +28,7 @@ import cn.hutool.captcha.CaptchaUtil;
 import cn.hutool.captcha.CircleCaptcha;
 import cn.hutool.core.img.ImgUtil;
 import cn.hutool.core.lang.UUID;
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.crypto.SecureUtil;
 
 import javax.servlet.http.HttpServletRequest;
@@ -42,7 +47,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
-import javax.servlet.ServletRequest;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 
@@ -68,6 +72,7 @@ public class LoginService extends ServiceImpl<PersonnelMapper, Personnel> {
     private final RoleFunctionDataService roleFunctionDataService;
     private final FunctionService functionService;
     private final ApplicationService applicationService;
+    private final SmsService smsService;
     @Autowired
     private PersonnelMapper personnelMapper;
     @Autowired
@@ -402,6 +407,7 @@ public class LoginService extends ServiceImpl<PersonnelMapper, Personnel> {
         loginVO.setPersonnelUserName(personnel.getPersonnelUserName());
         loginVO.setPersonnelPhone(personnel.getPersonnelPhone());
         loginVO.setMachineCode(vo.getMachineCode());
+        loginVO.setPersonnelConfig(personnel.getPersonConfig());
         //Sa-token 登录方法 登录后 生成Token 如果集成了Redis的话 会自动存入Redis
         StpUtil.login(personnel.getId());
         loginVO.setToken(StpUtil.getTokenValue());
@@ -536,4 +542,109 @@ public class LoginService extends ServiceImpl<PersonnelMapper, Personnel> {
         }
         return functionVOS;
     }
+
+    //---------------------------------------二期开发--------------------------
+    /**
+     * 发送验证码
+     *
+     * @param vo
+     * @return
+     */
+    public String getPhoneCode(SendCodeDTO vo) {
+        String res = "发送验证码失败";
+        if (Boolean.TRUE.equals(StringUtils.isEmpty(vo.getPhoneNum()))) {
+            return Response.error(ResponseEnum.THE_PHONE_IS_NOT_EMPTY);
+        }
+        if (!RegexUtil.isPhoneLegal(vo.getPhoneNum())) {
+            return Response.error(ResponseEnum.THE_PHONE_FORMAT_ERROR);
+        }
+        if (StringUtils.isNotEmpty(vo.getPhoneNum())) {
+            //生成验证码
+            String random = RandomUtil.getSixRandom();
+            //手机号和验证码放进缓存 设置过期时间60s
+            redisUtil.set(LoginCacheKeyUtil.getLoginCaptcha(vo.getPhoneNum()), random);
+            redisUtil.expire(LoginCacheKeyUtil.getLoginCaptcha(vo.getPhoneNum()), 60L,TimeUnit.SECONDS);
+            //发送短信
+            smsService.sendMessage(vo.getPhoneNum(), random);
+            res = "发送验证码成功";
+        }
+        return res;
+    }
+
+    /**
+     * 手机号登录
+     *
+     * @param dto
+     * @return
+     */
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+    public String loginByPhone(PhoneLoginDTO dto) throws Exception {
+        String machineCode = dto.getMachineCode();
+        final String sign = dto.getSign();
+        final String appKey = dto.getAppKey();
+        long currentTimeMillis = dto.getCurrentTimeMillis() / 1000;
+        long currentTimeSecond = System.currentTimeMillis() / 1000;
+        final long second = currentTimeSecond - currentTimeMillis;
+        if (second > 30) {
+            return Response.error(ResponseEnum.THE_REQUEST_TIME_OVERTIME);
+        }
+        String appSecret = appKey + currentTimeMillis;
+        String md5Sign = SecureUtil.md5(appSecret);
+        if (Boolean.TRUE.equals(StringUtils.isEmpty(sign)) || !sign.equals(md5Sign)) {
+            return Response.error(ResponseEnum.THE_SIGN_IS_NOT_SAME);
+        }
+        if (Boolean.TRUE.equals(StringUtils.isEmpty(machineCode))) {
+            return Response.error(ResponseEnum.THE_MACHINE_CODE_IS_NULL);
+        }
+        //获取缓存中验证码
+        String code = redisUtil.get(LoginCacheKeyUtil.getLoginCaptcha(dto.getPhoneNum()));
+        if (Boolean.TRUE.equals(StringUtils.isEmpty(code))) {
+            return Response.error(ResponseEnum.THE_PHONE_CODE_IS_INVALID);
+        }
+
+        //校验验证码
+        if (Boolean.TRUE.equals(StringUtils.isEmpty(dto.getPhoneCode()))) {
+            return Response.error(ResponseEnum.THE_PHONE_CODE_IS_NOT_NULL);
+        }
+
+        if (!org.apache.commons.lang3.StringUtils.equals(code, dto.getPhoneCode())) {
+            return Response.error(ResponseEnum.THE_PHONE_CODE_IS_INCONFORMITY);
+        }
+        //校验验证码成功后使其失效
+        redisUtil.delete(LoginCacheKeyUtil.getLoginCaptcha(dto.getPhoneNum()));
+        //查询用户
+        LambdaQueryWrapper<Personnel> queryWrapper = new LambdaQueryWrapper<>();
+        if (org.apache.commons.lang3.StringUtils.isNotEmpty(dto.getPhoneNum())) {
+            queryWrapper.eq(Personnel::getPersonnelPhone, dto.getPhoneNum());
+        }
+        Personnel person = personnelMapper.selectOne(queryWrapper);
+        if (org.apache.commons.lang3.ObjectUtils.isEmpty(person)) {
+            return Response.error(ResponseEnum.THE_PERSONNEL_IS_NOT_EXIST);
+        }
+        if (person.getPersonnelStatus().equals(0)) {
+            return Response.error(ResponseEnum.THE_PERSONNEL_IS_FORBIDDEN);
+        }
+        //人员信息中私钥或公钥为空则添加进去
+        this.updatePersonnel(person.getPrivateKey(), person.getPublicKey(), person.getSymmetryKey(), person.getId());
+        person = personnelMapper.selectById(person.getId());
+        List<AssoPersonnelMachine> machineList = assoPersonnelMachineMapper.selectList(new LambdaQueryWrapper<AssoPersonnelMachine>()
+                .eq(AssoPersonnelMachine::getPersonnelId, person.getId())
+                .ne(AssoPersonnelMachine::getMachineCode, SecureUtil.md5(machineCode)));
+        if (machineList.size() > 1) {
+            return Response.error(ResponseEnum.DO_NOT_LOG_IN_TO_MORE_THAN_TWO_NEW_MACHINES_WITH_THE_SAME_ACCOUNT);
+        }
+        addOrUpdatePersonnelMachine(machineCode, person);
+        PhoneLoginVO loginVO = new PhoneLoginVO();
+        loginVO.setPersonId(person.getId());
+        loginVO.setPersonnelUserName(person.getPersonnelUserName());
+        loginVO.setPersonnelName(person.getPersonnelName());
+        loginVO.setPersonnelPhone(person.getPersonnelPhone());
+        loginVO.setPrivateKey(person.getPrivateKey());
+        loginVO.setPersonnelConfig(person.getPersonConfig());
+        loginVO.setMachineCode(loginVO.getMachineCode());
+        //Sa-token 登录方法 登录后 生成Token 如果集成了Redis的话 会自动存入Redis
+        StpUtil.login(person.getId());
+        loginVO.setToken(StpUtil.getTokenValue());
+        return Response.success(loginVO);
+    }
 }

+ 6 - 1
PCS/src/main/resources/application-dev.yml

@@ -40,4 +40,9 @@ spring:
         login-password: 123456
       web-stat-filter:
         exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
-queueName: emailProd.queue
+queueName: emailProd.queue
+##################  短信 ####################
+SMS:
+  regionId: cn-shanghai
+  accessKeyId: LTAI5tGyG1Q7fKprgg1nWhXj
+  secret: Y6Erboh5lEFiRPR4XK8oCPMvUzYGLN

+ 37 - 0
PCS/src/test/java/cn/cslg/permission/EncryptionPersonTest.java

@@ -3,8 +3,12 @@ package cn.cslg.permission;
 
 import cn.cslg.permission.common.model.dto.EncryptionFunctionDTO;
 import cn.cslg.permission.common.model.dto.EncryptionLoginDTO;
+import cn.cslg.permission.common.model.dto.PhoneLoginDTO;
+import cn.cslg.permission.common.model.dto.SendCodeDTO;
+import cn.cslg.permission.common.model.personnel.UploadPersonnelConfigDTO;
 import cn.cslg.permission.common.utils.RSAUtils;
 import cn.cslg.permission.service.LoginService;
+import cn.cslg.permission.service.PersonnelService;
 import cn.hutool.crypto.SecureUtil;
 
 import org.junit.Test;
@@ -22,6 +26,8 @@ public class EncryptionPersonTest {
     @Autowired
     private LoginService loginService;
 
+    @Autowired
+    private PersonnelService personnelService;
 
     @Test
     public void test() throws Exception {
@@ -73,4 +79,35 @@ public class EncryptionPersonTest {
         final String decrypt = RSAUtils.decryptByPrivateKey(data, privateKey);
         System.out.println(decrypt);
     }
+
+    @Test
+    public void uploadPersonnelConfig() {
+        UploadPersonnelConfigDTO vo = new UploadPersonnelConfigDTO();
+        vo.setPersonnelConfig("{url:\"shdfgjsdgfdsj\"}");
+        personnelService.setPersonConfig(vo);
+    }
+
+    @Test
+    public void getPhoneCode() {
+        SendCodeDTO vo = new SendCodeDTO();
+        vo.setPhoneNum("15705220533");
+        String s = loginService.getPhoneCode(vo);
+        System.out.println(s);
+    }
+
+    @Test
+    public void loginByPhone() throws Exception {
+        PhoneLoginDTO vo = new PhoneLoginDTO();
+        vo.setPhoneNum("15705220533");
+        vo.setPhoneCode("228405");
+        vo.setAppKey("4e95e3d926a2a4befa5d913acc0aa9f5");
+        vo.setMachineCode("BFEBFBFF000A0654");
+        final long timeMillis = System.currentTimeMillis();
+        vo.setCurrentTimeMillis(timeMillis);
+        String appSecret = vo.getAppKey() + timeMillis / 1000;
+        String md5Sign = SecureUtil.md5(appSecret);
+        vo.setSign(md5Sign);
+        final String login = loginService.loginByPhone(vo);
+        System.out.println(login);
+    }
 }