package com.zbf.system.service.impl;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zbf.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; //添加
import com.zbf.system.mapper.TUserFavoritesMapper;
import com.zbf.system.domain.TUserFavorites;
import com.zbf.system.service.ITUserFavoritesService;

/**
 * 常用功能收藏夹Service业务层处理
 *
 * @author tony
 * @date 2024-07-03
 */
@Service
public class TUserFavoritesServiceImpl extends ServiceImpl<TUserFavoritesMapper, TUserFavorites> implements ITUserFavoritesService //修改
{
    @Autowired
    private TUserFavoritesMapper tUserFavoritesMapper;

    /**
     * 查询常用功能收藏夹
     *
     * @param id 常用功能收藏夹主键
     * @return 常用功能收藏夹
     */
    @Override
    public TUserFavorites selectTUserFavoritesById(String id) {
        return tUserFavoritesMapper.selectById(id);
    }

    /**
     * 查询常用功能收藏夹列表
     *
     * @param tUserFavorites 常用功能收藏夹
     * @return 常用功能收藏夹
     */
    @Override
    public List<TUserFavorites> selectTUserFavoritesList(TUserFavorites tUserFavorites) {
        LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<TUserFavorites>(tUserFavorites);
        return tUserFavoritesMapper.selectList(queryWrapper);
    }

    /**
     * 新增常用功能收藏夹
     *
     * @param tUserFavorites 常用功能收藏夹
     * @return 结果
     */
    @Override
    public int insertTUserFavorites(TUserFavorites tUserFavorites) {
        return tUserFavoritesMapper.insert(tUserFavorites);
    }

    /**
     * 修改常用功能收藏夹
     *
     * @param tUserFavorites 常用功能收藏夹
     * @return 结果
     */
    @Override
    public int updateTUserFavorites(TUserFavorites tUserFavorites) {
        return tUserFavoritesMapper.updateById(tUserFavorites);
    }

    /**
     * 批量删除常用功能收藏夹
     *
     * @param ids 需要删除的常用功能收藏夹主键
     * @return 结果
     */
    @Override
    public int deleteTUserFavoritesByIds(String[] ids) {
        return tUserFavoritesMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除常用功能收藏夹信息
     *
     * @param id 常用功能收藏夹主键
     * @return 结果
     */
    @Override
    public int deleteTUserFavoritesById(String id) {
        return tUserFavoritesMapper.deleteById(id);
    }


    /**
     * 批量禁用
     *
     * @param ids 常用功能收藏夹主键
     * @return 结果
     */
    @Override
    public int disabledTUserFavoritesByIds(String[] ids) {
        Arrays.stream(ids).forEach(id -> {
            TUserFavorites favorites = new TUserFavorites();
            favorites.setId(id);
            favorites.setStatus("1");
            tUserFavoritesMapper.updateById(favorites);
        });
        return ids.length;
    }

    /**
     * 批量启用
     *
     * @param ids 常用功能收藏夹主键
     * @return 结果
     */
    @Override
    public int enableTUserFavoritesByIds(String[] ids) {
        Arrays.stream(ids).forEach(id -> {
            TUserFavorites favorites = new TUserFavorites();
            favorites.setId(id);
            favorites.setStatus("0");
            tUserFavoritesMapper.updateById(favorites);
        });
        return ids.length;
    }

    /**
     * 修改状态
     *
     * @param tUserFavorites 工序管理主键
     * @return 结果
     */
    @Override
    public int updateStatus(TUserFavorites tUserFavorites) {
        return tUserFavoritesMapper.updateById(tUserFavorites);
    }

}
