yanghui
2022-10-14 4040856595952ea0b8f8b764ba2770d5c244c891
flower_city/src/main/resources/mapper/SysUserMapper.xml
@@ -1,8 +1,8 @@
<?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.dg.core.db.gen.mapper.SysUserMapper">
    <resultMap type="com.dg.core.db.gen.entity.SysUser" id="SysUserResult">
        <id     property="id"      column="id"      />
        <id     property="userId"      column="user_id"      />
        <result property="loginName"     column="login_name"     />
        <result property="userName"   column="user_name"   />
@@ -27,8 +27,6 @@
        <result property="departmentId"      column="department_id"      />
        <result property="stairId"      column="stair_id"      />
        <result property="secondLevelId"      column="second_level_id"      />
        <result property="departmentName"      column="department_name"      />
        <result property="departmentArea"      column="department_area"      />
        <result property="leisureState"      column="leisure_state"      />
@@ -36,13 +34,13 @@
        <result property="masterNames"      column="master_names"      />
        <result property="transactionIds"      column="transaction_ids"      />
        <result property="transactionNames"      column="transaction_names"      />
        <result property="openid"      column="openid"      />
        <result property="transactionNum"      column="transaction_num"      />
    </resultMap>
    <sql id="selectSysUserVo">
        SELECT
            id,
            user_id,
            login_name,
            user_name,
@@ -50,6 +48,7 @@
            phonenumber,
            sex,
            avatar,
            password,
            salt,
            status,
            del_flag,
@@ -60,32 +59,40 @@
            create_time,
            update_by,
            update_time,
            remark,
            role_ids,
            data_permission,
            department_id,
            stair_id,
            second_level_id,
            (select organization_name from organization_chart where sys_user.department_id=organization_chart.id) as department_name,
            department_area,
            leisure_state,
            master_ids,
            master_names,
            transaction_ids,
            transaction_names,
            remark
            openid,
            transaction_num,
            (select organization_name from automessage_organization_chart where automessage_sys_user.department_id=automessage_organization_chart.id) as department_name
        FROM
            sys_user
            automessage_sys_user
    </sql>
    <select id="selectNum" resultType="integer">
        select count(user_id) from sys_user
    <select id="selectNum" parameterType="string" resultType="integer">
        select count(user_id) from automessage_sys_user
        <where>
            <if test="userType != null and userType != ''">
                AND user_type=#{userType}
            </if>
        </where>
    </select>
    <select id="queryList"  resultMap="SysUserResult">
        <include refid="selectSysUserVo"/>
        <where>
            user_type=#{userType}
        </where>
        ORDER BY department_id
    </select>
    <select id="selectConfigList" parameterType="string" resultMap="SysUserResult">
@@ -103,8 +110,37 @@
    </select>
    <select id="selectData" parameterType="string"  resultMap="SysUserResult">
        <include refid="selectSysUserVo"/>
        <where>
            <if test="userId!=null and userId!='' ">
                user_id= #{userId}
            </if>
        </where>
    </select>
    <select id="selectListByDepartmentId"  resultMap="SysUserResult">
        <include refid="selectSysUserVo"/>
         <where>
             user_type=2 and status=0
        <if test="list!=null">
            and  department_id in
            <foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
         </if>
         <if test="classifyIdFront!=null and classifyIdFront!='' and classifyIdAfter!=null and classifyIdAfter!=''">
            and (master_ids like concat('%',#{classifyIdFront}, '%') or master_ids like concat('%',#{classifyIdAfter}, '%'))
         </if>
         </where>
         order by transaction_num
    </select>
    <insert id="insertConfig" parameterType="com.dg.core.db.gen.entity.SysUser">
        insert into sys_user (
        insert into automessage_sys_user (
        create_time
        <if test="userId != null and userId != '' ">,user_id</if>
        <if test="loginName != null and loginName != '' ">,login_name</if>
@@ -136,6 +172,7 @@
        <if test="masterNames != null and masterNames != '' ">,master_names</if>
        <if test="transactionIds != null and transactionIds != '' ">,transaction_ids</if>
        <if test="transactionNames != null and transactionNames != '' ">,transaction_names</if>
        <if test="openid != null and openid != '' ">,openid</if>
        )values(
        sysdate()
        <if test="userId != null and userId != '' ">,#{userId}</if>
@@ -168,11 +205,12 @@
        <if test="masterNames != null and masterNames != '' ">,#{masterNames}</if>
        <if test="transactionIds != null and transactionIds != '' ">,#{transactionIds}</if>
        <if test="transactionNames != null and transactionNames != '' ">,#{transactionNames}</if>
        <if test="openid != null and openid != '' ">,#{openid}</if>
        )
    </insert>
    <update id="updateConfig" parameterType="com.dg.core.db.gen.entity.SysUser">
        update sys_user
        update automessage_sys_user
        <set>
            <if test="userId != null and userId != '' ">user_id=#{userId}</if>
            <if test="loginName != null and loginName != '' ">,login_name=#{loginName}</if>
@@ -204,16 +242,14 @@
            <if test="masterNames != null and masterNames != '' ">,master_names=#{masterNames}</if>
            <if test="transactionIds != null and transactionIds != '' ">,transaction_ids=#{transactionIds}</if>
            <if test="transactionNames != null and transactionNames != '' ">,transaction_names=#{transactionNames}</if>
            <if test="openid != null and openid != '' ">,openid=#{openid}</if>
            ,update_time=sysdate()
        </set>
        where user_id= #{userId}
    </update>
    <delete id="deleteConfigById" parameterType="string">
        delete from sys_user where user_id= #{id}
        delete from automessage_sys_user where user_id= #{id}
    </delete>
</mapper>