package com.yiqi.core.service.impl;

import java.util.List;
import com.yiqi.common.utils.DateUtils;
import com.yiqi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yiqi.core.mapper.ClothCraftMapper;
import com.yiqi.core.domain.ClothCraft;
import com.yiqi.core.service.IClothCraftService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 衣服工艺Service业务层处理
 *
 * @author xiaohei
 * @date 2023-08-20
 */
@Service
public class ClothCraftServiceImpl extends ServiceImpl<ClothCraftMapper,ClothCraft> implements IClothCraftService {

    /**
     * 查询衣服工艺
     *
     * @param id 衣服工艺主键
     * @return 衣服工艺
     */
    @Override
    public ClothCraft selectClothCraftById(Long id) {
        return baseMapper.selectClothCraftById(id);
    }

    /**
     * 查询衣服工艺列表
     *
     * @param clothCraft 衣服工艺
     * @return 衣服工艺
     */
    @Override
    public List<ClothCraft> selectClothCraftList(ClothCraft clothCraft) {
        return baseMapper.selectClothCraftList(clothCraft);
    }

    /**
     * 新增衣服工艺
     *
     * @param clothCraft 衣服工艺
     * @return 结果
     */
    @Override
    public int insertClothCraft(ClothCraft clothCraft) {
        clothCraft.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insertClothCraft(clothCraft);
    }

    /**
     * 修改衣服工艺
     *
     * @param clothCraft 衣服工艺
     * @return 结果
     */
    @Override
    public int updateClothCraft(ClothCraft clothCraft) {
        clothCraft.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateClothCraft(clothCraft);
    }

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

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

    /**
     * 修改衣服工艺状态
     *
     * @param clothCraft 衣服工艺
     * @return 结果
     */
    @Override
    public int updateClothCraftStatus(ClothCraft clothCraft) {
        clothCraft.setUpdateById(SecurityUtils.getUserId());
        clothCraft.setUpdateBy(SecurityUtils.getUsername());
        clothCraft.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateClothCraft(clothCraft);
    }
}
