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 org.springframework.stereotype.Service;
import com.yiqi.core.mapper.ClothTypeMapper;
import com.yiqi.core.domain.ClothType;
import com.yiqi.core.service.IClothTypeService;

/**
 * 衣服种类Service业务层处理
 *
 * @author ruoyi
 * @date 2023-08-03
 */
@Service
public class ClothTypeServiceImpl extends ServiceImpl<ClothTypeMapper, ClothType> implements IClothTypeService {

    /**
     * 查询衣服种类
     *
     * @param id 衣服种类主键
     * @return 衣服种类
     */
    @Override
    public ClothType selectClothTypeById(Long id) {
        return baseMapper.selectClothTypeById(id);
    }

    /**
     * 查询衣服种类列表
     *
     * @param clothType 衣服种类
     * @return 衣服种类
     */
    @Override
    public List<ClothType> selectClothTypeList(ClothType clothType) {
        return baseMapper.selectClothTypeList(clothType);
    }

    /**
     * 新增衣服种类
     *
     * @param clothType 衣服种类
     * @return 结果
     */
    @Override
    public int insertClothType(ClothType clothType) {
        clothType.setCreateTime(DateUtils.getNowDate());
        clothType.setCreateBy(SecurityUtils.getUsername());
        clothType.setCreateById(SecurityUtils.getUserId());
        clothType.setDelFlag(UserStatus.OK.getCode());
        clothType.setStatus(UserStatus.OK.getCode());
        return baseMapper.insertClothType(clothType);
    }

    /**
     * 修改衣服种类
     *
     * @param clothType 衣服种类
     * @return 结果
     */
    @Override
    public int updateClothType(ClothType clothType) {
        clothType.setUpdateTime(DateUtils.getNowDate());
        clothType.setUpdateBy(SecurityUtils.getUsername());
        clothType.setUpdateById(SecurityUtils.getUserId());
        return baseMapper.updateClothType(clothType);
    }

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

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

    @Override
    public int updateTypeStatus(ClothType clothType) {
        clothType.setUpdateTime(DateUtils.getNowDate());
        clothType.setUpdateBy(SecurityUtils.getUsername());
        clothType.setUpdateById(SecurityUtils.getUserId());
        return baseMapper.updateClothType(clothType);
    }
}
