123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- <?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.IndustryMapper">
- <resultMap id="IndustryDtoResultMap" type="com.zhyc.xps.sys.dto.IndustryDto" >
- <id column="industry_id" property="industryId" jdbcType="BIGINT" />
- <result column="industry_code" property="industryCode" jdbcType="VARCHAR" />
- <result column="industry_name" property="industryName" jdbcType="VARCHAR" />
- <result column="parent_id" property="parentId" jdbcType="BIGINT" />
- <result column="parent_name" property="parentName" jdbcType="VARCHAR" />
- <result column="root_id" property="rootId" jdbcType="BIGINT" />
- <result column="industry_type_id" property="industryTypeId" jdbcType="VARCHAR" />
- <result column="industry_logo" property="industryLogo" jdbcType="VARCHAR" />
- <result column="industry_desc" property="industryDesc" jdbcType="VARCHAR" />
- <result column="sort_no" property="sortNo" jdbcType="BIGINT" />
- <result column="node_left" property="nodeLeft" jdbcType="BIGINT" />
- <result column="node_right" property="nodeRight" jdbcType="BIGINT" />
- <result column="node_level" property="nodeLevel" jdbcType="BIGINT" />
- <result column="is_leaf" property="isLeaf" jdbcType="BIGINT" />
- </resultMap>
- <sql id="IndustryDto_Cols">
- A.industry_id,
- A.industry_code,
- A.industry_name,
- A.parent_id,
- B.industry_name as parent_name,
- A.root_id,
- A.industry_logo,
- A.industry_type_id,
- A.industry_desc,
- A.sort_no,
- A.node_left,
- A.node_right,
- A.node_level,
- A.is_leaf,
- A.created_by,
- A.updated_by,
- A.created_at,
- A.updated_at
- </sql>
-
- <!--获取子行业的数目-->
- <select id="countOfSubIndustry" resultType="java.lang.Integer" >
- SELECT
- count(*)
- FROM
- industry
- WHERE 1 = 1 AND deleted_flag = 0
- AND parent_id = #{parentId, jdbcType=BIGINT}
- </select>
-
- <!--根据ID获取行业信息-->
- <select id="getById" resultMap="IndustryDtoResultMap" parameterType="java.lang.Long">
- SELECT
- <include refid="IndustryDto_Cols"/>
- FROM industry AS A
- LEFT JOIN industry AS B ON (A.parent_id = B.industry_id)
- WHERE A.industry_id = #{industryId, jdbcType=BIGINT}
- </select>
- <!--列表查询-->
- <select id="getByList" parameterType="java.util.Map" resultMap="IndustryDtoResultMap">
- SELECT
- <include refid="IndustryDto_Cols"/>
- FROM industry AS A
- LEFT JOIN industry AS B ON (A.parent_id = B.industry_id)
- WHERE A.deleted_flag = 0
- <if test="industryCode != null and industryCode != ''">
- AND A.industry_code = #{industryCode, jdbcType=VARCHAR}
- </if>
- <if test="industryName != null and industryName != ''">
- AND A.industry_name = #{industryName, jdbcType=VARCHAR}
- </if>
- <if test="industryLogo != null and industryLogo != ''">
- AND A.industry_logo = #{industryLogo, jdbcType=VARCHAR}
- </if>
- <if test="parentId != null">
- AND A.parent_id = #{parent_id, jdbcType=BIGINT}
- </if>
- ORDER BY A.sort_no ASC
- </select>
- <!--Create 新增-->
- <insert id="create" parameterType="com.zhyc.xps.sys.entity.Industry">
- INSERT INTO industry
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="industryId != null">
- industry_id,
- </if>
- <if test="parentId != null">
- parent_id,
- </if>
- <if test="rootId != null">
- root_id,
- </if>
- <if test="industryCode != null and industryCode != ''">
- industry_code,
- </if>
- <if test="industryName != null and industryName != ''">
- industry_name,
- </if>
- <if test="industryLogo != null and industryLogo != ''">
- industry_logo,
- </if>
- <if test="industryTypeId != null">
- industry_type_id,
- </if>
- <if test="industryDesc != null and industryDesc != ''">
- industry_desc,
- </if>
- <if test="sortNo != null">
- sort_no,
- </if>
- <if test="nodeLeft != null">
- node_left,
- </if>
- <if test="nodeRight != null">
- node_right,
- </if>
- <if test="nodeLevel != null">
- node_level,
- </if>
- <if test="isLeaf != null">
- is_leaf,
- </if>
- <if test="createdBy != null">
- created_by,
- </if>
- <if test="createdAt != null">
- created_at,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="industryId != null">
- #{industryId ,jdbcType=BIGINT},
- </if>
- <if test="parentId != null">
- #{parentId ,jdbcType=BIGINT},
- </if>
- <if test="rootId != null">
- #{rootId ,jdbcType=BIGINT},
- </if>
- <if test="industryCode != null and industryCode != ''">
- #{industryCode ,jdbcType=VARCHAR},
- </if>
- <if test="industryName != null and industryName != ''">
- #{industryName ,jdbcType=VARCHAR},
- </if>
- <if test="industryLogo != null and industryLogo != ''">
- #{industryLogo ,jdbcType=VARCHAR},
- </if>
- <if test="industryTypeId != null">
- #{industryTypeId ,jdbcType=BIGINT},
- </if>
- <if test="industryDesc != null and industryDesc != ''">
- #{industryDesc ,jdbcType=VARCHAR},
- </if>
- <if test="sortNo != null">
- #{sortNo ,jdbcType=BIGINT},
- </if>
- <if test="nodeLeft != null">
- #{nodeLeft ,jdbcType=BIGINT},
- </if>
- <if test="nodeRight != null">
- #{nodeRight ,jdbcType=BIGINT},
- </if>
- <if test="nodeLevel != null">
- #{nodeLevel ,jdbcType=BIGINT},
- </if>
- <if test="isLeaf != null">
- #{isLeaf ,jdbcType=BIGINT},
- </if>
- <if test="createdBy != null">
- #{createdBy ,jdbcType=BIGINT},
- </if>
- <if test="createdAt != null">
- #{createdAt ,jdbcType=DATETIME},
- </if>
- </trim>
- </insert>
-
- <!--Update更新-->
- <update id="update" parameterType="com.zhyc.xps.sys.entity.Industry">
- UPDATE industry
- <set>
- <if test="parentId != null">
- parent_id = #{parentId,jdbcType=BIGINT},
- </if>
- <if test="rootId != null">
- root_id = #{rootId ,jdbcType=BIGINT},
- </if>
- <if test="industryCode != null and industryCode != ''">
- industry_code = #{industryCode,jdbcType=VARCHAR},
- </if>
- <if test="industryName != null and industryName != ''">
- industry_name = #{industryName,jdbcType=VARCHAR},
- </if>
- <if test="industryLogo != null and industryLogo != ''">
- industry_logo = #{industryLogo,jdbcType=VARCHAR},
- </if>
- <if test="industryTypeId != null">
- industry_type_id = #{industryTypeId,jdbcType=BIGINT},
- </if>
- <if test="industryDesc != null and industryDesc != ''">
- industry_desc = #{industryDesc,jdbcType=VARCHAR},
- </if>
- <if test="sortNo != null">
- sort_no = #{sortNo ,jdbcType=BIGINT},
- </if>
- <if test="nodeLeft != null">
- node_left = #{nodeLeft ,jdbcType=BIGINT},
- </if>
- <if test="nodeRight != null">
- node_right = #{nodeRight ,jdbcType=BIGINT},
- </if>
- <if test="nodeLevel != null">
- node_level = #{nodeLevel ,jdbcType=BIGINT},
- </if>
- <if test="isLeaf != null">
- is_leaf = #{isLeaf ,jdbcType=BIGINT},
- </if>
- <if test="updatedBy != null">
- updated_by = #{updatedBy,jdbcType=BIGINT},
- </if>
- <if test="updatedAt != null">
- updated_at = #{updatedAt,jdbcType=DATETIME},
- </if>
- </set>
- WHERE industry_id = #{industryId ,jdbcType=BIGINT}
- </update>
- <!--删除-->
- <delete id="delete" parameterType="java.util.Map">
- DELETE FROM industry
- WHERE 1 = 1
- <if test="industryId != null">
- AND industry_id = #{industryId,jdbcType=BIGINT}
- </if>
- </delete>
- </mapper>
|