Browse Source

Merge remote-tracking branch 'origin/master'

yanliming 2 năm trước cách đây
mục cha
commit
6e2005567e

+ 3 - 0
common/src/main/java/com/jpsoft/education/modules/base/dao/EmployeeDAO.java

@@ -20,4 +20,7 @@ public interface EmployeeDAO {
 	List<Employee> search(Map<String, Object> searchParams, List<Sort> sortList);
 	Employee findByRegId(String regUserId);
 	List<Employee> loadByIds(@Param("employeeIds") String employeeIds);
+	Employee getByPhone(String phone);
+	
+	int  updateForBindReg(@Param("regId") String regId, @Param("phone") String phone);
 }

+ 4 - 0
common/src/main/java/com/jpsoft/education/modules/base/service/EmployeeService.java

@@ -18,4 +18,8 @@ public interface EmployeeService {
 	Page<Employee> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
 	Employee findByRegId(String regUserId);
 	List<Employee> loadByIds(String[] employeeId);
+	
+	Employee getByPhone(String phone);
+	
+	int updateForBindReg(String regId,String phone);
 }

+ 10 - 0
common/src/main/java/com/jpsoft/education/modules/base/service/impl/EmployeeServiceImpl.java

@@ -86,4 +86,14 @@ public class EmployeeServiceImpl implements EmployeeService {
 	public List<Employee> loadByIds(String[] employeeId){
 		return employeeDAO.loadByIds("'"+StringUtils.join(employeeId,"','")+"'");
 	}
+	
+	@Override
+	public Employee getByPhone(String phone) {
+		return employeeDAO.getByPhone(phone);
+	}
+
+	@Override
+	public int updateForBindReg(String regId, String phone) {
+		return employeeDAO.updateForBindReg(regId,phone);
+	}
 }

+ 8 - 0
common/src/main/resources/mapper/base/Employee.xml

@@ -128,4 +128,12 @@
 	<select id="loadByIds" resultMap="EmployeeMap">
 		select distinct * from t_employee where employee_id in (${employeeIds})
 	</select>
+	
+	<select id="getByPhone" resultMap="EmployeeMap">
+		select * from t_employee where del_if = 0 and phone = #{0} limit 1
+	</select>
+	
+	<update id="updateForBindReg">
+		update t_employee set reg_user_id=#{regId} where phone=#{phone}
+	</update>
 </mapper>

+ 34 - 23
web/src/main/java/com/jpsoft/education/modules/mobile/controller/RegUserApiController.java

@@ -1,37 +1,41 @@
 package com.jpsoft.education.modules.mobile.controller;
 
-import cn.hutool.core.lang.Validator;
-import cn.hutool.core.util.StrUtil;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.lang3.StringUtils;
+import org.joda.time.DateTime;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
 import com.alibaba.fastjson.JSONObject;
-import com.github.pagehelper.Page;
 import com.jpsoft.education.modules.base.entity.Employee;
 import com.jpsoft.education.modules.base.entity.RegUser;
 import com.jpsoft.education.modules.base.entity.Student;
 import com.jpsoft.education.modules.base.service.EmployeeService;
 import com.jpsoft.education.modules.base.service.RegUserService;
 import com.jpsoft.education.modules.base.service.StudentService;
-import com.jpsoft.education.modules.common.dto.Sort;
-import com.jpsoft.education.modules.common.utils.JwtUtil;
-import com.jpsoft.education.modules.common.utils.PojoUtils;
 import com.jpsoft.education.modules.common.dto.MessageResult;
+import com.jpsoft.education.modules.common.utils.JwtUtil;
 import com.jpsoft.education.modules.common.utils.SMSUtil;
 import com.jpsoft.education.modules.sys.entity.SysLog;
 import com.jpsoft.education.modules.sys.service.SysLogService;
+
+import cn.hutool.core.util.StrUtil;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.joda.time.DateTime;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.data.redis.core.ValueOperations;
-import org.springframework.format.annotation.DateTimeFormat;
-import org.springframework.web.bind.annotation.*;
-
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
 
 @Slf4j
 @RestController
@@ -262,12 +266,17 @@ public class RegUserApiController {
         try {
             String key = "SMS_" + telephone;
 
-            RegUser regUser = regUserService.findByPhone(telephone);
-
-            if (regUser != null && regUser.getUserType().contains("2")) {
-                //教师
-            } else {
-                throw new Exception("该手机号未注册!");
+			/*
+			 * RegUser regUser = regUserService.findByPhone(telephone);
+			 * 
+			 * if (regUser != null && regUser.getUserType().contains("2")) { //教师 } else {
+			 * throw new Exception("该手机号未注册!"); }
+			 */
+            Employee  employee=employeeService.getByPhone(telephone);
+            if(employee==null) {
+            	messageResult.setResult(false);
+                messageResult.setMessage("该手机号未登记,请联系管理员");
+                return messageResult;
             }
 
             //1分钟限制
@@ -365,6 +374,8 @@ public class RegUserApiController {
                         regUser.setHeadImg(headImg);
                     }
                     regUserService.insert(regUser);
+                    employeeService.updateForBindReg(regUser.getId(), telephone);
+                    token = JwtUtil.createToken(jwtSecret, regUser.getId(), DateTime.now().plusHours(6).toDate());
 
                 }
             }

+ 12 - 17
web/src/main/resources/application-production.yml

@@ -1,29 +1,24 @@
 spring:
   datasource:
-    url: jdbc:log4jdbc:mysql://192.168.33.20:3336/education_training?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+    url: jdbc:log4jdbc:mysql://127.0.0.1:3306/education_training?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
     username: root
-    password: jpsoft8121234
+    password: JpSoft8121234
   devtools:
+    add-properties: false
     restart:
       enabled: true
-  redis:
-    # Redis数据库索引(默认为0)
-    database: 1
-    # Redis服务器地址
-    host: 192.168.0.1
-    # Redis服务器连接端口
-    port: 6379
-    password:
+  jackson:
+    default-property-inclusion: always
+
+mybatis:
+  configuration:
+    call-setters-on-nulls: true
+
 logger:
   level: WARN
-  # 这里填的是容器中地址,需要在容器启动时挂在服务器相应文件夹地址
-  dir: /usr/local/tomcat/api-logs
+  dir: C:\Logs\education-training-server
+
 
-springfox:
-  documentation:
-    swagger:
-      v2:
-        host: wsbmapi.xiaoxinda.com
 
 baidu:
   ak: "ECKKpSyZRaFqtfSEV0TSyPZP"