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.PlayClerkTypeUserInfoMapper;
import com.starry.admin.modules.clerk.module.entity.PlayClerkTypeUserInfoEntity;
import com.starry.admin.modules.clerk.service.IPlayClerkTypeUserInfoService;
import com.starry.common.utils.IdUtils;
import java.util.Arrays;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 店员和分类关系Service业务层处理
 *
 * @author admin
 * @since 2024-05-31
 */
@Service
public class PlayClerkTypeUserInfoServiceImpl
        extends
            ServiceImpl<PlayClerkTypeUserInfoMapper, PlayClerkTypeUserInfoEntity>
        implements
            IPlayClerkTypeUserInfoService {
    @Resource
    private PlayClerkTypeUserInfoMapper playClerkTypeUserInfoMapper;

    /**
     * 查询店员和分类关系
     *
     * @param id
     *            店员和分类关系主键
     * @return 店员和分类关系
     */
    @Override
    public PlayClerkTypeUserInfoEntity selectPlayClerkTypeUserInfoById(String id) {
        return this.baseMapper.selectById(id);
    }

    /**
     * 查询店员和分类关系列表
     *
     * @param playClerkTypeUserInfo
     *            店员和分类关系
     * @return 店员和分类关系
     */
    @Override
    public IPage<PlayClerkTypeUserInfoEntity> selectPlayClerkTypeUserInfoByPage(
            PlayClerkTypeUserInfoEntity playClerkTypeUserInfo) {
        Page<PlayClerkTypeUserInfoEntity> page = new Page<>(1, 10);
        return this.baseMapper.selectPage(page, new LambdaQueryWrapper<PlayClerkTypeUserInfoEntity>());
    }

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

    /**
     * 修改店员和分类关系
     *
     * @param playClerkTypeUserInfo
     *            店员和分类关系
     * @return 结果
     */
    @Override
    public boolean update(PlayClerkTypeUserInfoEntity playClerkTypeUserInfo) {
        return updateById(playClerkTypeUserInfo);
    }

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

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