tipserviceimp.java

来自「关于java的web编程」· Java 代码 · 共 66 行

JAVA
66
字号
package service;

import hibernate.Brand;
import hibernate.Model;

import java.util.ArrayList;
import java.util.List;

import dao.BrandDao;
import dao.ModelDao;

public class TipServiceImp implements TipService{
    private BrandDao branddao;
    private ModelDao modeldao;
	public List<String> getBrandsByPrefix(String prefix) {
	
	List<Brand> list=branddao.findAllBrand();
	List<String> result=new ArrayList<String>();
	   for(Brand brand:list)
	   {
		   if(brand.getName().toUpperCase().startsWith(prefix.toUpperCase()))
		   {
			   result.add(brand.getName());
		   }
	   }
	   return result;
	}

	public String getDescByModel(String model_name) {
		
		Model model=modeldao.findByModel(model_name);
		if(model!=null)
		{
			return model.getDescr();
		}
		return null;
	}

	public List<String> getModelsByPrefix(String brand) {
		List<Model> list=modeldao.findByBrand(brand);
		List<String> result=new ArrayList<String>();
		for(Model model:list)
		{
			result.add(model.getName());
		}
		return result;
	}

	public BrandDao getBranddao() {
		return branddao;
	}

	public void setBranddao(BrandDao branddao) {
		this.branddao = branddao;
	}

	public ModelDao getModeldao() {
		return modeldao;
	}

	public void setModeldao(ModelDao modeldao) {
		this.modeldao = modeldao;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?