MybatisPlus的一些補充

JaxYoun發表於2024-05-06
package com.dao.repository;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.entity.MedicareCatalogLimitPriceInfoDO;
import com.dao.mapper.MedicareCatalogLimitPriceInfoMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @description:
 * @author: Yang JianXiong
 * @since: 2020/10/30
 */
@Service
public class MedicareLimitPriceInfoRepository extends ServiceImpl<MedicareLimitPriceInfoMapper, MedicareLimitPriceInfoDO> {

    @Resource
    private MedicareLimitPriceInfoMapper mapper;

    // 獲取單個欄位
    public String getMaxSeriesNo() {
        MedicareLimitPriceInfoDO one = new LambdaQueryChainWrapper<>(this.mapper)
                .select(MedicareCatalogLimitPriceInfoDO::getHilistLsh)
                .in(MedicareCatalogLimitPriceInfoDO::getDeleted, 0, 1)
                .orderByDesc(MedicareCatalogLimitPriceInfoDO::getHilistLsh)
                .last(" limit 1, offset 0 ")
                .one();
        if (Objects.nonNull(one)) {
            return one.getHilistLsh();
        } else {
            return null;
        }

//        return this.getObj(new QueryWrapper<MedicareLimitPriceInfoDO>().select(MedicareImportHandler.MAX_SERIES_NO_SQL), Object::toString);
    }

}

相關文章