Search in sources :

Example 1 with TbContentCategory

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

the class ContentCatServiceImpl method addContentCat.

@Override
public int addContentCat(ContentCatDto contentCatDto) {
    TbContentCategory tbContentCategory = DtoUtil.ContentCatDto2TbContentCategory(contentCatDto);
    tbContentCategory.setParentId((long) 0);
    tbContentCategory.setCreated(new Date());
    tbContentCategory.setUpdated(new Date());
    if (tbContentCategoryMapper.insert(tbContentCategory) != 1) {
        throw new XmallException("添加内容分类失败");
    }
    // 同步缓存
    deleteHomeRedis();
    return 1;
}
Also used : TbContentCategory(cn.exrick.manager.pojo.TbContentCategory) XmallException(cn.exrick.common.exception.XmallException) Date(java.util.Date)

Example 2 with TbContentCategory

use of cn.exrick.manager.pojo.TbContentCategory 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 3 with TbContentCategory

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

the class ContentCatServiceImpl method getContentCatList.

@Override
public List<ZTreeNode> getContentCatList(Long parentId) {
    TbContentCategoryExample example = new TbContentCategoryExample();
    TbContentCategoryExample.Criteria criteria = example.createCriteria();
    criteria.andParentIdEqualTo(parentId);
    example.setOrderByClause("sort_order");
    List<TbContentCategory> catList = tbContentCategoryMapper.selectByExample(example);
    List<ZTreeNode> list = new ArrayList<>();
    for (int i = 0; i < catList.size(); i++) {
        ZTreeNode zTreeNode = DtoUtil.TbContentCategory2ZTreeNode(catList.get(i));
        list.add(zTreeNode);
    }
    return list;
}
Also used : TbContentCategoryExample(cn.exrick.manager.pojo.TbContentCategoryExample) TbContentCategory(cn.exrick.manager.pojo.TbContentCategory) ArrayList(java.util.ArrayList) ZTreeNode(cn.exrick.common.pojo.ZTreeNode)

Example 4 with TbContentCategory

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

the class ContentCatServiceImpl method updateContentCat.

@Override
public int updateContentCat(ContentCatDto contentCatDto) {
    TbContentCategory tbContentCategory = DtoUtil.ContentCatDto2TbContentCategory(contentCatDto);
    TbContentCategory old = getContentCatById(tbContentCategory.getId());
    tbContentCategory.setParentId(old.getParentId());
    tbContentCategory.setIcon(old.getIcon());
    tbContentCategory.setCreated(old.getCreated());
    tbContentCategory.setUpdated(new Date());
    if (tbContentCategoryMapper.updateByPrimaryKey(tbContentCategory) != 1) {
        throw new XmallException("更新内容分类失败");
    }
    // 同步缓存
    deleteHomeRedis();
    return 1;
}
Also used : TbContentCategory(cn.exrick.manager.pojo.TbContentCategory) XmallException(cn.exrick.common.exception.XmallException) Date(java.util.Date)

Aggregations

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