From 378eff99be28d570498a87b9043a80c1f825732d Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 3 Jan 2022 16:16:14 +0800 Subject: [PATCH 1/4] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=88=90=E9=80=82=E5=90=88=E8=BF=90=E8=A1=8C=E5=9C=A8=E8=99=9A?= =?UTF-8?q?=E6=8B=9F=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back-end_code/src/main/resources/application-pro.yml | 8 ++++---- back-end_code/src/main/resources/application.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/back-end_code/src/main/resources/application-pro.yml b/back-end_code/src/main/resources/application-pro.yml index 55c39ba..2124426 100644 --- a/back-end_code/src/main/resources/application-pro.yml +++ b/back-end_code/src/main/resources/application-pro.yml @@ -3,10 +3,10 @@ server: spring: datasource: - username: xiangwan - password: dingwanren + username: root + password: jiaxintang #url中database为对应的数据库名称 - url: jdbc:mysql://47.103.214.177:3306/service2.0?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC + url: jdbc:mysql://localhost:3306/service2.0?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC driver-class-name: com.mysql.cj.jdbc.Driver mybatis: @@ -28,4 +28,4 @@ oss: #文件上传路径 filepath: - bin: "E:/file/bin/" \ No newline at end of file + bin: "C:/file/bin/" \ No newline at end of file diff --git a/back-end_code/src/main/resources/application.yml b/back-end_code/src/main/resources/application.yml index caf4dfc..fc3033b 100644 --- a/back-end_code/src/main/resources/application.yml +++ b/back-end_code/src/main/resources/application.yml @@ -1,3 +1,3 @@ spring: profiles: - active: dev \ No newline at end of file + active: pro \ No newline at end of file -- Gitee From 3701e52a70f9e9f3c59a14cb2e80330c1179cca2 Mon Sep 17 00:00:00 2001 From: WenZong9 <2937021973@qq.com> Date: Mon, 3 Jan 2022 16:49:50 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9pom.xml=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml => back-end_code/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename pom.xml => back-end_code/pom.xml (98%) diff --git a/pom.xml b/back-end_code/pom.xml similarity index 98% rename from pom.xml rename to back-end_code/pom.xml index 2d58506..f3b0005 100644 --- a/pom.xml +++ b/back-end_code/pom.xml @@ -10,7 +10,7 @@ com.shop service - 0.0.1-SNAPSHOT + 1.0.1-SNAPSHOT com.shop.service 购物网站后台 -- Gitee From 2ba4c9be10f2b286d542b5386dea5706f08423c4 Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 28 Feb 2022 10:26:23 +0800 Subject: [PATCH 3/4] =?UTF-8?q?1.=E5=AE=8C=E5=96=84Result=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=B1=BB=202.=E5=B0=86Goods=E4=B8=AD=E7=9A=84searchSe?= =?UTF-8?q?llingGoods=E5=92=8CsearchWelcomeGoods=E6=94=B9=E6=88=90?= =?UTF-8?q?=E4=BD=BF=E7=94=A8Result=E5=B7=A5=E5=85=B7=E7=B1=BB=E5=BD=A2?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/shop/controller/GoodsController.java | 44 ++++++++++--------- .../src/main/java/com/shop/utils/Result.java | 33 ++++++++------ .../src/main/resources/application.yml | 2 +- 3 files changed, 45 insertions(+), 34 deletions(-) diff --git a/back-end_code/src/main/java/com/shop/controller/GoodsController.java b/back-end_code/src/main/java/com/shop/controller/GoodsController.java index f419bca..5acde53 100644 --- a/back-end_code/src/main/java/com/shop/controller/GoodsController.java +++ b/back-end_code/src/main/java/com/shop/controller/GoodsController.java @@ -5,6 +5,7 @@ import com.shop.service.GOService; import com.shop.service.GoodsService; import com.shop.service.OrderService; import com.shop.service.UploadImageService; +import com.shop.utils.Result; import com.shop.utils.StringUtil; import net.minidev.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; @@ -102,29 +103,32 @@ public class GoodsController { } //在goods表中查找所有正在出售的商品 - @RequestMapping(value = "/searchSellingGoods") - public Object searchSellingGoods(HttpServletRequest request, HttpServletResponse response){ - String message = "error"; - JSONObject jsonObject = new JSONObject(); - List goods= goodsService.searchSellingGoods(); - message = "success"; - jsonObject.put("message",message); - jsonObject.put("goods",goods); - return jsonObject; + @GetMapping(value = "/searchSellingGoods") + public Object searchSellingGoods(){ + try { + JSONObject jsonObject = new JSONObject(); + List goods= goodsService.searchSellingGoods(); + jsonObject.put("goods",goods); + return Result.ok(goods); + }catch (Exception e){ + return Result.fail(); + } } - //在goods表中查找所有正在出售的商品。 - @RequestMapping(value = "/searchWelcomeGoods") + //在goods表中查找欢迎界面商品 + @GetMapping(value = "/searchWelcomeGoods") public Object searchWelcomeGoods(){ - String message = "error"; - JSONObject jsonObject = new JSONObject(); - List goods = goodsService.searchWelcomeGoods(); - List stringList = orderService.searchSellingGoodsBuyerRealname(); - message = "success"; - jsonObject.put("goods",goods); - jsonObject.put("Strings",stringList); - jsonObject.put("message",message); - return jsonObject; + try{ + JSONObject jsonObject = new JSONObject(); + List goods = goodsService.searchWelcomeGoods(); + List stringList = orderService.searchSellingGoodsBuyerRealname(); + jsonObject.put("goods",goods); + jsonObject.put("Strings",stringList); + return Result.ok(jsonObject); + }catch (Exception e){ + return Result.fail(); + } + } //在goods表中查询历史商品 diff --git a/back-end_code/src/main/java/com/shop/utils/Result.java b/back-end_code/src/main/java/com/shop/utils/Result.java index fa52d53..d9c7766 100644 --- a/back-end_code/src/main/java/com/shop/utils/Result.java +++ b/back-end_code/src/main/java/com/shop/utils/Result.java @@ -14,20 +14,23 @@ public class Result extends JSONObject { private Result() {} public static Result ok() { - return Result.ok(SUCCESS); + Result result = new Result(); + result.put("code:",200); + return result; } - public static Result ok(String message) { + public static Result ok(Object data) { Result result = new Result(); - result.put("message:",message); + result.put("code:",200); + result.put("data:",data); return result; } - public static Result ok(String dataName, Object data) { + public static Result ok(String message, Object data) { Result result = new Result(); - result.put("message:",SUCCESS); - result.put(dataName,data); + result.put("code:",200); + result.put("data:",data); return result; } @@ -36,17 +39,21 @@ public class Result extends JSONObject { } public static Result fail(String message) { - return Result.fail("message", message); - } - - - public static Result fail(String dataName, Object data) { Result result = new Result(); - result.put("message:",FAILURE); - result.put(dataName,data); + result.put("code:",500); + result.put("message:",message); return result; } + +// public static Result fail(String dataName, Object data) { +// Result result = new Result(); +// result.put("code:",500); +// result.put("message:",FAILURE); +// result.put(dataName,data); +// return result; +// } + public boolean isResult() { return result; } diff --git a/back-end_code/src/main/resources/application.yml b/back-end_code/src/main/resources/application.yml index fc3033b..caf4dfc 100644 --- a/back-end_code/src/main/resources/application.yml +++ b/back-end_code/src/main/resources/application.yml @@ -1,3 +1,3 @@ spring: profiles: - active: pro \ No newline at end of file + active: dev \ No newline at end of file -- Gitee From 57d6fed2cffb13c44bba0e312bb736278778c938 Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 28 Feb 2022 10:33:40 +0800 Subject: [PATCH 4/4] =?UTF-8?q?1.=E5=AE=8C=E5=96=84Result=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=B1=BB=202.=E5=B0=86Goods=E4=B8=AD=E7=9A=84searchSe?= =?UTF-8?q?llingGoods=E5=92=8CsearchWelcomeGoods=E6=94=B9=E6=88=90?= =?UTF-8?q?=E4=BD=BF=E7=94=A8Result=E5=B7=A5=E5=85=B7=E7=B1=BB=E5=BD=A2?= =?UTF-8?q?=E5=BC=8F=203.=E4=BF=AE=E6=94=B9FileController=E4=B8=ADResult?= =?UTF-8?q?=E7=9A=84=E7=94=A8=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/shop/controller/FileController.java | 5 ++++- .../java/com/shop/controller/GoodsController.java | 2 +- .../src/main/java/com/shop/utils/Result.java | 12 ++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/back-end_code/src/main/java/com/shop/controller/FileController.java b/back-end_code/src/main/java/com/shop/controller/FileController.java index 6380a1f..1ea4cfc 100644 --- a/back-end_code/src/main/java/com/shop/controller/FileController.java +++ b/back-end_code/src/main/java/com/shop/controller/FileController.java @@ -2,6 +2,7 @@ package com.shop.controller; import com.shop.utils.Result; import com.shop.utils.StringUtil; +import net.minidev.json.JSONObject; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.PropertySource; import org.springframework.web.bind.annotation.RequestMapping; @@ -28,8 +29,10 @@ public class FileController { String fullPath = fileBinPath+newFilename; File dest = new File(fullPath); try { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("path",fullPath); file.transferTo(dest); - return Result.ok("path",fullPath); + return Result.ok(jsonObject); } catch (IOException e) { e.printStackTrace(); return Result.fail(); diff --git a/back-end_code/src/main/java/com/shop/controller/GoodsController.java b/back-end_code/src/main/java/com/shop/controller/GoodsController.java index 5acde53..3c72a8c 100644 --- a/back-end_code/src/main/java/com/shop/controller/GoodsController.java +++ b/back-end_code/src/main/java/com/shop/controller/GoodsController.java @@ -109,7 +109,7 @@ public class GoodsController { JSONObject jsonObject = new JSONObject(); List goods= goodsService.searchSellingGoods(); jsonObject.put("goods",goods); - return Result.ok(goods); + return Result.ok(jsonObject); }catch (Exception e){ return Result.fail(); } diff --git a/back-end_code/src/main/java/com/shop/utils/Result.java b/back-end_code/src/main/java/com/shop/utils/Result.java index d9c7766..9259986 100644 --- a/back-end_code/src/main/java/com/shop/utils/Result.java +++ b/back-end_code/src/main/java/com/shop/utils/Result.java @@ -27,12 +27,12 @@ public class Result extends JSONObject { } - public static Result ok(String message, Object data) { - Result result = new Result(); - result.put("code:",200); - result.put("data:",data); - return result; - } +// public static Result ok(String message, Object data) { +// Result result = new Result(); +// result.put("code:",200); +// result.put("data:",data); +// return result; +// } public static Result fail() { return Result.fail(FAILURE); -- Gitee