<?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.stylefeng.guns.modular.system.dao.UserMgrDao">

	<sql id="Base_Column_List">
		id, account, name, birthday, sex, email,
		phone, roleid,
		deptid, status,
		createtime, version
	</sql>
	
	<sql id="Base_Column_List_With_Pwd">
		id, account, name, birthday,password, sex, email,
		phone, roleid,salt,
		deptid, status,
		createtime, version
	</sql>

	<select id="selectUsers" resultType="map">
		select
		<include refid="Base_Column_List" />
		from _user
		where status != 5
		<if test="condition != null and condition != ''">
			and (phone like CONCAT('%',#{condition},'%') 
			or account like CONCAT('%',#{condition},'%') 
			or name like CONCAT('%',#{condition},'%'))
		</if>
	</select>

	<update id="setStatus">
		update _user set status = #{status} where id =
		#{userId}
	</update>

	<update id="changePwd">
		update _user set password = #{pwd} where id =
		#{userId}
	</update>
	
	<update id="setRoles">
		update _user set roleid = #{roleIds} where id =
		#{userId}
	</update>
	
	<select id="getByAccount" resultType="user">
		select
		<include refid="Base_Column_List_With_Pwd" />
		from _user where account = #{account}
	</select>

</mapper>