<?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.bicloud.mapper.UserMapper">

    <resultMap id="BaseResultMap" type="com.bicloud.pojo.entity.User">
        <id column="id" property="id"/>
        <result column="username" property="username"/>
        <result column="company" property="company"/>
        <result column="job" property="job"/>
        <result column="address" property="address"/>
        <result column="introduce" property="introduce"/>
        <result column="mobile" property="mobile"/>
        <result column="email" property="email"/>
        <result column="pwd" property="pwd"/>
        <result column="salt" property="salt"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <select id="selectByMobile" resultMap="BaseResultMap">
        SELECT * FROM users WHERE mobile = #{mobile}
    </select>

    <select id="selectByEmail" resultMap="BaseResultMap">
        SELECT * FROM users WHERE email = #{email}
    </select>

    <select id="selectByUsername" resultMap="BaseResultMap">
        SELECT * FROM users WHERE username = #{username}
    </select>

    <select id="selectById" resultMap="BaseResultMap">
        SELECT * FROM users WHERE id = #{id}
    </select>

    <insert id="insert" parameterType="com.bicloud.pojo.entity.User" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO users (username, company, job, address, introduce, mobile, email, pwd, salt, addtime, updtime)
        VALUES (#{username}, #{company}, #{job}, #{address}, #{introduce}, #{mobile}, #{email}, #{pwd}, #{salt}, #{createTime}, #{updateTime})
    </insert>

</mapper>
