Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fileServe
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vanke
fileServe
Commits
5a2dace9
Commit
5a2dace9
authored
Jun 16, 2020
by
XiaHou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权星相关接口修复
parent
42d4737d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
0 deletions
+49
-0
PmsProductAttributeCategoryController.java
...oller/quanxing/PmsProductAttributeCategoryController.java
+11
-0
PmsProductAttributeCategoryService.java
.../service/quanxing/PmsProductAttributeCategoryService.java
+7
-0
PmsProductAttributeCategoryServiceImpl.java
...quanxing/impl/PmsProductAttributeCategoryServiceImpl.java
+31
-0
No files found.
mall-portal/src/main/java/com/macro/mall/portal/controller/quanxing/PmsProductAttributeCategoryController.java
View file @
5a2dace9
...
...
@@ -2,6 +2,7 @@ package com.macro.mall.portal.controller.quanxing;
import
com.macro.mall.common.api.CommonResult
;
import
com.macro.mall.model.PmsProductAttributeCategory
;
import
com.macro.mall.service.quanxing.PmsProductAttributeCategoryService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -13,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
java.util.List
;
@Controller
@Api
(
tags
=
"权星小程序_商品分类相关接口"
,
description
=
"商品属性分类管理"
)
@RequestMapping
(
"/pmsProductAttributeCategory"
)
...
...
@@ -27,4 +30,12 @@ public class PmsProductAttributeCategoryController {
@ApiParam
(
"非必传 不传父级id 则查所有分类"
)
@RequestParam
(
"parentId"
)
Long
parentId
){
return
CommonResult
.
success
(
this
.
productAttributeCategoryService
.
getAttributeCategoryList
(
page
,
size
,
parentId
));
}
@ApiOperation
(
"根据名称查询分类 一级名称返回一条数据 二级名称返回二条数据 三级名称返回三条数据"
)
@RequestMapping
(
value
=
"/getAttributeCategoryListByName"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
CommonResult
<
List
<
PmsProductAttributeCategory
>>
getAttributeCategoryListByName
(
@ApiParam
(
"分类名称"
)
@RequestParam
(
"name"
)
String
name
){
return
CommonResult
.
success
(
this
.
productAttributeCategoryService
.
getAtributeCategoryListByName
(
name
));
}
}
mall-service/src/main/java/com/macro/mall/service/quanxing/PmsProductAttributeCategoryService.java
View file @
5a2dace9
...
...
@@ -35,4 +35,11 @@ public interface PmsProductAttributeCategoryService {
*/
List
<
PmsProductAttributeCategory
>
getAttributeCategoryList
(
Integer
pageSize
,
Integer
pageNum
,
Long
parentId
);
/**
* 根据名字查询商品分类 如果一级返回一条数据 两级返回两条数据 三级返回三条数据
* @param name
* @return
*/
List
<
PmsProductAttributeCategory
>
getAtributeCategoryListByName
(
String
name
);
}
mall-service/src/main/java/com/macro/mall/service/quanxing/impl/PmsProductAttributeCategoryServiceImpl.java
View file @
5a2dace9
...
...
@@ -158,4 +158,34 @@ public class PmsProductAttributeCategoryServiceImpl implements PmsProductAttribu
return
productAttributeCategoryMapper
.
selectByExample
(
pmsProductAttributeCategoryExample
);
}
@Override
public
List
<
PmsProductAttributeCategory
>
getAtributeCategoryListByName
(
String
name
){
//返回集合数据
List
<
PmsProductAttributeCategory
>
dataList
=
new
ArrayList
<>();
//example对象
PmsProductAttributeCategoryExample
example
=
new
PmsProductAttributeCategoryExample
();
PmsProductAttributeCategoryExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andDeleteStatusEqualTo
(
0
);
//删除标识0 未删除 1已删除
criteria
.
andNameEqualTo
(
name
);
//传入名称
List
<
PmsProductAttributeCategory
>
ppacList1
=
this
.
productAttributeCategoryMapper
.
selectByExample
(
example
);
return
this
.
getRecursiongList
(
dataList
,
ppacList1
.
get
(
0
));
}
private
List
<
PmsProductAttributeCategory
>
getRecursiongList
(
List
<
PmsProductAttributeCategory
>
list
,
PmsProductAttributeCategory
ppac
){
if
(
ppac
!=
null
&&
ppac
.
getId
()
!=
null
&&
ppac
.
getParentId
()
!=
null
){
//将查询的结果判断 父级Id是否为0 如果为0 则是1级分类 否则继续下查
list
.
add
(
ppac
);
if
(
ppac
.
getParentId
()
!=
null
&&
ppac
.
getParentId
()
!=
0
){
//如果父级id不为空 并且不为0 则根据父级id查询
this
.
productAttributeCategoryMapper
.
selectByPrimaryKey
(
ppac
.
getParentId
());
//还要继续判断 如果还存在 递归调用
this
.
getRecursiongList
(
list
,
ppac
);
}
else
{
return
list
;
}
}
return
null
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment