package com.jojubanking.boot.module.system.dal.mysql.ksinfo;

import java.util.*;

import com.jojubanking.boot.framework.common.pojo.PageResult;
import com.jojubanking.boot.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.jojubanking.boot.framework.mybatis.core.mapper.BaseMapperX;
import com.jojubanking.boot.module.system.dal.dataobject.ksinfo.KsInfoDO;
import com.jojubanking.boot.module.system.dal.dataobject.wqda.WqdaDOx;
import org.apache.ibatis.annotations.Mapper;
import com.jojubanking.boot.module.system.controller.admin.ksinfo.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 科室信息 Mapper
 *
 * @author admin
 */
@Mapper
public interface KsInfoMapper extends BaseMapperX<KsInfoDO> {

    default PageResult<KsInfoDO> selectPage(KsInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<KsInfoDO>()
                .likeIfPresent(KsInfoDO::getName, reqVO.getName())
                .eqIfPresent(KsInfoDO::getTid, reqVO.getTid())
                .eqIfPresent(KsInfoDO::getInfo, reqVO.getInfo())
                .eqIfPresent(KsInfoDO::getAddress, reqVO.getAddress())
                .eqIfPresent(KsInfoDO::getImg, reqVO.getImg())
                .eqIfPresent(KsInfoDO::getDepartcode, reqVO.getDepartcode())
                .eqIfPresent(KsInfoDO::getDeparttype, reqVO.getDeparttype())
                .eqIfPresent(KsInfoDO::getUptype, reqVO.getUptype())
                .betweenIfPresent(KsInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(KsInfoDO::getId));
    }

    default PageResult<KsInfoDO> selectDzPage(KsInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<KsInfoDO>()
                .likeIfPresent(KsInfoDO::getName, reqVO.getName())
                .eqIfPresent(KsInfoDO::getTid, reqVO.getTid())
                .eqIfPresent(KsInfoDO::getInfo, reqVO.getInfo())
                .eqIfPresent(KsInfoDO::getAddress, reqVO.getAddress())
                .eqIfPresent(KsInfoDO::getImg, reqVO.getImg())
                .eqIfPresent(KsInfoDO::getDepartcode, reqVO.getDepartcode())
                .eqIfPresent(KsInfoDO::getDeparttype, reqVO.getDeparttype())
                .eqIfPresent(KsInfoDO::getUptype, reqVO.getUptype())
                .betweenIfPresent(KsInfoDO::getCreateTime, reqVO.getCreateTime())
                .last("and uptype != '99' ORDER BY id"));
    }

    default List<KsInfoDO> selectList(KsInfoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<KsInfoDO>()
                .likeIfPresent(KsInfoDO::getName, reqVO.getName())
                .eqIfPresent(KsInfoDO::getTid, reqVO.getTid())
                .eqIfPresent(KsInfoDO::getInfo, reqVO.getInfo())
                .eqIfPresent(KsInfoDO::getAddress, reqVO.getAddress())
                .eqIfPresent(KsInfoDO::getImg, reqVO.getImg())
                .eqIfPresent(KsInfoDO::getDepartcode, reqVO.getDepartcode())
                .eqIfPresent(KsInfoDO::getDeparttype, reqVO.getDeparttype())
                .eqIfPresent(KsInfoDO::getUptype, reqVO.getUptype())
                .betweenIfPresent(KsInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(KsInfoDO::getId));
    }

}
