|
|
@@ -3,19 +3,24 @@ package com.finikes.oc.base.controller;
|
|
|
import com.finikes.oc.BaseDTO;
|
|
|
import com.finikes.oc.BizException;
|
|
|
import com.finikes.oc.base.dao.PassportDAO;
|
|
|
+import com.finikes.oc.base.dto.PassportHouseInfoResponseDTO;
|
|
|
import com.finikes.oc.base.dto.RegisterResponseDTO;
|
|
|
import com.finikes.oc.base.entity.Passport;
|
|
|
+import com.finikes.oc.estate.dao.EstateUnitDAO;
|
|
|
+import com.finikes.oc.estate.dao.HouseDAO;
|
|
|
+import com.finikes.oc.estate.entity.EstateUnit;
|
|
|
+import com.finikes.oc.estate.entity.House;
|
|
|
+import com.finikes.oc.management.dao.HouseRelationDAO;
|
|
|
+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.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
-import java.util.Date;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@RequestMapping("/passport")
|
|
|
@@ -25,6 +30,15 @@ public class PassportController {
|
|
|
@Autowired
|
|
|
private PassportDAO passportDAO;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private HouseRelationDAO houseRelationDAO;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private HouseDAO houseDAO;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private EstateUnitDAO estateUnitDAO;
|
|
|
+
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/", method = RequestMethod.PUT)
|
|
|
public BaseDTO register(@RequestBody Map<String, Object> map) {
|
|
|
@@ -42,7 +56,13 @@ public class PassportController {
|
|
|
long veriCodeDeadline = now + 60 * 1000 * 5;
|
|
|
int id = 0;
|
|
|
if (tmp == null) {
|
|
|
- id = passportDAO.insert(mobile, password, veriCode, veriCodeDeadline);
|
|
|
+ Passport p = new Passport();
|
|
|
+ p.setMobile(mobile);
|
|
|
+ p.setPassword(password);
|
|
|
+ p.setVeriCode(veriCode);
|
|
|
+ p.setVeriCodeDeadline(veriCodeDeadline);
|
|
|
+ passportDAO.insert(p);
|
|
|
+ id = p.getId();
|
|
|
} else {
|
|
|
passportDAO.updateVeriCode(mobile, veriCode, veriCodeDeadline);
|
|
|
id = tmp.getId();
|
|
|
@@ -60,11 +80,8 @@ public class PassportController {
|
|
|
String mobile = (String) map.get("mobile");
|
|
|
String securityCode = (String) map.get("securityCode");
|
|
|
String type = (String) map.get("type");
|
|
|
- System.out.println(mobile + " ++++++");
|
|
|
Passport tmp = passportDAO.findByMobile(mobile);
|
|
|
- System.out.println(tmp);
|
|
|
if (tmp == null || tmp.getState() != 1) {
|
|
|
- System.out.println("00000000");
|
|
|
return new BaseDTO(new BizException("101", "登录失败"));
|
|
|
}
|
|
|
|
|
|
@@ -74,18 +91,60 @@ public class PassportController {
|
|
|
session.setAttribute("PASSPORT", tmp);
|
|
|
return new BaseDTO();
|
|
|
} else {
|
|
|
- System.out.println("1111111");
|
|
|
return new BaseDTO(new BizException("101", "登录失败"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
if (securityCode.equals(tmp.getVeriCode()) && (System.currentTimeMillis() + 6000 * 5) <= tmp.getVeriCodeDeadline()) {
|
|
|
HttpSession session = request.getSession();
|
|
|
session.setAttribute("PASSPORT", tmp);
|
|
|
return new BaseDTO();
|
|
|
} else {
|
|
|
- System.out.println("2222222222");
|
|
|
return new BaseDTO(new BizException("101", "登录失败"));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping(value = "/", method = RequestMethod.GET)
|
|
|
+ public BaseDTO getPassportAndHouse(@RequestParam("id") String id) {
|
|
|
+ int _id = Integer.parseInt(id);
|
|
|
+ Passport passport = passportDAO.findById(_id);
|
|
|
+ if (passport == null || passport.getState() != 1) {
|
|
|
+ // 不能查看
|
|
|
+ return new BaseDTO("300", "没有用户");
|
|
|
+ }
|
|
|
+
|
|
|
+ PassportHouseInfoResponseDTO dto = new PassportHouseInfoResponseDTO();
|
|
|
+ dto.setMobile(passport.getMobile());
|
|
|
+ HouseRelation relation = houseRelationDAO.findByPassport(_id);
|
|
|
+ if (relation != null && relation.getState() == 1) {
|
|
|
+ House house = houseDAO.findById(relation.getHouseId());
|
|
|
+ String houseAddress = getHouseFullName(house);
|
|
|
+ dto.setArea(String.valueOf(house.getArea()));
|
|
|
+ dto.setCertificateNo(relation.getCertificateNo());
|
|
|
+ dto.setHouseAddress(houseAddress);
|
|
|
+ dto.setFunction(house.getFunction());
|
|
|
+ dto.setCertificateUrl(relation.getCertificateUrl());
|
|
|
+ }
|
|
|
+
|
|
|
+ return new BaseDTO().setContent(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getHouseFullName(House house) {
|
|
|
+ StringBuilder builder = new StringBuilder(house.getName());
|
|
|
+ List<String> fullName = new ArrayList<>();
|
|
|
+ EstateUnit eu = estateUnitDAO.findById(house.getUnitId());
|
|
|
+ fullName.add(eu.getName() + eu.getExp());
|
|
|
+ while (eu.getId() != 1) {
|
|
|
+ eu = estateUnitDAO.findById(eu.getParentId());
|
|
|
+ fullName.add(eu.getName() + eu.getExp());
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String name : fullName) {
|
|
|
+ builder = new StringBuilder(name).append(builder);
|
|
|
+ }
|
|
|
+
|
|
|
+ return builder.toString();
|
|
|
+ }
|
|
|
}
|