package com.kcim.dao.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kcim.common.util.UserContext;
import com.kcim.dao.mapper.FreeCostMapMapper;
import com.kcim.dao.model.FreeCostMap;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * @program: CostAccount
 * @description:
 * @author: Wang.YS
 * @create: 2024-04-03 10:28
 **/
@Repository
public class FreeCostMapRepository extends ServiceImpl<FreeCostMapMapper, FreeCostMap> {
    public List<FreeCostMap> getList(String filter) {
        LambdaQueryWrapper<FreeCostMap> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(FreeCostMap::getHospId, UserContext.getHospId());
        if(!StringUtils.isEmpty(filter)){
            queryWrapper.and(q->q.like(FreeCostMap::getFreeAccountCode,filter).or().like(FreeCostMap::getFreeAccountName,filter));
        }
        return this.list(queryWrapper);
    }
}
