如何使用mybatis-spring实现订单的查询?

如何使用mybatis-spring实现订单的查询?_第1张图片

 

package cn.kgc.dao;

import java.util.List;

import cn.kgc.pojo.Bill;

public interface BillMapper {
      public List getBillList(Bill bill);
}




  	

 

package cn.kgc.pojo;

import java.math.BigDecimal;
import java.util.Date;

public class Bill {
	 
	private int id;      //ida
	private String billCode;  //账单编码
	private String productName;  //商品的名称
	private String productDesc;  //商品描述
	private String productUnit;   //商品的单位
	private BigDecimal productCount; //商品数量
	private BigDecimal totalPrice;  //总金额
	private int isPayment;    //是否支付
	private int providerId;    //供应商id
	private int createBy;    //建立者
	private Date creationDate; // 建立时间
	private int modifyBy;    //更新者
	private Date modifyDate;  //更新时间
	

	private String providerName;    //供应商的名称


	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public String getBillCode() {
		return billCode;
	}


	public void setBillCode(String billCode) {
		this.billCode = billCode;
	}


	public String getProductName() {
		return productName;
	}


	public void setProductName(String productName) {
		this.productName = productName;
	}


	public String getProductDesc() {
		return productDesc;
	}


	public void setProductDesc(String productDesc) {
		this.productDesc = productDesc;
	}


	public String getProductUnit() {
		return productUnit;
	}


	public void setProductUnit(String productUnit) {
		this.productUnit = productUnit;
	}


	public BigDecimal getProductCount() {
		return productCount;
	}


	public void setProductCount(BigDecimal productCount) {
		this.productCount = productCount;
	}


	public BigDecimal getTotalPrice() {
		return totalPrice;
	}


	public void setTotalPrice(BigDecimal totalPrice) {
		this.totalPrice = totalPrice;
	}


	public int getIsPayment() {
		return isPayment;
	}


	public void setIsPayment(int isPayment) {
		this.isPayment = isPayment;
	}


	public int getProviderId() {
		return providerId;
	}


	public void setProviderId(int providerId) {
		this.providerId = providerId;
	}


	public int getCreateBy() {
		return createBy;
	}


	public void setCreateBy(int createBy) {
		this.createBy = createBy;
	}


	public Date getCreationDate() {
		return creationDate;
	}


	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}


	public int getModifyBy() {
		return modifyBy;
	}


	public void setModifyBy(int modifyBy) {
		this.modifyBy = modifyBy;
	}


	public Date getModifyDate() {
		return modifyDate;
	}


	public void setModifyDate(Date modifyDate) {
		this.modifyDate = modifyDate;
	}


	public String getProviderName() {
		return providerName;
	}


	public void setProviderName(String providerName) {
		this.providerName = providerName;
	}
	
	
	
}

 

package cn.kgc.service.impl;

import java.util.List;

import cn.kgc.pojo.Bill;

public interface BillService {
	
	List find(Bill bill);
	

}

 

package cn.kgc.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import cn.kgc.dao.BillMapper;
import cn.kgc.pojo.Bill;
@Service("billService")
public class BillServiceImpl implements BillService {
      @Autowired
      @Qualifier("billMapper")
	  private BillMapper billMapper;
	@Override
	public List find(Bill bill) {
		// TODO Auto-generated method stub
		try{
			return billMapper.getBillList(bill);	
		}catch (RuntimeException e){
			e.printStackTrace();
			throw e;
		}
		
	}


}

 

package cn.kgc.test;

import static org.junit.Assert.*;

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

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.kgc.pojo.Bill;
import cn.kgc.service.impl.BillService;

public class BillTest {

	@Test
	public void test() {
		  ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
		  
		  BillService billService=(BillService)ctx.getBean("billService");
		  List billList=new ArrayList();
		  Bill bill=new Bill();
		  bill.setId(1);
		 
		  billList=billService.find(bill);
		  
		  for(Bill el : billList){
			   System.out.println(el.getBillCode()+"----------"+el.getProductName());
		  }
		  
	}

}

 



     
        
	     
	          
	          
	          
	          
	     
	     

	    
	     
	           
	           
	           
	           
	           
	     
	     
	     
	     
	            
	     
	     
	     
           
           
           
           
           
             
                  
                    
                    
             
             
            
             
                 
                     
                                              
                          
                          
                          
                          
                     
             
     
             
             
             	
            
             	
             	
              
             
             

如何使用mybatis-spring实现订单的查询?_第2张图片

 




	  
	  	
	  

 

 

 

你可能感兴趣的:(课堂,Spring)