Browse Source

清理无用代码

deason 5 years ago
parent
commit
e8f6dee3f3

+ 1 - 10
src/main/java/cn/com/qmth/examcloud/app/controller/SystemRestController.java

@@ -8,9 +8,8 @@
 package cn.com.qmth.examcloud.app.controller;
 
 import cn.com.qmth.examcloud.app.model.Result;
-import cn.com.qmth.examcloud.app.service.CoreOeService;
-import cn.com.qmth.examcloud.app.service.SmsService;
 import cn.com.qmth.examcloud.app.service.CoreAuthService;
+import cn.com.qmth.examcloud.app.service.CoreOeService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,8 +33,6 @@ public class SystemRestController {
     private CoreOeService oeService;
     @Autowired
     private CoreAuthService authService;
-    @Autowired
-    private SmsService smsService;
 
     @ApiOperation(value = "获取服务器当前时间接口")
     @RequestMapping(value = "/system/currentTime", method = {RequestMethod.POST})
@@ -55,10 +52,4 @@ public class SystemRestController {
         return authService.code4Student(phone, true);
     }
 
-    @ApiOperation(value = "校验短信验证码接口", hidden = true)
-    @RequestMapping(value = "/check/sms/code", method = {RequestMethod.POST})
-    public Result checkSmsCode(@RequestHeader(name = PARAM_APP_KEY) String key, @RequestHeader(name = PARAM_APP_TOKEN) String token, @RequestParam String phone, @RequestParam String code) throws Exception {
-        return smsService.checkSmsCode(key, token, phone, code);
-    }
-
 }

+ 0 - 21
src/main/java/cn/com/qmth/examcloud/app/core/SysProperty.java

@@ -26,15 +26,6 @@ public class SysProperty {
     @Value("${$upyun.site.1.domain}")
     private String upYunUrl;//又拍云文件服务
 
-    //@Value("${examcloud.sms.url}")
-    private String smsUrl;//短信服务地址
-
-    //@Value("${examcloud.sms.sign}")
-    private String smsSign;//短信签名
-
-    //@Value("${examcloud.sms.template}")
-    private String smsTemplate;//短信模板Code
-
     public String getProxyUrl(Server server) {
         return discoveryClient.getInstanceUrl(server.getInstanceName());
     }
@@ -67,16 +58,4 @@ public class SysProperty {
         return upYunUrl;
     }
 
-    public String getSmsUrl() {
-        return smsUrl;
-    }
-
-    public String getSmsSign() {
-        return smsSign;
-    }
-
-    public String getSmsTemplate() {
-        return smsTemplate;
-    }
-
 }

+ 0 - 43
src/main/java/cn/com/qmth/examcloud/app/service/SmsService.java

@@ -1,43 +0,0 @@
-/*
- * *************************************************
- * Copyright (c) 2018 QMTH. All Rights Reserved.
- * Created by Deason on 2018-07-31 17:36:02.
- * *************************************************
- */
-
-package cn.com.qmth.examcloud.app.service;
-
-import cn.com.qmth.examcloud.app.model.Result;
-
-/**
- * 短信服务接口
- *
- * @author: fengdesheng
- * @since: 2018/7/31
- */
-public interface SmsService {
-
-    /**
-     * 获取短信验证码
-     *
-     * @param key
-     * @param token
-     * @param phone
-     * @return
-     * @throws Exception
-     */
-    Result<String> sendSmsCode(String key, String token, String phone) throws Exception;
-
-    /**
-     * 校验短信验证码
-     *
-     * @param key
-     * @param token
-     * @param phone
-     * @param code
-     * @return
-     * @throws Exception
-     */
-    Result<String> checkSmsCode(String key, String token, String phone, String code) throws Exception;
-
-}

+ 0 - 90
src/main/java/cn/com/qmth/examcloud/app/service/impl/SmsServiceImpl.java

@@ -1,90 +0,0 @@
-/*
- * *************************************************
- * Copyright (c) 2018 QMTH. All Rights Reserved.
- * Created by Deason on 2018-07-31 17:19:06.
- * *************************************************
- */
-
-package cn.com.qmth.examcloud.app.service.impl;
-
-import cn.com.qmth.examcloud.app.core.utils.HttpUtils;
-import cn.com.qmth.examcloud.app.core.utils.JsonMapper;
-import cn.com.qmth.examcloud.app.core.utils.StrUtils;
-import cn.com.qmth.examcloud.app.model.Constants;
-import cn.com.qmth.examcloud.app.model.ResBody;
-import cn.com.qmth.examcloud.app.model.Result;
-import cn.com.qmth.examcloud.app.core.SysProperty;
-import cn.com.qmth.examcloud.app.service.SmsService;
-import okhttp3.FormBody;
-import okhttp3.MediaType;
-import okhttp3.RequestBody;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.Assert;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 短信服务接口
- *
- * @author: fengdesheng
- * @since: 2018/7/16
- */
-@Service
-public class SmsServiceImpl implements SmsService {
-    private static Logger log = LoggerFactory.getLogger(SmsServiceImpl.class);
-    @Autowired
-    private SysProperty sysProperty;
-
-    @Override
-    public Result<String> sendSmsCode(String key, String token, String phone) throws Exception {
-        Assert.notNull(phone, "Phone must be not null.");
-        Assert.isTrue(StrUtils.isMobile(phone), "Phone is wrong number.");
-        //生成code
-        String code = StrUtils.randomNumber().toString();
-        //封装请求参数
-        final String requestUrl = String.format("%s/api/exchange/inner/sendSms/sendIdentifyingCode", sysProperty.getSmsUrl());
-        Map<String, String> params = new HashMap<>();
-        params.put("phone", phone);//手机号码
-        params.put("code", code);//验证码
-        params.put("sign", sysProperty.getSmsSign());//签名
-        params.put("templateCode", sysProperty.getSmsTemplate());//短信模板
-        String json = new JsonMapper().toJson(params);
-        RequestBody formBody = FormBody.create(MediaType.parse(Constants.CHARSET_JSON_UTF8), json);
-        //发送短信
-        Result<String> result = HttpUtils.doPost(requestUrl, formBody, key, token);
-        return this.parseResult(result);
-    }
-
-    @Override
-    public Result<String> checkSmsCode(String key, String token, String phone, String code) throws Exception {
-        //封装请求参数
-        final String requestUrl = String.format("%s/api/exchange/inner/sendSms/checkIdentifyingCode", sysProperty.getSmsUrl());
-        Map<String, String> params = new HashMap<>();
-        params.put("phone", phone);
-        params.put("code", code);
-        String json = new JsonMapper().toJson(params);
-        RequestBody formBody = FormBody.create(MediaType.parse(Constants.CHARSET_JSON_UTF8), json);
-        Result<String> result = HttpUtils.doPost(requestUrl, formBody, key, token);
-        return this.parseResult(result);
-    }
-
-    private Result<String> parseResult(Result<String> result) {
-        if (!result.isSuccess()) {
-            return result;
-        }
-        ResBody body = new JsonMapper().fromJson(result.getData(), ResBody.class);
-        if (body != null && body.getSuccess() != null) {
-            if (body.getSuccess() == true) {
-                return new Result().success();
-            } else {
-                return new Result().error(body.getReturnMsg());
-            }
-        }
-        return result;
-    }
-
-}