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 ad24ae80
authored
May 11, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加了品牌商、产品服务类别接口
1 parent
9218eb4f
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
260 additions
and
1 deletions
project-order/pom.xml
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/ProductController.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/ProductCategoryDao.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/CategoryDTO.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/ItemsDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/ProductCategoryEntity.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/pom.xml
View file @
ad24ae8
...
...
@@ -76,7 +76,10 @@
<groupId>
org.postgresql
</groupId>
<artifactId>
postgresql
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
...
...
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/ProductController.java
0 → 100644
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/dao/ProductCategoryDao.java
0 → 100644
View file @
ad24ae8
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dao
;
import
com.alibaba.cloud.integration.order.entity.ProductCategoryEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
ProductCategoryDao
extends
JpaRepository
<
ProductCategoryEntity
,
Long
>
{
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/BrandDTO.java
0 → 100644
View file @
ad24ae8
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.util.List
;
@Data
@Accessors
(
chain
=
true
)
public
class
BrandDTO
{
private
List
<
String
>
brands
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CategoryDTO.java
0 → 100644
View file @
ad24ae8
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
@Data
@Accessors
(
chain
=
true
)
public
class
CategoryDTO
{
private
Long
id
;
private
String
value
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/ItemDTO.java
0 → 100644
View file @
ad24ae8
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.util.List
;
@Data
@Accessors
(
chain
=
true
)
public
class
ItemDTO
{
private
String
brand
;
private
List
<
CategoryDTO
>
categories
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/ItemsDTO.java
0 → 100644
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/entity/ProductCategoryEntity.java
0 → 100644
View file @
ad24ae8
package
com
.
alibaba
.
cloud
.
integration
.
order
.
entity
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
java.io.Serializable
;
import
java.util.Date
;
import
javax.persistence.*
;
@Entity
@Data
@Table
(
name
=
"product_category"
)
public
class
ProductCategoryEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
/**
* 小组id
*/
@Column
(
name
=
"product_service_id"
)
private
Long
productServiceId
;
/**
* 品牌
*/
@Column
(
name
=
"brand"
)
private
String
brand
;
/**
* 产品类别
*/
@Column
(
name
=
"type"
)
private
String
type
;
/**
* 服务类型
*/
@Column
(
name
=
"skill"
)
private
String
skill
;
/**
* 所需工时(分钟)
*/
@Column
(
name
=
"take_time"
)
private
Integer
takeTime
;
/**
* 所需人数
*/
@Column
(
name
=
"take_engineer"
)
private
Integer
takeEngineer
;
/**
* 是否需要低压电工证
*/
@Column
(
name
=
"low_electrician_cert"
)
private
int
lowElectricianCert
;
/**
* 是否需要燃气证
*/
@Column
(
name
=
"gas_cert"
)
private
int
gasCert
;
/**
* 图层标签
*/
@Column
(
name
=
"tag"
)
private
String
tag
;
/**
* 备注
*/
@Column
(
name
=
"memo"
)
private
String
memo
;
/**
* 创建时间
*/
@Column
(
name
=
"create_time"
)
private
Date
createTime
;
/**
* 更新时间
*/
@Column
(
name
=
"update_time"
)
private
Date
updateTime
;
public
ProductCategoryEntity
()
{
}
}
\ No newline at end of file
project-order/src/main/java/com/alibaba/cloud/integration/order/service/ProductService.java
0 → 100644
View file @
ad24ae8
package
com
.
alibaba
.
cloud
.
integration
.
order
.
service
;
import
com.alibaba.cloud.integration.common.Result
;
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
0 → 100644
View file @
ad24ae8
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.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.*
;
@Service
public
class
ProductServiceImpl
implements
ProductService
{
@Autowired
private
ProductCategoryDao
productCategoryDao
;
private
static
final
String
[]
BRANDS
=
{
"博世/西门子"
,
"GGN"
};
public
Result
<
BrandDTO
>
getAllBrand
()
{
return
Result
.
success
(
new
BrandDTO
().
setBrands
(
new
ArrayList
<>(
Arrays
.
asList
(
BRANDS
))));
}
@Override
public
Result
<?>
getProductCategoryList
()
{
Map
<
String
,
ItemDTO
>
itemsMap
=
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
);
}
else
{
ItemDTO
itemDto
=
new
ItemDTO
();
itemDto
.
setBrand
(
brand
);
List
<
CategoryDTO
>
categoryDTOS
=
new
ArrayList
<>();
categoryDTOS
.
add
(
categoryDto
);
itemDto
.
setCategories
(
categoryDTOS
);
itemsMap
.
put
(
brand
,
itemDto
);
}
}
ItemsDTO
items
=
new
ItemsDTO
();
items
.
setItems
((
List
<
ItemDTO
>)
itemsMap
.
values
());
return
Result
.
success
(
items
);
}
}
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