Search in sources :

Example 1 with Picture

use of com.moxi.mogublog.commons.entity.Picture in project mogu_blog_v2 by moxi624.

the class PictureServiceImpl method addPicture.

@Override
public String addPicture(List<PictureVO> pictureVOList) {
    List<Picture> pictureList = new ArrayList<>();
    if (pictureVOList.size() > 0) {
        for (PictureVO pictureVO : pictureVOList) {
            Picture picture = new Picture();
            picture.setFileUid(pictureVO.getFileUid());
            picture.setPictureSortUid(pictureVO.getPictureSortUid());
            picture.setPicName(pictureVO.getPicName());
            picture.setStatus(EStatus.ENABLE);
            pictureList.add(picture);
        }
        pictureService.saveBatch(pictureList);
    } else {
        return ResultUtil.errorWithMessage(MessageConf.INSERT_FAIL);
    }
    return ResultUtil.successWithMessage(MessageConf.INSERT_SUCCESS);
}
Also used : Picture(com.moxi.mogublog.commons.entity.Picture) PictureVO(com.moxi.mogublog.xo.vo.PictureVO)

Example 2 with Picture

use of com.moxi.mogublog.commons.entity.Picture in project mogu_blog_v2 by moxi624.

the class PictureServiceImpl method getTopOne.

@Override
public Picture getTopOne() {
    QueryWrapper<Picture> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.orderByAsc(SQLConf.CREATE_TIME);
    queryWrapper.last(SysConf.LIMIT_ONE);
    Picture picture = pictureService.getOne(queryWrapper);
    return picture;
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Picture(com.moxi.mogublog.commons.entity.Picture)

Example 3 with Picture

use of com.moxi.mogublog.commons.entity.Picture 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);
}
Also used : PictureSort(com.moxi.mogublog.commons.entity.PictureSort) Picture(com.moxi.mogublog.commons.entity.Picture)

Example 4 with Picture

use of com.moxi.mogublog.commons.entity.Picture in project mogu_blog_v2 by moxi624.

the class PictureServiceImpl method deleteBatchPicture.

@Override
public String deleteBatchPicture(PictureVO pictureVO) {
    // 参数校验
    // 图片删除的时候,是携带多个id拼接而成的
    String uidStr = pictureVO.getUid();
    if (StringUtils.isEmpty(uidStr)) {
        return ResultUtil.errorWithMessage(MessageConf.PARAM_INCORRECT);
    }
    List<String> uids = StringUtils.changeStringToString(pictureVO.getUid(), SysConf.FILE_SEGMENTATION);
    for (String item : uids) {
        Picture picture = pictureService.getById(item);
        picture.setStatus(EStatus.DISABLED);
        picture.setUpdateTime(new Date());
        picture.updateById();
    }
    return ResultUtil.successWithMessage(MessageConf.DELETE_SUCCESS);
}
Also used : Picture(com.moxi.mogublog.commons.entity.Picture)

Example 5 with Picture

use of com.moxi.mogublog.commons.entity.Picture in project mogu_blog_v2 by moxi624.

the class PictureServiceImpl method editPicture.

@Override
public String editPicture(PictureVO pictureVO) {
    Picture picture = pictureService.getById(pictureVO.getUid());
    // 这里需要更新所有的博客,将图片替换成 裁剪的图片
    QueryWrapper<Blog> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
    queryWrapper.eq(SQLConf.FILE_UID, picture.getFileUid());
    List<Blog> blogList = blogService.list(queryWrapper);
    if (blogList.size() > 0) {
        blogList.forEach(item -> {
            item.setFileUid(pictureVO.getFileUid());
        });
        blogService.updateBatchById(blogList);
        Map<String, Object> map = new HashMap<>();
        map.put(SysConf.COMMAND, SysConf.EDIT_BATCH);
        // 发送到RabbitMq
        rabbitTemplate.convertAndSend(SysConf.EXCHANGE_DIRECT, SysConf.MOGU_BLOG, map);
    }
    picture.setFileUid(pictureVO.getFileUid());
    picture.setPicName(pictureVO.getPicName());
    picture.setPictureSortUid(pictureVO.getPictureSortUid());
    picture.setUpdateTime(new Date());
    picture.updateById();
    return ResultUtil.successWithMessage(MessageConf.UPDATE_SUCCESS);
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Picture(com.moxi.mogublog.commons.entity.Picture) Blog(com.moxi.mogublog.commons.entity.Blog)

Aggregations

Picture (com.moxi.mogublog.commons.entity.Picture)7 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)4 PictureSort (com.moxi.mogublog.commons.entity.PictureSort)2 IPage (com.baomidou.mybatisplus.core.metadata.IPage)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 Blog (com.moxi.mogublog.commons.entity.Blog)1 PictureVO (com.moxi.mogublog.xo.vo.PictureVO)1