package com.xindazhou.framework.social.dal.mysql;

import com.xindazhou.framework.common.pojo.PageResult;
import com.xindazhou.framework.common.pojo.PageParam;
import com.xindazhou.framework.mybatis.core.mapper.BaseMapperX;
import com.xindazhou.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.xindazhou.framework.social.dal.dataobject.SocialClientDO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface SocialClientMapper extends BaseMapperX<SocialClientDO> {

    default SocialClientDO selectBySocialTypeAndUserType(Integer socialType, Integer userType) {
        return selectOne(SocialClientDO::getSocialType, socialType,
                SocialClientDO::getUserType, userType);
    }

    default PageResult<SocialClientDO> selectPage(PageParam pageParam, String name, Integer socialType, Integer userType, String clientId, Integer status) {
        return selectPage(pageParam, new LambdaQueryWrapperX<SocialClientDO>()
                .likeIfPresent(SocialClientDO::getName, name)
                .eqIfPresent(SocialClientDO::getSocialType, socialType)
                .eqIfPresent(SocialClientDO::getUserType, userType)
                .likeIfPresent(SocialClientDO::getClientId, clientId)
                .eqIfPresent(SocialClientDO::getStatus, status)
                .orderByDesc(SocialClientDO::getId));
    }

}
