package com.yiqi.core.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yiqi.common.enums.UserStatus;
import com.yiqi.common.utils.DateUtils;
import com.yiqi.common.utils.SecurityUtils;
import com.yiqi.core.domain.ClothColor;
import com.yiqi.core.mapper.ClothColorMapper;
import com.yiqi.core.service.IClothColorService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 衣服颜色Service业务层处理
 *
 * @author ruoyi
 * @date 2023-08-03
 */
@Service
public class ClothColorServiceImpl extends ServiceImpl<ClothColorMapper, ClothColor> implements IClothColorService {


    /**
     * 查询衣服颜色
     *
     * @param id 衣服颜色主键
     * @return 衣服颜色
     */
    @Override
    public ClothColor selectClothColorById(Long id) {
        return baseMapper.selectClothColorById(id);
    }

    /**
     * 查询衣服颜色列表
     *
     * @param clothColor 衣服颜色
     * @return 衣服颜色
     */
    @Override
    public List<ClothColor> selectClothColorList(ClothColor clothColor) {
        return baseMapper.selectClothColorList(clothColor);
    }

    /**
     * 新增衣服颜色
     *
     * @param clothColor 衣服颜色
     * @return 结果
     */
    @Override
    public int insertClothColor(ClothColor clothColor) {
        clothColor.setCreateTime(DateUtils.getNowDate());
        clothColor.setCreateBy(SecurityUtils.getUsername());
        clothColor.setCreateById(SecurityUtils.getUserId());
        clothColor.setDelFlag(UserStatus.OK.getCode());
        clothColor.setStatus(UserStatus.OK.getCode());
        return baseMapper.insertClothColor(clothColor);
    }

    /**
     * 修改衣服颜色
     *
     * @param clothColor 衣服颜色
     * @return 结果
     */
    @Override
    public int updateClothColor(ClothColor clothColor) {
        clothColor.setUpdateTime(DateUtils.getNowDate());
        clothColor.setUpdateBy(SecurityUtils.getUsername());
        clothColor.setUpdateById(SecurityUtils.getUserId());
        return baseMapper.updateClothColor(clothColor);
    }

    /**
     * 批量删除衣服颜色
     *
     * @param ids 需要删除的衣服颜色主键
     * @return 结果
     */
    @Override
    public int deleteClothColorByIds(Long[] ids) {
        return baseMapper.deleteClothColorByIds(ids);
    }

    /**
     * 删除衣服颜色信息
     *
     * @param id 衣服颜色主键
     * @return 结果
     */
    @Override
    public int deleteClothColorById(Long id) {
        return baseMapper.deleteClothColorById(id);
    }

    @Override
    public int updateColorStatus(ClothColor clothColor) {
        clothColor.setUpdateTime(DateUtils.getNowDate());
        clothColor.setUpdateBy(SecurityUtils.getUsername());
        clothColor.setUpdateById(SecurityUtils.getUserId());
        return baseMapper.updateById(clothColor);
    }
}
