Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6a176e90
authored
May 12, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将品牌商、产品服务、优先级、tag等创建订单总是需要的小数据,打包为一个接口予以实现
1 parent
ad24ae80
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
89 deletions
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/OrderController.java
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/ProductController.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/BrandDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/ItemsDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CategoryDTO.java → project-order/src/main/java/com/alibaba/cloud/integration/order/dto/KeyValueDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/ItemDTO.java → project-order/src/main/java/com/alibaba/cloud/integration/order/dto/ParameterRespDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/ProductService.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/ProductServiceImpl.java
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/OrderController.java
View file @
6a176e9
...
...
@@ -20,11 +20,9 @@ import com.alibaba.cloud.integration.common.BusinessException;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.service.OrderService
;
import
com.alibaba.cloud.integration.order.service.ProductService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
/**
* @author TrevorLink
...
...
@@ -36,6 +34,9 @@ public class OrderController {
@Autowired
private
OrderService
orderService
;
@Autowired
private
ProductService
productService
;
@PostMapping
(
"/create"
)
public
Result
<?>
createOrder
(
@RequestParam
(
"userId"
)
String
userId
,
@RequestParam
(
"commodityCode"
)
String
commodityCode
,
...
...
@@ -50,4 +51,15 @@ public class OrderController {
return
res
;
}
@GetMapping
(
"/service/parameter"
)
public
Result
<?>
getParameter
(){
Result
<?>
res
=
null
;
try
{
res
=
productService
.
getProductCategoryList
();
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
return
res
;
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/ProductController.java
deleted
100644 → 0
View file @
ad24ae8
package
com
.
alibaba
.
cloud
.
integration
.
order
.
controller
;
import
com.alibaba.cloud.integration.common.BusinessException
;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.service.ProductService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/order/service"
)
public
class
ProductController
{
@Autowired
ProductService
productService
;
@GetMapping
(
"/category"
)
public
Result
<?>
getProductCategory
(){
Result
<?>
res
=
null
;
try
{
res
=
productService
.
getProductCategoryList
();
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
return
res
;
}
@GetMapping
(
"/brand"
)
public
Result
<?>
brand
(){
Result
<?>
res
=
null
;
try
{
res
=
productService
.
getAllBrand
();
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
return
res
;
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/BrandDTO.java
View file @
6a176e9
...
...
@@ -8,5 +8,7 @@ import java.util.List;
@Data
@Accessors
(
chain
=
true
)
public
class
BrandDTO
{
private
List
<
String
>
brands
;
private
String
label
;
private
String
value
;
private
List
<
KeyValueDTO
>
categories
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/ItemsDTO.java
deleted
100644 → 0
View file @
ad24ae8
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
ItemsDTO
{
private
List
<
ItemDTO
>
items
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/
Category
DTO.java
→
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/
KeyValue
DTO.java
View file @
6a176e9
...
...
@@ -5,7 +5,7 @@ import lombok.experimental.Accessors;
@Data
@Accessors
(
chain
=
true
)
public
class
CategoryDTO
{
private
Long
id
;
public
class
KeyValueDTO
{
private
String
value
;
private
String
label
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/
Item
DTO.java
→
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/
ParameterResp
DTO.java
View file @
6a176e9
...
...
@@ -7,8 +7,8 @@ import java.util.List;
@Data
@Accessors
(
chain
=
true
)
public
class
ItemDTO
{
private
String
brand
;
private
List
<
CategoryDTO
>
categories
;
public
class
ParameterRespDTO
{
private
List
<
BrandDTO
>
brands
;
private
List
<
KeyValueDTO
>
priorities
;
private
List
<
KeyValueDTO
>
standardTags
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/service/ProductService.java
View file @
6a176e9
...
...
@@ -5,6 +5,4 @@ import com.alibaba.cloud.integration.order.dto.BrandDTO;
public
interface
ProductService
{
Result
<?>
getProductCategoryList
();
Result
<
BrandDTO
>
getAllBrand
();
}
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/ProductServiceImpl.java
View file @
6a176e9
...
...
@@ -3,15 +3,17 @@ package com.alibaba.cloud.integration.order.service.impl;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.dao.ProductCategoryDao
;
import
com.alibaba.cloud.integration.order.dto.BrandDTO
;
import
com.alibaba.cloud.integration.order.dto.CategoryDTO
;
import
com.alibaba.cloud.integration.order.dto.ItemDTO
;
import
com.alibaba.cloud.integration.order.dto.ItemsDTO
;
import
com.alibaba.cloud.integration.order.dto.KeyValueDTO
;
import
com.alibaba.cloud.integration.order.dto.ParameterRespDTO
;
import
com.alibaba.cloud.integration.order.entity.ProductCategoryEntity
;
import
com.alibaba.cloud.integration.order.service.ProductService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
ProductServiceImpl
implements
ProductService
{
...
...
@@ -19,34 +21,35 @@ public class ProductServiceImpl implements ProductService {
@Autowired
private
ProductCategoryDao
productCategoryDao
;
private
static
final
String
[]
BRANDS
=
{
"博世/西门子"
,
"GGN"
};
private
List
<
KeyValueDTO
>
getPriorities
()
{
return
null
;
}
p
ublic
Result
<
BrandDTO
>
getAllBrand
()
{
return
Result
.
success
(
new
BrandDTO
().
setBrands
(
new
ArrayList
<>(
Arrays
.
asList
(
BRANDS
))))
;
p
rivate
List
<
KeyValueDTO
>
getStandardTags
()
{
return
null
;
}
@Override
public
Result
<?>
getProductCategoryList
()
{
Map
<
String
,
ItemDTO
>
itemsMap
=
new
HashMap
<>();
private
List
<
BrandDTO
>
getBrands
()
{
Map
<
String
,
BrandDTO
>
brandMap
=
new
HashMap
<>();
for
(
ProductCategoryEntity
e
:
productCategoryDao
.
findAll
())
{
String
brand
=
e
.
getBrand
();
String
value
=
String
.
format
(
"%s-%s"
,
e
.
getType
(),
e
.
getSkill
());
CategoryDTO
categoryDto
=
new
CategoryDTO
().
setId
(
e
.
getProductServiceId
()).
setValue
(
value
);
if
(
itemsMap
.
containsKey
(
brand
))
{
ItemDTO
itemDto
=
itemsMap
.
get
(
brand
);
itemDto
.
getCategories
().
add
(
categoryDto
);
String
text
=
String
.
format
(
"%s-%s"
,
e
.
getType
(),
e
.
getSkill
());
KeyValueDTO
categoryDto
=
new
KeyValueDTO
().
setLabel
(
text
).
setValue
(
e
.
getProductServiceId
().
toString
());
if
(
brandMap
.
containsKey
(
brand
))
{
brandMap
.
get
(
brand
).
getCategories
().
add
(
categoryDto
);
}
else
{
ItemDTO
itemDto
=
new
ItemDTO
();
itemDto
.
setBrand
(
brand
);
List
<
CategoryDTO
>
categoryDTOS
=
new
ArrayList
<>();
categoryDTOS
.
add
(
categoryDto
);
itemDto
.
setCategories
(
categoryDTOS
);
itemsMap
.
put
(
brand
,
itemDto
);
BrandDTO
brandDTO
=
new
BrandDTO
().
setLabel
(
brand
).
setValue
(
brand
).
setCategories
(
new
ArrayList
<>());
brandDTO
.
getCategories
().
add
(
categoryDto
);
brandMap
.
put
(
brand
,
brandDTO
);
}
}
ItemsDTO
items
=
new
ItemsDTO
();
items
.
setItems
((
List
<
ItemDTO
>)
itemsMap
.
values
());
return
Result
.
success
(
items
);
return
(
List
<
BrandDTO
>)
brandMap
.
values
();
}
@Override
public
Result
<?>
getProductCategoryList
()
{
ParameterRespDTO
parameterDTO
=
new
ParameterRespDTO
().
setBrands
(
getBrands
()).
setPriorities
(
getPriorities
()).
setStandardTags
(
getStandardTags
());
return
Result
.
success
(
parameterDTO
);
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment