package com.amms.service.impl;

import java.util.List;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.amms.mapper.ItemCategoryMapper;
import com.amms.domain.ItemCategory;
import com.amms.service.IItemCategoryService;
import com.amms.security.SecurityUtils;

/**
 * 藏品分类Service业务层处理
 */
@Service
public class ItemCategoryServiceImpl implements IItemCategoryService {

    @Autowired
    private ItemCategoryMapper itemCategoryMapper;

    /**
     * 查询藏品分类列表
     *
     * @param itemCategory 藏品分类
     * @return 藏品分类
     */
    @Override
    public List<ItemCategory> selectItemCategoryList(ItemCategory itemCategory) {
        return itemCategoryMapper.selectItemCategoryList(itemCategory);
    }

    /**
     * 查询藏品分类
     *
     * @param id 藏品分类主键
     * @return 藏品分类
     */
    @Override
    public ItemCategory selectItemCategoryById(Long id) {
        return itemCategoryMapper.selectItemCategoryById(id);
    }

    /**
     * 新增藏品分类
     *
     * @param itemCategory 藏品分类
     * @return 结果
     */
    @Override
    public int insertItemCategory(ItemCategory itemCategory) {
        itemCategory.setCreateTime(new Date());
        itemCategory.setCreator(SecurityUtils.getCurrentUser().getId());
        return itemCategoryMapper.insertItemCategory(itemCategory);
    }

    /**
     * 修改藏品分类
     *
     * @param itemCategory 藏品分类
     * @return 结果
     */
    @Override
    public int updateItemCategory(ItemCategory itemCategory) {
        itemCategory.setUpdateTime(new Date());
        itemCategory.setUpdater(SecurityUtils.getCurrentUser().getId());
        return itemCategoryMapper.updateItemCategory(itemCategory);
    }

    /**
     * 删除藏品分类信息
     *
     * @param id 藏品分类主键
     * @return 结果
     */
    @Override
    public int deleteItemCategoryById(Long id) {
        return itemCategoryMapper.deleteItemCategoryById(id);
    }

}
