package cn.iocoder.yudao.module.crm.dal.mysql.userlivetree;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.crm.controller.admin.userlivetree.vo.UserLiveTreeListVO;
import cn.iocoder.yudao.module.crm.controller.admin.userlivetree.vo.UserLiveTreePageReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.userlivetree.UserLiveTreeDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * crm用户结构树 Mapper
 *
 * @author 艾楷
 */
@Mapper
public interface UserLiveTreeMapper extends BaseMapperX<UserLiveTreeDO> {

    default PageResult<UserLiveTreeDO> selectPage(UserLiveTreePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserLiveTreeDO>()
                .eqIfPresent(UserLiveTreeDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserLiveTreeDO::getPid, reqVO.getPid())
                .betweenIfPresent(UserLiveTreeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserLiveTreeDO::getId));
    }

    /**
     * 获取用户结构树列表
     *
     * @return
     */
    List<UserLiveTreeListVO> userLiveTreeList();
}
