From 2b2c3e18f30c05f91812a89d61a0f548cf689771 Mon Sep 17 00:00:00 2001 From: pkq Date: Tue, 10 Nov 2020 21:04:08 +0800 Subject: [PATCH] init --- .idea/.gitignore | 8 +++ .idea/compiler.xml | 13 ++++ .idea/jarRepositories.xml | 20 +++++++ .idea/misc.xml | 14 +++++ Top-Java.iml | 2 + pom.xml | 12 ++++ src/main/java/cart/CartService.java | 50 ++++++++++++++++ src/main/java/cart/Sku.java | 80 +++++++++++++++++++++++++ src/main/java/cart/SkuCategoryEnum.java | 18 ++++++ 9 files changed, 217 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 Top-Java.iml create mode 100644 pom.xml create mode 100644 src/main/java/cart/CartService.java create mode 100644 src/main/java/cart/Sku.java create mode 100644 src/main/java/cart/SkuCategoryEnum.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..1c30702 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0f9e86a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Top-Java.iml b/Top-Java.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/Top-Java.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b1a2c75 --- /dev/null +++ b/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.pkq + Top-Java + 1.0-SNAPSHOT + + + \ No newline at end of file diff --git a/src/main/java/cart/CartService.java b/src/main/java/cart/CartService.java new file mode 100644 index 0000000..1055a67 --- /dev/null +++ b/src/main/java/cart/CartService.java @@ -0,0 +1,50 @@ +package cart; + + +import java.util.List; + +/** + * 购物车服务类 + */ +public class CartService { + private List cartSkuList = List.of( + new Sku(6423368, "无人机", 3052.00, + 100, 30520.00, SkuCategoryEnum.ELECTRONICS), + + new Sku(642934, "VR一体机", + 2299.00, 1, + 2299.00, SkuCategoryEnum.ELECTRONICS), + + new Sku(645321, "纯色衬衫", + 409.00, 3, + 1227.00, SkuCategoryEnum.CLOTHING), + + new Sku(654327, "牛仔裤", + 528.00, 1, + 528.00, SkuCategoryEnum.CLOTHING), + + new Sku(675489, "跑步机", + 2699.00, 1, + 2699.00, SkuCategoryEnum.SPORTS), + + new Sku(644564, "Java编程思想", + 79.80, 1, + 79.80, SkuCategoryEnum.BOOKS), + + new Sku(678678, "Java核心技术", + 149.00, 1, + 149.00, SkuCategoryEnum.BOOKS), + + new Sku(697894, "算法", + 78.20, 1, + 78.20, SkuCategoryEnum.BOOKS), + + new Sku(696968, "TensorFlow进阶指南", + 85.10, 1, + 85.10, SkuCategoryEnum.BOOKS)); + + + + + +} diff --git a/src/main/java/cart/Sku.java b/src/main/java/cart/Sku.java new file mode 100644 index 0000000..70ecf3d --- /dev/null +++ b/src/main/java/cart/Sku.java @@ -0,0 +1,80 @@ +package cart; + +/** + * 下单商品信息对象 + */ +public class Sku { + //编号 + private Integer skuId; + //商品名称 + private String skuName; + //商品价格 + private Double skuPrice; + //购买个数 + private Integer totalNum; + //总价 + private Double totalPrice; + //商品类型 + private Enum skuCategory; + + public Sku(Integer skuId, String skuName, Double skuPrice, Integer totalNum, Double totalPrice, Enum skuCategory) { + this.skuId = skuId; + this.skuName = skuName; + this.skuPrice = skuPrice; + this.totalNum = totalNum; + this.totalPrice = totalPrice; + this.skuCategory = skuCategory; + } + + + public Sku() { + } + + public Integer getSkuId() { + return skuId; + } + + public void setSkuId(Integer skuId) { + this.skuId = skuId; + } + + public String getSkuName() { + return skuName; + } + + public void setSkuName(String skuName) { + this.skuName = skuName; + } + + public Double getSkuPrice() { + return skuPrice; + } + + public void setSkuPrice(Double skuPrice) { + this.skuPrice = skuPrice; + } + + public Integer getTotalNum() { + return totalNum; + } + + public void setTotalNum(Integer totalNum) { + this.totalNum = totalNum; + } + + public Double getTotalPrice() { + return totalPrice; + } + + public void setTotalPrice(Double totalPrice) { + this.totalPrice = totalPrice; + } + + public Enum getSkuCategory() { + return skuCategory; + } + + public void setSkuCategory(Enum skuCategory) { + this.skuCategory = skuCategory; + } +} diff --git a/src/main/java/cart/SkuCategoryEnum.java b/src/main/java/cart/SkuCategoryEnum.java new file mode 100644 index 0000000..c700fa1 --- /dev/null +++ b/src/main/java/cart/SkuCategoryEnum.java @@ -0,0 +1,18 @@ +package cart; + +public enum SkuCategoryEnum { + CLOTHING(10,"服装类"), + ELECTRONICS(20,"数码类"), + SPORTS(30,"运动类"), + BOOKS(40,"图书类"); + + private Integer code; + private String name; + + + SkuCategoryEnum(Integer code, String name) { + this.code = code; + this.name = name; + } + +}