package org.kitchenstudio;

import org.kitchenstudio.entity.Driver;
import org.kitchenstudio.entity.Staff;
import org.kitchenstudio.entity.StoreItem;
import org.kitchenstudio.entity.StoreType;
import org.kitchenstudio.entity.Type;
import org.kitchenstudio.repository.DriverRepository;
import org.kitchenstudio.repository.StaffRepository;
import org.kitchenstudio.repository.StoreRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

@Component
public class ContextRefreshedEventHandler implements
		ApplicationListener<ContextRefreshedEvent> {

	private static final Logger logger = LoggerFactory
			.getLogger(ContextRefreshedEventHandler.class);

	@Autowired
	private StaffRepository staffRepository;

	@Autowired
	private DriverRepository driverRepository;
	
	@Autowired
	private StoreRepository storeRepository;

	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		logger.info("Context Refreshed!");

		for (int i = 0; i < 10; i++) {
			Staff staff = new Staff();
			staff.setName("王小欣" + i);
			staff.setPhoneNumber("18366110000");
			staff.setIDCard("328333922232323224");
			staff.setBankNumber("1234123412341234123");

			staffRepository.save(staff);
		}

		for(int i=0;i<10;i++){
			Driver driver = new Driver();
			driver.setName("老司机"+i);
			driver.setBankNumber("123456789098765432"+i);
			driver.setIDcard("12345678901234567"+i);
			driver.setNation(""+i);
			driver.setPlateNumber("沪A1234"+i);
			driver.setPhoneNumber(""+i+i+i+i);
			
			driverRepository.save(driver);
		}
		
		StoreItem storeItem = new StoreItem();
		storeItem.setStoreType(new StoreType(Type.STEEL_PIPE, "1.1"));
		storeItem.setQuantity(10);
		storeRepository.save(storeItem);
		
		storeItem = new StoreItem();
		storeItem.setStoreType(new StoreType(Type.STEEL_PIPE, "1.1"));
		storeItem.setQuantity(21);
		storeRepository.save(storeItem);
		
		storeItem = storeRepository.findOne(new StoreType(Type.STEEL_PIPE, "1.1"));
		logger.info(String.format("钢管1.1米有 --- %d 米", storeItem.getQuantity()));
	}
}

@@ -1001,17 +1001,16 @@
 sitory;%0A
-%09
 %0A%09@Autow
@@ -1437,26 +1437,34 @@
 %09for
+ 
 (int i
-=0;i%3C
+ = 0; i %3C 
 10;
+ 
 i++)
+ 
 %7B%0A%09%09
@@ -1517,17 +1517,19 @@
 me(%22%E8%80%81%E5%8F%B8%E6%9C%BA%22
-+
+ + 
 i);%0A%09%09%09d
@@ -1568,17 +1568,19 @@
 8765432%22
-+
+ + 
 i);%0A%09%09%09d
@@ -1614,17 +1614,19 @@
 1234567%22
-+
+ + 
 i);%0A%09%09%09d
@@ -1643,17 +1643,19 @@
 ation(%22%22
-+
+ + 
 i);%0A%09%09%09d
@@ -1683,17 +1683,19 @@
 %22%E6%B2%AAA1234%22
-+
+ + 
 i);%0A%09%09%09d
@@ -1721,22 +1721,27 @@
 r(%22%22
-+i+i+i+
+ + i + i + i + 
 i);%0A
-%09%09%09
 %0A%09%09%09
@@ -1775,18 +1775,16 @@
 r);%0A%09%09%7D%0A
-%09%09
 %0A%09%09Store
@@ -1938,34 +1938,32 @@
 ave(storeItem);%0A
-%09%09
 %0A%09%09storeItem = n
@@ -2107,18 +2107,16 @@
 eItem);%0A
-%09%09
 %0A%09%09store
@@ -2168,33 +2168,37 @@
 Type.STEEL_PIPE,
- 
+%0A%09%09%09%09
 %221.1%22));%0A%09%09logge

更改初始数据，去掉真实信息