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.PlayAvatarFrameInfoMapper;
import com.starry.admin.modules.clerk.module.entity.PlayAvatarFrameInfoEntity;
import com.starry.admin.modules.clerk.module.vo.PlayAvatarFrameInfoQueryVo;
import com.starry.admin.modules.clerk.service.IPlayAvatarFrameInfoService;
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-06-06
 */
@Service
public class PlayAvatarFrameInfoServiceImpl extends ServiceImpl<PlayAvatarFrameInfoMapper, PlayAvatarFrameInfoEntity>
        implements
            IPlayAvatarFrameInfoService {
    @Resource
    private PlayAvatarFrameInfoMapper playAvatarFrameInfoMapper;

    /**
     * 查询店员头像框
     *
     * @param id
     *            店员头像框主键
     * @return 店员头像框
     */
    @Override
    public PlayAvatarFrameInfoEntity selectPlayAvatarFrameInfoById(String id) {
        return this.baseMapper.selectById(id);
    }

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

    @Override
    public IPage<PlayAvatarFrameInfoEntity> selectByPage(PlayAvatarFrameInfoQueryVo vo) {
        return this.baseMapper.selectPage(new Page<>(vo.getPageNum(), vo.getPageSize()), new LambdaQueryWrapper<>());
    }

    /**
     * 查询店员头像框列表
     *
     * @param playAvatarFrameInfo
     *            店员头像框
     * @return 店员头像框
     */
    @Override
    public IPage<PlayAvatarFrameInfoEntity> selectPlayAvatarFrameInfoByPage(
            PlayAvatarFrameInfoEntity playAvatarFrameInfo) {
        Page<PlayAvatarFrameInfoEntity> page = new Page<>(1, 10);
        return this.baseMapper.selectPage(page, new LambdaQueryWrapper<>());
    }

    /**
     * 新增店员头像框
     *
     * @param playAvatarFrameInfo
     *            店员头像框
     * @return 结果
     */
    @Override
    public boolean create(PlayAvatarFrameInfoEntity playAvatarFrameInfo) {
        if (StrUtil.isBlankIfStr(playAvatarFrameInfo.getId())) {
            playAvatarFrameInfo.setId(IdUtils.getUuid());
        }
        return save(playAvatarFrameInfo);
    }

    /**
     * 修改店员头像框
     *
     * @param playAvatarFrameInfo
     *            店员头像框
     * @return 结果
     */
    @Override
    public boolean update(PlayAvatarFrameInfoEntity playAvatarFrameInfo) {
        return updateById(playAvatarFrameInfo);
    }

    /**
     * 批量删除店员头像框
     *
     * @param ids
     *            需要删除的店员头像框主键
     * @return 结果
     */
    @Override
    public int deletePlayAvatarFrameInfoByIds(String[] ids) {
        return playAvatarFrameInfoMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除店员头像框信息
     *
     * @param id
     *            店员头像框主键
     * @return 结果
     */
    @Override
    public int deletePlayAvatarFrameInfoById(String id) {
        return playAvatarFrameInfoMapper.deleteById(id);
    }
}
