package cn.ey.biz.module.system.dal.mapper.app;

import cn.ey.biz.common.pojo.PageResult;
import cn.ey.biz.framework.mybatis.core.mapper.BaseMapperX;
import cn.ey.biz.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ey.biz.module.system.controller.admin.app.vo.AppExportReqVO;
import cn.ey.biz.module.system.controller.admin.app.vo.AppPageReqVO;
import cn.ey.biz.module.system.controller.admin.app.vo.AppRespVO;
import cn.ey.biz.module.system.dal.dataobject.app.AppDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;

/**
 * 系统应用 Mapper
 *
 */
@Mapper
public interface AppMapper extends BaseMapperX<AppDO> {

    default PageResult<AppDO> selectPage(AppPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AppDO>()
                .likeIfPresent(AppDO::getCode, reqVO.getCode())
                .likeIfPresent(AppDO::getName, reqVO.getName())
                .eqIfPresent(AppDO::getStatus, reqVO.getStatus())
                .eqIfPresent(AppDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(AppDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AppDO::getId));
    }

    default List<AppDO> selectList(AppExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AppDO>()
                .eqIfPresent(AppDO::getCode, reqVO.getCode())
                .likeIfPresent(AppDO::getName, reqVO.getName())
                .eqIfPresent(AppDO::getStatus, reqVO.getStatus())
                .eqIfPresent(AppDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(AppDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AppDO::getId));
    }

    IPage<AppRespVO> selectPageApp(IPage page,
                                   @Param("appPageReqVO")AppPageReqVO appPageReqVO,
                                   @Param("acceptLanguage")String acceptLanguage);

}
