Search in sources :

Example 1 with TbImage

use of cn.exrick.manager.pojo.TbImage in project xmall by Exrick.

the class ContentImageServiceImpl method getContentImage.

@Override
public DataTablesResult getContentImage() {
    DataTablesResult result = new DataTablesResult();
    List<ImageDto> list = new ArrayList<>();
    TbImageExample example = new TbImageExample();
    List<TbImage> listImage = tbImageMapper.selectByExample(example);
    for (int i = 0; i < listImage.size(); i++) {
        ImageDto imageDto = DtoUtil.TbImage2ImageDto(listImage.get(i));
        TbContentCategory tbContentCategory = tbContentCategoryMapper.selectByPrimaryKey(Long.valueOf(listImage.get(i).getCategoryId()));
        imageDto.setCategory(tbContentCategory.getName());
        list.add(imageDto);
    }
    result.setData(list);
    return result;
}
Also used : TbImage(cn.exrick.manager.pojo.TbImage) TbContentCategory(cn.exrick.manager.pojo.TbContentCategory) DataTablesResult(cn.exrick.common.pojo.DataTablesResult) ArrayList(java.util.ArrayList) ImageDto(cn.exrick.manager.dto.ImageDto) TbImageExample(cn.exrick.manager.pojo.TbImageExample)

Example 2 with TbImage

use of cn.exrick.manager.pojo.TbImage in project xmall by Exrick.

the class ContentImageServiceImpl method updateContentImage.

@Override
public int updateContentImage(TbImage tbImage) {
    TbImage old = getContentImageById(Long.valueOf(tbImage.getId()));
    if (tbImage.getImage().isEmpty()) {
        tbImage.setImage(old.getImage());
    }
    tbImage.setUpdated(new Date());
    tbImage.setImageMobile(old.getImageMobile());
    tbImage.setCreated(old.getCreated());
    if (tbImageMapper.updateByPrimaryKey(tbImage) != 1) {
        throw new XmallException("更新图片失败");
    }
    // 同步缓存
    deleteHomeRedis();
    return 1;
}
Also used : TbImage(cn.exrick.manager.pojo.TbImage) XmallException(cn.exrick.common.exception.XmallException) Date(java.util.Date)

Aggregations

TbImage (cn.exrick.manager.pojo.TbImage)2 XmallException (cn.exrick.common.exception.XmallException)1 DataTablesResult (cn.exrick.common.pojo.DataTablesResult)1 ImageDto (cn.exrick.manager.dto.ImageDto)1 TbContentCategory (cn.exrick.manager.pojo.TbContentCategory)1 TbImageExample (cn.exrick.manager.pojo.TbImageExample)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1