finikes 2 жил өмнө
parent
commit
7db8b984ea

+ 8 - 1
src/main/java/com/finikes/oc/base/controller/VerificationCodeController.java

@@ -2,6 +2,7 @@ package com.finikes.oc.base.controller;
 
 import com.finikes.oc.BaseDTO;
 import com.finikes.oc.BizException;
+import com.finikes.oc.Passports;
 import com.finikes.oc.base.dao.PassportDAO;
 import com.finikes.oc.base.dto.RegisterResponseDTO;
 import com.finikes.oc.base.entity.Passport;
@@ -9,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
 import java.util.Map;
 
 @RequestMapping("/verificationCode")
@@ -42,7 +45,7 @@ public class VerificationCodeController {
 
     @ResponseBody
     @RequestMapping(value = "/", method = RequestMethod.POST)
-    public BaseDTO checkVeriCode(@RequestBody Map<String, Object> map) {
+    public BaseDTO checkVeriCode(@RequestBody Map<String, Object> map, HttpServletRequest request) {
         // 获取手机号码
         String mobile = (String) map.get("mobile");
         String verificationCode = (String) map.get("verificationCode");
@@ -57,6 +60,10 @@ public class VerificationCodeController {
         long veriCodeDeadline = now + 60 * 1000 * 5;
         if (verificationCode.equals(veriCode) && veriCodeDeadline <= tmp.getVeriCodeDeadline()) {
             passportDAO.updateState(mobile, 1, now);
+            HttpSession session = request.getSession();
+            session.setAttribute("PASSPORT", tmp);
+
+            System.out.println(Passports.getPassport(request) + " =============");
             return new BaseDTO();
         } else {
             return new BaseDTO(new BizException("103", "验证码错误或失效"));

+ 29 - 0
src/main/java/com/finikes/oc/estate/controller/HouseController.java

@@ -9,10 +9,14 @@ import com.finikes.oc.management.entity.HouseRelation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+import java.io.IOException;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
 @RequestMapping("/house")
 @ResponseBody
@@ -55,6 +59,31 @@ public class HouseController {
         return new BaseDTO();
     }
 
+    @RequestMapping(value = "/cert", method = RequestMethod.POST)
+    @ResponseBody
+    public BaseDTO uploadCertificate(MultipartFile file) {
+        String name = null;
+        try {
+            name = saveCert(file);
+        } catch (IOException e) {
+            e.printStackTrace();
+            return new BaseDTO("000", e.getMessage());
+        }
+        return new BaseDTO().setContent(name);
+    }
+
+    public String saveCert(MultipartFile cert) throws IOException {//将文件保存到本地
+        String dir = "/home/ocv1-server";//建议这里写resources目录的绝对路径
+        File path = new File(dir + "/upload/");
+        if (!path.exists()) {//如果当前目录不存在
+            path.mkdir();
+        }
+        String name = UUID.randomUUID().toString().replaceAll("-", "") + "." + cert.getOriginalFilename().split("\\.")[1];
+        File file = new File(dir + "/upload/" + name);
+        cert.transferTo(file);//将此图像保存到file本地
+
+        return name;
+    }
 
     @ResponseBody
     @RequestMapping(value = "/passport/security", method = RequestMethod.POST)