123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- <?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="cn.cslg.pas.mapper.StructureMapper">
- <!--插入数据-->
- <!--int insert(Structure structure);-->
- <insert id="insert" useGeneratedKeys="true" keyProperty="id">
- insert into structure (parent_id, structure_name, path, remark, product_id, create_person_id,
- create_person_name)
- values (#{parentId}, #{structureName}, #{path}, #{remark}, #{productId}, #{createPersonId},
- #{createPersonName});
- </insert>
- <!--根据id删除数据-->
- <!--int deleteById(Integer id);-->
- <delete id="deleteById">
- delete
- from structure
- where id = #{id}
- </delete>
- <!--根据id批量删除数据-->
- <!--int deleteByIds(List<Integer> ids);-->
- <delete id="deleteByIds">
- delete
- from structure
- where id in (
- <foreach collection="list" item="n" separator=",">
- #{n}
- </foreach>
- )
- </delete>
- <!--根据id修改数据-->
- <!--int update(Structure structure);-->
- <update id="update">
- update structure
- <set>
- <if test="parentId != null">
- parent_id = #{parentId},
- </if>
- <if test="structureName != null">
- structure_name = #{structureName},
- </if>
- <if test="path != null">
- path = #{path},
- </if>
- <if test="remark != null">
- remark = #{remark},
- </if>
- <if test="productId != null">
- product_id = #{productId},
- </if>
- </set>
- where id = #{id}
- </update>
- <!--根据父级id和名称和架构id统计数量-->
- <!--int countByparentIdAndStructureName(Integer parentId, String structureName, Integer structureId);-->
- <select id="countByparentIdAndStructureName" resultType="int">
- select count(*)
- from structure
- where
- product_id = #{productId}
- and parent_id = #{parentId}
- and structure_name = #{structureName}
- <if test="structureId != null">
- and id != #{structureId}
- </if>
- </select>
- <!--根据id查询数据-->
- <!--Structure selectById(Integer id);-->
- <select id="getStandardById" resultMap="getStandardByIdMap">
- select id,
- parent_id,
- structure_name,
- path,
- remark,
- product_id,
- create_person_name,
- create_time
- from structure
- where id = #{id}
- </select>
- <resultMap id="getStandardByIdMap" type="cn.cslg.pas.domain.Structure">
- <id column="id" property="id"/>
- <result column="parent_id" property="parentId"/>
- <result column="structure_name" property="structureName"/>
- <result column="path" property="path"/>
- <result column="remark" property="remark"/>
- <result column="product_id" property="productId"/>
- <result column="create_person_name" property="createPersonName"/>
- <result column="create_time" property="createTime"/>
- </resultMap>
- <!--根据id查询数据和图片-->
- <!--StructureVO getStandAndPictureById(Integer id);-->
- <!-- <select id="getStandardAndPictureById" resultMap="selectByParentIdMap">-->
- <!-- select id s_id,-->
- <!-- parent_id,-->
- <!-- structure_name,-->
- <!-- path,-->
- <!-- remark,-->
- <!-- product_id,-->
- <!-- create_person_name,-->
- <!-- create_time-->
- <!-- from structure-->
- <!-- where id = #{id}-->
- <!-- </select>-->
- <select id="getStandardAndPictureById" resultMap="selectTreeMap">
- select stru.id as stru_id,
- stru.parent_id,
- stru.structure_name,
- stru.path,
- stru.remark,
- stru.product_id,
- stru.create_person_name,
- stru.create_time,
- count(distinct struP.patent_no) as patent_num
- from structure stru
- left join asso_structure_patent struP on find_in_set(stru.id, struP.path)
- where stru.id = #{id}
- </select>
- <!--根据父级id和产品id查询数据-->
- <!--List<StructureVO> selectByParentIdAndProductId(Integer parentId, Integer productId, List<Integer> ids);-->
- <select id="selectByParentIdAndProductId" resultMap="selectByParentIdMap">
- select id s_id,
- parent_id,
- structure_name,
- path,
- remark,
- product_id,
- create_person_name,
- create_time
- from structure
- where parent_id = #{parentId}
- and product_id = #{productId}
- <if test="ids != null">
- and id in
- <foreach collection="ids" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- order by s_id
- </select>
- <resultMap id="selectByParentIdMap" type="cn.cslg.pas.common.model.vo.StructureVO">
- <id column="s_id" property="id"/>
- <result column="parent_id" property="parentId"/>
- <result column="structure_name" property="structureName"/>
- <result column="path" property="path"/>
- <result column="remark" property="remark"/>
- <result column="product_id" property="productId"/>
- <result column="create_person_name" property="createPersonName"/>
- <result column="create_time" property="createTime"/>
- <collection property="pictures" ofType="cn.cslg.pas.common.model.vo.StructurePictureVO"
- select="selectByParentId2" column="s_id">
- </collection>
- <collection property="patentNum" ofType="integer"
- select="selectByParentId3" column="s_id">
- </collection>
- </resultMap>
- <select id="selectByParentId2" resultMap="selectByParentIdMap2">
- select id,
- structure_id,
- name,
- suffix,
- url
- from asso_structure_picture
- where structure_id = #{s_id}
- </select>
- <resultMap id="selectByParentIdMap2" type="cn.cslg.pas.common.model.vo.StructurePictureVO">
- <id column="id" property="id"/>
- <result column="structure_id" property="structureId"/>
- <result column="name" property="name"/>
- <result column="suffix" property="suffix"/>
- <result column="url" property="url"/>
- </resultMap>
- <select id="selectByParentId3" resultType="integer">
- select count(*)
- from asso_structure_patent
- where structure_id in (select id from structure where find_in_set(#{s_id}, path))
- </select>
- <!--根据父级id和产品id查询数据-->
- <!--List<StructureVO> selectTree(Integer parentId, Integer productId, List<Integer> ids);-->
- <select id="selectTree" resultMap="selectTreeMap">
- select stru.id as stru_id,
- stru.parent_id,
- stru.structure_name,
- stru.path,
- stru.remark,
- stru.product_id,
- stru.create_person_name,
- stru.create_time,
- count(distinct struP.patent_no) as patent_num
- from structure stru
- left join asso_structure_patent struP on find_in_set(stru.id, struP.path)
- where stru.parent_id = #{parentId}
- and stru.product_id = #{productId}
- <if test="ids != null and ids.size > 0">
- and stru.id in (
- <foreach collection="ids" item="item" separator=",">
- #{item}
- </foreach>
- )
- </if>
- group by stru.id
- order by stru.id
- </select>
- <resultMap id="selectTreeMap" type="cn.cslg.pas.common.model.vo.StructureVO">
- <id column="stru_id" property="id"/>
- <result column="parent_id" property="parentId"/>
- <result column="structure_name" property="structureName"/>
- <result column="path" property="path"/>
- <result column="remark" property="remark"/>
- <result column="product_id" property="productId"/>
- <result column="create_person_name" property="createPersonName"/>
- <result column="create_time" property="createTime"/>
- <result column="patent_num" property="patentNum"/>
- </resultMap>
- <!--根据模糊路径查询数据-->
- <!--List<StructureVO> selectByFindInSetPath(String findInSetPath);-->
- <select id="selectByFindInSetPath" resultMap="selectByFindInSetPathMap">
- select id,
- parent_id,
- structure_name,
- path,
- remark,
- product_id
- from structure
- where find_in_set(#{findInSetPath}, path)
- order by id
- </select>
- <resultMap id="selectByFindInSetPathMap" type="cn.cslg.pas.common.model.vo.StructureVO">
- <id column="id" property="id"/>
- <result column="parent_id" property="parentId"/>
- <result column="structure_name" property="structureName"/>
- <result column="path" property="path"/>
- <result column="remark" property="remark"/>
- <result column="product_id" property="productId"/>
- </resultMap>
- <!--根据产品id查询数据-->
- <!--List<StructureVO> selectAllByProductId(Integer productId);-->
- <select id="selectAllByProductId" resultMap="selectByFindInSetPathMap">
- select id,
- parent_id,
- structure_name,
- path,
- remark,
- product_id
- from structure
- where product_id = #{productId}
- order by path
- </select>
- <!--根据架构id查询数据-->
- <!--List<StructureVO> selectAllByStructureId(Integer structureId);-->
- <select id="selectAllByStructureId" resultMap="selectByFindInSetPathMap">
- select id,
- parent_id,
- structure_name,
- path,
- remark,
- product_id
- from structure
- where find_in_set(#{structureId}, path)
- order by path
- </select>
- </mapper>
|