123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- <?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.huaxu.dao.OrgMapper">
- <!-- 结果集 -->
- <resultMap type="com.huaxu.entity.Org" id="OrgMap">
- <result property="id" column="ID" jdbcType="INTEGER"/>
- <result property="tenantId" column="TENANT_ID" jdbcType="VARCHAR"/>
- <result property="orgType" column="ORG_TYPE" jdbcType="VARCHAR"/>
- <result property="parentOrgId" column="PARENT_ORG_ID" jdbcType="INTEGER"/>
- <result property="orgAreaId" column="ORG_AREA_ID" jdbcType="INTEGER"/>
- <result property="orgName" column="ORG_NAME" jdbcType="VARCHAR"/>
- <result property="orgState" column="ORG_STATE" jdbcType="INTEGER"/>
- <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
- <result property="orgLeaderName" column="ORG_LEADER_NAME" jdbcType="VARCHAR"/>
- <result property="orgLeaderPhone" column="ORG_LEADER_PHONE" jdbcType="VARCHAR"/>
- <result property="orgLeaderEmail" column="ORG_LEADER_EMAIL" jdbcType="VARCHAR"/>
- <result property="orgLeaderSex" column="ORG_LEADER_SEX" jdbcType="VARCHAR"/>
- <result property="status" column="STATUS" jdbcType="INTEGER"/>
- <result property="dateCreate" column="DATE_CREATE" jdbcType="TIMESTAMP"/>
- <result property="createBy" column="CREATE_BY" jdbcType="VARCHAR"/>
- <result property="dateUpdate" column="DATE_UPDATE" jdbcType="TIMESTAMP"/>
- <result property="updateBy" column="UPDATE_BY" jdbcType="VARCHAR"/>
- <result property="parentId" column="parentId" jdbcType="INTEGER"/>
- <result property="parentName" column="parentName" jdbcType="VARCHAR"/>
- <result property="areaName" column="areaName" jdbcType="VARCHAR"/>
- </resultMap>
- <!-- 基本字段 -->
- <sql id="Base_Column_List">
- ID, TENANT_ID, ORG_TYPE, PARENT_ORG_ID, ORG_AREA_ID, ORG_NAME, ORG_STATE, REMARK, ORG_LEADER_NAME, ORG_LEADER_PHONE, ORG_LEADER_EMAIL, ORG_LEADER_SEX, STATUS, DATE_CREATE, CREATE_BY, DATE_UPDATE, UPDATE_BY </sql>
- <!-- 查询单个 -->
- <select id="selectById" resultMap="OrgMap">
- select a.id, a.tenant_id, a.org_type, a.parent_org_id, a.org_area_id, a.org_name, a.org_state, a.remark, a.org_leader_name, a.org_leader_phone, a.org_leader_email, a.org_leader_sex, a.status
- ,b.id parentId,b.ORG_NAME parentName,c.NAME areaName
- from uims_org a left join uims_org b on a.PARENT_ORG_ID=b.ID
- left join uims_area c on a.ORG_AREA_ID=c.id
- where a.ID = #{id}
- </select>
- <!-- 查询全部 -->
- <select id="selectAll" resultMap="OrgMap">
- select
- <include refid="Base_Column_List"/>
- from uims_org
- </select>
- <!--通过实体作为筛选条件查询-->
- <select id="selectList" resultMap="OrgMap">
- select
- <include refid="Base_Column_List"/>
- from uims_org
- <where>
- <if test="id != null">
- and ID = #{id}
- </if>
- <if test="tenantId != null and tenantId != ''">
- and TENANT_ID = #{tenantId}
- </if>
- <if test="orgType != null and orgType != ''">
- and ORG_TYPE = #{orgType}
- </if>
- <if test="parentOrgId != null">
- and PARENT_ORG_ID = #{parentOrgId}
- </if>
- <if test="orgAreaId != null">
- and ORG_AREA_ID = #{orgAreaId}
- </if>
- <if test="orgName != null and orgName != ''">
- and ORG_NAME = #{orgName}
- </if>
- <if test="orgState != null">
- and ORG_STATE = #{orgState}
- </if>
- <if test="remark != null and remark != ''">
- and REMARK = #{remark}
- </if>
- <if test="orgLeaderName != null and orgLeaderName != ''">
- and ORG_LEADER_NAME = #{orgLeaderName}
- </if>
- <if test="orgLeaderPhone != null and orgLeaderPhone != ''">
- and ORG_LEADER_PHONE = #{orgLeaderPhone}
- </if>
- <if test="orgLeaderEmail != null and orgLeaderEmail != ''">
- and ORG_LEADER_EMAIL = #{orgLeaderEmail}
- </if>
- <if test="orgLeaderSex != null and orgLeaderSex != ''">
- and ORG_LEADER_SEX = #{orgLeaderSex}
- </if>
- <if test="status != null">
- and STATUS = #{status}
- </if>
- <if test="dateCreate != null">
- and DATE_CREATE = #{dateCreate}
- </if>
- <if test="createBy != null and createBy != ''">
- and CREATE_BY = #{createBy}
- </if>
- <if test="dateUpdate != null">
- and DATE_UPDATE = #{dateUpdate}
- </if>
- <if test="updateBy != null and updateBy != ''">
- and UPDATE_BY = #{updateBy}
- </if>
- </where>
- </select>
- <!-- 新增所有列 -->
- <insert id="insert" keyProperty="id" useGeneratedKeys="true">
- insert into uims_org(ID, TENANT_ID, ORG_TYPE, PARENT_ORG_ID, ORG_AREA_ID, ORG_NAME, ORG_STATE, REMARK, ORG_LEADER_NAME, ORG_LEADER_PHONE, ORG_LEADER_EMAIL, ORG_LEADER_SEX, STATUS, DATE_CREATE, CREATE_BY, DATE_UPDATE, UPDATE_BY)
- values ( #{id}, #{tenantId}, #{orgType}, #{parentOrgId}, #{orgAreaId}, #{orgName}, #{orgState}, #{remark}, #{orgLeaderName}, #{orgLeaderPhone}, #{orgLeaderEmail}, #{orgLeaderSex}, #{status}, #{dateCreate}, #{createBy}, #{dateUpdate}, #{updateBy})
- </insert>
- <!-- 批量新增 -->
- <insert id="batchInsert">
- insert into uims_org(ID, TENANT_ID, ORG_TYPE, PARENT_ORG_ID, ORG_AREA_ID, ORG_NAME, ORG_STATE, REMARK,
- ORG_LEADER_NAME, ORG_LEADER_PHONE, ORG_LEADER_EMAIL, ORG_LEADER_SEX, STATUS, DATE_CREATE, CREATE_BY,
- DATE_UPDATE, UPDATE_BY)
- values
- <foreach collection="orgs" item="item" index="index" separator=",">
- (
- #{item.id}, #{item.tenantId}, #{item.orgType}, #{item.parentOrgId}, #{item.orgAreaId}, #{item.orgName},
- #{item.orgState}, #{item.remark}, #{item.orgLeaderName}, #{item.orgLeaderPhone}, #{item.orgLeaderEmail},
- #{item.orgLeaderSex}, #{item.status}, #{item.dateCreate}, #{item.createBy}, #{item.dateUpdate},
- #{item.updateBy} )
- </foreach>
- </insert>
- <!-- 通过主键修改数据 -->
- <update id="update">
- update uims.uims_org
- <set>
- <if test="tenantId != null and tenantId != ''">
- TENANT_ID = #{tenantId},
- </if>
- <if test="orgType != null and orgType != ''">
- ORG_TYPE = #{orgType},
- </if>
- <if test="parentOrgId != null">
- PARENT_ORG_ID = #{parentOrgId},
- </if>
- <if test="orgAreaId != null">
- ORG_AREA_ID = #{orgAreaId},
- </if>
- <if test="orgName != null and orgName != ''">
- ORG_NAME = #{orgName},
- </if>
- <if test="orgState != null">
- ORG_STATE = #{orgState},
- </if>
- <if test="remark != null and remark != ''">
- REMARK = #{remark},
- </if>
- <if test="orgLeaderName != null and orgLeaderName != ''">
- ORG_LEADER_NAME = #{orgLeaderName},
- </if>
- <if test="orgLeaderPhone != null and orgLeaderPhone != ''">
- ORG_LEADER_PHONE = #{orgLeaderPhone},
- </if>
- <if test="orgLeaderEmail != null and orgLeaderEmail != ''">
- ORG_LEADER_EMAIL = #{orgLeaderEmail},
- </if>
- <if test="orgLeaderSex != null and orgLeaderSex != ''">
- ORG_LEADER_SEX = #{orgLeaderSex},
- </if>
- <if test="status != null">
- STATUS = #{status},
- </if>
- <if test="dateCreate != null">
- DATE_CREATE = #{dateCreate},
- </if>
- <if test="createBy != null and createBy != ''">
- CREATE_BY = #{createBy},
- </if>
- <if test="dateUpdate != null">
- DATE_UPDATE = #{dateUpdate},
- </if>
- <if test="updateBy != null and updateBy != ''">
- UPDATE_BY = #{updateBy},
- </if>
- </set>
- where ID = #{id}
- </update>
- <!--通过主键删除-->
- <delete id="deleteById">
- delete from uims_org where ID = #{id}
- </delete>
- <!-- 总数 -->
- <select id="count" resultType="int">
- select count(*) from uims_org
- </select>
- <select id="selectPage" resultMap="OrgMap">
- select
- <include refid="Base_Column_List"/>
- from uims_org
- <where>
- status!=0
- <if test="org.id != null">
- and ID = #{org.id}
- </if>
- <if test="org.tenantId != null and org.tenantId != ''">
- and TENANT_ID = #{org.tenantId}
- </if>
- <if test="org.orgType != null and org.orgType != ''">
- and ORG_TYPE = #{org.orgType}
- </if>
- <if test="org.parentOrgId != null">
- and PARENT_ORG_ID = #{org.parentOrgId}
- </if>
- <if test="org.orgAreaId != null">
- and ORG_AREA_ID = #{org.orgAreaId}
- </if>
- <if test="org.orgName != null and org.orgName != ''">
- and ORG_NAME = #{org.orgName}
- </if>
- <if test="org.orgState != null">
- and ORG_STATE = #{org.orgState}
- </if>
- <if test="org.remark != null and org.remark != ''">
- and REMARK = #{org.remark}
- </if>
- <if test="org.orgLeaderName != null and org.orgLeaderName != ''">
- and ORG_LEADER_NAME = #{org.orgLeaderName}
- </if>
- <if test="org.orgLeaderPhone != null and org.orgLeaderPhone != ''">
- and ORG_LEADER_PHONE = #{org.orgLeaderPhone}
- </if>
- <if test="org.orgLeaderEmail != null and org.orgLeaderEmail != ''">
- and ORG_LEADER_EMAIL = #{org.orgLeaderEmail}
- </if>
- <if test="org.orgLeaderSex != null and org.orgLeaderSex != ''">
- and ORG_LEADER_SEX = #{org.orgLeaderSex}
- </if>
- <if test="org.status != null">
- and STATUS = #{org.status}
- </if>
- <if test="org.dateCreate != null">
- and DATE_CREATE = #{org.dateCreate}
- </if>
- <if test="org.createBy != null and org.createBy != ''">
- and CREATE_BY = #{org.createBy}
- </if>
- <if test="org.dateUpdate != null">
- and DATE_UPDATE = #{org.dateUpdate}
- </if>
- <if test="org.updateBy != null and org.updateBy != ''">
- and UPDATE_BY = #{org.updateBy}
- </if>
- </where>
- </select>
- <select id="findOrgUser" resultType="com.huaxu.entity.Org">
- select a.ID,a.ORG_NAME orgName from uims_org a join uims_user b on
- (a.ID=b.DEPT_ORG_ID or a.ID=b.COMPANY_ORG_ID)
- where a.id=#{id} and b.status!=0
- limit 1
- </select>
- <select id="selectTrees" resultType="com.huaxu.dto.OrgTree">
- select ID, TENANT_ID, ORG_TYPE, PARENT_ORG_ID, ORG_AREA_ID, ORG_NAME, ORG_STATE, REMARK, ORG_LEADER_NAME, ORG_LEADER_PHONE, ORG_LEADER_EMAIL, ORG_LEADER_SEX, STATUS, DATE_CREATE, CREATE_BY, DATE_UPDATE, UPDATE_BY
- from uims_org
- <where>
- and status!=0
- <if test="tenantId!=null ">
- and TENANT_ID=#{tenantId}
- </if>
- <if test="orgType=='company'||orgType=='department'">
- and ORG_TYPE=#{orgType}
- </if>
- <if test="id!=null">
- and id=#{id}
- </if>
- </where>
- </select>
- <select id="findOrgType" resultType="com.huaxu.entity.Org">
- select a.ORG_TYPE , b.ORG_TYPE parentType,c.ORG_TYPE childType
- from uims_org a left join uims_org b on a.PARENT_ORG_ID=b.ID
- left join uims_org c on a.id=c.PARENT_ORG_ID
- where a.id=#{id} limit 1
- </select>
- </mapper>
|