Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
chnmuseum-party
Project
Project
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
liqin
chnmuseum-party
Commits
5edefe51
Commit
5edefe51
authored
May 17, 2021
by
jiawei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG修改===》》》修改学习内容展板列表排序问题
parent
5cc29b80
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
9 deletions
+80
-9
ExhibitionBoard.java
src/main/java/cn/chnmuseum/party/model/ExhibitionBoard.java
+5
-0
LearningContentBoardController.java
.../party/web/controller/LearningContentBoardController.java
+53
-0
LearningContentController.java
...useum/party/web/controller/LearningContentController.java
+22
-9
No files found.
src/main/java/cn/chnmuseum/party/model/ExhibitionBoard.java
View file @
5edefe51
...
...
@@ -189,4 +189,9 @@ public class ExhibitionBoard implements Serializable {
@TableField
(
exist
=
false
)
private
List
<
Map
<
String
,
String
>>
audioLanguageList
;
/**
* 学习类容展板排序加的临时字段,表中不存在
*/
@TableField
(
exist
=
false
)
private
Integer
sortorder
;
}
src/main/java/cn/chnmuseum/party/web/controller/LearningContentBoardController.java
View file @
5edefe51
...
...
@@ -13,6 +13,7 @@ import io.swagger.annotations.ApiImplicitParams;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.shiro.authz.annotation.RequiresAuthentication
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
...
...
@@ -147,5 +148,57 @@ public class LearningContentBoardController extends BaseController {
return
getSuccessResult
();
}
/**
* 修改后的接口
* 通用排序方法(拖拽排序/所有排序完成后点击保存)
*
* @param sourceId 源实体ID
* @param targetId 目标实体ID
* @return Void
*/
@ApiOperation
(
value
=
"根据学习内容id-展板排序"
)
@PutMapping
(
value
=
"/sortById"
)
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"id"
,
value
=
"学习内容id"
,
paramType
=
"query"
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"sourceId"
,
value
=
"展板源id"
,
paramType
=
"query"
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"targetId"
,
value
=
"展板目标id"
,
paramType
=
"query"
,
dataType
=
"String"
)
})
@RequiresAuthentication
//@RequiresPermissions("learning:content:board:sort")
public
Map
<
String
,
Object
>
sortById
(
String
id
,
String
sourceId
,
String
targetId
)
{
LambdaQueryWrapper
<
LearningContentBoard
>
sourceEq
=
new
QueryWrapper
<
LearningContentBoard
>().
lambda
()
.
eq
(
LearningContentBoard:
:
getLearningContentId
,
id
)
.
eq
(
LearningContentBoard:
:
getExhibitionBoardId
,
sourceId
);
//
LambdaQueryWrapper
<
LearningContentBoard
>
targetEq
=
new
QueryWrapper
<
LearningContentBoard
>().
lambda
()
.
eq
(
LearningContentBoard:
:
getLearningContentId
,
id
)
.
eq
(
LearningContentBoard:
:
getExhibitionBoardId
,
targetId
);
List
<
LearningContentBoard
>
theSource
=
this
.
learningContentBoardService
.
list
(
sourceEq
);
List
<
LearningContentBoard
>
theTarget
=
this
.
learningContentBoardService
.
list
(
targetEq
);
if
(
CollectionUtils
.
isEmpty
(
theSource
)
&&
CollectionUtils
.
isEmpty
(
theTarget
))
{
return
getFailResult
(
"排序展板不存在"
);
}
//排序字段互换
LearningContentBoard
lcbS
=
theSource
.
get
(
0
);
LearningContentBoard
lcbT
=
theTarget
.
get
(
0
);
theSource
.
stream
().
forEach
(
s
->
{
s
.
setSortorder
(
lcbT
.
getSortorder
());
});
theTarget
.
stream
().
forEach
(
t
->
{
t
.
setSortorder
(
lcbS
.
getSortorder
());
});
boolean
batch
=
learningContentBoardService
.
updateBatchById
(
theSource
);
boolean
batch1
=
learningContentBoardService
.
updateBatchById
(
theTarget
);
return
getSuccessResult
();
}
}
src/main/java/cn/chnmuseum/party/web/controller/LearningContentController.java
View file @
5edefe51
...
...
@@ -31,10 +31,7 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -141,9 +138,11 @@ public class LearningContentController extends BaseController {
learningContentBoardQueryWrapper
.
select
(
"max(sortorder) as sortorder"
);
LearningContentBoard
one
=
this
.
learningContentBoardService
.
getOne
(
learningContentBoardQueryWrapper
);
if
(
one
!=
null
&&
one
.
getSortorder
()
!=
null
)
{
learningContent
.
setSortorder
(
one
.
getSortorder
()
+
1
);
// learningContent.setSortorder(one.getSortorder() + 1);
learningContentBoard
.
setSortorder
(
one
.
getSortorder
()
+
1
);
}
else
{
learningContent
.
setSortorder
(
1
);
// learningContent.setSortorder(1);
learningContentBoard
.
setSortorder
(
1
);
}
this
.
learningContentBoardService
.
save
(
learningContentBoard
);
}
...
...
@@ -420,10 +419,24 @@ public class LearningContentController extends BaseController {
}
final
LambdaQueryWrapper
<
LearningContentBoard
>
queryWrapper2
=
Wrappers
.<
LearningContentBoard
>
lambdaQuery
().
eq
(
LearningContentBoard:
:
getLearningContentId
,
id
);
queryWrapper2
.
select
(
LearningContentBoard:
:
getExhibitionBoardId
);
final
List
<
String
>
exhibitionBoardIdList
=
this
.
learningContentBoardService
.
listObjs
(
queryWrapper2
,
Object:
:
toString
);
queryWrapper2
.
select
(
LearningContentBoard:
:
getExhibitionBoardId
,
LearningContentBoard:
:
getSortorder
)
.
orderByAsc
(
LearningContentBoard:
:
getSortorder
);
final
List
<
LearningContentBoard
>
exhibitionBoardIdListNew
=
this
.
learningContentBoardService
.
list
(
queryWrapper2
);
final
List
<
String
>
exhibitionBoardIdList
=
exhibitionBoardIdListNew
.
stream
().
map
(
LearningContentBoard:
:
getExhibitionBoardId
).
collect
(
Collectors
.
toList
());
// final List<String> exhibitionBoardIdList = this.learningContentBoardService.listObjs(queryWrapper2, Object::toString);
if
(!
exhibitionBoardIdList
.
isEmpty
())
{
final
List
<
ExhibitionBoard
>
exhibitionBoardList
=
this
.
exhibitionBoardService
.
listByIds
(
exhibitionBoardIdList
);
List
<
ExhibitionBoard
>
exhibitionBoardList
=
this
.
exhibitionBoardService
.
listByIds
(
exhibitionBoardIdList
);
//设置sortorder ,然后在排序
exhibitionBoardList
.
stream
().
forEach
(
eb
->
{
exhibitionBoardIdListNew
.
stream
().
forEach
(
lcb
->
{
if
(
eb
.
getId
().
equals
(
lcb
.
getExhibitionBoardId
()))
{
eb
.
setSortorder
(
lcb
.
getSortorder
());
}
});
});
exhibitionBoardList
=
exhibitionBoardList
.
stream
().
sorted
(
Comparator
.
comparing
(
ExhibitionBoard:
:
getSortorder
)).
collect
(
Collectors
.
toList
());
if
(!
exhibitionBoardList
.
isEmpty
())
{
learningContent
.
setExhibitionBoardIdList
(
exhibitionBoardList
.
stream
().
map
(
ExhibitionBoard:
:
getId
).
collect
(
Collectors
.
toList
()));
learningContent
.
setExhibitionBoardNameList
(
exhibitionBoardList
.
stream
().
map
(
ExhibitionBoard:
:
getName
).
collect
(
Collectors
.
toList
()));
...
...
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