|
@@ -1,430 +1,48 @@
|
|
|
<?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">
|
|
|
-
|
|
|
+<!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">
|
|
|
+ <!--namespace根据自己需要创建的的mapper的路径和名称填写-->
|
|
|
+ <select id="getProduct" resultType="cn.cslg.pas.common.vo.business.ProductVO">
|
|
|
+ select product.id as id ,product.name as name , product.license_rate as licenseRate
|
|
|
+ ,product.category_id as categoryId,product.show_type as showType
|
|
|
+ ,product.description as description,
|
|
|
+ product.create_id as createId, product.tenant_id as tenantId,
|
|
|
+ product.market_time as
|
|
|
+ marketTime,product.create_time as createTime,
|
|
|
+ product.company_name,product.description as description
|
|
|
+ from
|
|
|
+ product as product left join product_category as category
|
|
|
+ on category.id = product.category_id
|
|
|
+ <if test="sql1!=''">
|
|
|
+ where ${sql1}
|
|
|
+ </if>
|
|
|
+ ${sql2} ${sql3}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getProductCount" resultType="java.lang.Long">
|
|
|
select count(*)
|
|
|
- from product
|
|
|
- where product_name = #{productName}
|
|
|
- and product_category_id = #{productCategoryId}
|
|
|
- </select>
|
|
|
+ from product as product left join product_category as category
|
|
|
+ on category.id = product.category_id
|
|
|
+ <if test="sql!=''">
|
|
|
|
|
|
- <!--根据id统计数量-->
|
|
|
- <!--int countById(Integer id);-->
|
|
|
- <select id="countById" resultType="int">
|
|
|
- select count(*)
|
|
|
- from product
|
|
|
- where id = #{id}
|
|
|
- </select>
|
|
|
+ where ${sql}
|
|
|
+ </if>
|
|
|
|
|
|
- <!--根据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
|
|
|
+ <select id="getProductOrCategoryNameOrder" resultType="cn.cslg.pas.common.vo.ProductOrCategoryVO">
|
|
|
+ select *
|
|
|
+ from (select id as id, name as name, 2 as type
|
|
|
from product
|
|
|
- where id = #{id}
|
|
|
+ union all
|
|
|
+ select id as id, name as name, 3 as type
|
|
|
+ from product_category) as c
|
|
|
+ order by name
|
|
|
+ <if test="orderType==0">
|
|
|
+ asc
|
|
|
+ </if>
|
|
|
+ <if test="orderType!=0">
|
|
|
+ desc
|
|
|
+ </if>
|
|
|
</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>
|