package com.starry.admin.modules.clerk.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.starry.admin.modules.clerk.mapper.PlayClerkClassificationInfoMapper;
import com.starry.admin.modules.clerk.module.entity.PlayClerkClassificationInfoEntity;
import com.starry.admin.modules.clerk.service.IPlayClerkClassificationInfoService;
import com.starry.common.utils.IdUtils;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 店员分类Service业务层处理
 *
 * @author admin
 * @since 2024-04-06
 */
@Service
public class PlayClerkClassificationInfoServiceImpl
        extends
            ServiceImpl<PlayClerkClassificationInfoMapper, PlayClerkClassificationInfoEntity>
        implements
            IPlayClerkClassificationInfoService {
    @Resource
    private PlayClerkClassificationInfoMapper playClerkClassificationInfoMapper;

    /**
     * 查询店员分类
     *
     * @param id
     *            店员分类主键
     * @return 店员分类
     */
    @Override
    public PlayClerkClassificationInfoEntity selectPlayClerkClassificationInfoById(String id) {
        return this.baseMapper.selectById(id);
    }

    /**
     * 查询店员分类列表
     *
     * @return 店员分类
     */
    @Override
    public List<PlayClerkClassificationInfoEntity> selectAll() {
        return this.baseMapper.selectList(new LambdaQueryWrapper<>());
    }

    /**
     * 查询店员分类列表
     *
     * @param playClerkClassificationInfo
     *            店员分类
     * @return 店员分类
     */
    @Override
    public IPage<PlayClerkClassificationInfoEntity> selectPlayClerkClassificationInfoByPage(
            PlayClerkClassificationInfoEntity playClerkClassificationInfo) {
        Page<PlayClerkClassificationInfoEntity> page = new Page<>(1, 10);
        return this.baseMapper.selectPage(page, new LambdaQueryWrapper<>());
    }

    /**
     * 新增店员分类
     *
     * @param playClerkClassificationInfo
     *            店员分类
     * @return 结果
     */
    @Override
    public boolean create(PlayClerkClassificationInfoEntity playClerkClassificationInfo) {
        if (StrUtil.isBlankIfStr(playClerkClassificationInfo.getId())) {
            playClerkClassificationInfo.setId(IdUtils.getUuid());
        }
        return save(playClerkClassificationInfo);
    }

    /**
     * 修改店员分类
     *
     * @param playClerkClassificationInfo
     *            店员分类
     * @return 结果
     */
    @Override
    public boolean update(PlayClerkClassificationInfoEntity playClerkClassificationInfo) {
        return updateById(playClerkClassificationInfo);
    }

    /**
     * 批量删除店员分类
     *
     * @param ids
     *            需要删除的店员分类主键
     * @return 结果
     */
    @Override
    public int deletePlayClerkClassificationInfoByIds(String[] ids) {
        return playClerkClassificationInfoMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除店员分类信息
     *
     * @param id
     *            店员分类主键
     * @return 结果
     */
    @Override
    public int deletePlayClerkClassificationInfoById(String id) {
        return playClerkClassificationInfoMapper.deleteById(id);
    }
}
