package com.ruoyi.cai.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.cai.domain.Anchor;
import com.ruoyi.cai.dto.admin.vo.AnchorAdminVo;
import com.ruoyi.cai.dto.app.query.index.AnchorListQuery;
import com.ruoyi.cai.dto.app.vo.AnchorListVo;
import com.ruoyi.cai.mapper.AnchorMapper;
import com.ruoyi.cai.service.AnchorService;
import com.ruoyi.common.core.domain.PageQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 女神列表Service业务层处理
 *
 * @author 77
 * @date 2023-12-22
 */
@RequiredArgsConstructor
@Service
public class AnchorServiceImpl extends ServiceImpl<AnchorMapper, Anchor> implements AnchorService {

    @Override
    public Page<AnchorAdminVo> pageAdmin(PageQuery pageQuery, AnchorAdminVo bo) {
        return baseMapper.pageAdmin(pageQuery.build(),bo);
    }

    @Override
    public Page<AnchorListVo> pageApp(PageQuery pageQuery, AnchorListQuery query) {
        if(query.getType() != null && query.getType() != 3){
            query.setCityId(null);
        }
        return baseMapper.pageApp(pageQuery.build(),query);
    }

    @Override
    public Anchor getByUserId(Long userId){
        return this.getOne(Wrappers.lambdaQuery(Anchor.class).eq(Anchor::getUserId,userId));
    }

    @Override
    public void updateVideoStatus(Long userId, int videoStatus) {
        this.update(Wrappers.lambdaUpdate(Anchor.class)
                .eq(Anchor::getUserId,userId)
                .set(Anchor::getVideoStatus,videoStatus));
    }
}
