123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- <?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.zhyc.xps.sys.mapper.AccountMapper">
- <resultMap id="BaseResultMap" type="com.zhyc.xps.sys.entity.Account">
- <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--公司或组织ID-->
- <result column="account_id" property="accountId" jdbcType="BIGINT" /><!--帐号ID-->
- <result column="account_name" property="accountName" jdbcType="VARCHAR" />
- <result column="password" property="password" jdbcType="VARCHAR" />
- <result column="account_type" property="accountType" jdbcType="BIGINT" />
- <result column="account_staff_no" property="accountStaffNo" jdbcType="VARCHAR" />
- <result column="account_phone" property="accountPhone" jdbcType="VARCHAR" />
- <result column="account_last_ip" property="accountLastIp" jdbcType="VARCHAR" />
- <result column="account_loc" property="accountLoc" jdbcType="VARCHAR" />
- <result column="status" property="status" jdbcType="BIGINT" />
- <result column="account_avatar" property="accountAvatar" jdbcType="VARCHAR" />
- <result column="account_photo" property="accountPhoto" jdbcType="VARCHAR" />
- <result column="account_real_name" property="accountRealName" jdbcType="VARCHAR" />
- <result column="account_email" property="accountMail" jdbcType="VARCHAR" />
- <result column="account_intro" property="accountIntro" jdbcType="VARCHAR" />
- <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
- </resultMap>
- <!--AccountDto-->
- <resultMap id="AccountDtoResultMap" type="com.zhyc.xps.sys.dto.AccountDto" extends="BaseResultMap">
- <result column="oc_type_id" property="ocTypeId" jdbcType="VARCHAR" />
- <result column="oc_name" property="ocName" jdbcType="VARCHAR" /><!--公司或组织ID-->
- <result column="wx_id" property="wxId" jdbcType="VARCHAR" />
- <result column="group_id" property="groupId" jdbcType="BIGINT" />
- <result column="position_id" property="positionId" jdbcType="BIGINT" />
- </resultMap>
- <sql id="Ext_Column_List">
- A.oc_id,
- B.oc_type_id,
- B.oc_name,
- A.account_id,
- A.account_name,
- A.account_real_name,
- A.password,
- A.account_type,
- A.account_staff_no,
- A.account_phone,
- A.account_last_ip,
- A.account_loc,
- A.status,
- A.account_avatar,
- A.account_photo,
- A.account_real_name,
- A.account_intro,
- A.wx_id,
- A.is_fixed
- </sql>
- <!--通过ID 获取账号信息-->
- <select id="getById" resultMap="AccountDtoResultMap">
- SELECT
- <include refid="Ext_Column_List"/>
- FROM account AS A
- LEFT JOIN oc AS B ON (A.oc_id = B.oc_id )
- WHERE A.deleted_flag = 0
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType = BIGINT}
- </if>
- <if test="accountId != null">
- AND A.account_id = #{accountId ,jdbcType = BIGINT}
- </if>
- </select>
- <!--根据用户名或手机号或工号获取账号信息 -->
- <select id="getAccountByCode" resultMap="AccountDtoResultMap">
- SELECT
- <include refid="Ext_Column_List"/>
- FROM account AS A
- LEFT JOIN oc AS B ON (A.oc_id = B.oc_id )
- WHERE A.deleted_flag = 0
- AND (A.account_name = #{code, jdbcType=VARCHAR}
- OR A.account_phone = #{code, jdbcType=VARCHAR}
- OR A.account_mail = #{code, jdbcType=VARCHAR}
- OR A.account_staff_no = #{code, jdbcType=VARCHAR})
- </select>
- <!--根据名字获取账号信息 -->
- <select id="getAccountById" resultMap="AccountDtoResultMap">
- SELECT
- <include refid="Ext_Column_List"/>
- FROM account AS A
- LEFT JOIN oc AS B ON (A.oc_id = B.oc_id )
- WHERE A.deleted_flag = 0
- AND A.account_id = #{accountId ,jdbcType = BIGINT}
- </select>
- <!--根据查询条件获取账号信息-->
- <select id="getByPage" parameterType="java.util.Map" resultMap="AccountDtoResultMap">
- SELECT
- <include refid="Ext_Column_List"/>
- FROM account AS A
- LEFT JOIN oc AS B ON (A.oc_id = B.oc_id )
- WHERE A.deleted_flag = 0
- <if test="keywords != null and keywords != ''">
- AND ( A.account_real_name LIKE "%"#{keywords}"%"
- OR A.account_name LIKE "%"#{keywords}"%"
- OR A.account_phone LIKE "%"#{keywords}"%")
- </if>
- <if test="ocId != null and ocId != ''">
- AND A.oc_id = #{ocId ,jdbcType = BIGINT}
- </if>
- <if test="orderBy != null and orderBy != ''">
- ORDER BY A.${orderBy}
- </if>
- </select>
- <!--根据查询条件获取账号信息-->
- <select id="getByList" parameterType="java.util.Map" resultMap="AccountDtoResultMap">
- SELECT
- <include refid="Ext_Column_List"/>,C.group_id,C.position_id
- FROM account AS A
- LEFT JOIN oc AS B ON (A.oc_id = B.oc_id )
- LEFT JOIN s_group_member_position AS C ON (A.oc_id = C.oc_id and C.account_id = A.account_id )
- WHERE A.deleted_flag = 0
- <if test="keywords != null and keywords != ''">
- AND ( A.account_real_name LIKE "%"#{keywords}"%"
- OR A.account_name LIKE "%"#{keywords}"%"
- OR A.account_phone LIKE "%"#{keywords}"%")
- </if>
- <if test="ocId != null">
- AND A.oc_id = #{ocId ,jdbcType = BIGINT}
- </if>
- <if test="orderBy != null and orderBy != ''">
- ORDER BY A.${orderBy}
- </if>
- </select>
- <!--新增-->
- <insert id="create" useGeneratedKeys="true" keyProperty="accountId" parameterType="com.zhyc.xps.sys.entity.Account">
- insert into account
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="accountId != null">
- account_id,
- </if>
- <if test="accountName != null and accountName != ''">
- account_name,
- </if>
- <if test="password != null and password != ''">
- password,
- </if>
- <if test="accountType != null">
- account_type,
- </if>
- <if test="accountStaffNo != null and accountStaffNo != ''">
- account_staff_no,
- </if>
- <if test="accountPhone != null and accountPhone != ''">
- account_phone,
- </if>
- <if test="accountLastIp != null and accountLastIp!= ''">
- account_last_ip,
- </if>
- <if test="accountLoc != null and accountLoc != ''">
- account_loc,
- </if>
- <if test="status != null">
- status,
- </if>
- <if test="accountAvatar != null and accountAvatar != ''">
- account_avatar,
- </if>
- <if test="accountPhoto != null and accountPhoto !=''">
- account_photo,
- </if>
- <if test="accountRealName != null and accountRealName != ''">
- account_real_name,
- </if>
- <if test="accountMail != null and accountMail != ''">
- account_mail,
- </if>
- <if test="accountIntro != null and accountIntro != ''">
- account_intro,
- </if>
- <if test="isFixed != null">
- is_fixed,
- </if>
- <if test="createdAt != null">
- created_at,
- </if>
- <if test="createdBy != null">
- created_by,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- #{ocId, jdbcType=BIGINT},
- </if>
- <if test="accountId != null">
- #{accountId, jdbcType=BIGINT},
- </if>
- <if test="accountName != null and accountName !=''">
- #{accountName, jdbcType=VARCHAR},
- </if>
- <if test="password != null and password != ''">
- #{password, jdbcType=VARCHAR},
- </if>
- <if test="accountType != null">
- #{accountType, jdbcType=BIGINT},
- </if>
- <if test="accountStaffNo != null and accountStaffNo != ''">
- #{accountStaffNo, jdbcType=VARCHAR},
- </if>
- <if test="accountPhone != null and accountPhone!= ''">
- #{accountPhone, jdbcType=VARCHAR},
- </if>
- <if test="accountLastIp != null and accountLastIp != ''">
- #{accountLastIp, jdbcType=VARCHAR},
- </if>
- <if test="accountLoc != null and accountLoc != ''">
- #{accountLoc, jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- #{status, jdbcType=BIGINT},
- </if>
- <if test="accountAvatar != null and accountAvatar !=''">
- #{accountAvatar, jdbcType=VARCHAR},
- </if>
- <if test="accountPhoto != null and accountPhoto !=''">
- #{accountPhoto, jdbcType=VARCHAR},
- </if>
- <if test="accountRealName != null and accountRealName != ''">
- #{accountRealName, jdbcType=VARCHAR},
- </if>
- <if test="accountMail != null and accountMail != ''">
- #{accountMail, jdbcType=VARCHAR},
- </if>
- <if test="accountIntro != null and accountIntro != ''">
- #{accountIntro, jdbcType=VARCHAR},
- </if>
- <if test="isFixed != null">
- #{isFixed, jdbcType=BIGINT},
- </if>
- <if test="createdAt != null">
- #{createdAt, jdbcType=DATE},
- </if>
- <if test="createdBy != null">
- #{createdBy, jdbcType=BIGINT},
- </if>
- </trim>
- </insert>
- <!--Update-->
- <update id="update" parameterType="com.zhyc.xps.sys.entity.Account">
- UPDATE account
- <trim suffixOverrides=",">
- <set>
- <if test="accountName != null and accountName != ''">
- account_name = #{accountName,jdbcType=VARCHAR},
- </if>
- <if test="accountRealName != null and accountRealName !=''">
- account_real_name = #{accountRealName,jdbcType=VARCHAR},
- </if>
- <if test="password != null and password !=''">
- password = #{password,jdbcType=VARCHAR},
- </if>
- <if test="accountIntro != null">
- account_intro = #{accountIntro,jdbcType=VARCHAR},
- </if>
- <if test="isFixed != null">
- is_fixed = #{isFixed,jdbcType=BIGINT},
- </if>
- <if test="accountStaffNo != null">
- account_staff_no = #{accountStaffNo,jdbcType=VARCHAR},
- </if>
- <if test="accountPhone != null and accountPhone != ''">
- account_phone = #{accountPhone,jdbcType=VARCHAR},
- </if>
- <if test="wxId != null">
- wx_id = #{wxId,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- status = #{status,jdbcType=BIGINT},
- </if>
- <if test="accountAvatar != null">
- account_avatar = #{accountAvatar,jdbcType=VARCHAR},
- </if>
- <if test="accountPhoto != null">
- account_photo = #{accountPhoto,jdbcType=VARCHAR},
- </if>
- <if test="accountMail != null">
- account_mail = #{accountMail, jdbcType=VARCHAR},
- </if>
- <if test="updatedAt != null">
- updated_at = #{updatedAt,jdbcType=DATE},
- </if>
- <if test="updatedBy != null">
- updated_by = #{updatedBy,jdbcType=BIGINT},
- </if>
- </set>
- </trim>
- WHERE oc_id = #{ocId, jdbcType=BIGINT} AND account_id = #{accountId ,jdbcType=BIGINT}
- </update>
- <!--更新密码-->
- <update id="updatePassword" parameterType="java.util.Map">
- UPDATE account
- SET password = #{password ,jdbcType=VARCHAR}
- WHERE deleted_flag = 0
- AND oc_id = #{ocId, jdbcType=BIGINT}
- AND account_id = #{accountId,jdbcType=BIGINT}
- </update>
- <!--删除-->
- <update id="delete" parameterType="java.util.Map">
- UPDATE account
- <trim suffixOverrides=",">
- <set>
- <if test="deletedFlag != null">
- deleted_flag = #{deletedFlag,jdbcType=BIGINT},
- </if>
- <if test="deletedTime != null">
- deleted_time = #{deletedTime,jdbcType=VARCHAR},
- </if>
- <if test="deletedBy != null">
- deleted_by = #{deletedBy,jdbcType=BIGINT},
- </if>
- </set>
- </trim>
- WHERE 1 = 1
- <if test="ocId != null">
- AND oc_id = #{ocId, jdbcType=BIGINT}
- </if>
- <if test="accountId != null">
- AND account_id = #{accountId ,jdbcType = BIGINT}
- </if>
- </update>
- <!--检查用户名及电话是否存在-->
- <select id="isAccountInfoExist" parameterType="java.util.Map" resultType="java.lang.Long">
- SELECT count(*)
- FROM account
- <where>
- deleted_flag = 0
- <if test="ocId != null">
- AND oc_id = #{ocId, jdbcType=BIGINT}
- </if>
- <if test="accountName != null and accountName != ''">
- AND account_name = #{accountName,jdbcType=VARCHAR}
- </if>
- <if test="accountPhone != null and accountPhone != ''">
- AND account_phone = #{accountPhone ,jdbcType=VARCHAR}
- </if>
- <if test="accountStaffNo != null and accountStaffNo != ''">
- AND account_staff_no = #{accountStaffNo, jdbcType=VARCHAR}
- </if>
- <if test="accountId != null">
- AND account_id != #{accountId, jdbcType=BIGINT}
- </if>
- </where>
- </select>
- <!--检查微信ID是否存在-->
- <select id="isWxIdExist" resultType="java.lang.Long">
- SELECT 1
- FROM account AS A
- WHERE A.deleted_flag = 0
- AND A.wx_id = #{wxId,jdbcType=VARCHAR}
- Limit 1
- </select>
- <!--检查帐号名称是否存在-->
- <select id="isAccountNameExist" resultType="java.lang.Long">
- SELECT 1
- FROM account AS A
- WHERE A.deleted_flag = 0
- AND A.account_name = #{accountName, jdbcType=VARCHAR}
- LIMIT 1
- </select>
- <!--检查电话号码是否存在-->
- <select id="isAccountPhoneExist" resultType="java.lang.Long">
- SELECT 1
- FROM account AS A
- WHERE A.deleted_flag = 0
- AND A.account_phone = #{accountPhone, jdbcType=VARCHAR}
- LIMIT 1
- </select>
- <!--检查电话号码是否存在-->
- <select id="isAccountStaffNoExist" resultType="java.lang.Long">
- SELECT 1
- FROM account AS A
- WHERE A.deleted_flag = 0
- AND A.oc_id = #{ocId, jdbcType=BIGINT}
- AND A.account_staff_no = #{accountStaffNo, jdbcType=VARCHAR}
- LIMIT 1
- </select>
- <!--检查EMAIL是否存在-->
- <select id="isAccountMailExist" resultType="java.lang.Long">
- SELECT 1
- FROM account AS A
- WHERE A.deleted_flag = 0
- AND A.account_mail = #{accountMail, jdbcType=VARCHAR}
- LIMIT 1
- </select>
- </mapper>
|