From 7b09f233bde70508f6db7e08e983e9a2c4bb3e99 Mon Sep 17 00:00:00 2001
From: XiaoRuby <3114200645@qq.com>
Date: 星期五, 11 八月 2023 17:50:23 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
sale-server/src/main/java/com/yuanchu/mom/controller/SaleController.java | 38 ++++++++++++++------------------------
1 files changed, 14 insertions(+), 24 deletions(-)
diff --git a/sale-server/src/main/java/com/yuanchu/mom/controller/SaleController.java b/sale-server/src/main/java/com/yuanchu/mom/controller/SaleController.java
index ec732e4..97fa896 100644
--- a/sale-server/src/main/java/com/yuanchu/mom/controller/SaleController.java
+++ b/sale-server/src/main/java/com/yuanchu/mom/controller/SaleController.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.pojo.dto.vo.SaleVo;
+import com.yuanchu.mom.utils.JackSonUtil;
import org.json.JSONException;
import org.json.JSONObject;
import com.yuanchu.mom.pojo.dto.SaleDto;
@@ -17,10 +18,8 @@
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.lang.reflect.Array;
+import java.util.*;
/**
* <p>
@@ -61,12 +60,9 @@
@ApiOperation(value = "鏂板閿�鍞崟")
@PostMapping("/addSale")
- public Result addSale(@RequestHeader("token") String token, @RequestBody SaleDto saleDto) throws JSONException {
- Map<String, String> map = jwt.readJWT(token);
- String data = map.get("data");
- JSONObject jsonObject = new JSONObject(data);
- String saleman = jsonObject.getString("name");
- saleService.addSale(saleman, saleDto);
+ public Result addSale(@RequestHeader("token") String token, @RequestBody SaleDto saleDto) throws Exception {
+ Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class);
+ saleService.addSale(data.get("name").replaceAll("\"", ""), saleDto);
return Result.success("鏂板鎴愬姛!");
}
@@ -84,12 +80,9 @@
@ApiImplicitParam(name = "id", value = "閿�鍞崟id", dataTypeClass = Integer.class, required = true)
})
@PostMapping("/updateSaleById")
- public Result updateSaleById(@RequestHeader("token") String token, Integer id, @RequestBody SaleVo saleVo) throws JSONException {
- Map<String, String> map = jwt.readJWT(token);
- String data = map.get("data");
- JSONObject jsonObject = new JSONObject(data);
- String saleman = jsonObject.getString("name");
- saleService.updateSaleById(saleman,id, saleVo);
+ public Result updateSaleById(@RequestHeader("token") String token, Integer id, @RequestBody SaleVo saleVo) throws Exception {
+ Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class);
+ saleService.updateSaleById(data.get("name").replaceAll("\"", ""),id, saleVo);
return Result.success("淇敼鎴愬姛!");
}
@@ -105,10 +98,10 @@
@ApiOperation(value = "鎵归噺鍒犻櫎")
@ApiImplicitParams(value = {
- @ApiImplicitParam(name = "ids", value = "閿�鍞崟id", dataTypeClass = String.class, dataType = "List", required = true)
+ @ApiImplicitParam(name = "ids", value = "ids", dataTypeClass = Integer.class, dataType = "List",required = true)
})
@PostMapping("/delAllSale")
- public Result delAllSale( List<Integer> ids) {
+ public Result delAllSale( @RequestParam("ids") List<Integer> ids) {
saleService.delAllSale(ids);
return Result.success();
}
@@ -119,12 +112,9 @@
@ApiImplicitParam(name = "type", value = "鐘舵��", dataTypeClass = Integer.class, required = true)
})
@PostMapping("/check")
- public Result check(@RequestHeader("token") String token,Integer id,Integer type) throws JSONException {
- Map<String, String> map = jwt.readJWT(token);
- String data = map.get("data");
- JSONObject jsonObject = new JSONObject(data);
- String checkname = jsonObject.getString("name");
- saleService.check(checkname,id,type);
+ public Result check(@RequestHeader("token") String token,Integer id,Integer type) throws Exception {
+ Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class);
+ saleService.check(data.get("name").replaceAll("\"", ""),id,type);
return Result.success("瀹℃牳鎴愬姛");
}
--
Gitblit v1.9.3