deason 7 роки тому
батько
коміт
5f48534cfc

+ 3 - 0
pom.xml

@@ -8,6 +8,9 @@
     <packaging>war</packaging>
 
     <parent>
+        <!--<groupId>cn.com.qmth.examcloud</groupId>-->
+        <!--<artifactId>examcloud-parent</artifactId>-->
+        <!--<version>2.0-SNAPSHOT</version>-->
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>1.5.14.RELEASE</version>

+ 7 - 3
src/main/java/cn/com/qmth/examcloud/app/controller/version1/UserAuthRestController.java

@@ -10,6 +10,7 @@ package cn.com.qmth.examcloud.app.controller.version1;
 import cn.com.qmth.examcloud.app.model.LoginInfo;
 import cn.com.qmth.examcloud.app.model.Result;
 import cn.com.qmth.examcloud.app.model.UserInfo;
+import cn.com.qmth.examcloud.app.service.BaseInfoService;
 import cn.com.qmth.examcloud.app.service.UserAuthService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -32,8 +33,10 @@ public class UserAuthRestController {
     private final static Logger log = LoggerFactory.getLogger(UserAuthRestController.class);
     @Autowired
     private UserAuthService userAuthService;
+    @Autowired
+    private BaseInfoService baseInfoService;
 
-    @ApiOperation(value = "登录接口")
+    @ApiOperation(value = "登录接口", notes = "参数accountType值说明:普通账号类型=COMMON_LOGIN_NAME,学号类型=STUDENT_CODE,学生手机号类型=STUDENT_PHONE")
     @RequestMapping(value = "/user/login", method = {RequestMethod.GET, RequestMethod.POST})
     public Result<UserInfo> login(@RequestParam String account, @RequestParam String password, @RequestParam(required = false) String accountType,
                                   @RequestParam(required = false) Long rootOrgId, @RequestParam(required = false) String domain) throws Exception {
@@ -55,7 +58,8 @@ public class UserAuthRestController {
     @ApiOperation(value = "获取用户信息接口")
     @RequestMapping(value = "/user/info", method = {RequestMethod.GET, RequestMethod.POST})
     public Result getUserInfo(@RequestHeader String key, @RequestHeader String token) throws Exception {
-        return userAuthService.getUserInfo(key, token);
+        //return userAuthService.getUserInfo(key, token);
+        return baseInfoService.getStudentInfo(key, token);
     }
 
     @ApiOperation(value = "修改密码接口")
@@ -67,7 +71,7 @@ public class UserAuthRestController {
     @ApiOperation(value = "保存用户绑定的手机号接口", hidden = true)
     @RequestMapping(value = "/user/binding/phone", method = {RequestMethod.GET, RequestMethod.POST})
     public Result userBindingPhone(@RequestHeader String key, @RequestHeader String token, @RequestParam Long userId, @RequestParam String phone, @RequestParam String code) throws Exception {
-        return userAuthService.userBindingPhone(key, token, userId, phone, code);
+        return baseInfoService.userBindingPhone(key, token, userId, phone, code);
     }
 
 }

+ 1 - 2
src/main/java/cn/com/qmth/examcloud/app/core/utils/HttpUtils.java

@@ -78,8 +78,7 @@ public class HttpUtils {
         Response response = HttpBuilder.client.getInstance().newCall(request).execute();
         String bodyStr = response.body().string();
         if (response.isSuccessful()) {
-            String data = HttpUtils.filterNullAttributes(bodyStr);
-            return new Result().success(data);
+            return new Result().success(bodyStr);
         } else {
             log.warn("[Response] " + bodyStr);
             ResBody body = new JsonMapper().fromJson(bodyStr, ResBody.class);

+ 2 - 2
src/main/java/cn/com/qmth/examcloud/app/model/LoginType.java

@@ -26,8 +26,8 @@ public enum LoginType {
     STUDENT_CODE,
 
     /**
-     * 手机号登录
+     * 学生手机号登录
      */
-    PHONE_LOGIN
+    STUDENT_PHONE
 
 }

+ 24 - 0
src/main/java/cn/com/qmth/examcloud/app/service/BaseInfoService.java

@@ -0,0 +1,24 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-08-02 15:15:46.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.app.service;
+
+import cn.com.qmth.examcloud.app.model.Result;
+
+/**
+ * 基础信息服务接口
+ *
+ * @author: fengdesheng
+ * @since: 2018/7/31
+ */
+public interface BaseInfoService {
+
+    Result getStudentInfo(String key, String token) throws Exception;
+
+    Result userBindingPhone(String key, String token, Long userId, String phone, String code);
+
+}

+ 6 - 0
src/main/java/cn/com/qmth/examcloud/app/service/PropertyService.java

@@ -18,6 +18,8 @@ import org.springframework.stereotype.Component;
 @Component
 public class PropertyService {
     private static Logger log = LoggerFactory.getLogger(PropertyService.class);
+    @Value("${examcloud.base.info.url}")
+    private String baseInfoUrl;//基础信息服务
     @Value("${examcloud.exam.admin.url}")
     private String examAdminUrl;//考务服务
     @Value("${examcloud.net.exam.url}")
@@ -35,6 +37,10 @@ public class PropertyService {
     @Value("${examcloud.sms.template}")
     private String smsTemplate;//短信模板Code
 
+    public String getBaseInfoUrl() {
+        return baseInfoUrl;
+    }
+
     public String getExamAdminUrl() {
         return examAdminUrl;
     }

+ 1 - 2
src/main/java/cn/com/qmth/examcloud/app/service/UserAuthService.java

@@ -23,12 +23,11 @@ public interface UserAuthService {
 
     Result logout(String key, String token) throws Exception;
 
+    @Deprecated
     Result getUserInfo(String key, String token) throws Exception;
 
     Result updatePassword(String key, String token, Long userId, String password) throws Exception;
 
-    Result userBindingPhone(String key, String token, Long userId, String phone, String code);
-
     void cacheLoginInfo(LoginInfo loginInfo, UserInfo userInfo);
 
     void cacheLoginInfo(LoginInfo loginInfo, String key);

+ 45 - 0
src/main/java/cn/com/qmth/examcloud/app/service/impl/BaseInfoServiceImpl.java

@@ -0,0 +1,45 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-08-02 15:16:01.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.app.service.impl;
+
+import cn.com.qmth.examcloud.app.core.utils.HttpUtils;
+import cn.com.qmth.examcloud.app.model.Result;
+import cn.com.qmth.examcloud.app.service.BaseInfoService;
+import cn.com.qmth.examcloud.app.service.PropertyService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 基础信息服务接口
+ *
+ * @author: fengdesheng
+ * @since: 2018/7/16
+ */
+@Service
+public class BaseInfoServiceImpl implements BaseInfoService {
+    private static Logger log = LoggerFactory.getLogger(BaseInfoServiceImpl.class);
+    @Autowired
+    private PropertyService propertyService;
+
+    @Override
+    public Result getStudentInfo(String key, String token) throws Exception {
+        //封装请求参数
+        final String requestUrl = String.format("%s/api/ecs_core/student/getStudentInfoBySession", propertyService.getBaseInfoUrl());
+        //包含头像、手机号等字段
+        return HttpUtils.doGet(requestUrl, key, token);
+    }
+
+    @Override
+    public Result userBindingPhone(String key, String token, Long userId, String phone, String code) {
+        //api/core_api/auth/sendVerificationCode
+        return new Result().error();
+    }
+
+}

+ 0 - 7
src/main/java/cn/com/qmth/examcloud/app/service/impl/UserAuthServiceImpl.java

@@ -96,7 +96,6 @@ public class UserAuthServiceImpl implements UserAuthService {
                 .add(PARAM_KEY, key)
                 .add(PARAM_TOKEN, token)
                 .build();
-        //todo 待补充'头像、手机号、年级'字段
         return HttpUtils.doPost(requestUrl, formBody, key, token);
     }
 
@@ -112,12 +111,6 @@ public class UserAuthServiceImpl implements UserAuthService {
         return HttpUtils.doPut(requestUrl, formBody, key, token);
     }
 
-    @Override
-    public Result userBindingPhone(String key, String token, Long userId, String phone, String code) {
-        //todo
-        return new Result().error();
-    }
-
     @Override
     public void cacheLoginInfo(LoginInfo loginInfo, UserInfo userInfo) {
         if (loginInfo == null || userInfo == null) {

+ 2 - 0
src/main/resources/application-dev.properties

@@ -25,6 +25,8 @@ spring.redis.host=192.168.10.30
 spring.redis.password=
 spring.redis.database=0
 spring.redis.timeout=15000
+# 價插陓洘督昢華硊
+examcloud.base.info.url=http://192.168.10.30:8000
 # 蕉昢督昢華硊
 examcloud.exam.admin.url=http://192.168.10.30:8001
 # 厙蕉督昢華硊

+ 2 - 0
src/main/resources/application-prod.properties

@@ -25,6 +25,8 @@ spring.redis.host=192.168.10.30
 spring.redis.password=
 spring.redis.database=0
 spring.redis.timeout=15000
+# 價插陓洘督昢華硊
+examcloud.base.info.url=http://192.168.10.30:8000
 # 蕉昢督昢華硊
 examcloud.exam.admin.url=http://192.168.10.30:8001
 # 厙蕉督昢華硊

+ 2 - 0
src/main/resources/application-test.properties

@@ -25,6 +25,8 @@ spring.redis.host=192.168.10.30
 spring.redis.password=
 spring.redis.database=0
 spring.redis.timeout=15000
+# 價插陓洘督昢華硊
+examcloud.base.info.url=http://192.168.10.30:8000
 # 蕉昢督昢華硊
 examcloud.exam.admin.url=http://192.168.10.30:8001
 # 厙蕉督昢華硊