package com.amms.service.impl;

import java.util.List;
import java.util.Date;

import com.amms.security.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.amms.mapper.ItemCollectionMapper;
import com.amms.domain.ItemCollection;
import com.amms.service.IItemCollectionService;

/**
 * 收藏Service业务层处理
 */
@Service
public class ItemCollectionServiceImpl implements IItemCollectionService {

    @Autowired
    private ItemCollectionMapper itemCollectionMapper;

    /**
     * 查询收藏列表
     *
     * @param itemCollection 收藏
     * @return 收藏
     */
    @Override
    public List<ItemCollection> selectItemCollectionList(ItemCollection itemCollection) {
        return itemCollectionMapper.selectItemCollectionList(itemCollection);
    }

    /**
     * 查询收藏
     *
     * @param id 收藏主键
     * @return 收藏
     */
    @Override
    public ItemCollection selectItemCollectionById(Long id) {
        return itemCollectionMapper.selectItemCollectionById(id);
    }

    /**
     * 新增收藏
     *
     * @param itemCollection 收藏
     * @return 结果
     */
    @Override
    public int insertItemCollection(ItemCollection itemCollection) {
        itemCollection.setUserId(SecurityUtils.getCurrentUser().getId());
        itemCollection.setCreateTime(new Date());
        return itemCollectionMapper.insertItemCollection(itemCollection);
    }

    /**
     * 修改收藏
     *
     * @param itemCollection 收藏
     * @return 结果
     */
    @Override
    public int updateItemCollection(ItemCollection itemCollection) {
        return itemCollectionMapper.updateItemCollection(itemCollection);
    }

    /**
     * 删除收藏信息
     *
     * @param id 收藏主键
     * @return 结果
     */
    @Override
    public int deleteItemCollectionById(Long id) {
        return itemCollectionMapper.deleteItemCollectionById(id);
    }

}
