Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
education
Project
Project
Details
Activity
Releases
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
李丛阳
education
Commits
a91d1853
Commit
a91d1853
authored
Sep 27, 2019
by
jiangpengpeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
banner排序
parent
b619ecb8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
24 deletions
+72
-24
BBannerController.java
...cisoft/business/bbanner/controller/BBannerController.java
+21
-12
BBannerRepository.java
...a/org/rcisoft/business/bbanner/dao/BBannerRepository.java
+9
-0
BBannerService.java
.../org/rcisoft/business/bbanner/service/BBannerService.java
+14
-0
BBannerServiceImpl.java
...oft/business/bbanner/service/impl/BBannerServiceImpl.java
+28
-12
No files found.
src/main/java/org/rcisoft/business/bbanner/controller/BBannerController.java
View file @
a91d1853
...
...
@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiImplicitParam;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.ibatis.annotations.Param
;
import
org.rcisoft.business.bbanner.dto.AddOrUpdateDTO
;
import
org.rcisoft.business.bbanner.dto.FindBannerPaginDTO
;
import
org.rcisoft.business.bbanner.dto.TopDownDTO
;
...
...
@@ -40,7 +41,7 @@ public class BBannerController extends PaginationController<BBanner> {
@Autowired
private
BBannerService
bBannerService
;
@ApiOperation
(
value
=
"101 添加/编辑Banner"
,
notes
=
"businessId为空时是添加方法,不为空时是修改方法"
)
@ApiOperation
(
value
=
"101 添加/编辑Banner"
,
notes
=
"businessId为空时是添加方法,不为空时是修改方法"
)
@PostMapping
(
value
=
"/add"
)
public
Result
add
(
CurUser
curUser
,
@Valid
AddOrUpdateDTO
addOrUpdateDTO
,
BindingResult
bindingResult
)
{
PersistModel
data
=
bBannerService
.
persist
(
addOrUpdateDTO
);
...
...
@@ -51,7 +52,7 @@ public class BBannerController extends PaginationController<BBanner> {
}
@ApiOperation
(
value
=
"102 删除Banner"
,
notes
=
"根据ID删除一条记录"
)
@ApiOperation
(
value
=
"102 删除Banner"
,
notes
=
"根据ID删除一条记录"
)
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"主键id"
,
required
=
true
,
dataType
=
"varchar"
)
@PostMapping
(
value
=
"/remove"
)
public
Result
remove
(
CurUser
curUser
,
String
businessId
,
BindingResult
bindingResult
)
{
...
...
@@ -63,10 +64,10 @@ public class BBannerController extends PaginationController<BBanner> {
}
@ApiOperation
(
value
=
"103 唯一查找"
,
notes
=
"根据ID查找一条记录"
)
@ApiOperation
(
value
=
"103 唯一查找"
,
notes
=
"根据ID查找一条记录"
)
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"主键id"
,
required
=
true
,
dataType
=
"varchar"
)
@GetMapping
(
value
=
"/one"
)
public
Result
queryOne
(
CurUser
curUser
,
String
businessId
,
BindingResult
bindingResult
)
{
public
Result
queryOne
(
CurUser
curUser
,
String
businessId
,
BindingResult
bindingResult
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
...
...
@@ -74,18 +75,18 @@ public class BBannerController extends PaginationController<BBanner> {
}
@ApiOperation
(
value
=
"104 分页获取banner"
,
notes
=
"根据条件分页查询"
)
@ApiOperation
(
value
=
"104 分页获取banner"
,
notes
=
"根据条件分页查询"
)
@GetMapping
(
value
=
"/queryBBannerByPagination"
)
public
Result
queryBBannerByPagination
(
CurUser
curUser
,
@Valid
FindBannerPaginDTO
param
,
BindingResult
bindingResult
)
{
bBannerService
.
queryBannerByPagination
(
getPaginationUtility
(),
param
);
bBannerService
.
queryBannerByPagination
(
getPaginationUtility
(),
param
);
GridModel
gridModel
=
getGridModelResponse
();
return
Result
.
builder
(
new
PersistModel
(
1
),
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
gridModel
);
}
/*
@ApiOperation(value="105 Banner向上调顺序", notes="Banner向上调顺序")
@PostMapping(value = "/updateTopBanner")
public Result updateTopBanner(CurUser curUser, @Valid TopDownDTO topDownDTO, BindingResult bindingResult){
...
...
@@ -94,10 +95,9 @@ public class BBannerController extends PaginationController<BBanner> {
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
topDownDTO);
}
}
*/
@ApiOperation
(
value
=
"106 Banner向下调顺序"
,
notes
=
"Banner向下调顺序"
)
/*@ApiOperation(value="106 Banner向下调顺序", notes="Banner向下调顺序")
@PostMapping(value = "/updateDownBanner")
public Result updateDownBanner( CurUser curUser, @Valid TopDownDTO topDownDTO, BindingResult bindingResult){
int data = bBannerService.updateDownChapter(topDownDTO);
...
...
@@ -105,6 +105,15 @@ public class BBannerController extends PaginationController<BBanner> {
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
topDownDTO);
}
}
*/
@ApiOperation
(
value
=
"107 Banner重新排序"
,
notes
=
"Banner重新排序"
)
@PostMapping
(
value
=
"/updateBannerOrder"
)
public
Result
updateBannerOrder
(
CurUser
curUser
,
@Param
(
"bannerOrderMap"
)
String
bannerOrderMap
,
BindingResult
bindingResult
){
int
data
=
bBannerService
.
updateBannerOrder
(
bannerOrderMap
);
return
Result
.
builder
(
new
PersistModel
(
data
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
bannerOrderMap
);
}
}
src/main/java/org/rcisoft/business/bbanner/dao/BBannerRepository.java
View file @
a91d1853
...
...
@@ -105,4 +105,13 @@ public interface BBannerRepository extends BaseMapper<BBanner> {
"ORDER BY banner_sort desc LIMIT 1</script>"
)
@ResultMap
(
value
=
"BaseResultMap"
)
BBanner
getlessChapter
(
TopDownDTO
param
);
//重新排序
@Update
(
"<script> <foreach collection=\"bannerOrderMap.entrySet()\" index=\"key\" item=\"value\" separator=\";\">"
+
"update b_banner "
+
"set banner_sort = #{value}"
+
"WHERE business_id = #{key}"
+
"</foreach></script>"
)
int
updateBannerOrderByid
(
@Param
(
"bannerOrderMap"
)
Map
<
String
,
Object
>
bannerOrderMap
);
}
src/main/java/org/rcisoft/business/bbanner/service/BBannerService.java
View file @
a91d1853
package
org
.
rcisoft
.
business
.
bbanner
.
service
;
import
org.rcisoft.business.bbanner.dto.AddOrUpdateDTO
;
import
org.rcisoft.business.bbanner.dto.BannerInfoRspDTO
;
import
org.rcisoft.business.bbanner.dto.FindBannerPaginDTO
;
...
...
@@ -57,4 +60,15 @@ public interface BBannerService {
* @return
*/
int
updateDownChapter
(
TopDownDTO
topDownDTO
);
/**
* @author: jiangpengpeng
* @description: TODO
* @date: 2019/9/26 16:25
* @param bannerOrderMap
* @return
*/
int
updateBannerOrder
(
String
bannerOrderMap
);
}
src/main/java/org/rcisoft/business/bbanner/service/impl/BBannerServiceImpl.java
View file @
a91d1853
package
org
.
rcisoft
.
business
.
bbanner
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
org.apache.commons.lang3.StringUtils
;
import
org.rcisoft.business.bbanner.dto.AddOrUpdateDTO
;
import
org.rcisoft.business.bbanner.dto.BannerInfoRspDTO
;
...
...
@@ -19,6 +20,7 @@ import org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -37,7 +39,7 @@ public class BBannerServiceImpl implements BBannerService {
public
PersistModel
persist
(
AddOrUpdateDTO
addOrUpdateDTO
)
{
BBanner
model
=
new
BBanner
();
BeanUtils
.
copyProperties
(
addOrUpdateDTO
,
model
);
BeanUtils
.
copyProperties
(
addOrUpdateDTO
,
model
);
int
line
=
0
;
//外部链接但外部URL为空或长度为0 抛异常
...
...
@@ -47,7 +49,7 @@ public class BBannerServiceImpl implements BBannerService {
if
(
"0"
.
equals
(
model
.
getIsExternalLink
())
&&
(
StringUtils
.
isEmpty
(
model
.
getLineType
())
||
StringUtils
.
isEmpty
(
model
.
getCourseId
())))
throw
new
ServiceException
(
"必填项未填写"
);
if
(
model
.
getBusinessId
()
!=
null
)
{
if
(
bBannerRepository
.
selectCountById
(
model
.
getBusinessId
())
==
0
){
if
(
bBannerRepository
.
selectCountById
(
model
.
getBusinessId
())
==
0
)
{
throw
new
ServiceException
(
"该数据不存在"
);
}
UserUtil
.
setCurrentMergeOperation
(
model
);
...
...
@@ -64,11 +66,11 @@ public class BBannerServiceImpl implements BBannerService {
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
readOnly
=
false
)
@Override
public
PersistModel
removeBanner
(
String
id
)
{
if
(
bBannerRepository
.
selectCountById
(
id
)
==
0
){
if
(
bBannerRepository
.
selectCountById
(
id
)
==
0
)
{
throw
new
ServiceException
(
"该数据不存在"
);
}
return
new
PersistModel
(
1
,
bBannerRepository
.
deleteBanner
(
id
));
return
new
PersistModel
(
1
,
bBannerRepository
.
deleteBanner
(
id
));
}
@Override
...
...
@@ -84,35 +86,49 @@ public class BBannerServiceImpl implements BBannerService {
return
bBannerRepository
.
queryBanners
(
model
);
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
readOnly
=
false
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
readOnly
=
false
)
@Override
public
int
updateTopChapter
(
TopDownDTO
topDownDTO
)
{
int
result
=
0
;
BBanner
lessBanner
=
bBannerRepository
.
getlessChapter
(
topDownDTO
);
int
sort
=
topDownDTO
.
getBannerSort
();
int
lessSort
=
lessBanner
.
getBannerSort
();
int
data
=
bBannerRepository
.
updateSortById
(
topDownDTO
.
getBusinessId
(),
lessSort
);
int
data2
=
bBannerRepository
.
updateSortById
(
lessBanner
.
getBusinessId
(),
sort
);
if
(
data
==
data2
)
{
int
data
=
bBannerRepository
.
updateSortById
(
topDownDTO
.
getBusinessId
(),
lessSort
);
int
data2
=
bBannerRepository
.
updateSortById
(
lessBanner
.
getBusinessId
(),
sort
);
if
(
data
==
data2
)
{
result
=
1
;
}
return
result
;
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
readOnly
=
false
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
readOnly
=
false
)
@Override
public
int
updateDownChapter
(
TopDownDTO
topDownDTO
)
{
int
result
=
0
;
BBanner
bigBanner
=
bBannerRepository
.
getBigChapter
(
topDownDTO
);
int
sort
=
topDownDTO
.
getBannerSort
();
int
bigSort
=
bigBanner
.
getBannerSort
();
int
data
=
bBannerRepository
.
updateSortById
(
topDownDTO
.
getBusinessId
(),
bigSort
);
int
data2
=
bBannerRepository
.
updateSortById
(
bigBanner
.
getBusinessId
(),
sort
);
if
(
data
==
data2
)
{
int
data
=
bBannerRepository
.
updateSortById
(
topDownDTO
.
getBusinessId
(),
bigSort
);
int
data2
=
bBannerRepository
.
updateSortById
(
bigBanner
.
getBusinessId
(),
sort
);
if
(
data
==
data2
)
{
result
=
1
;
}
return
result
;
}
/**
* @param bannerOrderMap
* @return
* @author: jiangpengpeng
* @description: 更新banner顺序
* @date: 2019/9/26 16:27
*/
@Override
public
int
updateBannerOrder
(
String
bannerOrderMap
)
{
//获取将字符串中的主键和位置对应关系转成Map
Map
parse
=
(
Map
)
JSON
.
parse
(
bannerOrderMap
);
int
i
=
bBannerRepository
.
updateBannerOrderByid
(
parse
);
return
i
;
}
}
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