package com.mcwl.communityCenter.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mcwl.communityCenter.domain.Publish;
import com.mcwl.communityCenter.domain.dto.MyPublishPageRes;
import com.mcwl.communityCenter.domain.dto.PublishPageRes;
import com.mcwl.communityCenter.domain.dto.PublishRemoveRes;
import com.mcwl.communityCenter.domain.vo.PublishVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;

import javax.validation.constraints.NotNull;
import java.util.List;

@Mapper
public interface PublishMapper extends BaseMapper<Publish> {

    @InterceptorIgnore(tenantLine = "true")
    Page<Publish> selectByTenantIdAndCommunityIdPage(Page<Publish> page, @Param("tenantId") Long tenantId, @Param("communityId") Long communityId);

    @InterceptorIgnore(tenantLine = "true")
    Publish selectByIdAndTenantIdAndCommunityId(@Param("id")
                                                Long id,
                                                @Param("tenantId")
                                                Long tenantId,
                                                @Param("communityId")
                                                Long communityId);

    @InterceptorIgnore(tenantLine = "true")
    Page<Publish> selectByTenantIdAndCommunityIdAndNotNullImagePage(Page<Publish> page,
                                                                    @Param("tenantId")
                                                                    Long tenantId,
                                                                    @Param("communityId")
                                                                    Long communityId);

    @InterceptorIgnore(tenantLine = "true")
    Page<Publish> selectByTenantIdAndCommunityIdAndNotNullFilePage(Page<Publish> page,
                                                                   @Param("tenantId")
                                                                   Long tenantId,
                                                                   @Param("communityId")
                                                                   Long communityId);

    void elitePublish(@Param("tenantId") Long tenantId, @Param("communityId") Long communityId, @Param("publishId") Long publishId);

    @InterceptorIgnore(tenantLine = "true")
    List<PublishVo> publishList(Page<Publish> page, @Param("publishPageRes") PublishPageRes publishPageRes);

    @InterceptorIgnore(tenantLine = "true")
    List<PublishVo> myPublishList(Page<Publish> page,
                                  @Param("myPublishPageRes") MyPublishPageRes myPublishPageRes,
                                  @Param("userId") Long userId);

    @InterceptorIgnore(tenantLine = "true")
    void insertPublish(@Param("publish") Publish publish);

    @InterceptorIgnore(tenantLine = "true")
    Publish getLastPublish(@Param("tenantId") Long tenantId, @Param("communityId") Long communityId);

    @InterceptorIgnore(tenantLine = "true")
    void removePublish(@Param("publishRemoveRes") PublishRemoveRes publishRemoveRes);

    @InterceptorIgnore(tenantLine = "true")
    void updateLikeNum(@Param("publish") Publish publish);
}
