Parcourir la source

console工程中无法实例化,删除返回信息封装VO和枚举,页面返回信息和请求头修改

yuzijian il y a 2 ans
Parent
commit
faa9a18dee

+ 0 - 8
src/main/java/com/syjy/calculate/config/StarterAutoConfigure.java

@@ -64,13 +64,5 @@ public class StarterAutoConfigure {
     }
     }
 
 
 
 
-/*    @Bean
-    @ConditionalOnMissingBean
-    @ConditionalOnProperty(prefix = "calculate.service", value = "enabled", havingValue = "true")
-    CalculationFormulaMapper calculationFormulaMapper() {
-        return new CalculationFormulaMapper();
-    }*/
-
-
 
 
 }
 }

+ 11 - 10
src/main/java/com/syjy/calculate/conotroller/JarCalculate.java

@@ -4,7 +4,7 @@ package com.syjy.calculate.conotroller;
 import com.syjy.calculate.entity.CalculationFormula;
 import com.syjy.calculate.entity.CalculationFormula;
 import com.syjy.calculate.repository.CalculationFormulaRepository;
 import com.syjy.calculate.repository.CalculationFormulaRepository;
 import com.syjy.calculate.service.AccuracyPassRateCalculateService;
 import com.syjy.calculate.service.AccuracyPassRateCalculateService;
-import com.syjy.calculate.vo.ResponseVO;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -23,7 +23,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
 @Controller
 @Controller
-@RequestMapping("jarCalculate")
+@RequestMapping("calculateView/jarCalculate")
 public class JarCalculate {
 public class JarCalculate {
     @Resource
     @Resource
     public JdbcTemplate jdbcTemplate;
     public JdbcTemplate jdbcTemplate;
@@ -38,7 +38,7 @@ public class JarCalculate {
     }
     }
   @GetMapping("select")
   @GetMapping("select")
     @ResponseBody
     @ResponseBody
-    public ResponseVO select() {
+    public  List<CalculationFormula> select() {
       String sql = "SELECT * from t_calculation_formula";
       String sql = "SELECT * from t_calculation_formula";
 
 
       List<CalculationFormula> calculationFormulaList = new ArrayList<>();
       List<CalculationFormula> calculationFormulaList = new ArrayList<>();
@@ -47,11 +47,12 @@ public class JarCalculate {
       } catch (DataAccessException e) {
       } catch (DataAccessException e) {
           e.printStackTrace();
           e.printStackTrace();
       }
       }
-        return ResponseVO.success(calculationFormulaList);
+        return calculationFormulaList;
     }
     }
     @PostMapping("edit")
     @PostMapping("edit")
     @ResponseBody
     @ResponseBody
-    public ResponseVO edit(@RequestBody CalculationFormula calculationFormula ) {
+    public String edit(@RequestBody CalculationFormula calculationFormula ) {
+
         Integer id =calculationFormula.getId();
         Integer id =calculationFormula.getId();
         String type =calculationFormula.getType();
         String type =calculationFormula.getType();
         Integer orderNo =calculationFormula.getOrderNo();
         Integer orderNo =calculationFormula.getOrderNo();
@@ -63,11 +64,11 @@ public class JarCalculate {
         } catch (DataAccessException e) {
         } catch (DataAccessException e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
-        return ResponseVO.success("修改成功");
+        return "修改成功" ;
     }
     }
     @PostMapping("add")
     @PostMapping("add")
     @ResponseBody
     @ResponseBody
-    public ResponseVO add(@RequestBody CalculationFormula calculationFormula) {
+    public String add(@RequestBody CalculationFormula calculationFormula) {
         System.out.println("sss"+calculationFormula);
         System.out.println("sss"+calculationFormula);
 
 
         String type =calculationFormula.getType();
         String type =calculationFormula.getType();
@@ -84,12 +85,12 @@ public class JarCalculate {
         } catch (DataAccessException e) {
         } catch (DataAccessException e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
-        return ResponseVO.success("新增成功");
+        return "新增成功" ;
     }
     }
 
 
     @PostMapping( "delet")
     @PostMapping( "delet")
     @ResponseBody
     @ResponseBody
-    public ResponseVO delete(@RequestBody CalculationFormula calculationFormula) {
+    public String delete(@RequestBody CalculationFormula calculationFormula) {
         System.out.println("id"+calculationFormula.getId());
         System.out.println("id"+calculationFormula.getId());
     Integer id =calculationFormula.getId();
     Integer id =calculationFormula.getId();
         try {
         try {
@@ -97,7 +98,7 @@ public class JarCalculate {
         } catch (DataAccessException e) {
         } catch (DataAccessException e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
-        return ResponseVO.success("删除成功");
+        return "删除成功";
     }
     }
 
 
 }
 }

+ 0 - 25
src/main/java/com/syjy/calculate/enum/ResponseEnum.java

@@ -1,25 +0,0 @@
-package com.syjy.calculate;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-/**
- * 数据信息状态枚举类
- *
- * @author zzy
- * @version 1.0
- * @since 2019/6/24 9:34
- */
-@Getter
-@AllArgsConstructor
-public enum ResponseEnum {
-    /**
-     * 0 表示返回成功
-     */
-    SUCCESS(0, "操作成功!"),
-    FAILED(1, "操作失败!"),
-    ERROR(-1, "系统错误!");
-
-    private Integer code;
-    private String message;
-}

+ 0 - 87
src/main/java/com/syjy/calculate/vo/ResponseVO.java

@@ -1,87 +0,0 @@
-package com.syjy.calculate.vo;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.syjy.calculate.ResponseEnum;
-import com.syjy.calculate.exception.BusinessException;
-import lombok.*;
-import lombok.experimental.Accessors;
-
-import java.io.Serializable;
-
-/**
- * 数据格式返回统一
- *
- * @author zzy
- * @version 1.0
- * @since 2019/5/10 16:34
- */
-@ToString
-@NoArgsConstructor
-@AllArgsConstructor
-@Accessors(chain = true)
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class ResponseVO<T> implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 状态码
-     */
-    @Getter
-    @Setter
-    private Integer code;
-
-    /**
-     * 描述
-     */
-    @Getter
-    @Setter
-    private String message;
-
-    /**
-     * 数据
-     */
-    @Getter
-    @Setter
-    private T data;
-
-    public static <T> ResponseVO<T> success() {
-        return restResult(ResponseEnum.SUCCESS.getCode(), null, null);
-    }
-
-    public static <T> ResponseVO<T> success(T data) {
-        return restResult(ResponseEnum.SUCCESS.getCode(), data, ResponseEnum.SUCCESS.getMessage());
-    }
-
-    public static <T> ResponseVO<T> success(T data, String message) {
-        return restResult(ResponseEnum.SUCCESS.getCode(), data, message);
-    }
-
-    public static <T> ResponseVO<T> fail() {
-        return restResult(ResponseEnum.FAILED.getCode(), null, null);
-    }
-
-    public static <T> ResponseVO<T> fail(T data) {
-        return restResult(ResponseEnum.FAILED.getCode(), data, ResponseEnum.FAILED.getMessage());
-    }
-
-    public static <T> ResponseVO<T> fail(T data, String msg) {
-        return restResult(ResponseEnum.FAILED.getCode(), data, msg);
-    }
-
-    public static ResponseVO fail(BusinessException exception) {
-        return restResult(ResponseEnum.FAILED.getCode(), null, exception.getMessage());
-    }
-
-    public static ResponseVO error(Throwable exception) {
-        return restResult(ResponseEnum.ERROR.getCode(), null, exception.getMessage());
-    }
-
-    private static <T> ResponseVO<T> restResult(Integer code, T data, String message) {
-        ResponseVO<T> apiResult = new ResponseVO<>();
-        apiResult.setCode(code);
-        apiResult.setData(data);
-        apiResult.setMessage(message);
-        return apiResult;
-    }
-}

+ 11 - 13
src/main/resources/META-INF/resources/calculateView/calculate.html

@@ -204,12 +204,12 @@
         }
         }
     ];
     ];
     $.ajax({
     $.ajax({
-        url: "http://localhost:9089/jarCalculate/select",
+        url: "jarCalculate/select",
         type: "GET",
         type: "GET",
         async: false,
         async: false,
         dataType: "json",
         dataType: "json",
         success: function (res) {
         success: function (res) {
-            list = res.data;
+            list = res;
         }
         }
     });
     });
 
 
