package cn.ey.biz.module.system.service.serviceline;

import cn.ey.biz.module.system.dal.dataobject.codeblock.SubServiceLineDO;
import cn.ey.biz.module.system.dal.mapper.serviceline.ServiceSubLineMapper;
import cn.ey.biz.module.system.service.serviceline.ServiceSubLineService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author zhangjunlong
 * @since 2023/10/31 17:13
 */
@Service
public class ServiceSubLineServiceImpl extends ServiceImpl<ServiceSubLineMapper, SubServiceLineDO> implements ServiceSubLineService {
    @Override
    @Cacheable(cacheNames = "ey:gpt:sub-service-line", key = "#code", unless = "#result==null")
    public String getSubServiceLineNameStr(String code) {
        SubServiceLineDO subServiceLineDO =
                lambdaQuery().select(SubServiceLineDO::getSslName).eq(SubServiceLineDO::getSslCode,
                        code).one();
        if (Objects.isNull(subServiceLineDO)) {
            return "";
        }
        return subServiceLineDO.getSslName();
    }
}
