package com.yc.ship.module.miniapplet.dal.mysql.menu;

import com.yc.ship.framework.common.enums.CommonStatusEnum;
import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.module.miniapplet.controller.admin.menu.vo.AppletMenuPageReqVO;
import com.yc.ship.module.miniapplet.dal.dataobject.menu.AppletMenuDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 小程序菜单 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface AppletMenuMapper extends BaseMapperX<AppletMenuDO> {

    default PageResult<AppletMenuDO> selectPage(AppletMenuPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AppletMenuDO>()
                .likeIfPresent(AppletMenuDO::getName, reqVO.getName())
                .eqIfPresent(AppletMenuDO::getStatus, reqVO.getStatus())
                .orderByAsc(AppletMenuDO::getSort));
    }

    /**
     * 获取app菜单列表
     * @return
     */
    default List<AppletMenuDO> selectAppList() {
        return selectList(new LambdaQueryWrapperX<AppletMenuDO>()
                .eq(AppletMenuDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
                .orderByAsc(AppletMenuDO::getSort));
    }
}