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 3c4ac354
authored
Jun 06, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增获取服务列表接口
1 parent
2ebef9b4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
130 additions
and
0 deletions
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/ProductCategoryController.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/ProductCategory2Dao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/ProductCategoryResp.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/ProductCategory.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/ProductCategoryService.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/ProductCategoryServiceImpl.java
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/ProductCategoryController.java
0 → 100644
View file @
3c4ac35
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.ProductCategoryService
;
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
(
"/pea-order"
)
public
class
ProductCategoryController
{
@Autowired
private
ProductCategoryService
productCategoryService
;
@GetMapping
(
"/product/category"
)
public
Result
<?>
getProductCategory
()
{
Result
<?>
res
=
null
;
try
{
res
=
productCategoryService
.
getProductCategory
();
}
catch
(
BusinessException
e
)
{
Result
.
failed
(
e
.
getMessage
());
}
return
res
;
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/ProductCategory2Dao.java
0 → 100644
View file @
3c4ac35
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dao
;
import
com.alibaba.cloud.integration.order.entity.ProductCategory
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
ProductCategory2Dao
extends
BaseMapper
<
ProductCategory
>
{
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/ProductCategoryResp.java
0 → 100644
View file @
3c4ac35
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
ProductCategoryResp
{
private
List
<
ProductCategory
>
categories
;
@Data
public
static
class
ProductCategory
{
private
String
brand
;
private
String
type
;
private
String
skill
;
private
String
categoryId
;
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/ProductCategory.java
0 → 100644
View file @
3c4ac35
package
com
.
alibaba
.
cloud
.
integration
.
order
.
entity
;
import
lombok.Data
;
@Data
public
class
ProductCategory
{
private
Integer
id
;
private
String
productCategoryId
;
private
String
brand
;
private
String
type
;
private
String
skill
;
private
Integer
takeTime
;
private
Integer
takeEngineer
;
private
Integer
lowElectricianCert
;
private
Integer
gasCert
;
private
String
tag
;
private
String
memo
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/service/ProductCategoryService.java
0 → 100644
View file @
3c4ac35
package
com
.
alibaba
.
cloud
.
integration
.
order
.
service
;
import
com.alibaba.cloud.integration.common.Result
;
public
interface
ProductCategoryService
{
Result
<?>
getProductCategory
();
}
\ No newline at end of file
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/ProductCategoryServiceImpl.java
0 → 100644
View file @
3c4ac35
package
com
.
alibaba
.
cloud
.
integration
.
order
.
service
.
impl
;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.dao.ProductCategory2Dao
;
import
com.alibaba.cloud.integration.order.dto.ProductCategoryResp
;
import
com.alibaba.cloud.integration.order.entity.ProductCategory
;
import
com.alibaba.cloud.integration.order.service.ProductCategoryService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.stream.Collectors
;
public
class
ProductCategoryServiceImpl
implements
ProductCategoryService
{
@Autowired
private
ProductCategory2Dao
productCategory2Dao
;
@Transactional
@Override
public
Result
<?>
getProductCategory
()
{
// 查询所有记录
List
<
ProductCategory
>
records
=
productCategory2Dao
.
selectList
(
null
);
// 排序brand+type+skill
Comparator
<
ProductCategory
>
byBrand
=
Comparator
.
comparing
(
ProductCategory:
:
getBrand
);
Comparator
<
ProductCategory
>
byType
=
Comparator
.
comparing
(
ProductCategory:
:
getType
);
Comparator
<
ProductCategory
>
bySkill
=
Comparator
.
comparing
(
ProductCategory:
:
getSkill
);
Comparator
<
ProductCategory
>
comp
=
byBrand
.
thenComparing
(
byType
).
thenComparing
(
bySkill
);
List
<
ProductCategory
>
results
=
records
.
stream
().
sorted
(
comp
).
collect
(
Collectors
.
toList
());
ProductCategoryResp
res
=
new
ProductCategoryResp
();
List
<
ProductCategoryResp
.
ProductCategory
>
categories
=
new
ArrayList
<>();
for
(
ProductCategory
p:
results
)
{
ProductCategoryResp
.
ProductCategory
item
=
new
ProductCategoryResp
.
ProductCategory
();
item
.
setBrand
(
p
.
getBrand
());
item
.
setType
(
p
.
getType
());
item
.
setSkill
(
p
.
getSkill
());
item
.
setCategoryId
(
p
.
getProductCategoryId
());
categories
.
add
(
item
);
}
res
.
setCategories
(
categories
);
return
Result
.
success
(
res
);
}
}
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