JiangChongBo 2 years ago
parent
commit
d0cecbe6b9

+ 2 - 0
src/main/java/com/caimei/mapper/cmMapper/AuthProductMapper.java

@@ -124,4 +124,6 @@ public interface AuthProductMapper {
     List<ProductPo> getSnList( @Param("sn") String sn);
 
     List<ProductListVo> getPronductInfo(Integer authId, Integer authUserId);
+
+    Integer getNewestRelationId();
 }

+ 3 - 1
src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java

@@ -314,7 +314,9 @@ public class AuthProductServiceImpl implements AuthProductService {
                 authProductMapper.updateProductByProductId(product);
             }
             // 插入机构设备关联关系
-            relationId = authProductMapper.insertProductRelation(authId, product.getProductId(), authType);
+             authProductMapper.insertProductRelation(authId, product.getProductId(), authType);
+            //查询最新关联id
+            relationId=authProductMapper.getNewestRelationId();
         } else {
             if (1 == dbRelation.getAuthType()) {
                 // 更新设备

+ 3 - 0
src/main/resources/mapper/AuthProductMapper.xml

@@ -578,4 +578,7 @@
                  left join cm_brand_club_user cbcu on p.createBy = cbcu.id and cbcu.delFlag = 0
         where a.id = #{authId} and a.authUserId=#{authUserId} and p.shopAuditStatus=1
     </select>
+    <select id="getNewestRelationId" resultType="java.lang.Integer">
+    select id from cm_brand_product_relation order by id desc limit 1
+    </select>
 </mapper>