SysOpSmapper.xml 13.4 KB
<?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.zteits.sys.mapper.smapper.SysOpSmapper">
   <resultMap id="BaseResultMap" type="com.zteits.sys.domain.SysOp" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="login_code" property="loginCode" jdbcType="VARCHAR" />
    <result column="login_password" property="loginPassword" jdbcType="VARCHAR" />
    <result column="op_code" property="opCode" jdbcType="VARCHAR" />
    <result column="op_name" property="opName" jdbcType="VARCHAR" />
    <result column="sex" property="sex" jdbcType="INTEGER" />
    <result column="age" property="age" jdbcType="INTEGER" />
    <result column="img_path" property="imgPath" jdbcType="VARCHAR" />
    <result column="contact_address" property="contactAddress" jdbcType="VARCHAR" />
    <result column="telephone" property="telephone" jdbcType="VARCHAR" />
    <result column="card_type_id" property="cardTypeId" jdbcType="INTEGER" />
    <result column="card_no" property="cardNo" jdbcType="VARCHAR" />
    <result column="email" property="email" jdbcType="VARCHAR" />
    <result column="try_times" property="tryTimes" jdbcType="INTEGER" />
    <result column="acct_start_date" property="acctStartDate" jdbcType="TIMESTAMP" />
    <result column="acct_end_date" property="acctEndDate" jdbcType="TIMESTAMP" />
    <result column="last_login_time" property="lastLoginTime" jdbcType="TIMESTAMP" />
    <result column="email_switch" property="emailSwitch" jdbcType="INTEGER" />
    <result column="sms_switch" property="smsSwitch" jdbcType="INTEGER" />
    <result column="sys_code" property="sysCode" jdbcType="VARCHAR" />
    <result column="data_state" property="dataState" jdbcType="INTEGER" />
    <result column="create_empid" property="createEmpid" jdbcType="VARCHAR" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
    <result column="modfiy_empid" property="modfiyEmpid" jdbcType="VARCHAR" />
    <result column="modfiy_date" property="modfiyDate" jdbcType="TIMESTAMP" />
    <result column="remark" property="remark" jdbcType="VARCHAR" />
    <result column="org_id" property="orgId" jdbcType="BIGINT" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, login_code, login_password, op_code, op_name, sex, age, img_path, contact_address, 
    telephone, card_type_id, card_no, email, try_times, acct_start_date, acct_end_date, 
    last_login_time, email_switch, sms_switch, sys_code, data_state, create_empid, create_date, 
    modfiy_empid, modfiy_date, remark, org_id
  </sql>
    <select id="querySysOp" resultMap="BaseResultMap" parameterType="com.zteits.sys.domain.SysOp">
       SELECT
			id, login_code, login_password, op_code, op_name, sex, age, img_path, contact_address, 
    telephone, card_type_id, card_no, email, try_times, acct_start_date, acct_end_date, 
    last_login_time, email_switch, sms_switch, sys_code, data_state, create_empid, create_date, 
    modfiy_empid, modfiy_date, remark, org_id
		FROM sys_op 
        where
        1=1
        <if test="id != null">
            AND id = #{id,jdbcType=BIGINT}
        </if>
        <if test="loginCode != null and loginCode!=''">
            and login_code = #{loginCode,jdbcType=VARCHAR}
        </if>
        <choose>
            <when test="dataState != null">
                and data_state = #{dataState,jdbcType=INTEGER}
            </when>
            <otherwise>
                and data_state =1
            </otherwise>
        </choose>
    </select>

    <select id="querySysOpByIds" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM sys_op
        <where>
            <if test="sysCode != null">
                and sys_code = #{sysCode,jdbcType=VARCHAR}
            </if>
            <choose>
                <when test="dataStatus != null">
                    and data_state = #{dataStatus,jdbcType=INTEGER}
                </when>
                <otherwise>
                    and data_state =1
                </otherwise>
            </choose>
            <if test="null !=opIds and opIds.size>0">
                AND id IN
                <foreach collection="opIds" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>

    <!-- 用户列表查询  langlw 2017-08-10-->
    <select id="querySysOpForList" resultMap="BaseResultMap" parameterType="com.zteits.sys.domain.SysOp">
        select
        <include refid="Base_Column_List"/>
        from sys_op
        where 1=1
        <if test="sysCode != null">
            and sys_code = #{sysCode,jdbcType=VARCHAR}
        </if>
        <choose>
            <when test="dataState != null">
                and data_state = #{dataState,jdbcType=INTEGER}
            </when>
            <otherwise>
                and data_state in (1,2)
            </otherwise>
        </choose>
        <if test="loginCode != null and loginCode!=''">
            and login_code =#{loginCode}
        </if>
        <if test="opName != null and opName != ''">
            and op_name like '%${opName}%'
        </if>
         <if test="telephone != null and telephone != ''">
            and telephone like '%${telephone}%'
        </if>
        <if test="orgId != null">
           and org_id =#{orgId,jdbcType=BIGINT}
        </if>
        order by id desc

    </select>
    
    
    
    <select id="querySysOpForListByTime" resultMap="BaseResultMap" parameterType="com.zteits.sys.domain.SysOp">
        select
        <include refid="Base_Column_List"/>
        from sys_op
        where 1=1
        <if test="sysOp.sysCode != null">
            and sys_code = #{sysOp.sysCode,jdbcType=VARCHAR}
        </if>
        <choose>
            <when test="sysOp.dataState != null">
                and data_state = #{sysOp.dataState,jdbcType=INTEGER}
            </when>
            <otherwise>
                and data_state in (1,2)
            </otherwise>
        </choose>
        <if test="sysOp.loginCode != null and sysOp.loginCode!=''">
            and login_code like '%${sysOp.loginCode}%'
        </if>
        <if test="sysOp.opName != null and sysOp.opName != ''">
            and op_name like '%${sysOp.opName}%'
        </if>
        <if test="beginTime != null and endTime != null">
            and acct_start_date between #{beginTime} and #{endTime}
        </if>

    </select>

    <!-- 保存操作员信息 2017-08-10-->
    <insert id="saveSysOp" parameterType="com.zteits.sys.domain.SysOp">
        <selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER">
            SELECT LAST_INSERT_ID() AS id
        </selectKey>
        insert into sys_op (login_code, login_password,
        op_code, op_name, sex,
        age, img_path, contact_address,
        telephone, card_type_id, card_no,
        email, try_times, acct_start_date,
        acct_end_date, last_login_time, email_switch,
        sms_switch, sys_code, data_state,
        create_empid, create_date, modfiy_empid,
        modfiy_date, remark,org_id)
        values ( #{loginCode,jdbcType=VARCHAR}, #{loginPassword,jdbcType=VARCHAR},
        #{opCode,jdbcType=VARCHAR}, #{opName,jdbcType=VARCHAR}, #{sex,jdbcType=INTEGER},
        #{age,jdbcType=INTEGER}, #{imgPath,jdbcType=VARCHAR}, #{contactAddress,jdbcType=VARCHAR},
        #{telephone,jdbcType=VARCHAR}, #{cardTypeId,jdbcType=INTEGER}, #{cardNo,jdbcType=VARCHAR},
        #{email,jdbcType=VARCHAR}, #{tryTimes,jdbcType=INTEGER}, #{acctStartDate,jdbcType=TIMESTAMP},
        #{acctEndDate,jdbcType=TIMESTAMP}, #{lastLoginTime,jdbcType=TIMESTAMP}, #{emailSwitch,jdbcType=INTEGER},
        #{smsSwitch,jdbcType=INTEGER}, #{sysCode,jdbcType=VARCHAR}, #{dataState,jdbcType=INTEGER},
        #{createEmpid,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, #{modfiyEmpid,jdbcType=VARCHAR},
        #{modfiyDate,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR},#{orgId,jdbcType=BIGINT})
    </insert>

    <!-- 通过操作员id查询操作员的职能id列表 -->
    <select id="querySysJobfuncBySysOpId" resultType="java.lang.Long" parameterType="java.lang.Long">
     SELECT
	a.sys_jobfunc_id
	FROM
		sys_role_jobfunc a,
		sys_op_role b
	WHERE
		1 = 1
	AND a.sys_role_id = b.sys_role_id
	AND b.sys_op_id = #{sysOpId,jdbcType=BIGINT}
  </select>

    <!-- 通过职能id list查询查询菜单ID list -->
    <select id="queryMenuByJobIdList" resultType="com.zteits.sys.domain.SysRes">
        SELECT
        a.id AS id ,
        a.res_code AS resCode ,
        a.res_name AS resName ,
        a.res_type AS res_type ,
        a.res_url AS resUrl ,
        a.parent_res_id AS parentResId ,
        a.res_icon AS resIcon ,
        a.sort_num AS sortNum ,
        a.if_display AS ifDisplay ,
        a.sys_code AS sysCode
        FROM
        sys_res a
        WHERE
        a.data_state = 1
        AND a.id IN(
        SELECT DISTINCT
        (b.res_id)
        FROM
        sys_res_jobfunc b
        WHERE
        b.data_state = 1
        AND b.jobfunc_id IN
        <choose>
            <when test="null==jobfunIdList||jobfunIdList.size==0">
                (-9999)
            </when>
            <otherwise>
                <foreach collection="jobfunIdList" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </otherwise>
        </choose>


        )
        and a.res_type=1
        and a.id !=-2

    </select>
	<!--修改用户 2017-08-10 -->
    <update id="updateByPrimaryKeySelective" parameterType="com.zteits.sys.domain.SysOp">
        update sys_op
        <set>
            <if test="loginCode != null">
                login_code = #{loginCode,jdbcType=VARCHAR},
            </if>
            <if test="loginPassword != null">
                login_password = #{loginPassword,jdbcType=VARCHAR},
            </if>
            <if test="opCode != null">
                op_code = #{opCode,jdbcType=VARCHAR},
            </if>
            <if test="opName != null">
                op_name = #{opName,jdbcType=VARCHAR},
            </if>
            <if test="sex != null">
                sex = #{sex,jdbcType=INTEGER},
            </if>
            <if test="age != null">
                age = #{age,jdbcType=INTEGER},
            </if>
            <if test="imgPath != null">
                img_path = #{imgPath,jdbcType=VARCHAR},
            </if>
            <if test="contactAddress != null">
                contact_address = #{contactAddress,jdbcType=VARCHAR},
            </if>
            <if test="telephone != null">
                telephone = #{telephone,jdbcType=VARCHAR},
            </if>
            <if test="cardTypeId != null">
                card_type_id = #{cardTypeId,jdbcType=INTEGER},
            </if>
            <if test="cardNo != null">
                card_no = #{cardNo,jdbcType=VARCHAR},
            </if>
            <if test="email != null">
                email = #{email,jdbcType=VARCHAR},
            </if>
            <if test="tryTimes != null">
                try_times = #{tryTimes,jdbcType=INTEGER},
            </if>
            <if test="acctStartDate != null">
                acct_start_date = #{acctStartDate,jdbcType=TIMESTAMP},
            </if>
            <if test="acctEndDate != null">
                acct_end_date = #{acctEndDate,jdbcType=TIMESTAMP},
            </if>
            <if test="lastLoginTime != null">
                last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
            </if>
            <if test="emailSwitch != null">
                email_switch = #{emailSwitch,jdbcType=INTEGER},
            </if>
            <if test="smsSwitch != null">
                sms_switch = #{smsSwitch,jdbcType=INTEGER},
            </if>
            <if test="dataState != null">
                data_state = #{dataState,jdbcType=INTEGER},
            </if>
            <if test="createEmpid != null">
                create_empid = #{createEmpid,jdbcType=VARCHAR},
            </if>
            <if test="createDate != null">
                create_date = #{createDate,jdbcType=TIMESTAMP},
            </if>
            <if test="modfiyEmpid != null">
                modfiy_empid = #{modfiyEmpid,jdbcType=VARCHAR},
            </if>
            <if test="modfiyDate != null">
                modfiy_date = #{modfiyDate,jdbcType=TIMESTAMP},
            </if>
            <if test="remark != null">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    
    
    
    <!-- 判断用户名是否唯一  2017-08-10-->
    <select id="loginCodeIsUsed" resultMap="BaseResultMap" parameterType="java.lang.String">
        select
        <include refid="Base_Column_List"/>
        from sys_op
        where  
        login_code =#{loginCode}
        and  data_state=1
        limit 1
    </select>
    <!--通过组织ids查询用户信息-->
    <select id="querySysOpByorgIds" resultType="com.zteits.sys.domain.SysOp" >
      SELECT
			CONCAT('-',a.id) as id,
			a.login_code as loginCode,
		    a.op_name as opName,
		    a.telephone as telephone,
		    b.sys_org_id  as orgId
		FROM
			sys_op a,
			sys_op_org b
		WHERE
			1 = 1
		AND a.data_state = 1
		and a.id = b.sys_op_id
		
		<if test="orgIds != null and orgIds.size >0">
		   and a.org_id in 
		   <foreach collection="orgIds" item="orgId" index="index" separator="," open="(" close=")">
		       #{orgId}
		   </foreach>
		</if>
    
    </select>
   
</mapper>