|
@@ -1,31 +1,38 @@
|
|
|
-package com.ylx.massage.service.impl;
|
|
|
|
|
|
|
+package com.ylx.banner.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.ylx.banner.domain.vo.BannerVO;
|
|
|
import com.ylx.common.exception.ServiceException;
|
|
import com.ylx.common.exception.ServiceException;
|
|
|
import com.ylx.common.utils.uuid.IdUtils;
|
|
import com.ylx.common.utils.uuid.IdUtils;
|
|
|
-import com.ylx.massage.domain.TLbt;
|
|
|
|
|
|
|
+import com.ylx.banner.domain.Banner;
|
|
|
|
|
+import com.ylx.giftCard.domain.GiftCard;
|
|
|
|
|
+import com.ylx.giftCard.domain.vo.GiftCardVO;
|
|
|
import com.ylx.massage.domain.dto.TLbtStatusDTO;
|
|
import com.ylx.massage.domain.dto.TLbtStatusDTO;
|
|
|
-import com.ylx.massage.mapper.TLbtMapper;
|
|
|
|
|
-import com.ylx.massage.service.TLbtService;
|
|
|
|
|
|
|
+import com.ylx.banner.mapper.BannerMapper;
|
|
|
|
|
+import com.ylx.banner.service.BannerService;
|
|
|
import com.ylx.common.utils.DateUtils;
|
|
import com.ylx.common.utils.DateUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 轮播图 服务实现类
|
|
* 轮播图 服务实现类
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
-public class TLbtServiceImpl extends ServiceImpl<TLbtMapper, TLbt> implements TLbtService {
|
|
|
|
|
|
|
+public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements BannerService {
|
|
|
private static final int STATUS_HIDE = 0;
|
|
private static final int STATUS_HIDE = 0;
|
|
|
private static final int STATUS_SHOW = 1;
|
|
private static final int STATUS_SHOW = 1;
|
|
|
private static final long MAX_SHOW_COUNT = 5L;
|
|
private static final long MAX_SHOW_COUNT = 5L;
|
|
|
private static final long MIN_SHOW_COUNT = 1L;
|
|
private static final long MIN_SHOW_COUNT = 1L;
|
|
|
|
|
+ private static final int NOT_DELETE = 0;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Boolean addOrUpdate(TLbt lbt) {
|
|
|
|
|
|
|
+ public Boolean addOrUpdate(Banner lbt) {
|
|
|
if (StringUtils.isBlank(lbt.getImgUrl())) {
|
|
if (StringUtils.isBlank(lbt.getImgUrl())) {
|
|
|
throw new ServiceException("图片不能为空");
|
|
throw new ServiceException("图片不能为空");
|
|
|
}
|
|
}
|
|
@@ -33,8 +40,8 @@ public class TLbtServiceImpl extends ServiceImpl<TLbtMapper, TLbt> implements TL
|
|
|
throw new ServiceException("序号不能为空");
|
|
throw new ServiceException("序号不能为空");
|
|
|
}
|
|
}
|
|
|
Integer i = lbt.getSort();
|
|
Integer i = lbt.getSort();
|
|
|
- LambdaQueryWrapper<TLbt> query = new LambdaQueryWrapper<TLbt>().eq(TLbt::getSort, i);
|
|
|
|
|
- TLbt one = getOne(query);
|
|
|
|
|
|
|
+ LambdaQueryWrapper<Banner> query = new LambdaQueryWrapper<Banner>().eq(Banner::getSort, i);
|
|
|
|
|
+ Banner one = getOne(query);
|
|
|
if (StringUtils.isBlank(lbt.getId())) {
|
|
if (StringUtils.isBlank(lbt.getId())) {
|
|
|
//新增
|
|
//新增
|
|
|
lbt.setId(IdUtils.simpleUUID());
|
|
lbt.setId(IdUtils.simpleUUID());
|
|
@@ -43,7 +50,7 @@ public class TLbtServiceImpl extends ServiceImpl<TLbtMapper, TLbt> implements TL
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
//修改
|
|
//修改
|
|
|
- query.ne(TLbt::getId, lbt.getId());
|
|
|
|
|
|
|
+ query.ne(Banner::getId, lbt.getId());
|
|
|
if (getOne(query) != null) {
|
|
if (getOne(query) != null) {
|
|
|
batchLbt(i);
|
|
batchLbt(i);
|
|
|
}
|
|
}
|
|
@@ -56,22 +63,22 @@ public class TLbtServiceImpl extends ServiceImpl<TLbtMapper, TLbt> implements TL
|
|
|
* @param i
|
|
* @param i
|
|
|
*/
|
|
*/
|
|
|
private void batchLbt(Integer i) {
|
|
private void batchLbt(Integer i) {
|
|
|
- LambdaQueryWrapper<TLbt> query1 = new LambdaQueryWrapper<TLbt>().ge(TLbt::getSort, i);
|
|
|
|
|
- List<TLbt> lbts = list(query1);
|
|
|
|
|
|
|
+ LambdaQueryWrapper<Banner> query1 = new LambdaQueryWrapper<Banner>().ge(Banner::getSort, i);
|
|
|
|
|
+ List<Banner> lbts = list(query1);
|
|
|
lbts.forEach(tLbt1 -> tLbt1.setSort(tLbt1.getSort() + 1));
|
|
lbts.forEach(tLbt1 -> tLbt1.setSort(tLbt1.getSort() + 1));
|
|
|
updateBatchById(lbts);
|
|
updateBatchById(lbts);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Boolean del(TLbt tLbt) {
|
|
|
|
|
- if (tLbt == null) {
|
|
|
|
|
|
|
+ public Boolean del(Banner banner) {
|
|
|
|
|
+ if (banner == null) {
|
|
|
throw new ServiceException("参数不能为空");
|
|
throw new ServiceException("参数不能为空");
|
|
|
}
|
|
}
|
|
|
- if (StringUtils.isBlank(tLbt.getId())) {
|
|
|
|
|
|
|
+ if (StringUtils.isBlank(banner.getId())) {
|
|
|
throw new ServiceException("ID不能为空");
|
|
throw new ServiceException("ID不能为空");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- TLbt exists = baseMapper.selectLbtById(tLbt.getId());
|
|
|
|
|
|
|
+ Banner exists = baseMapper.selectLbtById(banner.getId());
|
|
|
if (exists == null) {
|
|
if (exists == null) {
|
|
|
throw new ServiceException("轮播图不存在");
|
|
throw new ServiceException("轮播图不存在");
|
|
|
}
|
|
}
|
|
@@ -79,7 +86,7 @@ public class TLbtServiceImpl extends ServiceImpl<TLbtMapper, TLbt> implements TL
|
|
|
throw new ServiceException("当前banner已显示,不可删除!");
|
|
throw new ServiceException("当前banner已显示,不可删除!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- boolean removed = this.removeById(tLbt.getId());
|
|
|
|
|
|
|
+ boolean removed = this.removeById(banner.getId());
|
|
|
if (!removed) {
|
|
if (!removed) {
|
|
|
throw new ServiceException("轮播图删除失败");
|
|
throw new ServiceException("轮播图删除失败");
|
|
|
}
|
|
}
|
|
@@ -98,7 +105,7 @@ public class TLbtServiceImpl extends ServiceImpl<TLbtMapper, TLbt> implements TL
|
|
|
throw new ServiceException("显示状态值不正确");
|
|
throw new ServiceException("显示状态值不正确");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- TLbt exists = baseMapper.selectLbtById(dto.getId());
|
|
|
|
|
|
|
+ Banner exists = baseMapper.selectLbtById(dto.getId());
|
|
|
if (exists == null) {
|
|
if (exists == null) {
|
|
|
throw new ServiceException("轮播图不存在");
|
|
throw new ServiceException("轮播图不存在");
|
|
|
}
|
|
}
|
|
@@ -114,7 +121,7 @@ public class TLbtServiceImpl extends ServiceImpl<TLbtMapper, TLbt> implements TL
|
|
|
throw new ServiceException("当前banner已是最后一条显示,不可关闭!");
|
|
throw new ServiceException("当前banner已是最后一条显示,不可关闭!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- TLbt update = new TLbt();
|
|
|
|
|
|
|
+ Banner update = new Banner();
|
|
|
update.setId(dto.getId());
|
|
update.setId(dto.getId());
|
|
|
update.setStatus(dto.getStatus());
|
|
update.setStatus(dto.getStatus());
|
|
|
update.setUpdateTime(DateUtils.getNowDate());
|
|
update.setUpdateTime(DateUtils.getNowDate());
|
|
@@ -124,4 +131,29 @@ public class TLbtServiceImpl extends ServiceImpl<TLbtMapper, TLbt> implements TL
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Page<BannerVO> page(Page<Banner> page) {
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<Banner> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(Banner::getIsDelete, NOT_DELETE);
|
|
|
|
|
+ wrapper.eq(Banner::getStatus, STATUS_SHOW);
|
|
|
|
|
+ wrapper.orderByDesc(Banner::getSort);
|
|
|
|
|
+
|
|
|
|
|
+ Page<Banner> bannerPage = this.baseMapper.selectPage(page, wrapper);
|
|
|
|
|
+ Page<BannerVO> pageData = new Page<>(
|
|
|
|
|
+ bannerPage.getCurrent(),
|
|
|
|
|
+ bannerPage.getSize(),
|
|
|
|
|
+ bannerPage.getTotal()
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ if (CollectionUtil.isNotEmpty(bannerPage.getRecords())) {
|
|
|
|
|
+ List<BannerVO> voList = bannerPage.getRecords().stream()
|
|
|
|
|
+ .map(BannerVO::new)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ pageData.setRecords(voList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return pageData;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|