Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
haoban3.0
haoban-manage3.0
Commits
27b15d8b
Commit
27b15d8b
authored
Nov 18, 2021
by
xugaojun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【11-2迭代-[素材库默认查询全部分组]】:代码实现
parent
f9f42fc5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
30 deletions
+52
-30
MaterialApiServiceImpl.java
...nage/service/service/out/impl/MaterialApiServiceImpl.java
+7
-1
MaterialController.java
.../gic/haoban/manage/web/controller/MaterialController.java
+45
-29
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/MaterialApiServiceImpl.java
View file @
27b15d8b
...
@@ -277,7 +277,13 @@ public class MaterialApiServiceImpl implements MaterialApiService {
...
@@ -277,7 +277,13 @@ public class MaterialApiServiceImpl implements MaterialApiService {
@Override
@Override
public
Page
<
MaterialDTO
>
listMaterial
(
String
wxEnterpriseId
,
String
keyword
,
String
categoryId
,
public
Page
<
MaterialDTO
>
listMaterial
(
String
wxEnterpriseId
,
String
keyword
,
String
categoryId
,
Integer
materialType
,
BasePageInfo
pageInfo
)
{
Integer
materialType
,
BasePageInfo
pageInfo
)
{
List
<
String
>
categoryIds
=
this
.
listSubCategoryIdsByParentId
(
categoryId
);
List
<
String
>
categoryIds
;
if
(
"-1"
.
equals
(
categoryId
))
{
// 传入-1默认查询全部
categoryIds
=
Collections
.
emptyList
();
}
else
{
categoryIds
=
this
.
listSubCategoryIdsByParentId
(
categoryId
);
}
PageHelper
.
startPage
(
pageInfo
.
getPageNum
(),
pageInfo
.
getPageSize
());
PageHelper
.
startPage
(
pageInfo
.
getPageNum
(),
pageInfo
.
getPageSize
());
com
.
github
.
pagehelper
.
Page
<
TabHaobanMaterial
>
page
=
materialService
.
listMaterial
(
wxEnterpriseId
,
keyword
,
categoryIds
,
materialType
);
com
.
github
.
pagehelper
.
Page
<
TabHaobanMaterial
>
page
=
materialService
.
listMaterial
(
wxEnterpriseId
,
keyword
,
categoryIds
,
materialType
);
List
<
TabHaobanMaterial
>
result
=
page
.
getResult
();
List
<
TabHaobanMaterial
>
result
=
page
.
getResult
();
...
...
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/controller/MaterialController.java
View file @
27b15d8b
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.Page
;
import
com.gic.commons.util.DateUtil
;
import
com.gic.commons.util.DateUtil
;
import
com.gic.haoban.base.api.common.BasePageInfo
;
import
com.gic.haoban.base.api.common.BasePageInfo
;
...
@@ -26,21 +12,48 @@ import com.gic.haoban.manage.api.dto.MaterialDTO;
...
@@ -26,21 +12,48 @@ import com.gic.haoban.manage.api.dto.MaterialDTO;
import
com.gic.haoban.manage.api.service.MaterialApiService
;
import
com.gic.haoban.manage.api.service.MaterialApiService
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.vo.MaterialVO
;
import
com.gic.haoban.manage.web.vo.MaterialVO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@RestController
@RestController
public
class
MaterialController
extends
WebBaseController
{
public
class
MaterialController
extends
WebBaseController
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
MaterialController
.
class
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
MaterialController
.
class
);
@Autowired
@Autowired
private
MaterialApiService
materialApiService
;
private
MaterialApiService
materialApiService
;
/**
/**
* 素材查询
* desc: 分页查询素材
* @return
*
* @param wxEnterpriseId 企业微信id
* @param keyword 素材标题
* @param categoryId 分类id
* @param materialType 素材类型
* @param pageInfo 分页参数
* @return : {@link HaobanResponse}
* @author : YongEn
* @date : 2021/11/18
*/
*/
@RequestMapping
(
"/material-list"
)
@RequestMapping
(
"/material-list"
)
public
HaobanResponse
materialList
(
String
wxEnterpriseId
,
String
keyword
,
String
categoryId
,
Integer
materialType
,
BasePageInfo
pageInfo
)
{
public
HaobanResponse
materialList
(
String
wxEnterpriseId
,
Page
<
MaterialDTO
>
page
=
materialApiService
.
listMaterial
(
wxEnterpriseId
,
keyword
,
categoryId
,
materialType
,
pageInfo
);
String
keyword
,
String
categoryId
,
Integer
materialType
,
BasePageInfo
pageInfo
)
{
Page
<
MaterialDTO
>
page
=
materialApiService
.
listMaterial
(
wxEnterpriseId
,
keyword
,
categoryId
,
materialType
,
pageInfo
);
//暂时转换
//暂时转换
PageResult2
pageResult2
=
PageUtil
.
getPageInfo
(
page
);
PageResult2
pageResult2
=
PageUtil
.
getPageInfo
(
page
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
pageResult2
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
pageResult2
);
...
@@ -48,6 +61,7 @@ public class MaterialController extends WebBaseController{
...
@@ -48,6 +61,7 @@ public class MaterialController extends WebBaseController{
/**
/**
* 素材查询
* 素材查询
*
* @return
* @return
*/
*/
@RequestMapping
(
"/material-type"
)
@RequestMapping
(
"/material-type"
)
...
@@ -55,42 +69,44 @@ public class MaterialController extends WebBaseController{
...
@@ -55,42 +69,44 @@ public class MaterialController extends WebBaseController{
List
<
MaterialCategoryDTO
>
list
=
materialApiService
.
listCategory
(
wxEnterpriseId
);
List
<
MaterialCategoryDTO
>
list
=
materialApiService
.
listCategory
(
wxEnterpriseId
);
List
<
MaterialVO
>
handerList
=
new
ArrayList
<
MaterialVO
>();
List
<
MaterialVO
>
handerList
=
new
ArrayList
<
MaterialVO
>();
MaterialVO
vo
=
new
MaterialVO
();
MaterialVO
vo
=
new
MaterialVO
();
// 默认给-1位全部分组标准-查询列表时如果传入-1默认查询全部素材
vo
.
setCategoryId
(
"-1"
);
vo
.
setCategoryId
(
"-1"
);
vo
.
setCategoryName
(
"未
分组"
);
vo
.
setCategoryName
(
"全部
分组"
);
vo
.
setCategoryParentId
(
"0"
);
vo
.
setCategoryParentId
(
"0"
);
vo
.
setWxEnterpriseId
(
wxEnterpriseId
);
vo
.
setWxEnterpriseId
(
wxEnterpriseId
);
handerList
.
add
(
vo
);
handerList
.
add
(
vo
);
for
(
MaterialCategoryDTO
materialCategoryDTO
:
list
)
{
for
(
MaterialCategoryDTO
materialCategoryDTO
:
list
)
{
if
(
"0"
.
equals
(
materialCategoryDTO
.
getCategoryParentId
()))
{
if
(
"0"
.
equals
(
materialCategoryDTO
.
getCategoryParentId
()))
{
handerList
.
add
(
EntityUtil
.
changeEntityByJSON
(
MaterialVO
.
class
,
materialCategoryDTO
));
handerList
.
add
(
EntityUtil
.
changeEntityByJSON
(
MaterialVO
.
class
,
materialCategoryDTO
));
}
}
}
}
Map
<
String
,
List
<
MaterialCategoryDTO
>>
map
=
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
MaterialCategoryDTO:
:
getCategoryParentId
));
Map
<
String
,
List
<
MaterialCategoryDTO
>>
map
=
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
MaterialCategoryDTO:
:
getCategoryParentId
));
handerSonMaterial
(
handerList
,
map
);
handerSonMaterial
(
handerList
,
map
);
for
(
MaterialVO
materialVO
:
handerList
)
{
for
(
MaterialVO
materialVO
:
handerList
)
{
List
<
MaterialVO
>
sonVoList
=
materialVO
.
getList
();
List
<
MaterialVO
>
sonVoList
=
materialVO
.
getList
();
if
(
sonVoList
!=
null
&&
!
sonVoList
.
isEmpty
())
{
if
(
sonVoList
!=
null
&&
!
sonVoList
.
isEmpty
())
{
handerSonMaterial
(
sonVoList
,
map
);
handerSonMaterial
(
sonVoList
,
map
);
}
}
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
handerList
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
handerList
);
}
}
/**
/**
* 素材查询
* 素材查询
*
* @return
* @return
*/
*/
@RequestMapping
(
"/reupdalod-material"
)
@RequestMapping
(
"/reupdalod-material"
)
public
HaobanResponse
reUpdalodMetail
(
String
materialId
)
{
public
HaobanResponse
reUpdalodMetail
(
String
materialId
)
{
if
(
StringUtils
.
isBlank
(
materialId
))
{
if
(
StringUtils
.
isBlank
(
materialId
))
{
return
resultResponse
(
HaoBanErrCode
.
ERR_10015
);
return
resultResponse
(
HaoBanErrCode
.
ERR_10015
);
}
}
MaterialDTO
material
=
materialApiService
.
selectMaterialById
(
materialId
);
MaterialDTO
material
=
materialApiService
.
selectMaterialById
(
materialId
);
if
(
material
==
null
)
{
if
(
material
==
null
)
{
}
}
String
medialId
=
""
;
String
medialId
=
""
;
if
(
material
.
getMaterialType
()
==
2
||
material
.
getMaterialType
()
==
4
||
material
.
getMaterialType
()
==
5
)
{
if
(
material
.
getMaterialType
()
==
2
||
material
.
getMaterialType
()
==
4
||
material
.
getMaterialType
()
==
5
)
{
if
(
material
.
getMediaId
()
==
null
)
{
if
(
material
.
getMediaId
()
==
null
)
{
medialId
=
materialApiService
.
reUpdalodMetail
(
materialId
);
medialId
=
materialApiService
.
reUpdalodMetail
(
materialId
);
}
else
{
}
else
{
...
@@ -101,11 +117,11 @@ public class MaterialController extends WebBaseController{
...
@@ -101,11 +117,11 @@ public class MaterialController extends WebBaseController{
}
}
}
}
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
medialId
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
medialId
);
}
}
private
void
handerSonMaterial
(
List
<
MaterialVO
>
handerList
,
Map
<
String
,
List
<
MaterialCategoryDTO
>>
map
)
{
private
void
handerSonMaterial
(
List
<
MaterialVO
>
handerList
,
Map
<
String
,
List
<
MaterialCategoryDTO
>>
map
)
{
for
(
MaterialVO
materialVO
:
handerList
)
{
for
(
MaterialVO
materialVO
:
handerList
)
{
List
<
MaterialCategoryDTO
>
sonList
=
map
.
get
(
materialVO
.
getCategoryId
());
List
<
MaterialCategoryDTO
>
sonList
=
map
.
get
(
materialVO
.
getCategoryId
());
List
<
MaterialVO
>
sonVoList
=
EntityUtil
.
changeEntityListByJSON
(
MaterialVO
.
class
,
sonList
);
List
<
MaterialVO
>
sonVoList
=
EntityUtil
.
changeEntityListByJSON
(
MaterialVO
.
class
,
sonList
);
...
...
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