123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430 |
- <?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.ProductMapper">
- <!--插入数据-->
- <!--int insert(Product product);-->
- <insert id="insert" useGeneratedKeys="true" keyProperty="id">
- insert into product (product_name, market_time, company_name, tenant_id, create_person_tenant_id,
- product_explain, product_category_id, license_rate, create_person_id, create_person_name)
- values (#{productName}, #{marketTime}, #{companyName}, #{tenantId}, #{createPersonTenantId}, #{productExplain},
- #{productCategoryId}, #{licenseRate}, #{createPersonId}, #{createPersonName});
- </insert>
- <!--根据id删除产品-->
- <!--int deleteById(Integer id);-->
- <delete id="deleteById">
- delete
- from product
- where id = #{id}
- </delete>
- <!--根据产品id修改数据-->
- <!--int updateById(Product product);-->
- <update id="updateById">
- update product
- <set>
- product_name = #{productName},
- market_time = #{marketTime},
- company_name = #{companyName},
- <if test="tenantId != null">
- tenant_id = #{tenantId},
- </if>
- <if test="createPersonTenantId != null">
- create_person_tenant_id = #{createPersonTenantId},
- </if>
- product_explain = #{productExplain},
- product_category_id = #{productCategoryId},
- license_rate = #{licenseRate},
- </set>
- where id = #{id}
- </update>
- <!--根据产品名称统计数量-->
- <!--int countByProductName(String productName, Integer productCategoryId);-->
- <select id="countByProductName" resultType="int">
- select count(*)
- from product
- where product_name = #{productName}
- and product_category_id = #{productCategoryId}
- </select>
- <!--根据id统计数量-->
- <!--int countById(Integer id);-->
- <select id="countById" resultType="int">
- select count(*)
- from product
- where id = #{id}
- </select>
- <!--根据id查询名称-->
- <!-- String queryNameById(Integer id);;-->
- <select id="queryNameById" resultType="String">
- select product_Name
- from product
- where id = #{id}
- </select>
- <!--根据所属产品类别id统计数量-->
- <!--int countByProductCategoryId(Integer productCategoryId);-->
- <select id="countByProductCategoryId" resultType="int">
- select count(*)
- from product
- where product_category_id = #{productCategoryId}
- </select>
- <!--根据id查询数据-->
- <!--ProductVO getStandardById(Integer id);-->
- <select id="getStandardById" resultMap="queryMap">
- select id as p_id,
- product_name,
- market_time,
- company_name,
- tenant_id,
- product_explain,
- product_category_id,
- license_rate,
- create_person_name
- from product
- where id = #{id}
- </select>
- <!--分页查询数据-->
- <!--List<ProductVO> query(ProductQueryPageDTO productQueryPageDTO);-->
- <select id="query" resultMap="queryMap">
- select p.id p_id,
- product_name,
- market_time,
- company_name,
- p.tenant_id,
- create_person_tenant_id,
- product_explain,
- product_category_id,
- p.license_rate,
- p.create_person_name,
- product_category_name
- from product p
- join product_category pc on p.product_category_id = pc.id
- <where>
- <if test="productName != null and productName != ''">
- and product_name like '%${productName}%'
- </if>
- <if test="companyName != null and companyName != ''">
- and company_name like '%${companyName}%'
- </if>
- <if test="patentNo != null and patentNo != ''">
- and p.id in
- (select product_id from asso_product_patent where patent_no = #{patentNo})
- </if>
- <if test="productCategoryId != null and productCategoryId != ''">
- and product_category_id = #{productCategoryId}
- </if>
- <if test="productCategoryName != null and productCategoryName != ''">
- and product_category_id in (select id from product_category where product_category_name like
- '%${productCategoryName}%')
- </if>
- <if test="true">
- and create_person_tenant_id = #{createPersonTenantId}
- </if>
- </where>
- order by
- <choose>
- <when test="orderBy != null and orderBy != ''">
- ${orderBy} ${orderType}
- </when>
- <otherwise>
- p_id
- </otherwise>
- </choose>
- </select>
- <resultMap id="queryMap" type="cn.cslg.pas.common.model.vo.ProductVO">
- <id column="p_id" property="id"/>
- <result column="product_name" property="productName"/>
- <result column="market_time" property="marketTime"/>
- <result column="company_name" property="companyName"/>
- <result column="tenant_id" property="tenantId"/>
- <result column="product_explain" property="productExplain"/>
- <result column="product_category_id" property="productCategoryId"/>
- <result column="license_rate" property="licenseRate"/>
- <result column="create_person_name" property="createPersonName"/>
- <collection property="pictures" ofType="cn.cslg.pas.common.model.vo.ProductPictureVO"
- select="query2" column="{p_id=p_id}">
- </collection>
- <collection property="productPatentNum" ofType="Integer"
- select="query3" column="{p_id=p_id}">
- </collection>
- <collection property="patentNum" ofType="Integer"
- select="query33" column="{p_id=p_id}">
- </collection>
- <collection property="productCategory" ofType="cn.cslg.pas.common.model.vo.ProductCategoryVO"
- select="query4" column="{pc_id=product_category_id}">
- </collection>
- </resultMap>
- <select id="query2" resultMap="query2Map">
- select id, product_id, name, suffix, url
- from asso_product_picture
- where product_id = #{p_id}
- </select>
- <resultMap id="query2Map" type="cn.cslg.pas.common.model.vo.ProductPictureVO">
- <id column="id" property="id"/>
- <result column="product_id" property="productId"/>
- <result column="name" property="name"/>
- <result column="suffix" property="suffix"/>
- <result column="url" property="url"/>
- </resultMap>
- <select id="query3" resultType="Integer">
- select count(distinct patent_no)
- from asso_product_patent
- where product_id = #{p_id}
- </select>
- <select id="query33" resultType="Integer">
- select count(distinct patent_no)
- from asso_structure_patent
- where product_id = #{p_id}
- </select>
- <select id="query4" resultMap="query4Map">
- select id pc_id,
- product_category_name,
- remark,
- license_rate,
- create_person_name
- from product_category
- where id = #{pc_id}
- </select>
- <resultMap id="query4Map" type="cn.cslg.pas.common.model.vo.ProductCategoryVO">
- <id column="pc_id" property="id"/>
- <result column="product_category_name" property="productCategoryName"/>
- <result column="remark" property="remark"/>
- <result column="license_rate" property="licenseRate"/>
- <result column="create_person_name" property="createPersonName"/>
- <collection property="pictures" ofType="cn.cslg.pas.common.model.vo.ProductCategoryPictureVO"
- select="query41" column="pc_id">
- </collection>
- </resultMap>
- <select id="query41" resultMap="query41Map">
- select id, product_category_id, name, suffix, url
- from asso_product_category_picture
- where product_category_id = #{pc_id}
- </select>
- <resultMap id="query41Map" type="cn.cslg.pas.common.model.vo.ProductCategoryPictureVO">
- <id column="id" property="id"/>
- <result column="product_category_id" property="productCategoryId"/>
- <result column="name" property="name"/>
- <result column="suffix" property="suffix"/>
- <result column="url" property="url"/>
- </resultMap>
- <!--根据产品类别分组分页查询数据-->
- <!--List<ProductGroupVO> queryByGroupProductCategoryId(ProductQueryPageDTO productQueryPageDTO);-->
- <select id="queryByGroupProductCategoryId" resultMap="queryByGroupProductCategoryIdMap">
- select product_category_id pci,
- product_category_name,
- create_person_tenant_id as createPersonTenantId,
- ifnull(#{orderBy}, '') orderBy,
- ifnull(#{orderType}, '') orderType,
- ifnull(#{productName}, '') productName,
- ifnull(#{companyName}, '') companyName,
- ifnull(#{patentNo}, '') patentNo,
- ifnull(#{productCategoryId}, '') productCategoryId,
- ifnull(#{productCategoryName}, '') productCategoryName
- from product p
- join product_category pc on p.product_category_id = pc.id
- <where>
- <if test="productName != null and productName != ''">
- and product_name like '%${productName}%'
- </if>
- <if test="companyName != null and companyName != ''">
- and company_name like '%${companyName}%'
- </if>
- <if test="patentNo != null and patentNo != ''">
- and p.id in
- (select product_id from asso_product_patent where patent_no = #{patentNo})
- </if>
- <if test="productCategoryId != null and productCategoryId != ''">
- and product_category_id = #{productCategoryId}
- </if>
- <if test="productCategoryName != null and productCategoryName != ''">
- and product_category_id in (select id from product_category where product_category_name like
- '%${productCategoryName}%')
- </if>
- <if test="true">
- and p.create_person_tenant_id = #{createPersonTenantId}
- </if>
- </where>
- group by product_category_id
- order by product_category_id
- </select>
- <resultMap id="queryByGroupProductCategoryIdMap" type="cn.cslg.pas.common.model.vo.ProductGroupVO">
- <result column="product_category_id" property="productCategoryId"/>
- <result column="product_category_name" property="productCategoryName"/>
- <collection property="products" ofType="cn.cslg.pas.common.model.vo.ProductVO"
- select="queryByGroupProductCategoryId2"
- column="{pci=pci, orderBy=orderBy, orderType=orderType, productName=productName, companyName=companyName,
- patentNo=patentNo, productCategoryId=productCategoryId, productCategoryName=productCategoryName, createPersonTenantId=createPersonTenantId}">
- </collection>
- </resultMap>
- <select id="queryByGroupProductCategoryId2" resultMap="queryMap">
- select p.id p_id,
- product_name,
- market_time,
- company_name,
- p.tenant_id,
- product_explain,
- product_category_id,
- p.license_rate,
- p.create_person_name,
- product_category_name
- from product p
- join product_category pc on p.product_category_id = pc.id
- <where>
- <if test="productName != null and productName != ''">
- and product_name like '%${productName}%'
- </if>
- <if test="companyName != null and companyName != ''">
- and company_name like '%${companyName}%'
- </if>
- <if test="patentNo != null and patentNo != ''">
- and p.id in
- (select product_id from asso_product_patent where patent_no = #{patentNo}
- union select product_id from asso_structure_patent where patent_no = #{patentNo})
- </if>
- <if test="productCategoryId != null and productCategoryId != ''">
- and product_category_id = #{productCategoryId}
- </if>
- <if test="productCategoryName != null and productCategoryName != ''">
- and product_category_id in (select id from product_category where product_category_name like
- '%${productCategoryName}%')
- </if>
- <if test="true">
- and product_category_id = #{pci}
- </if>
- <if test="true">
- and p.create_person_tenant_id = #{createPersonTenantId}
- </if>
- </where>
- order by
- <choose>
- <when test="orderBy != null and orderBy != ''">
- ${orderBy} ${orderType}
- </when>
- <otherwise>
- p_id
- </otherwise>
- </choose>
- </select>
- <!--根据公司分组分页查询数据-->
- <!--List<ProductGroupVO> queryByGroupCompanyName(ProductQueryPageDTO productQueryPageDTO);-->
- <select id="queryByGroupCompanyName" resultMap="queryByGroupCompanyNameMap">
- select company_name cn,
- create_person_tenant_id as createPersonTenantId,
- ifnull(#{orderBy}, '') orderBy,
- ifnull(#{orderType}, '') orderType,
- ifnull(#{productName}, '') productName,
- ifnull(#{companyName}, '') companyName,
- ifnull(#{patentNo}, '') patentNo,
- ifnull(#{productCategoryId}, '') productCategoryId,
- ifnull(#{productCategoryName}, '') productCategoryName
- from product
- <where>
- <if test="productName != null and productName != ''">
- and product_name like '%${productName}%'
- </if>
- <if test="companyName != null and companyName != ''">
- and company_name like '%${companyName}%'
- </if>
- <if test="patentNo != null and patentNo != ''">
- and id in
- (select product_id from asso_product_patent where patent_no = #{patentNo})
- </if>
- <if test="productCategoryId != null and productCategoryId != ''">
- and product_category_id = #{productCategoryId}
- </if>
- <if test="productCategoryName != null and productCategoryName != ''">
- and product_category_id in (select id from product_category where product_category_name like
- '%${productCategoryName}%')
- </if>
- <if test="true">
- and company_name is not null
- </if>
- <if test="true">
- and create_person_tenant_id = #{createPersonTenantId}
- </if>
- </where>
- group by company_name
- order by company_name
- </select>
- <resultMap id="queryByGroupCompanyNameMap" type="cn.cslg.pas.common.model.vo.ProductGroupVO">
- <result column="cn" property="companyName"/>
- <collection property="products" ofType="cn.cslg.pas.common.model.vo.ProductVO"
- select="queryByGroupCompanyName2"
- column="{cn=cn, orderBy=orderBy, orderType=orderType, productName=productName, companyName=companyName,
- patentNo=patentNo, productCategoryId=productCategoryId, productCategoryName=productCategoryName, createPersonTenantId=createPersonTenantId}">
- </collection>
- </resultMap>
- <select id="queryByGroupCompanyName2" resultMap="queryMap">
- select p.id p_id,
- product_name,
- market_time,
- company_name,
- p.tenant_id,
- product_explain,
- product_category_id,
- p.license_rate,
- p.create_person_name,
- product_category_name
- from product p
- join product_category pc on p.product_category_id = pc.id
- <where>
- <if test="productName != null and productName != ''">
- and product_name like '%${productName}%'
- </if>
- <if test="companyName != null and companyName != ''">
- and company_name like '%${companyName}%'
- </if>
- <if test="patentNo != null and patentNo != ''">
- and p.id in
- (select product_id from asso_product_patent where patent_no = #{patentNo}
- union select product_id from asso_structure_patent where patent_no = #{patentNo})
- </if>
- <if test="productCategoryId != null and productCategoryId != ''">
- and product_category_id = #{productCategoryId}
- </if>
- <if test="productCategoryName != null and productCategoryName != ''">
- and product_category_id in (select id from product_category where product_category_name like
- '%${productCategoryName}%')
- </if>
- <if test="true">
- and company_name = #{cn}
- </if>
- <if test="true">
- and p.create_person_tenant_id = #{createPersonTenantId}
- </if>
- </where>
- order by
- <choose>
- <when test="orderBy != null and orderBy != ''">
- ${orderBy} ${orderType}
- </when>
- <otherwise>
- p_id
- </otherwise>
- </choose>
- </select>
- </mapper>
|