import com.ruoyi.admin.domain.Drug;
import com.ruoyi.admin.mapper.DrugMapper;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Optional;
@Component
public class DataFactoryUtil {
private static DataFactoryUtil dataFactoryUtil;
@Resource
private DrugMapper drugMapper;
@PostConstruct
public void init() {
dataFactoryUtil = this;
dataFactoryUtil.drugMapper = this.drugMapper;
}
public static String getDrugNameById(Long id) {
Drug drug = dataFactoryUtil.drugMapper.selectById(id);
return Optional.ofNullable(drug).map(u-> u.getDrugName()).orElse(null);
}
}
03-22
4597
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-22
1905
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-18