package com.yc.ship.module.resource.dal.mysql.guidegroup;

import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.module.resource.controller.admin.guidegroup.vo.GuideGroupPageReqVO;
import com.yc.ship.module.resource.controller.admin.vo.SimpleListReqVO;
import com.yc.ship.module.resource.dal.dataobject.guidegroup.GuideGroupDO;
import com.yc.ship.module.resource.enums.CommonStatusEnum;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;


/**
 * 导游分组 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface GuideGroupMapper extends BaseMapperX<GuideGroupDO> {

    default PageResult<GuideGroupDO> selectPage(GuideGroupPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GuideGroupDO>()
                .likeIfPresent(GuideGroupDO::getName, reqVO.getName())
                .eqIfPresent(GuideGroupDO::getGroupCode, reqVO.getGroupCode())
                .eqIfPresent(GuideGroupDO::getSort, reqVO.getSort())
                .betweenIfPresent(GuideGroupDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(GuideGroupDO::getSort));
    }

    default List<GuideGroupDO> selectList(SimpleListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<GuideGroupDO>()
            .likeIfPresent(GuideGroupDO::getName, reqVO.getName())
            .eqIfPresent(GuideGroupDO::getDeleted, CommonStatusEnum.ENABLE.getStatus())
            .eqIfPresent(GuideGroupDO::getTenantId, reqVO.getTenantId())
        .orderByAsc(GuideGroupDO::getSort));
    }

    default Long selectCountByParentId(String parentId) {
        return selectCount(GuideGroupDO::getParentId, parentId);
    }
}
