<?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.hotent.uc.dao.MatrixDao">
	<resultMap id="Matrix" type="com.hotent.uc.model.Matrix">
		<id property="id" column="ID_" jdbcType="VARCHAR"/>
		<result property="code" column="CODE_" jdbcType="VARCHAR"/>
		<result property="name" column="NAME_" jdbcType="VARCHAR"/>
		<result property="typeId" column="TYPE_ID_" jdbcType="VARCHAR"/>
		<result property="typeName" column="TYPE_NAME_" jdbcType="VARCHAR"/>
		<result property="status" column="STATUS_" jdbcType="NUMERIC"/>
		<result property="managerId" column="MANAGER_ID_" jdbcType="VARCHAR"/>
		<result property="managerName" column="MANAGER_NAME_" jdbcType="VARCHAR"/>
		<result property="isDele" column="IS_DELE_" jdbcType="NUMERIC"/>
		<result property="createBy" column="CREATE_BY_" jdbcType="VARCHAR"/>
		<result property="createTime" column="CREATE_TIME_" jdbcType="TIMESTAMP"/>
		<result property="createOrgId" column="CREATE_ORG_ID_" jdbcType="VARCHAR"/>
		<result property="updateBy" column="UPDATE_BY_" jdbcType="VARCHAR"/>
		<result property="updateTime" column="UPDATE_TIME_" jdbcType="TIMESTAMP"/>
		<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR"/>
		<result property="enabled" column="ENABLED_" jdbcType="NUMERIC"/>
	</resultMap>
	
	<select id="getByCode" parameterType="java.lang.String" resultMap="Matrix">
		SELECT * FROM uc_matrix
		WHERE 
		CODE_ = #{code}
	</select>
	<select id="isCodeExist" parameterType="java.util.Map" resultType="java.lang.Boolean">
		SELECT CASE WHEN count(1)>0 THEN 1 ELSE 0 END FROM uc_matrix
		WHERE 
		CODE_ = #{code}
		<if test="@com.hotent.base.ognl.Ognl@isNotEmpty(id)">
			AND ID_ != #{id}
		</if>
	</select>
	<update id="deleLogical" parameterType="java.util.Map">
		UPDATE uc_matrix SET 
		IS_DELE_ = 1
		WHERE
		ID_ IN 
		<foreach collection="ids" item="item" open="(" close=")" separator=",">
			#{item}
		</foreach>
	</update>
</mapper>