package com.cf.imes.module.system.dal.mysql.application;

import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.module.system.controller.admin.application.vo.application.ApplicationPageReqVO;
import com.cf.imes.module.system.dal.dataobject.application.ApplicationDO;
import com.cf.imes.module.system.dal.dataobject.user.AdminUserDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 应用信息表 process Mapper
 *
 * @author 晨丰科技
 */
@Mapper
public interface ApplicationMapper extends BaseMapperX<ApplicationDO> {

    default PageResult<ApplicationDO> selectPage(ApplicationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ApplicationDO>()
                .likeIfPresent(ApplicationDO::getName, reqVO.getName())
                .eqIfPresent(ApplicationDO::getAppId, reqVO.getAppId())
                .eqIfPresent(ApplicationDO::getCode, reqVO.getCode())
                .eqIfPresent(ApplicationDO::getServerIp, reqVO.getServerIp())
                .eqIfPresent(ApplicationDO::getCompany, reqVO.getCompany())
                .eqIfPresent(ApplicationDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ApplicationDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ApplicationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ApplicationDO::getId));
    }

    default ApplicationDO selectByAppId(String appId) {
        return selectOne(ApplicationDO::getAppId, appId);
    }

    default ApplicationDO selectByOrganId(Long organId) {
        return selectOne(ApplicationDO::getOrganId, organId);
    }
}
