package com.yiqi.core.service.impl;

import java.util.List;

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.vo.ClothHangerOrderRelationVO;
import org.springframework.stereotype.Service;
import com.yiqi.core.mapper.ClothCustomItemMapper;
import com.yiqi.core.domain.ClothCustomItem;
import com.yiqi.core.service.IClothCustomItemService;

/**
 * 自定义衣物Service业务层处理
 *
 * @author ruoyi
 * @date 2023-08-07
 */
@Service
public class ClothCustomItemServiceImpl extends ServiceImpl<ClothCustomItemMapper, ClothCustomItem> implements
        IClothCustomItemService {

    /**
     * 查询自定义衣物
     *
     * @param id 自定义衣物主键
     * @return 自定义衣物
     */
    @Override
    public ClothCustomItem selectClothItemById(Long id) {
        return baseMapper.selectClothItemById(id);
    }

    /**
     * 查询自定义衣物列表
     *
     * @param clothCustomItem 自定义衣物
     * @return 自定义衣物
     */
    @Override
    public List<ClothCustomItem> selectClothItemList(ClothCustomItem clothCustomItem) {
        return baseMapper.selectClothItemList(clothCustomItem);
    }

    /**
     * 新增自定义衣物
     *
     * @param clothCustomItem 自定义衣物
     * @return 结果
     */
    @Override
    public int insertClothItem(ClothCustomItem clothCustomItem) {
        clothCustomItem.setCreateTime(DateUtils.getNowDate());
        clothCustomItem.setCreateBy(SecurityUtils.getUsername());
        clothCustomItem.setCreateById(SecurityUtils.getUserId());
        clothCustomItem.setDelFlag(UserStatus.OK.getCode());
        clothCustomItem.setStatus(UserStatus.OK.getCode());
        return baseMapper.insertClothItem(clothCustomItem);
    }

    /**
     * 修改自定义衣物
     *
     * @param clothCustomItem 自定义衣物
     * @return 结果
     */
    @Override
    public int updateClothItem(ClothCustomItem clothCustomItem) {
        clothCustomItem.setUpdateTime(DateUtils.getNowDate());
        clothCustomItem.setUpdateBy(SecurityUtils.getUsername());
        clothCustomItem.setUpdateById(SecurityUtils.getUserId());
        return baseMapper.updateClothItem(clothCustomItem);
    }

    /**
     * 批量删除自定义衣物
     *
     * @param ids 需要删除的自定义衣物主键
     * @return 结果
     */
    @Override
    public int deleteClothItemByIds(Long[] ids) {
        return baseMapper.deleteClothItemByIds(ids);
    }

    /**
     * 删除自定义衣物信息
     *
     * @param id 自定义衣物主键
     * @return 结果
     */
    @Override
    public int deleteClothItemById(Long id) {
        return baseMapper.deleteClothItemById(id);
    }

    @Override
    public int updateItemStatus(ClothCustomItem clothCustomItem) {
        clothCustomItem.setUpdateTime(DateUtils.getNowDate());
        clothCustomItem.setUpdateBy(SecurityUtils.getUsername());
        clothCustomItem.setUpdateById(SecurityUtils.getUserId());
        return baseMapper.updateClothItem(clothCustomItem);
    }

}
