ソースを参照

接口代码修改

yuzijian 2 年 前
コミット
e55219c383
1 ファイル変更24 行追加23 行削除
  1. 24 23
      src/main/java/com/syjy/calculate/conotroller/JarCalculate.java

+ 24 - 23
src/main/java/com/syjy/calculate/conotroller/JarCalculate.java

@@ -2,13 +2,12 @@ package com.syjy.calculate.conotroller;
 
 
 import com.syjy.calculate.entity.tCalculationFormula;
-import com.syjy.calculate.mapper.CalculationFormulaMapper;
-import com.syjy.calculate.mapper.CalculationFormulaService;
 import com.syjy.calculate.repository.CalculationFormulaRepository;
 import com.syjy.calculate.service.AccuracyPassRateCalculateService;
 import com.syjy.calculate.vo.ResponseVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.dao.DataAccessException;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -16,6 +15,10 @@ import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -26,8 +29,7 @@ public class JarCalculate {
     public JdbcTemplate jdbcTemplate;
     @Autowired
     CalculationFormulaRepository calculationFormulaRepository;
-    @Autowired
-   CalculationFormulaService calculationFormulaService;
+
    @GetMapping("test")
     @ResponseBody
     public String test() {
@@ -47,51 +49,50 @@ public class JarCalculate {
       }
         return ResponseVO.success(calculationFormulaList);
     }
-/*
-    @PostMapping("add")
+    @PostMapping("edit")
     @ResponseBody
-    public ResponseVO add(@RequestBody CalculationFormula calculationFormula ) {
+    public ResponseVO edit(@RequestBody tCalculationFormula calculationFormula ) {
+        Integer id =calculationFormula.getId();
         String type =calculationFormula.getType();
-        Integer order =calculationFormula.getOrder();
+        Integer orderNo =calculationFormula.getOrderNo();
         String formula =calculationFormula.getFormula();
         String province =calculationFormula.getProvinceEnum();
         String state =calculationFormula.getState();
         try {
-
-            calculationFormulaMapper.add(type,order,formula,province,state);
+        jdbcTemplate.update("update t_calculation_formula set type=?,orderNo=?,formula=?,province_enum=?,state=? where id=?", type, orderNo, formula,province,state,id);
         } catch (DataAccessException e) {
             e.printStackTrace();
-            return ResponseVO.fail("添加失败");
         }
-        return ResponseVO.success("添加成功");
+        return ResponseVO.success("修改成功");
     }
-
-    @PostMapping("edit")
+    @PostMapping("add")
     @ResponseBody
-    public ResponseVO edit(@RequestBody CalculationFormula calculationFormula){
+    public ResponseVO add(@RequestBody tCalculationFormula calculationFormula ) {
         Integer id =calculationFormula.getId();
         String type =calculationFormula.getType();
-        Integer order =calculationFormula.getOrder();
+        Integer orderNo =calculationFormula.getOrderNo();
         String formula =calculationFormula.getFormula();
         String province =calculationFormula.getProvinceEnum();
         String state =calculationFormula.getState();
         try {
-            calculationFormulaMapper.edit(id,type,order,formula,province,state);
+            jdbcTemplate.execute("insert into t_calculation_formula(id,type,orderNo,formula,province_enum,state) values (id,type,orderNo,formula,province,state)");
         } catch (DataAccessException e) {
             e.printStackTrace();
-            return ResponseVO.fail("修改失败");
         }
-        return ResponseVO.success("修改成功");
+        return ResponseVO.success("新增成功");
     }
+
     @PostMapping("delete")
     @ResponseBody
-    public ResponseVO delete(@RequestBody CalculationFormula calculationFormula){
+    public ResponseVO delete(@RequestBody tCalculationFormula calculationFormula ) {
+        Integer id =calculationFormula.getId();
+
         try {
-            calculationFormulaMapper.delete(calculationFormula.getId());
+            jdbcTemplate.update("delete from t_calculation_formula where id=?", id);
         } catch (DataAccessException e) {
             e.printStackTrace();
-            return ResponseVO.fail("删除失败");
         }
         return ResponseVO.success("删除成功");
-    }*/
+    }
+
 }