Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/V1' into V1

jz.kai 5 gadi atpakaļ
vecāks
revīzija
fb99ffd110

+ 5 - 2
common/src/main/java/com/jpsoft/smart/modules/base/entity/PersonInfo.java

@@ -49,8 +49,8 @@ public class PersonInfo {
 	/**
 	 *微信openId
 	 */
-        @ApiModelProperty(value = "微信openId")
-	private Boolean openId;
+	@ApiModelProperty(value = "微信openId")
+	private String openId;
 	/**
 	 *人脸
 	 */
@@ -140,4 +140,7 @@ public class PersonInfo {
 	public void setCompanyName(String companyName) {
 		this.companyName = companyName;
 	}
+
+	@ApiModelProperty(value = "人脸相片地址")
+	private String faceImageUrl;
 }

+ 8 - 3
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -21,6 +21,7 @@
         <result property="position3" column="position3_"/>
         <result property="position4" column="position4_"/>
         <result property="position5" column="position5_"/>
+        <result property="faceImageUrl" column="face_image_url"/>
         <result property="delFlag" column="del_flag"/>
         <result property="createBy" column="create_by"/>
         <result property="createTime" column="create_time"/>
@@ -37,14 +38,14 @@
 		insert into base_person_info
 	    (company_id,name_,phone_,id_card,open_id,face_enabled,card_enabled,
 	    app_enabled,password_enabled,guest_enabled,position1_,position2_,
-	    position3_,position4_,position5_,del_flag,create_by,create_time,update_by,update_time)
+	    position3_,position4_,position5_,face_image_url,del_flag,create_by,create_time,update_by,update_time)
 		values
 		(
             #{companyId,jdbcType=VARCHAR}
             ,#{name,jdbcType=VARCHAR}
             ,#{phone,jdbcType=VARCHAR}
             ,#{idCard,jdbcType=VARCHAR}
-            ,#{openId,jdbcType= NUMERIC }
+            ,#{openId,jdbcType= VARCHAR }
             ,#{faceEnabled,jdbcType= NUMERIC }
             ,#{cardEnabled,jdbcType= NUMERIC }
             ,#{appEnabled,jdbcType= NUMERIC }
@@ -55,6 +56,7 @@
             ,#{position3,jdbcType=VARCHAR}
             ,#{position4,jdbcType=VARCHAR}
             ,#{position5,jdbcType=VARCHAR}
+            ,#{face_image_url,jdbcType=VARCHAR}
             ,#{delFlag,jdbcType= NUMERIC }
             ,#{createBy,jdbcType=VARCHAR}
             ,#{createTime,jdbcType= TIMESTAMP }
@@ -82,7 +84,7 @@
                 id_card=#{idCard,jdbcType=VARCHAR},
             </if>
             <if test="openId!=null">
-                open_id=#{openId,jdbcType= NUMERIC },
+                open_id=#{openId,jdbcType= VARCHAR },
             </if>
             <if test="faceEnabled!=null">
                 face_enabled=#{faceEnabled,jdbcType= NUMERIC },
@@ -114,6 +116,9 @@
             <if test="position5!=null">
                 position5_=#{position5,jdbcType=VARCHAR},
             </if>
+            <if test="faceImageUrl!=null">
+                face_image_url=#{faceImageUrl,jdbcType=VARCHAR},
+            </if>
             <if test="delFlag!=null">
                 del_flag=#{delFlag,jdbcType= NUMERIC },
             </if>

+ 48 - 7
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonInfoApiController.java

@@ -10,6 +10,7 @@ import com.jpsoft.smart.modules.common.utils.SMSUtil;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 @RestController
 @RequestMapping("/mobile/personInfoApi")
@@ -83,8 +85,6 @@ public class PersonInfoApiController {
         return messageResult;
     }
 
-
-
     @PostMapping("getVerifyCode")
     @ApiOperation(value="获取短信验证码")
     @ApiImplicitParams({
@@ -97,14 +97,23 @@ public class PersonInfoApiController {
              PersonInfo personInfo = personInfoService.get(personId);
 
             if(personInfo!=null){
-                throw new Exception("人员编号不存在@");
+                throw new Exception("人员编号不存在!");
             }
 
-            String verifyCode = SMSUtil.generateNumberString(6);
-            JSONObject verifyCodeJSON = new JSONObject();
-            verifyCodeJSON.put("code", verifyCode);
+            String key = "SMS_" + personId;
+
+            String  verifyCode =  (String)valueOperations.get(key);
+
+            if(StringUtils.isNotEmpty(verifyCode)) {
+                verifyCode = SMSUtil.generateNumberString(6);
+                JSONObject verifyCodeJSON = new JSONObject();
+                verifyCodeJSON.put("code", verifyCode);
 
-            messageResult = SMSUtil.send(personInfo.getPhone(), "SMS_49390047", verifyCodeJSON.toString());
+                messageResult = SMSUtil.send(personInfo.getPhone(), "SMS_49390047", verifyCodeJSON.toString());
+
+                //设置当前用户的验证码,60秒后过期
+                valueOperations.set(key, verifyCode, 60000, TimeUnit.SECONDS);
+            }
         }
         catch (Exception ex){
             messageResult.setResult(false);
@@ -138,4 +147,36 @@ public class PersonInfoApiController {
 
         return messageResult;
     }
+
+    @PostMapping("save")
+    @ApiOperation(value="保存人员信息")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name="personId",value = "人员编号",required = true,paramType = "form"),
+            @ApiImplicitParam(name="openId",value = "微信openId",required = true,paramType = "form"),
+            @ApiImplicitParam(name="faceImageUrl",value = "照片地址",required = true,paramType = "form")
+    })
+    public MessageResult<String> save(Long personId,String openId,String faceImageUrl){
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+            PersonInfo personInfo = personInfoService.get(personId);
+
+            if (personInfo==null){
+                throw new Exception("人员信息不存在!");
+            }
+
+            personInfo.setOpenId(openId);
+            personInfo.setFaceImageUrl(faceImageUrl);
+
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception e) {
+            logger.error(e.getMessage(),e);
+
+            messageResult.setResult(false);
+            messageResult.setMessage(e.getMessage());
+        }
+
+        return messageResult;
+    }
 }