<?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.sckw.example.dao.SysUserDao">
  <resultMap id="BaseResultMap" type="com.sckw.example.model.SysUser">
    <result column="id" property="id" />
    <result column="system_type" property="systemType" />
    <result column="account" property="account" />
    <result column="password" property="password" />
    <result column="name" property="name" />
    <result column="phone" property="phone" />
    <result column="photo" property="photo" />
    <result column="email" property="email" />
    <result column="is_main" property="isMain" />
    <result column="remark" property="remark" />
    <result column="status" property="status" />
    <result column="create_by" property="createBy" />
    <result column="create_time" property="createTime" />
    <result column="update_by" property="updateBy" />
    <result column="update_time" property="updateTime" />
    <result column="del_flag" property="delFlag" />
  </resultMap>

  <select id="findByAccount" parameterType="java.util.Map" resultType="com.sckw.example.model.SysUser">
    SELECT
      id, system_type systemType, account, password, name, phone, photo, email, is_main isMain,
      remark, status, create_by createBy, create_time createTime, update_by updateBy, update_time updateTime
    FROM
    sys_user
    where del_flag = 0
    <if test="systemType != null and systemType != ''">
      and system_type = #{systemType, jdbcType=VARCHAR}
    </if>
    <if test="account != null and account != ''">
      and account = #{account, jdbcType=VARCHAR}
    </if>
  </select>

  <select id="findPage" resultType="java.util.Map" parameterType="java.util.Map" >
    SELECT
    id, system_type systemType, account, password, name, phone, photo, email, is_main isMain,
    remark, status, create_by createBy, create_time createTime, update_by updateBy, update_time updateTime
    FROM
    sys_user u
    where del_flag = 0
    <if test="systemType != null and systemType != ''">
      and d.system_type = #{systemType, jdbcType=VARCHAR}
    </if>
    <if test="account != null and account != ''">
      and account = #{account, jdbcType=VARCHAR}
    </if>
    ORDER BY create_time desc
  </select>


</mapper>
