<?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.hzya.frame.sys.user.dao.impl.UserMapperImpl">
	<resultMap id="get-entity-result" type="com.hzya.frame.sys.user.entity.User">
		<!--主键ID -->
		<result property="id" column="id" />
		<!--显示名称 -->
		<result property="viewName" column="view_name" />
		<!--登录名 -->
		<result property="loginName" column="login_name" />
		<!--密码 -->
		<result property="password" column="password" />
		<!--加密策略 -->
		<result property="encryptionPolicy" column="encryption_policy" />
		<!--密码超期时间 -->
		<result property="expirationDate" column="expiration_date" />
		<!--密码次数 -->
		<result property="pawFrequency" column="paw_frequency" />
		<!--员工ID(人员编号) -->
		<result property="staffId" column="staff_id" />
		<!--头像路径 -->
		<result property="iconUrl" column="icon_url" />
		<!--是否启用 1:启用 0停用 -->
		<result property="state" column="state" />
		<!--是否是内部 1:是 0:否 -->
		<result property="builtIn" column="built_in" />
		<!--用户级别 -->
		<result property="level" column="level" />
		<!--电子邮件 -->
		<result property="email" column="email" />
		<!--手机号码 -->
		<result property="phone" column="phone" />
		<!--职务级别 -->
		<result property="userLvl" column="user_lvl" />
		<!--性别（0:男，1：女） -->
		<result property="sex" column="sex" />
		<!--锁定状态（0:锁定，1：未锁定） -->
		<result property="lockState" column="lock_state" />
		<!--在职/离职 1：在职 2：离职 -->
		<result property="useState" column="use_state" />
		<!--微信tocken -->
		<result property="wechatToken" column="wechat_token" />
		<!--是否可以登录 1:是 0:否 -->
		<result property="isLoginable" column="is_loginable" />
		<!--是否是虚拟账号 1:是 0:否 -->
		<result property="isVirtual" column="is_virtual" />
		<!--是否是管理员 1:是 0:否 -->
		<result property="isAdmin" column="is_admin" />
		<!--是否被分配 1:是 0:否 -->
		<result property="isAssigned" column="is_assigned" />
		<!--枚举：1：正式 2：非正式 -->
		<result property="memberType" column="member_type" />
		<!--是否被删除 1:删除  0:未删除 -->
		<result property="isDeleted" column="is_deleted" />
		<!--内外标识 0：内部1:  外部人员  -->
		<result property="externalType" column="external_type" />
		<!--编号 -->
		<result property="memberCode" column="member_code" />
		<!--出生日期 -->
		<result property="birthDate" column="birth_date" />
		<!--办公电话 -->
		<result property="officeTel" column="office_tel" />
		<!--备注 -->
		<result property="remarks" column="remarks" />
		<!--人员照片地址 -->
		<result property="photoAddress" column="photo_address" />
		<!--所属部门 -->
		<result property="department" column="department" />
		<!--排序 -->
		<result property="sorts" column="sorts" />
		<!--主岗 -->
		<result property="majorPosition" column="major_position" />
		<!--副岗 -->
		<result property="deputyPost" column="deputy_post" />
		<!--人员类型 -->
		<result property="userType" column="user_type" />
		<!--人员状态 -->
		<result property="personnelStatus" column="personnel_status" />
		<!--工作地 -->
		<result property="workplace" column="workplace" />
		<!--入职时间 -->
		<result property="entryTime" column="entry_time" />
		<!--汇报人 -->
		<result property="reporter" column="reporter" />
		<!--创建人id -->
		<result property="createUserId" column="create_user_id" />
		<!--创建时间 -->
		<result property="createTime" column="create_time" />
		<!--修改人id -->
		<result property="modifyUserId" column="modify_user_id" />
		<!--修改时间 -->
		<result property="modifyTime" column="modify_time" />
		<!--状态(Y正常N删除) -->
		<result property="sts" column="sts" />
		<!--组织机构ID -->
		<result property="orgId" column="org_id" />
	</resultMap>

	<sql id="Base_Column_List">
		id,
		view_name,
		login_name,
		password,
		encryption_policy,
		expiration_date,
		paw_frequency,
		staff_id,
		icon_url,
		state,
		built_in,
		level,
		email,
		phone,
		user_lvl,
		sex,
		lock_state,
		use_state,
		wechat_token,
		is_loginable,
		is_virtual,
		is_admin,
		is_assigned,
		member_type,
		is_deleted,
		external_type,
		member_code,
		birth_date,
		office_tel,
		remarks,
		photo_address,
		department,
		sorts,
		major_position,
		deputy_post,
		user_type,
		personnel_status,
		workplace,
		entry_time,
		reporter,
		create_user_id,
		create_time,
		modify_user_id,
		modify_time,
		sts,
		org_id
	</sql>

	<!--通过ID获取数据 -->
	<select id="entity_get" resultMap="get-entity-result">
		select
		<include refid="Base_Column_List" />
		from sys_user where id = #{ id } and sts='Y'
	</select>

	<!-- 查询 采用==查询 -->
	<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.user.entity.User">
		select
		<if test="viewFiledList != null and viewFiledList.size>0">
			<foreach collection="viewFiledList" item="item" index="index" separator=",">
				${item.datebaseName}
			</foreach>
		</if>
		<if test="viewFiledList == null or viewFiledList.size == 0">
			<include refid="Base_Column_List" />
		</if>
		from sys_user
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="viewName != null and viewName !='' "> and view_name = #{viewName}</if>
			<if test="loginName != null and loginName !='' "> and login_name = #{loginName}</if>
			<if test="password != null and password !='' "> and password = #{password}</if>
			<if test="encryptionPolicy != null and encryptionPolicy !='' "> and encryption_policy = #{encryptionPolicy}</if>
			<if test="expirationDate != null "> and expiration_date = #{expirationDate}</if>
			<if test="pawFrequency != null "> and paw_frequency = #{pawFrequency}</if>
			<if test="staffId != null and staffId !='' "> and staff_id = #{staffId}</if>
			<if test="iconUrl != null and iconUrl !='' "> and icon_url = #{iconUrl}</if>
			<if test="state != null and state !='' "> and state = #{state}</if>
			<if test="builtIn != null and builtIn !='' "> and built_in = #{builtIn}</if>
			<if test="level != null and level !='' "> and level = #{level}</if>
			<if test="email != null and email !='' "> and email = #{email}</if>
			<if test="phone != null and phone !='' "> and phone = #{phone}</if>
			<if test="userLvl != null and userLvl !='' "> and user_lvl = #{userLvl}</if>
			<if test="sex != null and sex !='' "> and sex = #{sex}</if>
			<if test="lockState != null and lockState !='' "> and lock_state = #{lockState}</if>
			<if test="useState != null and useState !='' "> and use_state = #{useState}</if>
			<if test="wechatToken != null and wechatToken !='' "> and wechat_token = #{wechatToken}</if>
			<if test="isLoginable != null and isLoginable !='' "> and is_loginable = #{isLoginable}</if>
			<if test="isVirtual != null and isVirtual !='' "> and is_virtual = #{isVirtual}</if>
			<if test="isAdmin != null and isAdmin !='' "> and is_admin = #{isAdmin}</if>
			<if test="isAssigned != null and isAssigned !='' "> and is_assigned = #{isAssigned}</if>
			<if test="memberType != null and memberType !='' "> and member_type = #{memberType}</if>
			<if test="isDeleted != null and isDeleted !='' "> and is_deleted = #{isDeleted}</if>
			<if test="externalType != null and externalType !='' "> and external_type = #{externalType}</if>
			<if test="memberCode != null and memberCode !='' "> and member_code = #{memberCode}</if>
			<if test="birthDate != null "> and birth_date = #{birthDate}</if>
			<if test="officeTel != null and officeTel !='' "> and office_tel = #{officeTel}</if>
			<if test="remarks != null and remarks !='' "> and remarks = #{remarks}</if>
			<if test="photoAddress != null and photoAddress !='' "> and photo_address = #{photoAddress}</if>
			<if test="department != null and department !='' "> and department = #{department}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="majorPosition != null and majorPosition !='' "> and major_position = #{majorPosition}</if>
			<if test="deputyPost != null and deputyPost !='' "> and deputy_post = #{deputyPost}</if>
			<if test="userType != null and userType !='' "> and user_type = #{userType}</if>
			<if test="personnelStatus != null and personnelStatus !='' "> and personnel_status = #{personnelStatus}</if>
			<if test="workplace != null and workplace !='' "> and workplace = #{workplace}</if>
			<if test="entryTime != null "> and entry_time = #{entryTime}</if>
			<if test="reporter != null and reporter !='' "> and reporter = #{reporter}</if>
			<if test="createUserId != null and createUserId !='' "> and create_user_id = #{createUserId}</if>
			<if test="createTime != null "> and create_time = #{createTime}</if>
			<if test="modifyUserId != null and modifyUserId !='' "> and modify_user_id = #{modifyUserId}</if>
			<if test="modifyTime != null "> and modify_time = #{modifyTime}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</if>
			<if test="orgId != null and orgId !='' "> and org_id = #{orgId}</if>
			<if test="userRoles != null and userRoles.size>0">
				AND id in
				<foreach collection="userRoles" item="item" index="index" open="(" close=")" separator=",">
					#{item.userId}
				</foreach>
			</if>
		</trim>
		<if test=" sort == null or sort =='' "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
	</select>

	<!-- 查询符合条件的数量 -->
	<select id="entity_count" resultType="Integer" parameterType="com.hzya.frame.sys.user.entity.User">
		select count(1) from sys_user
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="viewName != null and viewName !='' "> and view_name = #{viewName}</if>
			<if test="loginName != null and loginName !='' "> and login_name = #{loginName}</if>
			<if test="password != null and password !='' "> and password = #{password}</if>
			<if test="encryptionPolicy != null and encryptionPolicy !='' "> and encryption_policy = #{encryptionPolicy}</if>
			<if test="expirationDate != null "> and expiration_date = #{expirationDate}</if>
			<if test="pawFrequency != null "> and paw_frequency = #{pawFrequency}</if>
			<if test="staffId != null and staffId !='' "> and staff_id = #{staffId}</if>
			<if test="iconUrl != null and iconUrl !='' "> and icon_url = #{iconUrl}</if>
			<if test="state != null and state !='' "> and state = #{state}</if>
			<if test="builtIn != null and builtIn !='' "> and built_in = #{builtIn}</if>
			<if test="level != null and level !='' "> and level = #{level}</if>
			<if test="email != null and email !='' "> and email = #{email}</if>
			<if test="phone != null and phone !='' "> and phone = #{phone}</if>
			<if test="userLvl != null and userLvl !='' "> and user_lvl = #{userLvl}</if>
			<if test="sex != null and sex !='' "> and sex = #{sex}</if>
			<if test="lockState != null and lockState !='' "> and lock_state = #{lockState}</if>
			<if test="useState != null and useState !='' "> and use_state = #{useState}</if>
			<if test="wechatToken != null and wechatToken !='' "> and wechat_token = #{wechatToken}</if>
			<if test="isLoginable != null and isLoginable !='' "> and is_loginable = #{isLoginable}</if>
			<if test="isVirtual != null and isVirtual !='' "> and is_virtual = #{isVirtual}</if>
			<if test="isAdmin != null and isAdmin !='' "> and is_admin = #{isAdmin}</if>
			<if test="isAssigned != null and isAssigned !='' "> and is_assigned = #{isAssigned}</if>
			<if test="memberType != null and memberType !='' "> and member_type = #{memberType}</if>
			<if test="isDeleted != null and isDeleted !='' "> and is_deleted = #{isDeleted}</if>
			<if test="externalType != null and externalType !='' "> and external_type = #{externalType}</if>
			<if test="memberCode != null and memberCode !='' "> and member_code = #{memberCode}</if>
			<if test="birthDate != null "> and birth_date = #{birthDate}</if>
			<if test="officeTel != null and officeTel !='' "> and office_tel = #{officeTel}</if>
			<if test="remarks != null and remarks !='' "> and remarks = #{remarks}</if>
			<if test="photoAddress != null and photoAddress !='' "> and photo_address = #{photoAddress}</if>
			<if test="department != null and department !='' "> and department = #{department}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="majorPosition != null and majorPosition !='' "> and major_position = #{majorPosition}</if>
			<if test="deputyPost != null and deputyPost !='' "> and deputy_post = #{deputyPost}</if>
			<if test="userType != null and userType !='' "> and user_type = #{userType}</if>
			<if test="personnelStatus != null and personnelStatus !='' "> and personnel_status = #{personnelStatus}</if>
			<if test="workplace != null and workplace !='' "> and workplace = #{workplace}</if>
			<if test="entryTime != null "> and entry_time = #{entryTime}</if>
			<if test="reporter != null and reporter !='' "> and reporter = #{reporter}</if>
			<if test="createUserId != null and createUserId !='' "> and create_user_id = #{createUserId}</if>
			<if test="createTime != null "> and create_time = #{createTime}</if>
			<if test="modifyUserId != null and modifyUserId !='' "> and modify_user_id = #{modifyUserId}</if>
			<if test="modifyTime != null "> and modify_time = #{modifyTime}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</if>
			<if test="orgId != null and orgId !='' "> and org_id = #{orgId}</if>
		</trim>
	</select>

	<!-- 分页查询列表 采用like格式 -->
	<select id="entity_list_like" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.user.entity.User">
		select
		<if test="viewFiledList != null and viewFiledList.size>0">
			<foreach collection="viewFiledList" item="item" index="index" separator=",">
				${item.datebaseName}
			</foreach>
		</if>
		<if test="viewFiledList == null or viewFiledList.size == 0">
			<include refid="Base_Column_List" />
		</if>
		from sys_user
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' "> id like concat('%',#{id},'%') </if>
			<if test="viewName != null and viewName !='' "> and view_name like concat('%',#{viewName},'%') </if>
			<if test="loginName != null and loginName !='' "> and login_name like concat('%',#{loginName},'%') </if>
			<if test="password != null and password !='' "> and password like concat('%',#{password},'%') </if>
			<if test="encryptionPolicy != null and encryptionPolicy !='' "> and encryption_policy like concat('%',#{encryptionPolicy},'%') </if>
			<if test="expirationDate != null and expirationDate !='' "> and expiration_date like concat('%',#{expirationDate},'%') </if>
			<if test="pawFrequency != null "> and paw_frequency = #{pawFrequency}</if>
			<if test="staffId != null and staffId !='' "> and staff_id like concat('%',#{staffId},'%') </if>
			<if test="iconUrl != null and iconUrl !='' "> and icon_url like concat('%',#{iconUrl},'%') </if>
			<if test="state != null and state !='' "> and state like concat('%',#{state},'%') </if>
			<if test="builtIn != null and builtIn !='' "> and built_in like concat('%',#{builtIn},'%') </if>
			<if test="level != null and level !='' "> and level like concat('%',#{level},'%') </if>
			<if test="email != null and email !='' "> and email like concat('%',#{email},'%') </if>
			<if test="phone != null and phone !='' "> and phone like concat('%',#{phone},'%') </if>
			<if test="userLvl != null and userLvl !='' "> and user_lvl like concat('%',#{userLvl},'%') </if>
			<if test="sex != null and sex !='' "> and sex like concat('%',#{sex},'%') </if>
			<if test="lockState != null and lockState !='' "> and lock_state like concat('%',#{lockState},'%') </if>
			<if test="useState != null and useState !='' "> and use_state like concat('%',#{useState},'%') </if>
			<if test="wechatToken != null and wechatToken !='' "> and wechat_token like concat('%',#{wechatToken},'%') </if>
			<if test="isLoginable != null and isLoginable !='' "> and is_loginable like concat('%',#{isLoginable},'%') </if>
			<if test="isVirtual != null and isVirtual !='' "> and is_virtual like concat('%',#{isVirtual},'%') </if>
			<if test="isAdmin != null and isAdmin !='' "> and is_admin like concat('%',#{isAdmin},'%') </if>
			<if test="isAssigned != null and isAssigned !='' "> and is_assigned like concat('%',#{isAssigned},'%') </if>
			<if test="memberType != null and memberType !='' "> and member_type like concat('%',#{memberType},'%') </if>
			<if test="isDeleted != null and isDeleted !='' "> and is_deleted like concat('%',#{isDeleted},'%') </if>
			<if test="externalType != null and externalType !='' "> and external_type like concat('%',#{externalType},'%') </if>
			<if test="memberCode != null and memberCode !='' "> and member_code like concat('%',#{memberCode},'%') </if>
			<if test="birthDate != null and birthDate !='' "> and birth_date like concat('%',#{birthDate},'%') </if>
			<if test="officeTel != null and officeTel !='' "> and office_tel like concat('%',#{officeTel},'%') </if>
			<if test="remarks != null and remarks !='' "> and remarks like concat('%',#{remarks},'%') </if>
			<if test="photoAddress != null and photoAddress !='' "> and photo_address like concat('%',#{photoAddress},'%') </if>
			<if test="department != null and department !='' "> and department like concat('%',#{department},'%') </if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="majorPosition != null and majorPosition !='' "> and major_position like concat('%',#{majorPosition},'%') </if>
			<if test="deputyPost != null and deputyPost !='' "> and deputy_post like concat('%',#{deputyPost},'%') </if>
			<if test="userType != null and userType !='' "> and user_type like concat('%',#{userType},'%') </if>
			<if test="personnelStatus != null and personnelStatus !='' "> and personnel_status like concat('%',#{personnelStatus},'%') </if>
			<if test="workplace != null and workplace !='' "> and workplace like concat('%',#{workplace},'%') </if>
			<if test="entryTime != null and entryTime !='' "> and entry_time like concat('%',#{entryTime},'%') </if>
			<if test="reporter != null and reporter !='' "> and reporter like concat('%',#{reporter},'%') </if>
			<if test="createUserId != null and createUserId !='' "> and create_user_id like concat('%',#{createUserId},'%') </if>
			<if test="createTime != null and createTime !='' "> and create_time like concat('%',#{createTime},'%') </if>
			<if test="modifyUserId != null and modifyUserId !='' "> and modify_user_id like concat('%',#{modifyUserId},'%') </if>
			<if test="modifyTime != null and modifyTime !='' "> and modify_time like concat('%',#{modifyTime},'%') </if>
			<if test="sts != null and sts !='' "> and sts like concat('%',#{sts},'%') </if>
			<if test="orgId != null and orgId !='' "> and org_id like concat('%',#{orgId},'%') </if>
		</trim>
		<if test=" sort == null or sort =='' "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by  ${sort} ${order}</if>
	</select>

	<!-- 查询列表 字段采用or格式 -->
	<select id="entity_list_or" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.user.entity.User">
		select
		<if test="viewFiledList != null and viewFiledList.size>0">
			<foreach collection="viewFiledList" item="item" index="index" separator=",">
				${item.datebaseName}
			</foreach>
		</if>
		<if test="viewFiledList == null or viewFiledList.size == 0">
			<include refid="Base_Column_List" />
		</if>
		from sys_user
		<trim prefix="where" prefixOverrides="or">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="viewName != null and viewName !='' "> or view_name = #{viewName} </if>
			<if test="loginName != null and loginName !='' "> or login_name = #{loginName} </if>
			<if test="password != null and password !='' "> or password = #{password} </if>
			<if test="encryptionPolicy != null and encryptionPolicy !='' "> or encryption_policy = #{encryptionPolicy} </if>
			<if test="expirationDate != null and expirationDate !='' "> or expiration_date = #{expirationDate} </if>
			<if test="pawFrequency != null "> or paw_frequency = #{pawFrequency}</if>
			<if test="staffId != null and staffId !='' "> or staff_id = #{staffId} </if>
			<if test="iconUrl != null and iconUrl !='' "> or icon_url = #{iconUrl} </if>
			<if test="state != null and state !='' "> or state = #{state} </if>
			<if test="builtIn != null and builtIn !='' "> or built_in = #{builtIn} </if>
			<if test="level != null and level !='' "> or level = #{level} </if>
			<if test="email != null and email !='' "> or email = #{email} </if>
			<if test="phone != null and phone !='' "> or phone = #{phone} </if>
			<if test="userLvl != null and userLvl !='' "> or user_lvl = #{userLvl} </if>
			<if test="sex != null and sex !='' "> or sex = #{sex} </if>
			<if test="lockState != null and lockState !='' "> or lock_state = #{lockState} </if>
			<if test="useState != null and useState !='' "> or use_state = #{useState} </if>
			<if test="wechatToken != null and wechatToken !='' "> or wechat_token = #{wechatToken} </if>
			<if test="isLoginable != null and isLoginable !='' "> or is_loginable = #{isLoginable} </if>
			<if test="isVirtual != null and isVirtual !='' "> or is_virtual = #{isVirtual} </if>
			<if test="isAdmin != null and isAdmin !='' "> or is_admin = #{isAdmin} </if>
			<if test="isAssigned != null and isAssigned !='' "> or is_assigned = #{isAssigned} </if>
			<if test="memberType != null and memberType !='' "> or member_type = #{memberType} </if>
			<if test="isDeleted != null and isDeleted !='' "> or is_deleted = #{isDeleted} </if>
			<if test="externalType != null and externalType !='' "> or external_type = #{externalType} </if>
			<if test="memberCode != null and memberCode !='' "> or member_code = #{memberCode} </if>
			<if test="birthDate != null and birthDate !='' "> or birth_date = #{birthDate} </if>
			<if test="officeTel != null and officeTel !='' "> or office_tel = #{officeTel} </if>
			<if test="remarks != null and remarks !='' "> or remarks = #{remarks} </if>
			<if test="photoAddress != null and photoAddress !='' "> or photo_address = #{photoAddress} </if>
			<if test="department != null and department !='' "> or department = #{department} </if>
			<if test="sorts != null "> or sorts = #{sorts}</if>
			<if test="majorPosition != null and majorPosition !='' "> or major_position = #{majorPosition} </if>
			<if test="deputyPost != null and deputyPost !='' "> or deputy_post = #{deputyPost} </if>
			<if test="userType != null and userType !='' "> or user_type = #{userType} </if>
			<if test="personnelStatus != null and personnelStatus !='' "> or personnel_status = #{personnelStatus} </if>
			<if test="workplace != null and workplace !='' "> or workplace = #{workplace} </if>
			<if test="entryTime != null and entryTime !='' "> or entry_time = #{entryTime} </if>
			<if test="reporter != null and reporter !='' "> or reporter = #{reporter} </if>
			<if test="createUserId != null and createUserId !='' "> or create_user_id = #{createUserId} </if>
			<if test="createTime != null and createTime !='' "> or create_time = #{createTime} </if>
			<if test="modifyUserId != null and modifyUserId !='' "> or modify_user_id = #{modifyUserId} </if>
			<if test="modifyTime != null and modifyTime !='' "> or modify_time = #{modifyTime} </if>
			<if test="sts != null and sts !='' "> or sts = #{sts} </if>
			<if test="orgId != null and orgId !='' "> or org_id = #{orgId} </if>
		</trim>
		<if test=" sort == null or sort =='' "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by  ${sort} ${order}</if>
	</select>
	<!-- 新增 -->
	<insert id="entity_insert" parameterType="com.hzya.frame.sys.user.entity.User">
		insert into sys_user(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> id, </if>
			<if test="viewName != null and viewName !='' "> view_name, </if>
			<if test="loginName != null and loginName !='' "> login_name, </if>
			<if test="password != null and password !='' "> password, </if>
			<if test="encryptionPolicy != null and encryptionPolicy !='' "> encryption_policy, </if>
			<if test="expirationDate != null ">expiration_date,</if>
			<if test="pawFrequency != null ">paw_frequency,</if>
			<if test="staffId != null and staffId !='' "> staff_id, </if>
			<if test="iconUrl != null and iconUrl !='' "> icon_url, </if>
			<if test="state != null and state !='' "> state, </if>
			<if test="builtIn != null and builtIn !='' "> built_in, </if>
			<if test="level != null and level !='' "> level, </if>
			<if test="email != null and email !='' "> email, </if>
			<if test="phone != null and phone !='' "> phone, </if>
			<if test="userLvl != null and userLvl !='' "> user_lvl, </if>
			<if test="sex != null and sex !='' "> sex, </if>
			<if test="lockState != null and lockState !='' "> lock_state, </if>
			<if test="useState != null and useState !='' "> use_state, </if>
			<if test="wechatToken != null and wechatToken !='' "> wechat_token, </if>
			<if test="isLoginable != null and isLoginable !='' "> is_loginable, </if>
			<if test="isVirtual != null and isVirtual !='' "> is_virtual, </if>
			<if test="isAdmin != null and isAdmin !='' "> is_admin, </if>
			<if test="isAssigned != null and isAssigned !='' "> is_assigned, </if>
			<if test="memberType != null and memberType !='' "> member_type, </if>
			<if test="isDeleted != null and isDeleted !='' "> is_deleted, </if>
			<if test="externalType != null and externalType !='' "> external_type, </if>
			<if test="memberCode != null and memberCode !='' "> member_code, </if>
			<if test="birthDate != null ">birth_date,</if>
			<if test="officeTel != null and officeTel !='' "> office_tel, </if>
			<if test="remarks != null and remarks !='' "> remarks, </if>
			<if test="photoAddress != null and photoAddress !='' "> photo_address, </if>
			<if test="department != null and department !='' "> department, </if>
			<if test="sorts != null ">sorts,</if>
			<if test="majorPosition != null and majorPosition !='' "> major_position, </if>
			<if test="deputyPost != null and deputyPost !='' "> deputy_post, </if>
			<if test="userType != null and userType !='' "> user_type, </if>
			<if test="personnelStatus != null and personnelStatus !='' "> personnel_status, </if>
			<if test="workplace != null and workplace !='' "> workplace, </if>
			<if test="entryTime != null ">entry_time,</if>
			<if test="reporter != null and reporter !='' "> reporter, </if>
			<if test="createUserId != null and createUserId !='' "> create_user_id, </if>
			<if test="createTime != null ">create_time,</if>
			<if test="modifyUserId != null and modifyUserId !='' "> modify_user_id, </if>
			<if test="modifyTime != null ">modify_time,</if>
			<if test="sts != null and sts !='' "> sts, </if>
			<if test="orgId != null and orgId !='' "> org_id, </if>
		</trim>
		)values
		(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> #{id}, </if>
			<if test="viewName != null and viewName !='' "> #{viewName}, </if>
			<if test="loginName != null and loginName !='' "> #{loginName}, </if>
			<if test="password != null and password !='' "> #{password}, </if>
			<if test="encryptionPolicy != null and encryptionPolicy !='' "> #{encryptionPolicy}, </if>
			<if test="expirationDate != null ">#{expirationDate},</if>
			<if test="pawFrequency != null ">#{pawFrequency},</if>
			<if test="staffId != null and staffId !='' "> #{staffId}, </if>
			<if test="iconUrl != null and iconUrl !='' "> #{iconUrl}, </if>
			<if test="state != null and state !='' "> #{state}, </if>
			<if test="builtIn != null and builtIn !='' "> #{builtIn}, </if>
			<if test="level != null and level !='' "> #{level}, </if>
			<if test="email != null and email !='' "> #{email}, </if>
			<if test="phone != null and phone !='' "> #{phone}, </if>
			<if test="userLvl != null and userLvl !='' "> #{userLvl}, </if>
			<if test="sex != null and sex !='' "> #{sex}, </if>
			<if test="lockState != null and lockState !='' "> #{lockState}, </if>
			<if test="useState != null and useState !='' "> #{useState}, </if>
			<if test="wechatToken != null and wechatToken !='' "> #{wechatToken}, </if>
			<if test="isLoginable != null and isLoginable !='' "> #{isLoginable}, </if>
			<if test="isVirtual != null and isVirtual !='' "> #{isVirtual}, </if>
			<if test="isAdmin != null and isAdmin !='' "> #{isAdmin}, </if>
			<if test="isAssigned != null and isAssigned !='' "> #{isAssigned}, </if>
			<if test="memberType != null and memberType !='' "> #{memberType}, </if>
			<if test="isDeleted != null and isDeleted !='' "> #{isDeleted}, </if>
			<if test="externalType != null and externalType !='' "> #{externalType}, </if>
			<if test="memberCode != null and memberCode !='' "> #{memberCode}, </if>
			<if test="birthDate != null ">#{birthDate},</if>
			<if test="officeTel != null and officeTel !='' "> #{officeTel}, </if>
			<if test="remarks != null and remarks !='' "> #{remarks}, </if>
			<if test="photoAddress != null and photoAddress !='' "> #{photoAddress}, </if>
			<if test="department != null and department !='' "> #{department}, </if>
			<if test="sorts != null ">#{sorts},</if>
			<if test="majorPosition != null and majorPosition !='' "> #{majorPosition}, </if>
			<if test="deputyPost != null and deputyPost !='' "> #{deputyPost}, </if>
			<if test="userType != null and userType !='' "> #{userType}, </if>
			<if test="personnelStatus != null and personnelStatus !='' "> #{personnelStatus}, </if>
			<if test="workplace != null and workplace !='' "> #{workplace}, </if>
			<if test="entryTime != null ">#{entryTime},</if>
			<if test="reporter != null and reporter !='' "> #{reporter}, </if>
			<if test="createUserId != null and createUserId !='' "> #{createUserId}, </if>
			<if test="createTime != null ">#{createTime},</if>
			<if test="modifyUserId != null and modifyUserId !='' "> #{modifyUserId}, </if>
			<if test="modifyTime != null ">#{modifyTime},</if>
			<if test="sts != null and sts !='' "> #{sts}, </if>
			<if test="orgId != null and orgId !='' "> #{orgId}, </if>
		</trim>
		)
	</insert>

	<!-- 修改 -->
	<update id="entity_update" parameterType="com.hzya.frame.sys.user.entity.User">
		update sys_user set
		<trim suffix="" suffixOverrides=",">
				<if test="viewName != null and viewName !='' "> view_name = #{viewName},</if>
				<if test="loginName != null and loginName !='' "> login_name = #{loginName},</if>
				<if test="password != null and password !='' "> password = #{password},</if>
				<if test="encryptionPolicy != null and encryptionPolicy !='' "> encryption_policy = #{encryptionPolicy},</if>
				<if test="expirationDate != null ">expiration_date = #{expirationDate},</if>
				<if test="pawFrequency != null ">paw_frequency = #{pawFrequency},</if>
				<if test="staffId != null and staffId !='' "> staff_id = #{staffId},</if>
				<if test="iconUrl != null and iconUrl !='' "> icon_url = #{iconUrl},</if>
				<if test="state != null and state !='' "> state = #{state},</if>
				<if test="builtIn != null and builtIn !='' "> built_in = #{builtIn},</if>
				<if test="level != null and level !='' "> level = #{level},</if>
				<if test="email != null and email !='' "> email = #{email},</if>
				<if test="phone != null and phone !='' "> phone = #{phone},</if>
				<if test="userLvl != null and userLvl !='' "> user_lvl = #{userLvl},</if>
				<if test="sex != null and sex !='' "> sex = #{sex},</if>
				<if test="lockState != null and lockState !='' "> lock_state = #{lockState},</if>
				<if test="useState != null and useState !='' "> use_state = #{useState},</if>
				<if test="wechatToken != null and wechatToken !='' "> wechat_token = #{wechatToken},</if>
				<if test="isLoginable != null and isLoginable !='' "> is_loginable = #{isLoginable},</if>
				<if test="isVirtual != null and isVirtual !='' "> is_virtual = #{isVirtual},</if>
				<if test="isAdmin != null and isAdmin !='' "> is_admin = #{isAdmin},</if>
				<if test="isAssigned != null and isAssigned !='' "> is_assigned = #{isAssigned},</if>
				<if test="memberType != null and memberType !='' "> member_type = #{memberType},</if>
				<if test="isDeleted != null and isDeleted !='' "> is_deleted = #{isDeleted},</if>
				<if test="externalType != null and externalType !='' "> external_type = #{externalType},</if>
				<if test="memberCode != null and memberCode !='' "> member_code = #{memberCode},</if>
				<if test="birthDate != null ">birth_date = #{birthDate},</if>
				<if test="officeTel != null and officeTel !='' "> office_tel = #{officeTel},</if>
				<if test="remarks != null and remarks !='' "> remarks = #{remarks},</if>
				<if test="photoAddress != null and photoAddress !='' "> photo_address = #{photoAddress},</if>
				<if test="department != null and department !='' "> department = #{department},</if>
				<if test="sorts != null ">sorts = #{sorts},</if>
				<if test="majorPosition != null and majorPosition !='' "> major_position = #{majorPosition},</if>
				<if test="deputyPost != null and deputyPost !='' "> deputy_post = #{deputyPost},</if>
				<if test="userType != null and userType !='' "> user_type = #{userType},</if>
				<if test="personnelStatus != null and personnelStatus !='' "> personnel_status = #{personnelStatus},</if>
				<if test="workplace != null and workplace !='' "> workplace = #{workplace},</if>
				<if test="entryTime != null ">entry_time = #{entryTime},</if>
				<if test="reporter != null and reporter !='' "> reporter = #{reporter},</if>
				<if test="createUserId != null and createUserId !='' "> create_user_id = #{createUserId},</if>
				<if test="createTime != null ">create_time = #{createTime},</if>
				<if test="modifyUserId != null and modifyUserId !='' "> modify_user_id = #{modifyUserId},</if>
				<if test="modifyTime != null ">modify_time = #{modifyTime},</if>
				<if test="sts != null and sts !='' "> sts = #{sts},</if>
				<if test="orgId != null and orgId !='' "> org_id = #{orgId},</if>
		</trim>
		where id = #{id}
	</update>

	<!-- 逻辑删除 -->
	<update id="entity_logicDelete" parameterType="com.hzya.frame.sys.user.entity.User">
		update sys_user set
		sts='N',modify_time = now(),modify_user_id = #{modifyUserId} where
		id = #{id}
	</update>

	<!-- 逻辑删除多条件 -->
	<update id="entity_logicDelete_Multi_Condition" parameterType="com.hzya.frame.sys.user.entity.User">
		update sys_user set
		sts='N',modify_time = now(),modify_user_id = #{modifyUserId}
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="viewName != null and viewName !='' "> and view_name = #{viewName}</if>
			<if test="loginName != null and loginName !='' "> and login_name = #{loginName}</if>
			<if test="password != null and password !='' "> and password = #{password}</if>
			<if test="encryptionPolicy != null and encryptionPolicy !='' "> and encryption_policy = #{encryptionPolicy}</if>
			<if test="expirationDate != null and expirationDate !='' "> and expiration_date = #{expirationDate}</if>
			<if test="pawFrequency != null "> and paw_frequency = #{pawFrequency}</if>
			<if test="staffId != null and staffId !='' "> and staff_id = #{staffId}</if>
			<if test="iconUrl != null and iconUrl !='' "> and icon_url = #{iconUrl}</if>
			<if test="state != null and state !='' "> and state = #{state}</if>
			<if test="builtIn != null and builtIn !='' "> and built_in = #{builtIn}</if>
			<if test="level != null and level !='' "> and level = #{level}</if>
			<if test="email != null and email !='' "> and email = #{email}</if>
			<if test="phone != null and phone !='' "> and phone = #{phone}</if>
			<if test="userLvl != null and userLvl !='' "> and user_lvl = #{userLvl}</if>
			<if test="sex != null and sex !='' "> and sex = #{sex}</if>
			<if test="lockState != null and lockState !='' "> and lock_state = #{lockState}</if>
			<if test="useState != null and useState !='' "> and use_state = #{useState}</if>
			<if test="wechatToken != null and wechatToken !='' "> and wechat_token = #{wechatToken}</if>
			<if test="isLoginable != null and isLoginable !='' "> and is_loginable = #{isLoginable}</if>
			<if test="isVirtual != null and isVirtual !='' "> and is_virtual = #{isVirtual}</if>
			<if test="isAdmin != null and isAdmin !='' "> and is_admin = #{isAdmin}</if>
			<if test="isAssigned != null and isAssigned !='' "> and is_assigned = #{isAssigned}</if>
			<if test="memberType != null and memberType !='' "> and member_type = #{memberType}</if>
			<if test="isDeleted != null and isDeleted !='' "> and is_deleted = #{isDeleted}</if>
			<if test="externalType != null and externalType !='' "> and external_type = #{externalType}</if>
			<if test="memberCode != null and memberCode !='' "> and member_code = #{memberCode}</if>
			<if test="birthDate != null and birthDate !='' "> and birth_date = #{birthDate}</if>
			<if test="officeTel != null and officeTel !='' "> and office_tel = #{officeTel}</if>
			<if test="remarks != null and remarks !='' "> and remarks = #{remarks}</if>
			<if test="photoAddress != null and photoAddress !='' "> and photo_address = #{photoAddress}</if>
			<if test="department != null and department !='' "> and department = #{department}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="majorPosition != null and majorPosition !='' "> and major_position = #{majorPosition}</if>
			<if test="deputyPost != null and deputyPost !='' "> and deputy_post = #{deputyPost}</if>
			<if test="userType != null and userType !='' "> and user_type = #{userType}</if>
			<if test="personnelStatus != null and personnelStatus !='' "> and personnel_status = #{personnelStatus}</if>
			<if test="workplace != null and workplace !='' "> and workplace = #{workplace}</if>
			<if test="entryTime != null and entryTime !='' "> and entry_time = #{entryTime}</if>
			<if test="reporter != null and reporter !='' "> and reporter = #{reporter}</if>
			<if test="createUserId != null and createUserId !='' "> and create_user_id = #{createUserId}</if>
			<if test="createTime != null and createTime !='' "> and create_time = #{createTime}</if>
			<if test="modifyUserId != null and modifyUserId !='' "> and modify_user_id = #{modifyUserId}</if>
			<if test="modifyTime != null and modifyTime !='' "> and modify_time = #{modifyTime}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</if>
			<if test="orgId != null and orgId !='' "> and org_id = #{orgId}</if>
		</trim>
	</update>

	<!-- 物理删除 -->
	<delete id="entity_delete" parameterType="com.hzya.frame.sys.user.entity.User">
		delete from sys_user where id =#{id}
	</delete>
</mapper>
