123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- <?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.yonge.cooleshow.biz.dal.dao.EmployeeDao">
- <resultMap type="com.yonge.cooleshow.biz.dal.entity.Employee" id="Employee">
- <result column="user_id_" property="userId"/>
- <result column="job_nature_" property="jobNature"/>
- <result column="is_probation_period_" property="isProbationPeriod"/>
- <result column="education_background_" property="educationBackground"/>
- <result column="graduate_school_" property="graduateSchool"/>
- <result column="technical_titles_" property="technicalTitles"/>
- <result column="entry_date_" property="entryDate"/>
- <result column="update_time_" property="updateTime"/>
- <result column="create_time_" property="createTime"/>
- <result column="introduction_" property="introduction"/>
- <result column="demission_date_" property="demissionDate"/>
- <result column="contact_address_" property="contactAddress"/>
- <result column="lock_flag_" property="lockFlag" />
- <result column="customer_service_" property="customerService" />
- </resultMap>
- <resultMap type="com.yonge.cooleshow.auth.api.entity.SysUser" id="SysUser">
- <result column="id_" property="id"/>
- <result column="username_" property="username"/>
- <result column="password_" property="password"/>
- <result column="salt_" property="salt"/>
- <result column="phone_" property="phone"/>
- <result column="avatar_" property="avatar"/>
- <result column="create_time_" property="createTime"/>
- <result column="update_time_" property="updateTime"/>
- <result column="lock_flag_" property="lockFlag"/>
- <result column="del_flag_" property="delFlag"/>
- <result column="wx_openid_" property="wxOpenid"/>
- <result column="qq_openid_" property="qqOpenid"/>
- <result column="user_type_" property="userType"/>
- <result column="gender_" property="gender"/>
- <result column="nation_" property="nation"/>
- <result column="birthdate_" property="birthdate"/>
- <result column="email_" property="email"/>
- <result column="im_token_" property="imToken"/>
- <result column="real_name_" property="realName"/>
- <result column="id_card_no_" property="idCardNo"/>
- <result column="wechat_id_" property="wechatId"/>
- </resultMap>
- <sql id="baseColumns">
- t.user_id_ as "userId"
- , t.job_nature_ as "jobNature"
- , t.is_probation_period_ as "isProbationPeriod"
- , t.education_background_ as "educationBackground"
- , t.graduate_school_ as "graduateSchool"
- , t.technical_titles_ as "technicalTitles"
- , t.entry_date_ as "entryDate"
- , t.update_time_ as "updateTime"
- , t.create_time_ as "createTime"
- , t.introduction_ as "introduction"
- , t.demission_date_ as "demissionDate"
- , t.contact_address_ as "contactAddress"
- , t.customer_service_ as "customerService"
- </sql>
- <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.EmployeeVo">
- SELECT
- <include refid="baseColumns" />,
- if(u.lock_flag_ = 0 and t.lock_flag_ = 0,0,1) as lockFlag,
- username_ as username,
- phone_ as phone,
- gender_ as gender
- FROM employee t
- left join sys_user u on t.user_id_ = u.id_
- where u.del_flag_ = 0 and t.user_id_ = #{id}
- </select>
- <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.EmployeeVo">
- SELECT
- <include refid="baseColumns" />,
- if(u.lock_flag_ = 0 and t.lock_flag_ = 0,0,1) as lockFlag,
- u.username_ as username,
- u.phone_ as phone,
- u.gender_ as gender
- FROM employee t
- left join sys_user u on t.user_id_ = u.id_
- <where>
- <if test="null != param.search and '' != param.search">
- AND (
- t.user_id_ LIKE CONCAT('%', #{param.search}, '%') or
- u.username_ LIKE CONCAT('%', #{param.search}, '%') or
- u.phone_ LIKE CONCAT('%', #{param.search}, '%')
- )
- </if>
- <if test="null != param.gender">
- and u.gender_ = #{param.gender}
- </if>
- <if test="param.startTime !=null">
- <![CDATA[AND t.create_time_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.create_time_ < #{param.endTime} ]]>
- </if>
- <if test="null != param.lockFlag">
- and t.lock_flag_ = #{param.lockFlag}
- </if>
- <if test="null != param.delFlag">
- and u.del_flag_ = #{param.delFlag}
- </if>
- <if test="param.customerService != null">
- AND t.customer_service_ = #{param.customerService}
- </if>
- </where>
- </select>
- <insert id="insertSysUser" parameterType="com.yonge.cooleshow.auth.api.entity.SysUser" useGeneratedKeys="true" keyColumn="id"
- keyProperty="id">
- INSERT INTO sys_user
- (is_super_admin_,im_token_,id_,username_,salt_,phone_,avatar_,create_time_,update_time_,wx_openid_,qq_openid_,user_type_,
- gender_,nation_,birthdate_,email_,id_card_no_,wechat_id_,real_name_,certificate_type_,password_)
- VALUES(#{isSuperAdmin},#{imToken},#{id},#{username},#{salt},#{phone},#{avatar},now(),now(),#{wxOpenid},#{qqOpenid},#{userType},
- #{gender},#{nation},#{birthdate},#{email},#{idCardNo},#{wechatId},#{realName},#{certificateType},#{password})
- </insert>
- <update id="updateSysUser" parameterType="com.yonge.cooleshow.auth.api.entity.SysUser">
- UPDATE sys_user
- <set>
- <if test="wxOpenid != null and wxOpenid != ''">
- wx_openid_ = #{wxOpenid},
- </if>
- <if test="avatar != null and avatar != ''">
- avatar_ = #{avatar},
- </if>
- <if test="email != null and email != ''">
- email_ = #{email},
- </if>
- <if test="gender != null">
- gender_ = #{gender},
- </if>
- <if test="salt != null and salt != ''">
- salt_ = #{salt},
- </if>
- <if test="username != null and username != ''">
- username_ = #{username},
- </if>
- <if test="userType != null and userType != ''">
- user_type_ = #{userType},
- </if>
- <if test="updateTime != null">
- update_time_ = NOW(),
- </if>
- <if test="lockFlag != null">
- lock_flag_ = #{lockFlag},
- </if>
- <if test="birthdate != null">
- birthdate_ = #{birthdate},
- </if>
- <if test="phone != null and phone != ''">
- phone_ = #{phone},
- </if>
- <if test="qqOpenid != null and qqOpenid != ''">
- qq_openid_ = #{qqOpenid},
- </if>
- <if test="nation != null and nation != ''">
- nation_ = #{nation},
- </if>
- <if test="imToken != null and imToken != ''">
- im_token_ = #{imToken},
- </if>
- <if test="idCardNo != null and idCardNo != ''">
- id_card_no_ = #{idCardNo},
- </if>
- <if test="password != null and password != ''">
- password_ = #{password},
- </if>
- <if test="wechatId != null and wechatId != ''">
- wechat_id_ = #{wechatId},
- </if>
- <if test="realName != null and realName != ''">
- real_name_ = #{realName},
- </if>
- <if test="isSuperAdmin != null">
- is_super_admin_ = #{isSuperAdmin},
- </if>
- <if test="certificateType != null">
- certificate_type_ = #{certificateType},
- </if>
- </set>
- WHERE del_flag_ = 0 and id_ = #{id}
- </update>
- <insert id="insert" parameterType="com.yonge.cooleshow.biz.dal.entity.Employee" useGeneratedKeys="true" keyColumn="id"
- keyProperty="id">
- INSERT INTO employee
- (user_id_,job_nature_,is_probation_period_,education_background_,graduate_school_,technical_titles_,
- entry_date_,update_time_,create_time_,introduction_,demission_date_,contact_address_,customer_service_)
- VALUES(#{userId},#{jobNature},#{isProbationPeriod},#{educationBackground},#{graduateSchool},
- #{technicalTitles},#{entryDate},now(),now(),#{introduction},#{demissionDate},#{contactAddress},#{customerService})
- </insert>
- <update id="update" parameterType="com.yonge.cooleshow.biz.dal.entity.Employee">
- UPDATE employee
- <set>
- <if test="jobNature != null">
- job_nature_ = #{jobNature},
- </if>
- <if test="isProbationPeriod != null">
- is_probation_period_ = #{isProbationPeriod},
- </if>
- <if test="educationBackground != null">
- education_background_ = #{educationBackground},
- </if>
- <if test="graduateSchool != null">
- graduate_school_ = #{graduateSchool},
- </if>
- <if test="technicalTitles != null">
- technical_titles_ = #{technicalTitles},
- </if>
- <if test="entryDate != null">
- entry_date_ = #{entryDate},
- </if>
- <if test="updateTime != null">
- update_time_ = NOW(),
- </if>
- <if test="introduction != null">
- introduction_ = #{introduction},
- </if>
- <if test="demissionDate != null">
- demission_date_ = #{demissionDate},
- </if>
- <if test="contactAddress != null">
- contact_address_ = #{contactAddress},
- </if>
- <if test="lockFlag != null">
- lock_flag_ = #{lockFlag},
- </if>
- <if test="customerService != null">
- customer_service_ = #{customerService},
- </if>
- </set>
- WHERE user_id_ = #{userId}
- </update>
- <select id="queryUserRole" resultType="java.lang.Long">
- SELECT sur.role_id_ FROM sys_user_role sur
- LEFT JOIN sys_role r ON sur.role_id_ = r.id_
- WHERE r.del_flag_ = 0 and r.is_enable_ = 1 and sur.user_id_ = #{userId}
- </select>
- <insert id="batchAddEmployeeRole">
- INSERT INTO sys_user_role(user_id_,role_id_) values
- <foreach collection="roleIds" item="item" index="index" separator=",">
- (#{userId},#{item})
- </foreach>
- </insert>
- <delete id="delEmployeeRole">
- DELETE FROM sys_user_role WHERE user_id_ = #{userId}
- </delete>
- <insert id="batchInsertRoleMenu">
- INSERT INTO sys_role_menu (role_id_,menu_id_) VALUES
- <foreach collection="menuIds" item="item" index="index" separator=",">
- (#{roleId}, #{item})
- </foreach>
- </insert>
- <select id="querySysUserByPhoneAndLock" resultMap="SysUser">
- select * from sys_user where del_flag_ = 0 and (phone_ = #{phone} OR username_ = #{phone}) LIMIT 1 FOR UPDATE
- </select>
- <select id="querySysUserByPhone" resultMap="SysUser">
- select * from sys_user where del_flag_ = 0 and (phone_ = #{phone} OR username_ = #{phone})
- </select>
- <select id="querySysUserById" resultMap="SysUser">
- select * from sys_user where del_flag_ = 0 and id_ = #{id}
- </select>
- <update id="updateUserDemissionDate">
- UPDATE employee SET demission_date_ = IF(demission_date_ IS NULL,now(),NULL) WHERE user_id_=#{userID}
- </update>
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="Employee">
- SELECT * FROM employee WHERE user_id_ = #{userId}
- </select>
- <!-- 全查询 -->
- <select id="findAll" resultMap="Employee">
- SELECT * FROM employee ORDER BY user_id_
- </select>
- <delete id="delRoleMenu">
- DELETE FROM `sys_role_menu`
- WHERE menu_id_ in
- <foreach collection="menuIds" open="(" close=")" item="item" separator=",">
- #{item}
- </foreach>
- </delete>
- <insert id="insertSysRole" keyColumn="id_" keyProperty="id" parameterType="com.yonge.cooleshow.auth.api.entity.SysRole"
- useGeneratedKeys="true">
- INSERT INTO `sys_role` (`role_name_`, `role_code_`, `role_desc_`, `create_time_`,
- `update_time_`, `del_flag_`, `organ_id_`, `tenant_id_`)
- VALUES (#{roleName}, #{roleCode}, #{roleDesc}, #{createTime},
- #{updateTime}, #{delFlag}, #{organId}, #{tenantId});
- </insert>
- <update id="updatePasswordReq">
- UPDATE sys_user SET password_ = #{password} WHERE del_flag_ = 0 and id_ = #{userID}
- </update>
- <!-- 根据主键删除一条记录 -->
- <delete id="delete">
- DELETE FROM employee WHERE user_id_ = #{userId}
- </delete>
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(*) FROM employee where tenant_id_ = #{tenantId}
- </select>
- <select id="getUsers" resultMap="SysUser">
- select * from sys_user where del_flag_ = 0 and id_ IN
- <foreach collection="userIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </select>
- </mapper>
|