Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
c1d54204
Commit
c1d54204
authored
Aug 31, 2023
by
muhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增 所有分类的接口
parent
dec9de47
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
21 deletions
+62
-21
ch-dao/src/main/java/com/wwdz/ch/db/dao/CategoryDao.java
ch-dao/src/main/java/com/wwdz/ch/db/dao/CategoryDao.java
+5
-11
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/CategorySearchRequestDto.java
.../com/wwdz/ch/db/dto/request/CategorySearchRequestDto.java
+11
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/CategoryDaoImpl.java
...ao/src/main/java/com/wwdz/ch/db/impl/CategoryDaoImpl.java
+9
-8
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/CategoryServiceImpl.java
...rc/main/java/com/wwdz/ch/wx/impl/CategoryServiceImpl.java
+24
-2
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/CategoryService.java
...src/main/java/com/wwdz/ch/wx/service/CategoryService.java
+7
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxCategoryController.java
...rc/main/java/com/wwdz/ch/wx/web/WxCategoryController.java
+6
-0
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/dao/CategoryDao.java
View file @
c1d54204
package
com.wwdz.ch.db.dao
;
package
com.wwdz.ch.db.dao
;
import
com.wwdz.ch.db.domain.Category
;
import
com.wwdz.ch.db.domain.Category
;
import
com.wwdz.ch.db.dto.request.CategorySearchRequestDto
;
import
java.util.List
;
import
java.util.List
;
public
interface
CategoryDao
{
public
interface
CategoryDao
{
...
@@ -8,12 +10,12 @@ public interface CategoryDao {
...
@@ -8,12 +10,12 @@ public interface CategoryDao {
List
<
Category
>
queryByLevel
(
Integer
level
,
Integer
offset
,
Integer
limit
);
List
<
Category
>
queryByLevel
(
Integer
level
,
Integer
offset
,
Integer
limit
);
/**
/**
* 通过
level
查询未删除的分类列表
* 通过
条件
查询未删除的分类列表
*
*
* @param
level
* @param
dto
* @return
* @return
*/
*/
List
<
Category
>
list
ByLevel
(
Integer
level
);
List
<
Category
>
list
Selective
(
CategorySearchRequestDto
dto
);
List
<
Category
>
queryByPid
(
Integer
pid
);
List
<
Category
>
queryByPid
(
Integer
pid
);
...
@@ -27,14 +29,6 @@ public interface CategoryDao {
...
@@ -27,14 +29,6 @@ public interface CategoryDao {
*/
*/
Category
findByName
(
String
name
);
Category
findByName
(
String
name
);
/**
* 通过名称模糊查询未删除的分类列表
*
* @param name
* @return
*/
List
<
Category
>
queryByName
(
String
name
);
/**
/**
* 判断是否存在子类目
* 判断是否存在子类目
*
*
...
...
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/CategorySearchRequestDto.java
0 → 100644
View file @
c1d54204
package
com.wwdz.ch.db.dto.request
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
@Data
public
class
CategorySearchRequestDto
extends
BaseRequestDto
implements
Entity
{
private
Integer
level
;
private
Long
pid
;
private
String
name
;
}
ch-dao/src/main/java/com/wwdz/ch/db/impl/CategoryDaoImpl.java
View file @
c1d54204
package
com.wwdz.ch.db.impl
;
package
com.wwdz.ch.db.impl
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
com.wwdz.ch.db.dto.request.CategorySearchRequestDto
;
import
com.wwdz.ch.db.mapper.CategoryMapper
;
import
com.wwdz.ch.db.mapper.CategoryMapper
;
import
com.wwdz.ch.db.domain.Category
;
import
com.wwdz.ch.db.domain.Category
;
import
com.wwdz.ch.db.domain.CategoryExample
;
import
com.wwdz.ch.db.domain.CategoryExample
;
import
com.wwdz.ch.db.dao.CategoryDao
;
import
com.wwdz.ch.db.dao.CategoryDao
;
import
com.xxdxxs.db.component.JdbcHelper
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -36,9 +38,14 @@ public class CategoryDaoImpl implements CategoryDao {
...
@@ -36,9 +38,14 @@ public class CategoryDaoImpl implements CategoryDao {
return
categoryMapper
.
selectByExample
(
example
);
return
categoryMapper
.
selectByExample
(
example
);
}
}
public
List
<
Category
>
list
ByLevel
(
Integer
level
)
{
public
List
<
Category
>
list
Selective
(
CategorySearchRequestDto
dto
)
{
CategoryExample
example
=
new
CategoryExample
();
CategoryExample
example
=
new
CategoryExample
();
example
.
or
().
andLevelEqualTo
(
level
).
andIsDeletedEqualTo
(
false
);
CategoryExample
.
Criteria
criteria
=
example
.
createCriteria
();
JdbcHelper
.
ifPresent
(
dto
.
getLevel
(),
criteria:
:
andLevelEqualTo
);
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
dto
.
getName
()))
{
criteria
.
andNameLike
(
"%"
+
dto
.
getName
()
+
"%"
);
}
criteria
.
andIsDeletedEqualTo
(
false
);
return
categoryMapper
.
selectByExample
(
example
);
return
categoryMapper
.
selectByExample
(
example
);
}
}
...
@@ -58,12 +65,6 @@ public class CategoryDaoImpl implements CategoryDao {
...
@@ -58,12 +65,6 @@ public class CategoryDaoImpl implements CategoryDao {
return
categoryMapper
.
selectOneByExample
(
example
);
return
categoryMapper
.
selectOneByExample
(
example
);
}
}
public
List
<
Category
>
queryByName
(
String
name
)
{
CategoryExample
example
=
new
CategoryExample
();
example
.
or
().
andNameLike
(
"%"
+
name
+
"%"
).
andIsDeletedEqualTo
(
false
);
return
categoryMapper
.
selectByExample
(
example
);
}
@Override
@Override
public
boolean
isExistedChild
(
Integer
id
)
{
public
boolean
isExistedChild
(
Integer
id
)
{
CategoryExample
example
=
new
CategoryExample
();
CategoryExample
example
=
new
CategoryExample
();
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/CategoryServiceImpl.java
View file @
c1d54204
...
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
...
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.db.dao.CategoryDao
;
import
com.wwdz.ch.db.dao.CategoryDao
;
import
com.wwdz.ch.db.domain.Category
;
import
com.wwdz.ch.db.domain.Category
;
import
com.wwdz.ch.db.dto.request.CategorySearchRequestDto
;
import
com.wwdz.ch.wx.entity.request.CategoryRequestDto
;
import
com.wwdz.ch.wx.entity.request.CategoryRequestDto
;
import
com.wwdz.ch.wx.entity.vo.CategoryResponseVo
;
import
com.wwdz.ch.wx.entity.vo.CategoryResponseVo
;
import
com.wwdz.ch.wx.service.CategoryService
;
import
com.wwdz.ch.wx.service.CategoryService
;
...
@@ -59,7 +60,9 @@ public class CategoryServiceImpl implements CategoryService {
...
@@ -59,7 +60,9 @@ public class CategoryServiceImpl implements CategoryService {
categoryList
.
add
(
category
);
categoryList
.
add
(
category
);
int
i
=
category
.
getLevel
()
-
1
;
int
i
=
category
.
getLevel
()
-
1
;
while
(
i
>
0
)
{
while
(
i
>
0
)
{
categoryList
.
addAll
(
categoryDao
.
listByLevel
(
i
));
CategorySearchRequestDto
categorySearchRequestDto
=
new
CategorySearchRequestDto
();
categorySearchRequestDto
.
setLevel
(
i
);
categoryList
.
addAll
(
categoryDao
.
listSelective
(
categorySearchRequestDto
));
i
--;
i
--;
}
}
List
<
CategoryResponseVo
>
responseVoList
=
categoryList
.
stream
()
List
<
CategoryResponseVo
>
responseVoList
=
categoryList
.
stream
()
...
@@ -76,6 +79,23 @@ public class CategoryServiceImpl implements CategoryService {
...
@@ -76,6 +79,23 @@ public class CategoryServiceImpl implements CategoryService {
}
}
}
}
@Override
public
Result
all
()
{
try
{
CategorySearchRequestDto
categorySearchRequestDto
=
new
CategorySearchRequestDto
();
List
<
Category
>
list
=
categoryDao
.
listSelective
(
categorySearchRequestDto
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
Result
.
success
(
new
ArrayList
<>());
}
List
<
CategoryResponseVo
>
responseVoList
=
list
.
stream
()
.
map
(
this
::
toCategoryResponseVo
).
collect
(
Collectors
.
toList
());
return
Result
.
success
(
convertVoList
(
responseVoList
));
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询所有分类失败"
,
e
);
return
Result
.
failed
(
"查询所有分类失败"
);
}
}
@Override
@Override
public
Result
findNames
(
CategoryRequestDto
dto
)
{
public
Result
findNames
(
CategoryRequestDto
dto
)
{
if
(
StringUtils
.
isBlank
(
dto
.
getName
()))
{
if
(
StringUtils
.
isBlank
(
dto
.
getName
()))
{
...
@@ -83,7 +103,9 @@ public class CategoryServiceImpl implements CategoryService {
...
@@ -83,7 +103,9 @@ public class CategoryServiceImpl implements CategoryService {
}
}
try
{
try
{
List
<
Category
>
result
=
new
ArrayList
<>();
List
<
Category
>
result
=
new
ArrayList
<>();
List
<
Category
>
list
=
categoryDao
.
queryByName
(
dto
.
getName
());
CategorySearchRequestDto
categorySearchRequestDto
=
new
CategorySearchRequestDto
();
categorySearchRequestDto
.
setName
(
dto
.
getName
());
List
<
Category
>
list
=
categoryDao
.
listSelective
(
categorySearchRequestDto
);
// 筛选叶子节点
// 筛选叶子节点
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
for
(
Category
category
:
list
)
{
for
(
Category
category
:
list
)
{
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/CategoryService.java
View file @
c1d54204
...
@@ -28,6 +28,13 @@ public interface CategoryService {
...
@@ -28,6 +28,13 @@ public interface CategoryService {
*/
*/
Result
find
(
CategoryRequestDto
dto
);
Result
find
(
CategoryRequestDto
dto
);
/**
* 所有分类的树形列表
*
* @return
*/
Result
all
();
/**
/**
* 按名称搜索模糊匹配返回分类列表
* 按名称搜索模糊匹配返回分类列表
*
*
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxCategoryController.java
View file @
c1d54204
...
@@ -55,6 +55,12 @@ public class WxCategoryController {
...
@@ -55,6 +55,12 @@ public class WxCategoryController {
return
categoryService
.
find
(
dto
);
return
categoryService
.
find
(
dto
);
}
}
@ApiOperation
(
value
=
"所有分类查询"
)
@PostMapping
(
value
=
"/all"
)
public
Result
find
()
{
return
categoryService
.
all
();
}
@ApiOperation
(
value
=
"名称模糊联想"
)
@ApiOperation
(
value
=
"名称模糊联想"
)
@PostMapping
(
value
=
"/findNames"
)
@PostMapping
(
value
=
"/findNames"
)
public
Result
findNames
(
@RequestBody
CategoryRequestDto
dto
)
{
public
Result
findNames
(
@RequestBody
CategoryRequestDto
dto
)
{
...
...
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