package com.starry.admin.modules.shop.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.shop.mapper.PlayCommodityAndLevelInfoMapper;
import com.starry.admin.modules.shop.module.entity.PlayCommodityAndLevelInfoEntity;
import com.starry.admin.modules.shop.service.IPlayCommodityAndLevelInfoService;
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-08-16
 */
@Service
public class PlayCommodityAndLevelInfoServiceImpl
        extends
            ServiceImpl<PlayCommodityAndLevelInfoMapper, PlayCommodityAndLevelInfoEntity>
        implements
            IPlayCommodityAndLevelInfoService {
    @Resource
    private PlayCommodityAndLevelInfoMapper playCommodityAndLevelInfoMapper;

    @Override
    public PlayCommodityAndLevelInfoEntity queryById(String commodityId, String levelId) {
        LambdaQueryWrapper<PlayCommodityAndLevelInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PlayCommodityAndLevelInfoEntity::getCommodityId, commodityId);
        queryWrapper.eq(PlayCommodityAndLevelInfoEntity::getLevelId, levelId);
        return playCommodityAndLevelInfoMapper.selectOne(queryWrapper);
    }

    @Override
    public List<PlayCommodityAndLevelInfoEntity> selectAll() {
        return this.baseMapper.selectList(new LambdaQueryWrapper<>());
    }

    /**
     * 查询服务项目和店员等级数据
     *
     * @param id
     *            服务项目和店员等级数据主键
     * @return 服务项目和店员等级数据
     */
    @Override
    public PlayCommodityAndLevelInfoEntity selectPlayCommodityAndLevelInfoById(String id) {
        return this.baseMapper.selectById(id);
    }

    /**
     * 查询服务项目和店员等级数据列表
     *
     * @param playCommodityAndLevelInfo
     *            服务项目和店员等级数据
     * @return 服务项目和店员等级数据
     */
    @Override
    public IPage<PlayCommodityAndLevelInfoEntity> selectPlayCommodityAndLevelInfoByPage(
            PlayCommodityAndLevelInfoEntity playCommodityAndLevelInfo) {
        Page<PlayCommodityAndLevelInfoEntity> page = new Page<>(1, 10);
        return this.baseMapper.selectPage(page, new LambdaQueryWrapper<PlayCommodityAndLevelInfoEntity>());
    }

    /**
     * 新增服务项目和店员等级数据
     *
     * @param playCommodityAndLevelInfo
     *            服务项目和店员等级数据
     * @return 结果
     */
    @Override
    public boolean create(PlayCommodityAndLevelInfoEntity playCommodityAndLevelInfo) {
        if (StrUtil.isBlankIfStr(playCommodityAndLevelInfo.getId())) {
            playCommodityAndLevelInfo.setId(IdUtils.getUuid());
        }
        return save(playCommodityAndLevelInfo);
    }

    /**
     * 修改服务项目和店员等级数据
     *
     * @param playCommodityAndLevelInfo
     *            服务项目和店员等级数据
     * @return 结果
     */
    @Override
    public boolean update(PlayCommodityAndLevelInfoEntity playCommodityAndLevelInfo) {
        return updateById(playCommodityAndLevelInfo);
    }

    /**
     * 批量删除服务项目和店员等级数据
     *
     * @param ids
     *            需要删除的服务项目和店员等级数据主键
     * @return 结果
     */
    @Override
    public int deletePlayCommodityAndLevelInfoByIds(String[] ids) {
        return playCommodityAndLevelInfoMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除服务项目和店员等级数据信息
     *
     * @param id
     *            服务项目和店员等级数据主键
     * @return 结果
     */
    @Override
    public int deletePlayCommodityAndLevelInfoById(String id) {
        return playCommodityAndLevelInfoMapper.deleteById(id);
    }
}
