package com.younike.system.service.impl;

import com.younike.system.domain.CateDimension;
import com.younike.system.domain.vo.CateDimensionVo;
import com.younike.system.mapper.CateDimensionMapper;
import com.younike.system.service.ICateDimensionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 分类维度Service业务层处理
 * 
 * @author elev
 * @date 2022-01-04
 */
@Service
public class CateDimensionServiceImpl implements ICateDimensionService {
    @Autowired
    private CateDimensionMapper cateDimensionMapper;

    /**
     * 查询分类维度
     * 
     * @param id 分类维度主键
     * @return 分类维度
     */
    @Override
    public CateDimension selectCateDimensionById(Long id) {
        return cateDimensionMapper.selectCateDimensionById(id);
    }

    /**
     * 查询分类维度列表
     * 
     * @param cateDimension 分类维度
     * @return 分类维度
     */
    @Override
    public List<CateDimension> selectCateDimensionList(CateDimension cateDimension) {
        return cateDimensionMapper.selectCateDimensionList(cateDimension);
    }

    /**
     * 新增分类维度
     * 
     * @param cateDimension 分类维度
     * @return 结果
     */
    @Override
    public int insertCateDimension(CateDimension cateDimension) {
        cateDimension.setCreateTime(LocalDateTime.now());
        return cateDimensionMapper.insertCateDimension(cateDimension);
    }

    /**
     * 修改分类维度
     * 
     * @param cateDimension 分类维度
     * @return 结果
     */
    @Override
    public int updateCateDimension(CateDimension cateDimension) {
        cateDimension.setUpdateTime(LocalDateTime.now());
        return cateDimensionMapper.updateCateDimension(cateDimension);
    }

    /**
     * 批量删除分类维度
     * 
     * @param ids 需要删除的分类维度主键
     * @return 结果
     */
    @Override
    public int deleteCateDimensionByIds(Long[] ids) {
        return cateDimensionMapper.deleteCateDimensionByIds(ids);
    }

    /**
     * 删除分类维度信息
     * 
     * @param id 分类维度主键
     * @return 结果
     */
    @Override
    public int deleteCateDimensionById(Long id)
    {
        return cateDimensionMapper.deleteCateDimensionById(id);
    }

    /**
     * 通过分类id查询分类维度列表
     *
     * @param categoryId
     * @return
     */
    @Override
    public List<CateDimensionVo> listByCategoryId(Long categoryId) {
        // 查询分类维度列表
        return cateDimensionMapper.listByCategoryId(categoryId);
    }
}
