use of com.moxi.mogublog.commons.entity.PictureSort in project mogu_blog_v2 by moxi624.
the class PictureServiceImpl method setPictureCover.
@Override
public String setPictureCover(PictureVO pictureVO) {
PictureSort pictureSort = pictureSortService.getById(pictureVO.getPictureSortUid());
if (pictureSort != null) {
Picture picture = pictureService.getById(pictureVO.getUid());
if (picture != null) {
pictureSort.setFileUid(picture.getFileUid());
picture.setUpdateTime(new Date());
pictureSort.updateById();
} else {
return ResultUtil.errorWithMessage(MessageConf.THE_PICTURE_NOT_EXIST);
}
} else {
return ResultUtil.errorWithMessage(MessageConf.THE_PICTURE_SORT_NOT_EXIST);
}
return ResultUtil.successWithMessage(MessageConf.UPDATE_SUCCESS);
}
use of com.moxi.mogublog.commons.entity.PictureSort in project mogu_blog_v2 by moxi624.
the class PictureSortServiceImpl method editPictureSort.
@Override
public String editPictureSort(PictureSortVO pictureSortVO) {
PictureSort pictureSort = pictureSortService.getById(pictureSortVO.getUid());
pictureSort.setName(pictureSortVO.getName());
pictureSort.setParentUid(pictureSortVO.getParentUid());
pictureSort.setSort(pictureSortVO.getSort());
pictureSort.setFileUid(pictureSortVO.getFileUid());
pictureSort.setIsShow(pictureSortVO.getIsShow());
pictureSort.setUpdateTime(new Date());
pictureSort.updateById();
return ResultUtil.successWithMessage(MessageConf.UPDATE_SUCCESS);
}
use of com.moxi.mogublog.commons.entity.PictureSort in project mogu_blog_v2 by moxi624.
the class PictureSortServiceImpl method addPictureSort.
@Override
public String addPictureSort(PictureSortVO pictureSortVO) {
PictureSort pictureSort = new PictureSort();
pictureSort.setName(pictureSortVO.getName());
pictureSort.setParentUid(pictureSortVO.getParentUid());
pictureSort.setSort(pictureSortVO.getSort());
pictureSort.setFileUid(pictureSortVO.getFileUid());
pictureSort.setStatus(EStatus.ENABLE);
pictureSort.setIsShow(pictureSortVO.getIsShow());
pictureSort.setUpdateTime(new Date());
pictureSort.insert();
return ResultUtil.successWithMessage(MessageConf.INSERT_SUCCESS);
}
use of com.moxi.mogublog.commons.entity.PictureSort in project mogu_blog_v2 by moxi624.
the class PictureSortServiceImpl method getPageList.
@Override
public IPage<PictureSort> getPageList(PictureSortVO pictureSortVO) {
QueryWrapper<PictureSort> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotEmpty(pictureSortVO.getKeyword()) && !StringUtils.isEmpty(pictureSortVO.getKeyword().trim())) {
queryWrapper.like(SQLConf.NAME, pictureSortVO.getKeyword().trim());
}
if (pictureSortVO.getIsShow() != null) {
queryWrapper.eq(SQLConf.IS_SHOW, SysConf.ONE);
}
Page<PictureSort> page = new Page<>();
page.setCurrent(pictureSortVO.getCurrentPage());
page.setSize(pictureSortVO.getPageSize());
queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
queryWrapper.orderByDesc(SQLConf.SORT);
IPage<PictureSort> pageList = pictureSortService.page(page, queryWrapper);
List<PictureSort> list = pageList.getRecords();
final StringBuffer fileUids = new StringBuffer();
list.forEach(item -> {
if (StringUtils.isNotEmpty(item.getFileUid())) {
fileUids.append(item.getFileUid() + SysConf.FILE_SEGMENTATION);
}
});
String pictureResult = null;
Map<String, String> pictureMap = new HashMap<>();
if (fileUids != null) {
pictureResult = this.pictureFeignClient.getPicture(fileUids.toString(), SysConf.FILE_SEGMENTATION);
}
List<Map<String, Object>> picList = webUtil.getPictureMap(pictureResult);
picList.forEach(item -> {
pictureMap.put(item.get(SysConf.UID).toString(), item.get(SysConf.URL).toString());
});
for (PictureSort item : list) {
// 获取图片
if (StringUtils.isNotEmpty(item.getFileUid())) {
List<String> pictureUidsTemp = StringUtils.changeStringToString(item.getFileUid(), SysConf.FILE_SEGMENTATION);
List<String> pictureListTemp = new ArrayList<>();
pictureUidsTemp.forEach(picture -> {
pictureListTemp.add(pictureMap.get(picture));
});
item.setPhotoList(pictureListTemp);
}
}
pageList.setRecords(list);
return pageList;
}
use of com.moxi.mogublog.commons.entity.PictureSort in project mogu_blog_v2 by moxi624.
the class PictureSortServiceImpl method stickPictureSort.
@Override
public String stickPictureSort(PictureSortVO pictureSortVO) {
PictureSort pictureSort = pictureSortService.getById(pictureSortVO.getUid());
// 查找出最大的那一个
QueryWrapper<PictureSort> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc(SQLConf.SORT);
Page<PictureSort> page = new Page<>();
page.setCurrent(0);
page.setSize(1);
IPage<PictureSort> pageList = pictureSortService.page(page, queryWrapper);
List<PictureSort> list = pageList.getRecords();
PictureSort maxSort = list.get(0);
if (StringUtils.isEmpty(maxSort.getUid())) {
return ResultUtil.errorWithMessage(MessageConf.PARAM_INCORRECT);
}
if (maxSort.getUid().equals(pictureSort.getUid())) {
return ResultUtil.errorWithMessage(MessageConf.THIS_SORT_IS_TOP);
}
Integer sortCount = maxSort.getSort() + 1;
pictureSort.setSort(sortCount);
pictureSort.setUpdateTime(new Date());
pictureSort.updateById();
return ResultUtil.successWithMessage(MessageConf.OPERATION_SUCCESS);
}
Aggregations