Ver Fonte

finikes alpha 1

finikes há 2 anos atrás
pai
commit
5e79e1bc77

+ 7 - 1
src/main/java/com/finikes/oc/BaseDTO.java

@@ -13,6 +13,11 @@ public class BaseDTO {
         message = "OK";
     }
 
+    public BaseDTO(BizException be) {
+        this.code = be.code;
+        this.message = be.message;
+    }
+
     public BaseDTO(String code, String message) {
         this.code = code;
         this.message = message;
@@ -34,8 +39,9 @@ public class BaseDTO {
         this.message = message;
     }
 
-    public void setContent(Object content) {
+    public BaseDTO setContent(Object content) {
         this.content = content;
+        return this;
     }
 
     public Object getContent() {

+ 16 - 0
src/main/java/com/finikes/oc/BizException.java

@@ -0,0 +1,16 @@
+package com.finikes.oc;
+
+public class BizException extends RuntimeException {
+    protected String code;
+    protected String message;
+
+    public BizException(String code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    @Override
+    public Throwable fillInStackTrace() {
+        return null;
+    }
+}

+ 17 - 0
src/main/java/com/finikes/oc/Passports.java

@@ -0,0 +1,17 @@
+package com.finikes.oc;
+
+import com.finikes.oc.base.entity.Passport;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+public class Passports {
+    public static final Passport getPassport(HttpServletRequest request) {
+        HttpSession session = request.getSession();
+        if (null == session) {
+            return null;
+        }
+
+        return (Passport) session.getAttribute("PASSPORT");
+    }
+}

+ 68 - 2
src/main/java/com/finikes/oc/base/controller/PassportController.java

@@ -1,25 +1,91 @@
 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.RegisterResponseDTO;
+import com.finikes.oc.base.entity.Passport;
+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 javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.util.Date;
 import java.util.Map;
 
 @RequestMapping("/passport")
 @ResponseBody
 @Controller
 public class PassportController {
+    @Autowired
+    private PassportDAO passportDAO;
+
     @ResponseBody
     @RequestMapping(value = "/", method = RequestMethod.PUT)
     public BaseDTO register(@RequestBody Map<String, Object> map) {
         // 获取手机号码
         String mobile = (String) map.get("mobile");
-        // 如果已经注册就报错 TODO
+        String password = (String) map.get("password");
+        // 如果已经注册就报错
+        Passport tmp = passportDAO.findByMobile(mobile);
+        if (tmp != null && tmp.getState() == 1) {
+            return new BaseDTO(new BizException("100", "该手机号码已经注册"));
+        }
         // 预注册并生成短信验证码 TODO
-        return new BaseDTO();
+        String veriCode = "1234";
+        long now = System.currentTimeMillis();
+        long veriCodeDeadline = now + 60 * 1000 * 5;
+        int id = 0;
+        if (tmp == null) {
+            id = passportDAO.insert(mobile, password, veriCode, veriCodeDeadline);
+        } else {
+            passportDAO.updateVeriCode(mobile, veriCode, veriCodeDeadline);
+            id = tmp.getId();
+        }
+        RegisterResponseDTO dto = new RegisterResponseDTO();
+        dto.setPassportId(String.valueOf(id));
+        dto.setVerificationCode(veriCode);
+        return new BaseDTO().setContent(dto);
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "/", method = RequestMethod.POST)
+    public BaseDTO login(@RequestBody Map<String, Object> map, HttpServletRequest request,
+                         HttpServletResponse response) {
+        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", "登录失败"));
+        }
+
+        if ("1".equals(type)) { // 密码登录
+            if (securityCode.equals(tmp.getPassword())) {
+                HttpSession session = request.getSession();
+                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", "登录失败"));
+        }
     }
 }

+ 65 - 0
src/main/java/com/finikes/oc/base/controller/VerificationCodeController.java

@@ -0,0 +1,65 @@
+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.RegisterResponseDTO;
+import com.finikes.oc.base.entity.Passport;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+@RequestMapping("/verificationCode")
+@ResponseBody
+@Controller
+public class VerificationCodeController {
+    @Autowired
+    private PassportDAO passportDAO;
+
+    @ResponseBody
+    @RequestMapping(value = "/", method = RequestMethod.GET)
+    public BaseDTO refreshVeriCode(@RequestParam String mobile) {
+        // 如果已经注册就报错
+        Passport tmp = passportDAO.findByMobile(mobile);
+        // 预注册并生成短信验证码 TODO
+        String veriCode = "1234";
+        long now = System.currentTimeMillis();
+        long veriCodeDeadline = now + 60 * 1000 * 5;
+        int id = 0;
+        if (tmp == null) {
+            id = passportDAO.insert(mobile, null, veriCode, veriCodeDeadline);
+        } else {
+            passportDAO.updateVeriCode(mobile, veriCode, veriCodeDeadline);
+            id = tmp.getId();
+        }
+        RegisterResponseDTO dto = new RegisterResponseDTO();
+        dto.setPassportId(String.valueOf(id));
+        dto.setVerificationCode(veriCode);
+        return new BaseDTO().setContent(dto);
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "/", method = RequestMethod.POST)
+    public BaseDTO checkVeriCode(@RequestBody Map<String, Object> map) {
+        // 获取手机号码
+        String mobile = (String) map.get("mobile");
+        String verificationCode = (String) map.get("verificationCode");
+        // 如果已经注册就报错
+        Passport tmp = passportDAO.findByMobile(mobile);
+        if (tmp != null && tmp.getState() == 1) {
+            return new BaseDTO(new BizException("100", "该手机号码已经注册"));
+        }
+
+        String veriCode = tmp.getVeriCode();
+        long now = System.currentTimeMillis();
+        long veriCodeDeadline = now + 60 * 1000 * 5;
+        if (verificationCode.equals(veriCode) && veriCodeDeadline <= tmp.getVeriCodeDeadline()) {
+            passportDAO.updateState(mobile, 1, now);
+            return new BaseDTO();
+        } else {
+            return new BaseDTO(new BizException("103", "验证码错误或失效"));
+        }
+    }
+}

+ 16 - 0
src/main/java/com/finikes/oc/base/dao/PassportDAO.java

@@ -0,0 +1,16 @@
+package com.finikes.oc.base.dao;
+
+import com.finikes.oc.base.entity.Passport;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface PassportDAO {
+    Passport findByMobile(String mobile);
+
+    int insert(@Param("mobile") String mobile, @Param("password") String password, @Param("veriCode") String veriCode, @Param("veriCodeDeadline") long veriCodeDeadline);
+
+    void updateVeriCode(@Param("mobile") String mobile, @Param("veriCode") String veriCode, @Param("veriCodeDeadline") long veriCodeDeadline);
+
+    void updateState(@Param("mobile") String mobile, @Param("state") int state, @Param("createTime") long createTime);
+}

+ 22 - 0
src/main/java/com/finikes/oc/base/dto/RegisterResponseDTO.java

@@ -0,0 +1,22 @@
+package com.finikes.oc.base.dto;
+
+public class RegisterResponseDTO {
+    private String passportId;
+    private String verificationCode;
+
+    public String getPassportId() {
+        return passportId;
+    }
+
+    public void setPassportId(String passportId) {
+        this.passportId = passportId;
+    }
+
+    public String getVerificationCode() {
+        return verificationCode;
+    }
+
+    public void setVerificationCode(String verificationCode) {
+        this.verificationCode = verificationCode;
+    }
+}

+ 48 - 21
src/main/java/com/finikes/oc/base/entity/Passport.java

@@ -4,31 +4,58 @@ package com.finikes.oc.base.entity;
  * 账号通行证
  */
 public class Passport {
-	private int id;
-	private String mobile; // 手机号码
-	private String password; // 密码
+    private int id;
+    private String mobile; // 手机号码
+    private String password; // 密码
+    private transient int state;
+    private transient String veriCode;
+    private transient long veriCodeDeadline;
 
-	public int getId() {
-		return id;
-	}
+    public long getVeriCodeDeadline() {
+        return veriCodeDeadline;
+    }
 
-	public void setId(int id) {
-		this.id = id;
-	}
+    public void setVeriCodeDeadline(long veriCodeDeadline) {
+        this.veriCodeDeadline = veriCodeDeadline;
+    }
 
-	public String getMobile() {
-		return mobile;
-	}
+    public String getVeriCode() {
+        return veriCode;
+    }
 
-	public void setMobile(String mobile) {
-		this.mobile = mobile;
-	}
+    public void setVeriCode(String veriCode) {
+        this.veriCode = veriCode;
+    }
 
-	public String getPassword() {
-		return password;
-	}
+    public int getState() {
+        return state;
+    }
 
-	public void setPassword(String password) {
-		this.password = password;
-	}
+    public void setState(int state) {
+        this.state = state;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
 }

+ 45 - 0
src/main/java/com/finikes/oc/estate/controller/EstateController.java

@@ -0,0 +1,45 @@
+package com.finikes.oc.estate.controller;
+
+import com.finikes.oc.BaseDTO;
+import com.finikes.oc.base.dto.RegisterResponseDTO;
+import com.finikes.oc.estate.dao.EstateUnitDAO;
+import com.finikes.oc.estate.dao.HouseDAO;
+import com.finikes.oc.estate.dto.EstatesResponseDTO;
+import com.finikes.oc.estate.entity.EstateUnit;
+import com.finikes.oc.estate.entity.House;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+@RequestMapping("/estates")
+@ResponseBody
+@Controller
+public class EstateController {
+    @Autowired
+    private EstateUnitDAO estateUnitDAO;
+
+    @Autowired
+    private HouseDAO houseDAO;
+
+    @ResponseBody
+    @RequestMapping(value = "/", method = RequestMethod.GET)
+    public BaseDTO getEstatesByParent(@RequestParam String estateUnitId) {
+        EstateUnit eu = estateUnitDAO.findById(estateUnitId);
+        if(eu.isLeaf()) {
+            List<House> houses = houseDAO.findByUnitId(estateUnitId);
+            EstatesResponseDTO dto = new EstatesResponseDTO();
+            dto.setLeaf(true);
+            dto.setHouses(houses);
+            return new BaseDTO().setContent(dto);
+        }
+
+        List<EstateUnit> estateUnits = estateUnitDAO.findByParentId(estateUnitId);
+        EstatesResponseDTO dto = new EstatesResponseDTO();
+        dto.setLeaf(false);
+        dto.setSubs(estateUnits);
+        return new BaseDTO().setContent(dto);
+    }
+}

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

@@ -0,0 +1,77 @@
+package com.finikes.oc.estate.controller;
+
+import com.finikes.oc.BaseDTO;
+import com.finikes.oc.Passports;
+import com.finikes.oc.base.entity.Passport;
+import com.finikes.oc.estate.dao.HouseDAO;
+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.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.Map;
+
+@RequestMapping("/house")
+@ResponseBody
+@Controller
+public class HouseController {
+    @Autowired
+    private HouseRelationDAO houseRelationDAO;
+
+    @ResponseBody
+    @RequestMapping(value = "/passport", method = RequestMethod.PUT)
+    public BaseDTO bind(@RequestBody Map<String, Object> map, HttpServletRequest request) {
+        String certificateNo = (String) map.get("certificateNo");
+        String certificatePhoto = (String) map.get("certificatePhoto");
+        String houseId = (String) map.get("houseId");
+        Passport passport = Passports.getPassport(request);
+        if (passport == null) {
+            return new BaseDTO("104", "需要登录");
+        }
+
+        HouseRelation relation = houseRelationDAO.findByPassportAndHouse(passport.getId(), houseId);
+        if (relation != null) {
+            if (relation.getState() == 1) {
+                return new BaseDTO("105", "已绑定过");
+            } else {
+                relation.setState(2);
+                relation.setCertificateNo(certificateNo);
+                relation.setCertificateUrl(certificatePhoto);
+                houseRelationDAO.update(relation);
+                return new BaseDTO();
+            }
+        }
+
+        relation = new HouseRelation();
+        relation.setHouseId(Integer.parseInt(houseId));
+        relation.setPassportId(passport.getId());
+        relation.setState(2);
+        relation.setCertificateNo(certificateNo);
+        relation.setCertificateUrl(certificatePhoto);
+        houseRelationDAO.insert(relation);
+        return new BaseDTO();
+    }
+
+
+    @ResponseBody
+    @RequestMapping(value = "/passport/security", method = RequestMethod.POST)
+    public BaseDTO checkBind(@RequestBody Map<String, Object> map) {
+        String passportId = (String) map.get("passportId");
+        String houseId = (String) map.get("houseId");
+
+        HouseRelation relation = houseRelationDAO.findByPassportAndHouse(Integer.parseInt(passportId), houseId);
+        if (relation != null) {
+            if (relation.getState() == 1) {
+                return new BaseDTO();
+            } else {
+                houseRelationDAO.updateState(passportId, houseId, 1);
+                return new BaseDTO();
+            }
+        }
+
+        return new BaseDTO("000", "系统错误");
+    }
+}

+ 13 - 0
src/main/java/com/finikes/oc/estate/dao/EstateUnitDAO.java

@@ -0,0 +1,13 @@
+package com.finikes.oc.estate.dao;
+
+import com.finikes.oc.estate.entity.EstateUnit;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface EstateUnitDAO {
+    EstateUnit findById(String id);
+
+    List<EstateUnit> findByParentId(String parentId);
+}

+ 11 - 0
src/main/java/com/finikes/oc/estate/dao/HouseDAO.java

@@ -0,0 +1,11 @@
+package com.finikes.oc.estate.dao;
+
+import com.finikes.oc.estate.entity.House;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface HouseDAO {
+    List<House> findByUnitId(String estateUnitId);
+}

+ 36 - 0
src/main/java/com/finikes/oc/estate/dto/EstatesResponseDTO.java

@@ -0,0 +1,36 @@
+package com.finikes.oc.estate.dto;
+
+import com.finikes.oc.estate.entity.EstateUnit;
+import com.finikes.oc.estate.entity.House;
+
+import java.util.List;
+
+public class EstatesResponseDTO {
+    private boolean leaf;
+    private List<House> houses;
+    private List<EstateUnit> subs;
+
+    public boolean isLeaf() {
+        return leaf;
+    }
+
+    public void setLeaf(boolean leaf) {
+        this.leaf = leaf;
+    }
+
+    public List<House> getHouses() {
+        return houses;
+    }
+
+    public void setHouses(List<House> houses) {
+        this.houses = houses;
+    }
+
+    public List<EstateUnit> getSubs() {
+        return subs;
+    }
+
+    public void setSubs(List<EstateUnit> subs) {
+        this.subs = subs;
+    }
+}

+ 1 - 1
src/main/java/com/finikes/oc/estate/entity/House.java

@@ -4,7 +4,7 @@ package com.finikes.oc.estate.entity;
  * 房产
  */
 public class House {
-	private int unitId; // 属于那个单元(肯定是个物业单元的叶节点)
+	private transient int unitId; // 属于那个单元(肯定是个物业单元的叶节点)
 	private int id;
 	private String name; // 名称
 	private float area; // 面积

+ 24 - 0
src/main/java/com/finikes/oc/filter/CorsFilter.java

@@ -0,0 +1,24 @@
+package com.finikes.oc.filter;
+
+import org.springframework.stereotype.Component;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@Component
+public class CorsFilter implements Filter {
+
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+        HttpServletResponse httpServletResponse = (HttpServletResponse) response;
+        httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
+//        httpServletResponse.setHeader("Access-Control-Allow-Credentials", "true");
+        httpServletResponse.setHeader("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, DELETE");
+        httpServletResponse.setHeader("Access-Control-Max-Age", "3600");
+        httpServletResponse.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, client_id, uuid, Authorization");
+        httpServletResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
+        httpServletResponse.setHeader("Pragma", "no-cache");
+        chain.doFilter(request, httpServletResponse);
+    }
+}

+ 16 - 0
src/main/java/com/finikes/oc/management/dao/HouseRelationDAO.java

@@ -0,0 +1,16 @@
+package com.finikes.oc.management.dao;
+
+import com.finikes.oc.management.entity.HouseRelation;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface HouseRelationDAO {
+    HouseRelation findByPassportAndHouse(@Param("id") int id, @Param("houseId") String houseId);
+
+    void update(HouseRelation relation);
+
+    void insert(HouseRelation relation);
+
+    void updateState(@Param("passportId") String passportId, @Param("houseId") String houseId, @Param("state") int state);
+}

+ 18 - 0
src/main/java/com/finikes/oc/management/entity/HouseRelation.java

@@ -7,6 +7,24 @@ public class HouseRelation {
 	private int passportId; // 账号ID
 	private String certificateNo; // 房产证号码
 	private String certificateUrl; // 房产证图片地址(相对)
+	private int houseId;
+	private int state;
+
+	public int getState() {
+		return state;
+	}
+
+	public void setState(int state) {
+		this.state = state;
+	}
+
+	public int getHouseId() {
+		return houseId;
+	}
+
+	public void setHouseId(int houseId) {
+		this.houseId = houseId;
+	}
 
 	public int getPassportId() {
 		return passportId;

+ 17 - 0
src/main/resources/mapper/EstateUnitMapper.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.finikes.oc.estate.dao.EstateUnitDAO">
+
+    <select id="findById" resultType="com.finikes.oc.estate.entity.EstateUnit">
+        SELECT id, unitId, name, area, function
+        FROM t_house
+        WHERE id = #{id}
+    </select>
+
+    <select id="findByParentId" resultType="com.finikes.oc.estate.entity.EstateUnit">
+        SELECT id, unitId, name, area, function
+        FROM t_house
+        WHERE unitId = #{unitId}
+    </select>
+
+</mapper>

+ 11 - 0
src/main/resources/mapper/HouseMapper.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.finikes.oc.estate.dao.HouseDAO">
+
+    <select id="findByUnitId" resultType="com.finikes.oc.estate.entity.House">
+        SELECT id, unitId, name, area, function
+        FROM t_house
+        WHERE unitId = #{unitId}
+    </select>
+
+</mapper>

+ 30 - 0
src/main/resources/mapper/HouseRelationMapper.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.finikes.oc.management.dao.HouseRelationDAO">
+
+    <insert id="insert" useGeneratedKeys="true" keyProperty="id" keyColumn="id"
+            parameterType="com.finikes.oc.management.entity.HouseRelation">
+        INSERT INTO t_house_relation (passportId, houseId, state, certificateNo, certificateUrl)
+        VALUES (#{passportId}, #{houseId}, #{state}, #{certificateNo}, #{certificateUrl})
+    </insert>
+
+    <select id="findByPassportAndHouse" resultType="com.finikes.oc.management.entity.HouseRelation">
+        SELECT passportId, houseId, state, certificateNo, certificateUrl
+        FROM t_house_relation
+        WHERE passportId = #{passportId} AND houseId = #{houseId}
+    </select>
+
+    <update id="updateVeriCode" parameterType="com.finikes.oc.base.entity.Passport">
+        UPDATE t_house_relation
+        SET state      = #{state},
+            certificateNo = #{certificateNo},
+            certificateUrl = #{certificateUrl}
+        WHERE mobile = #{mobile}
+    </update>
+
+    <update id="updateState">
+        UPDATE t_house_relation
+        SET state      = #{state}
+        WHERE passportId = #{passportId} AND houseId = #{houseId}
+    </update>
+</mapper>

+ 30 - 0
src/main/resources/mapper/PassportMapper.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.finikes.oc.base.dao.PassportDAO">
+
+    <insert id="insert" useGeneratedKeys="true" keyProperty="id" keyColumn="id"
+            parameterType="com.finikes.oc.base.entity.Passport">
+        INSERT INTO t_passport (mobile, password, veriCode, veriCodeDeadline)
+        VALUES (#{mobile}, #{password}, #{veriCode}, #{veriCodeDeadline})
+    </insert>
+
+    <select id="findByMobile" parameterType="java.lang.String" resultType="com.finikes.oc.base.entity.Passport">
+        SELECT id, mobile, password, veriCode, state, veriCodeDeadline
+        FROM t_passport
+        WHERE mobile = #{mobile}
+    </select>
+
+    <update id="updateVeriCode" parameterType="com.finikes.oc.base.entity.Passport">
+        UPDATE t_passport
+        SET veriCode         = #{veriCode},
+            veriCodeDeadline = #{veriCodeDeadline}
+        WHERE mobile = #{mobile}
+    </update>
+
+    <update id="updateState" parameterType="com.finikes.oc.base.entity.Passport">
+        UPDATE t_passport
+        SET state      = #{state},
+            createTime = #{createTime}
+        WHERE mobile = #{mobile}
+    </update>
+</mapper>