package com.lideeyunji.service.system.mapper;

import com.lideeyunji.tool.framework.common.pojo.PageResult;
import com.lideeyunji.tool.framework.mybatis.core.mapper.BaseMapperX;
import com.lideeyunji.tool.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.lideeyunji.service.system.controller.vo.notify.template.NotifyTemplatePageReqVO;
import com.lideeyunji.service.system.entity.NotifyTemplateDO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface NotifyTemplateMapper extends BaseMapperX<NotifyTemplateDO> {

    default NotifyTemplateDO selectByCode(String code) {
        return selectOne(NotifyTemplateDO::getCode, code);
    }

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

}
