소스 검색

合作产品界面

shixr 1 년 전
부모
커밋
36ffe10b0b

+ 8 - 8
src/main/java/com/kexun/controller/CooperatorController.java

@@ -99,22 +99,22 @@ public class CooperatorController {
 //        return Result.success("ok", result);
 //    }
 
-    @GetMapping("findCooperatorFieldByNum")
-    public Result findCooperatorFieldByNum(String cooperatorNum) {
-
+    @GetMapping("findCooperatorFieldByNum/{cooperatorNum}")
+    public Result findCooperatorFieldByNum(@PathVariable("cooperatorNum")String cooperatorNum) {
         JSONObject result = new JSONObject();
-        List<CooperatorField> list = CooperatorService.findCooperatorFieldByNum();
-//        System.out.println(list);
+        List<CooperatorField> list = CooperatorService.findCooperatorFieldByNum(cooperatorNum);
+        System.out.println(list);
+
         result.put("cooperator_field",list);
 
         return Result.success("ok", result);
     }
 
-    @GetMapping("findCooperatorProductByNum")
-    public Result findCooperatorProductByNum(String cooperatorNum) {
+    @GetMapping("findCooperatorProductByNum/{cooperatorNum}")
+    public Result findCooperatorProductByNum(@PathVariable("cooperatorNum")String cooperatorNum) {
 
         JSONObject result = new JSONObject();
-        List<CooperatorProduct> list = CooperatorService.findCooperatorProductByNum();
+        List<CooperatorProduct> list = CooperatorService.findCooperatorProductByNum(cooperatorNum);
 //        System.out.println(list);
         result.put("cooperator_product",list);
 

+ 20 - 4
src/main/java/com/kexun/controller/CooperatorProductController.java

@@ -37,11 +37,12 @@ public class CooperatorProductController {
     }
 
     // 获取合作产品字段
-    @GetMapping("findCooperatorProductFieldByNum")
-    public Result findCooperatorProductFieldByNum(String productNum) {
+    @GetMapping("findCooperatorProductFieldByNum/{productNum}")
+    public Result findCooperatorProductFieldByNum(@PathVariable("productNum") String productNum) {
 
         JSONObject result = new JSONObject();
-        List<CooperatorField> list = CooperatorProductService.findCooperatorProductFieldByNum();
+        System.out.println(productNum);
+        List<CooperatorField> list = CooperatorProductService.findCooperatorProductFieldByNum(productNum);
         result.put("cooperator_product_field",list);
         System.out.println(list);
 
@@ -64,9 +65,24 @@ public class CooperatorProductController {
 
         CooperatorProductService.Apply(cooperatorNo, cooperatorName, productNo, productName, modelId, createTime);
 
-
         return Result.success();
+    }
+
+    @GetMapping("updateProductFieldNo/{productNum}/{fieldNo}")
+    public Result updateProductFieldNo(@PathVariable("productNum") String productNum,@PathVariable("fieldNo")  String fieldNo) {
+        JSONObject result = new JSONObject();
+        CooperatorProductService.updateProductFieldNo(productNum,fieldNo);
+        return Result.success("ok", result);
+    }
 
+    @GetMapping("findCooperatorFieldsByName/{cooperatorName}")
+    public Result findCooperatorFieldsByName(@PathVariable("cooperatorName") String cooperatorName){
+        JSONObject resJson=new JSONObject();
+        List<CooperatorField> list=CooperatorProductService.findCooperatorFieldsByName(cooperatorName);
+        resJson.put("cooperator_fields_by_name",list);
+        System.out.println(list);
+
+        return Result.success("ok",resJson);
     }
 
 }

+ 2 - 1
src/main/java/com/kexun/entity/CooperatorField.java

@@ -26,8 +26,9 @@ public class CooperatorField implements Serializable {
     @TableField(value = "type")
     private String type;
 
+    @TableField(value = "create_time")
     private String createTime;
 
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
-}
+}

+ 1 - 1
src/main/java/com/kexun/entity/CooperatorInfo.java

@@ -15,7 +15,7 @@ import java.io.Serializable;
 @Data
 public class CooperatorInfo implements Serializable {
 
-//    @TableId(value = "id" , type = IdType.AUTO)
+    @TableId(value = "id" , type = IdType.AUTO)
 //    @TableField(value = "id")
     private Long id;
 

+ 26 - 0
src/main/java/com/kexun/entity/CooperatorProductField.java

@@ -0,0 +1,26 @@
+package com.kexun.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@TableName(value = "product_field_ref")
+@Data
+public class CooperatorProductField implements Serializable {
+
+    @TableField(value = "product_num")
+    private String productNum;
+
+    @TableField(value = "product_name")
+    private String productName;
+
+    @TableField(value = "field_no")
+    private String fieldNo;
+
+
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 4 - 4
src/main/java/com/kexun/mapper/CooperatorMapper.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.kexun.entity.CooperatorInfo;
 import com.kexun.entity.CooperatorField;
 import com.kexun.entity.CooperatorProduct;
-import org.apache.ibatis.annotations.Param;
+import org.springframework.data.repository.query.Param;
 
 import java.util.List;
 
@@ -13,9 +13,9 @@ import java.util.List;
  */
 public interface CooperatorMapper extends BaseMapper<CooperatorInfo> {
 
-    // List<CooperatorField> Query(@Param("cooperatorNum") String cooperatorNum);
-    List<CooperatorField> Query();
-    List<CooperatorProduct> QueryProduct();
+    List<CooperatorField> Query(@Param("cooperatorNum") String cooperatorNum);
+
+    List<CooperatorProduct> QueryProduct(@Param("cooperatorNum") String cooperatorNum);
 
 }
 

+ 6 - 1
src/main/java/com/kexun/mapper/CooperatorProductMapper.java

@@ -3,6 +3,8 @@ package com.kexun.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.kexun.entity.CooperatorField;
 import com.kexun.entity.CooperatorProduct;
+import com.kexun.entity.CooperatorProductField;
+import org.springframework.data.repository.query.Param;
 
 import java.util.List;
 
@@ -12,6 +14,9 @@ import java.util.List;
 public interface CooperatorProductMapper extends BaseMapper<CooperatorProduct> {
 
     List<CooperatorProduct> Query();
-    List<CooperatorField> fieldQuery();
+    List<CooperatorField> fieldQuery(@Param("productNum") String productNum);
     void Apply(String cooperatorNo, String cooperatorName, String productNo, String productName, String modelId, String createTime);
+    void updateQuery(@Param("productNum") String productNum, @Param("fieldNo") String fieldNo);
+
+    List<CooperatorField> findCooperatorFieldsQuery(@Param("cooperatorName") String cooperatorName);
 }

+ 4 - 1
src/main/java/com/kexun/service/CooperatorProductService.java

@@ -12,6 +12,9 @@ import java.util.List;
  */
 public interface CooperatorProductService extends IService<CooperatorProduct> {
     List<CooperatorProduct> productList();
-    List<CooperatorField> findCooperatorProductFieldByNum();
+    List<CooperatorField> findCooperatorProductFieldByNum(String productNum);
     void Apply(String cooperatorNo, String cooperatorName, String productNo, String productName, String modelId, String createTime);
+    void updateProductFieldNo(String productNum,String fieldNo);
+
+    List<CooperatorField> findCooperatorFieldsByName(String cooperatorName);
 }

+ 2 - 2
src/main/java/com/kexun/service/CooperatorService.java

@@ -15,7 +15,7 @@ import java.util.List;
 public interface CooperatorService extends IService<CooperatorInfo> {
     CooperatorInfo findByCooperatorNum(String partnerName);
 //    List<CooperatorField> findCooperatorFieldByNum(String cooperatorNum);
-    List<CooperatorField> findCooperatorFieldByNum();
-    List<CooperatorProduct> findCooperatorProductByNum();
+    List<CooperatorField> findCooperatorFieldByNum(String cooperatorNum);
+    List<CooperatorProduct> findCooperatorProductByNum(String cooperatorNum);
     CooperatorInfo findByID(long id);
 }

+ 14 - 2
src/main/java/com/kexun/service/impl/CooperatorProductServiceImpl.java

@@ -27,8 +27,8 @@ public class CooperatorProductServiceImpl extends ServiceImpl<CooperatorProductM
     }
 
     @Override
-    public List<CooperatorField> findCooperatorProductFieldByNum() {
-        List<CooperatorField> l = cooperatorProductMapper.fieldQuery();
+    public List<CooperatorField> findCooperatorProductFieldByNum(String productNum) {
+        List<CooperatorField> l = cooperatorProductMapper.fieldQuery(productNum);
         return l;
     }
 
@@ -36,4 +36,16 @@ public class CooperatorProductServiceImpl extends ServiceImpl<CooperatorProductM
     public void Apply(String cooperatorNo, String cooperatorName, String productNo, String productName, String modelId, String createTime) {
         cooperatorProductMapper.Apply(cooperatorNo,cooperatorName, productNo, productName,  modelId,  createTime);
     }
+
+    @Override
+    public void updateProductFieldNo(String productNum,String fieldNo) {
+        cooperatorProductMapper.updateQuery(productNum,fieldNo);
+    }
+
+    @Override
+    public List<CooperatorField> findCooperatorFieldsByName(String cooperatorName){
+        List<CooperatorField> l = cooperatorProductMapper.findCooperatorFieldsQuery(cooperatorName);
+        return l;
+
+    }
 }

+ 4 - 4
src/main/java/com/kexun/service/impl/CooperatorServiceImpl.java

@@ -31,16 +31,16 @@ public class CooperatorServiceImpl extends ServiceImpl<CooperatorMapper, Coopera
     CooperatorMapper cooperatorMapper;
 
     @Override
-    public List<CooperatorField> findCooperatorFieldByNum() {
+    public List<CooperatorField> findCooperatorFieldByNum(String cooperatorNum) {
 //        System.out.println("aaa");
-        List<CooperatorField> l = cooperatorMapper.Query();
+        List<CooperatorField> l = cooperatorMapper.Query(cooperatorNum);
         return l;
     }
 
     @Override
-    public List<CooperatorProduct> findCooperatorProductByNum() {
+    public List<CooperatorProduct> findCooperatorProductByNum(String cooperatorNum) {
 //        System.out.println("aaa");
-        List<CooperatorProduct> l = cooperatorMapper.QueryProduct();
+        List<CooperatorProduct> l = cooperatorMapper.QueryProduct(cooperatorNum);
         return l;
     }
 

+ 3 - 3
src/main/resources/mapper/CooperatorMapper.xml

@@ -40,12 +40,12 @@
                 LEFT JOIN field_template_ref ON field_template_ref.field_no = field_define.field_no
                 LEFT JOIN cooperator_info ON cooperator_info.template_no = field_template_ref.template_no
         WHERE
-            cooperator_info.cooperator_num = "HBJK20230509";
+            cooperator_info.cooperator_num = #{cooperatorNum};
 
 
     </select>
 
-    <select id="QueryProduct" resultType="com.kexun.entity.CooperatorProduct">
+    <select id="QueryProduct" resultType="com.kexun.entity.CooperatorProduct" >
         SELECT DISTINCT
             prd_product.product_num,
             prd_product.product_name,
@@ -56,7 +56,7 @@
             prd_product
                 LEFT JOIN model ON model.model_no = prd_product.model_id
         WHERE
-            prd_product.cooperator_num = "HBJK20230509";
+            prd_product.cooperator_num = #{cooperatorNum};
 
 
     </select>

+ 23 - 2
src/main/resources/mapper/CooperatorProductMapper.xml

@@ -39,11 +39,12 @@
             field_define.field_no,
             field_define.`name`,
             field_define.name_zh,
-            field_define.type
+            field_define.type,
+            field_define.create_time
         FROM
             field_define
                 LEFT JOIN product_field_ref ON product_field_ref.field_no = field_define.field_no
-        WHERE product_field_ref.product_num = 'CPXX100'
+        WHERE product_field_ref.product_num = #{productNum}
     </select>
 
     <insert id="Apply">
@@ -51,5 +52,25 @@
         values(#{cooperatorNo},#{cooperatorName},#{productNo},#{productName},#{modelId},#{createTime})
     </insert>
 
+    <select id="updateQuery" >
+        UPDATE product_field_ref
+        SET product_field_ref.field_no=#{fieldNo}
+        WHERE product_field_ref.product_num=#{productNum}
+    </select>
+
+    <select id="findCooperatorFieldsQuery" resultType="com.kexun.entity.CooperatorField">
+        SELECT DISTINCT
+            field_define.field_no,
+            field_define.`name`,
+            field_define.name_zh,
+            field_define.type,
+            field_define.create_time
+        FROM
+            field_define
+                RIGHT JOIN field_template_ref ON field_template_ref.field_no = field_define.field_no
+                LEFT JOIN cooperator_info ON cooperator_info.template_no=field_template_ref.template_no
+        WHERE cooperator_info.cooperator_name = #{cooperatorName}
+    </select>
+
 
 </mapper>