@@ -218,32 +218,30 @@
         $.ajax({
         $.ajax({
 
 
             type: "post",
             type: "post",
-            dataType: "json",
             contentType: 'application/json',
             contentType: 'application/json',
-            url: "http://localhost:9089/jarCalculate/add",
+            url: "jarCalculate/add",
             /*    data,*/
             /*    data,*/
             data: JSON.stringify(data),
             data: JSON.stringify(data),
-
-
             type: "POST",
             type: "POST",
             async: false,
             async: false,
-            dataType: "json",
+            text: "json",
             success: function (res) {
             success: function (res) {
-                console.log(res)
                 // 将输入的数据存入数组
                 // 将输入的数据存入数组
                 message = {
                 message = {
                     "number": number,
                     "number": number,
-                    "id": res.data.id,
+                    "id": data.id,
                     "type": inputs[0].value,
                     "type": inputs[0].value,
                     "orderNo": inputs[1].value,
                     "orderNo": inputs[1].value,
                     'formula': inputs[2].value,
                     'formula': inputs[2].value,
                     'provinceEnum': inputs[3].value,
                     'provinceEnum': inputs[3].value,
                     'ruleFormula': inputs[4].value
                     'ruleFormula': inputs[4].value
                 };
                 };
+                alert('新增成功')
                 // 调用去重函数
                 // 调用去重函数
                 clearMess();
                 clearMess();
                 // 启用自动数据重置
                 // 启用自动数据重置
                 reset.click();
                 reset.click();
+
             }
             }
         });
         });
     };
     };
@@ -251,7 +249,7 @@
     // 修改
     // 修改
     function postEdit(data) {
     function postEdit(data) {
         $.ajax({
         $.ajax({
-            url: "http://localhost:9089/jarCalculate/edit",
+            url: "jarCalculate/edit",
             data: JSON.stringify(data),
             data: JSON.stringify(data),
             type: "POST",
             type: "POST",
             async: false,
             async: false,
@@ -259,7 +257,7 @@
             dataType: "json",
             dataType: "json",
             contentType: 'application/json',
             contentType: 'application/json',
             success: function (res) {
             success: function (res) {
-                alert(res.message);
+                alert(res);
             }
             }
         });
         });
     };
     };
@@ -268,7 +266,7 @@
     function postDelet(index) {
     function postDelet(index) {
 
 
         $.ajax({
         $.ajax({
-            url: "http://localhost:9089/jarCalculate/delet",
+            url: "jarCalculate/delet",
             data: JSON.stringify({
             data: JSON.stringify({
                 id: students[index].id
                 id: students[index].id
             }),
             }),
@@ -277,7 +275,7 @@
             contentType: 'application/json',
             contentType: 'application/json',
             cache: false,
             cache: false,
             success: function (res) {
             success: function (res) {
-                alert(res.message);
+                alert(res);
             }
             }
         });
         });
     }
     }