<repo_name>OlaAcademy/microtao<file_sep>/src/main/java/com/xpown/mybatis/BaseMybatisDao.java
package com.xpown.mybatis;
import java.io.Serializable;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



public abstract class BaseMybatisDao<E,PK extends Serializable> extends MybatisDao  implements EntityDao<E,PK> {
   
	private static Logger logger = LoggerFactory.getLogger(BaseMybatisDao.class);
	
    @SuppressWarnings("unchecked")
	public E getById(PK primaryKey) {
        return (E)getSqlSession().selectOne(getFindByPrimaryKeyStatement(), primaryKey);
    }
    
	public void deleteById(PK id) {
		getSqlSession().delete(getDeleteStatement(), id);
	}
	
    public void save(E entity) {
		prepareObjectForSaveOrUpdate(entity);
		getSqlSession().insert(getInsertStatement(), entity);    	
    }
    
	public int update(E entity) {
		prepareObjectForSaveOrUpdate(entity);
		int affectCount = getSqlSession().update(getUpdateStatement(), entity);
		return affectCount;
	}
	
	
	/**
	 * 用于子类覆盖,在insert,update之前调用
	 * @param o
	 */
    protected void prepareObjectForSaveOrUpdate(E o) {
    			logger.info("prepareObjectForSaveOrUpdate...");
    			// System.out.println("kw...");
    }

    /*public String getMybatisMapperNamesapce() {
        throw new RuntimeException("not yet implement");
    }*/
    
    public abstract String getMybatisMapperNamesapce();
    
    public String getFindByPrimaryKeyStatement() {
        return getMybatisMapperNamesapce()+".getById";
    }

    public String getInsertStatement() {
        return getMybatisMapperNamesapce()+".insert";
    }

    public String getUpdateStatement() {
    		return getMybatisMapperNamesapce()+".updateById";
    }

    public String getDeleteStatement() {
    		return getMybatisMapperNamesapce()+".deleteById";
    }
    
    public String getFindStatement() {
    		return getMybatisMapperNamesapce()+".findAll";
    }
   
	public List<E> findAll() {
		// throw new UnsupportedOperationException();
		String statementName = getFindStatement();
		return getSqlSession().selectList(statementName);
	}

	
	public boolean isUnique(E entity, String uniquePropertyNames) {
		throw new UnsupportedOperationException();
	}
	
	public void flush() {
		//ignore
	}
}
<file_sep>/src/main/java/com/xpown/mybatis/MybatisDao.java
package com.xpown.mybatis;
import java.util.List;
import java.util.Map;

import org.apache.commons.beanutils.PropertyUtils;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.util.ReflectionUtils;

import com.xpown.utils.Page;



/**
 * Mybatis分页查询工具类,为分页查询增加传递:
 * startRow,endRow : 用于oracle分页使用,从1开始
 * offset,limit : 用于mysql 分页使用,从0开始
 * 
 */

@SuppressWarnings("unchecked")
public class MybatisDao extends SqlSessionDaoSupport {

        public <T> Page<T> selectPage(Page<T> page, String statementName, Object parameter) {
                String countStatementName = statementName + "Count";
                return selectPage(page, statementName, countStatementName, parameter);
        }

        public <T> Page<T> selectPage(Page<T> page, String statementName, String countStatementName, Object parameter) {

                Number totalItems = (Number) getSqlSession().selectOne(countStatementName, parameter);
        		//Number totalItems = 10;
                if (totalItems != null && totalItems.longValue() > 0) {
                        List list = getSqlSession().selectList(statementName, toParameterMap(parameter, page));
                        page.setResult(list);
                        page.setTotalCount(totalItems.intValue());
                }
                return page;
        }

        protected static Map toParameterMap(Object parameter, Page p) {
                Map map = toParameterMap(parameter);
                //map.put("startRow", p.getStartRow());
                //map.put("startRow", p.getOffset());
                //map.put("endRow", p.getEndRow());
                map.put("offset", p.getOffset());
                map.put("limit", p.getPageSize());
                return map;
        }

        protected static Map toParameterMap(Object parameter) {
                if (parameter instanceof Map) {
                        return (Map) parameter;
                } else {
                        try {
                                return PropertyUtils.describe(parameter);
                        } catch (Exception e) {
                                ReflectionUtils.handleReflectionException(e);
                                return null;
                        }
                }
        }
}<file_sep>/target/m2e-wtp/web-resources/META-INF/maven/com.xpown.microtao/microtao/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.xpown.microtao</groupId>
	<artifactId>microtao</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>
	<name>microtao</name>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<spring.version>3.2.0.RELEASE</spring.version>
		<json.version>1.9.13</json.version>
		<slf4jVersion>1.6.1</slf4jVersion>
	</properties>


	<dependencies>

		<dependency>
			<groupId>org.quartz-scheduler</groupId>
			<artifactId>quartz</artifactId>
			<version>1.8.4</version>
		</dependency>

		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.26</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>${spring.version}</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring.version}</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context-support</artifactId>
			<version>${spring.version}</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>${spring.version}</version>
		</dependency>

		<dependency>
			<groupId>javax.servlet.jsp</groupId>
			<artifactId>jsp-api</artifactId>
			<version>2.1</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>javax.inject</groupId>
			<artifactId>javax.inject</artifactId>
			<version>1</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${spring.version}</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>${spring.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.8.2</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.json</groupId>
			<artifactId>json</artifactId>
			<version>20090211</version>
		</dependency>

		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
			<version>1.1.23</version>
		</dependency>

		<dependency>
			<groupId>org.codehaus.jackson</groupId>
			<artifactId>jackson-core-lgpl</artifactId>
			<version>${json.version}</version>
		</dependency>
		<dependency>
			<groupId>org.codehaus.jackson</groupId>
			<artifactId>jackson-core-asl</artifactId>
			<version>${json.version}</version>
		</dependency>
		<dependency>
			<groupId>org.codehaus.jackson</groupId>
			<artifactId>jackson-mapper-asl</artifactId>
			<version>${json.version}</version>
		</dependency>
		<dependency>
			<groupId>org.codehaus.jackson</groupId>
			<artifactId>jackson-mapper-lgpl</artifactId>
			<version>${json.version}</version>
		</dependency>

		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>${slf4jVersion}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>${slf4jVersion}</version>
		</dependency>

		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<version>4.3.3</version>
		</dependency>
		<dependency>
			<groupId>commons-httpclient</groupId>
			<artifactId>commons-httpclient</artifactId>
			<version>3.1</version>
		</dependency>
		<dependency>
			<groupId>commons-lang</groupId>
			<artifactId>commons-lang</artifactId>
			<version>2.6</version>
		</dependency>
		<dependency>
			<groupId>commons-beanutils</groupId>
			<artifactId>commons-beanutils</artifactId>
			<version>1.8.3</version>
		</dependency>
		<dependency>
			<groupId>commons-fileupload</groupId>
			<artifactId>commons-fileupload</artifactId>
			<version>1.2.2</version>
		</dependency>

		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>commons-configuration</groupId>
			<artifactId>commons-configuration</artifactId>
			<version>1.9</version>
		</dependency>

		<dependency>
			<groupId>net.sf.json-lib</groupId>
			<artifactId>json-lib</artifactId>
			<version>2.4</version>
			<classifier>jdk15</classifier>
		</dependency>

		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
			<version>3.1.1</version>
		</dependency>

		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis-spring</artifactId>
			<version>1.1.0</version>
		</dependency>

		<dependency>
			<groupId>cglib</groupId>
			<artifactId>cglib</artifactId>
			<version>2.2</version>
		</dependency>

		<!-- optional datasource pool -->
		<dependency>
			<groupId>commons-dbcp</groupId>
			<artifactId>commons-dbcp</artifactId>
			<version>1.4</version>
		</dependency>
		<dependency>
			<groupId>commons-pool</groupId>
			<artifactId>commons-pool</artifactId>
			<version>1.5.5</version>
		</dependency>

		<dependency>
			<groupId>commons-collections</groupId>
			<artifactId>commons-collections</artifactId>
			<version>3.2.1</version>
		</dependency>
		<dependency>
			<groupId>commons-codec</groupId>
			<artifactId>commons-codec</artifactId>
			<version>1.4</version>
		</dependency>
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>2.0.1</version>
		</dependency>
		<dependency>
			<groupId>asm</groupId>
			<artifactId>asm</artifactId>
			<version>3.3</version>
		</dependency>
		<dependency>
			<groupId>com.mchange</groupId>
			<artifactId>c3p0</artifactId>
			<version>0.9.2</version>
		</dependency>

		<dependency>
			<groupId>com.ning</groupId>
			<artifactId>async-http-client</artifactId>
			<version>1.6.2</version>
		</dependency>

		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>
		<dependency>
			<groupId>taglibs</groupId>
			<artifactId>standard</artifactId>
			<version>1.1.2</version>
		</dependency>
		<dependency>
			<groupId>com.sun.mail</groupId>
			<artifactId>javax.mail</artifactId>
			<version>1.5.3</version>
		</dependency>

		<!-- 手机短信 -->
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<version>4.3.5</version>
		</dependency>

		<!-- spring定时器 -->
		<dependency>
			<groupId>javax.transaction</groupId>
			<artifactId>jta</artifactId>
			<version>1.1</version>
		</dependency>

		<dependency>
			<groupId>jdom</groupId>
			<artifactId>jdom</artifactId>
			<version>1.0</version>
		</dependency>
	</dependencies>

</project><file_sep>/src/main/java/com/xpown/utils/Page.java
package com.xpown.utils;

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

/**
 * 与具体ORM实现无关的分页参数及查询结果封装.
 * 
 * 注意所有序号从1开始.
 * 
 * @param <T> Page中记录的类型.
 * 
 *  
 */
public class Page<T> {
	//-- 公共变量 --//
	public static final String ASC = "asc";
	public static final String DESC = "desc";

	//-- 分页参数 --//
	protected int pageNo = 1;
	protected int pageSize = -1;
	//protected String orderBy = null;
	//protected String order = null;
	//protected boolean autoCount = true;
	
	private int pageCount; //总页数
	
	private int offset = 0; // 起始条数
	
	//-- 返回结果 --//
	protected List<T> result = new ArrayList<T>();
	protected int totalCount = 0;

	//-- 构造函数 --//
	/**
	private Page() {
	}
	*/

/**
 * 
	public Page<T> end() {
		
		// 1, 总页码
		pageCount = ((int)this.totalCount + pageSize - 1) / pageSize;
		// 2, startPageIndex（显示的页码列表的开始索引）与endPageIndex（显示的页码列表的结束索引）
		// a, 总页码不大于10页
		if (pageCount <= 10) {
			startPageIndex = 1;
			endPageIndex = pageCount;
		}
		// b, 总码大于10页
		else {
			// 在中间，显示前面4个，后面5个
			startPageIndex = pageNo - 4;
			endPageIndex = pageNo + 5;

			// 前面不足4个时，显示前10个页码
			if (startPageIndex < 1) {
				startPageIndex = 1;
				endPageIndex = 10;
			}
			// 后面不足5个时，显示后10个页码
			else if (endPageIndex > pageCount) {
				endPageIndex = pageCount;
				startPageIndex = pageCount - 10 + 1;
			}
		}
		return this;

	}
**/
	/*
	public Page(int pageSize) {
		this.pageSize = pageSize;
	}
	*/

	public Page(int pageNo,int pageSize){
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		this.offset = (pageNo-1) * pageSize;
	}
	
	public Page(int pageNo,int pageSize,int totalCount){
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		this.offset = (pageNo-1) * pageSize;
		this.totalCount = totalCount;
	}
	
	//-- 分页参数访问函数 --//
	/**
	 * 获得当前页的页号,序号从1开始,默认为1.
	 */
	public int getPageNo() {
		return pageNo;
	}

	/**
	 * 设置当前页的页号,序号从1开始,低于1时自动调整为1.
	 */
	public void setPageNo(final int pageNo) {
		this.pageNo = pageNo;

		if (pageNo < 1) {
			this.pageNo = 1;
		}
	}

	/**
	 * 返回Page对象自身的setPageNo函数,可用于连续设置。
	 */
	public Page<T> pageNo(final int thePageNo) {
		setPageNo(thePageNo);
		return this;
	}

	/**
	 * 获得每页的记录数量, 默认为-1.
	 */
	public int getPageSize() {
		return pageSize;
	}

	/**
	 * 设置每页的记录数量.
	 */
	public void setPageSize(final int pageSize) {
		this.pageSize = pageSize;
	}

	/**
	 * 返回Page对象自身的setPageSize函数,可用于连续设置。
	 */
	public Page<T> pageSize(final int thePageSize) {
		setPageSize(thePageSize);
		return this;
	}

	/**
	 * 根据pageNo和pageSize计算当前页第一条记录在总结果集中的位置,序号从1开始.
	 */
	public int getFirst() {
		return ((pageNo - 1) * pageSize) + 1;
	}

	//-- 访问查询结果函数 --//

	/**
	 * 获得页内的记录列表.
	 */
	public List<T> getResult() {
		return result;
	}

	/**
	 * 设置页内的记录列表.
	 */
	public void setResult(final List<T> result) {
		this.result = result;
	}

	/**
	 * 获得总记录数, 默认值为-1.
	 */
	public long getTotalCount() {
		return totalCount;
	}

	/**
	 * 设置总记录数.
	 */
	public void setTotalCount(final int totalCount) {
		this.totalCount = totalCount;
		this.pageCount = getTotalPages();
	}

	/**
	 * 根据pageSize与totalCount计算总页数, 默认值为-1.
	 */
	public int getTotalPages() {
		if (totalCount < 0) {
			return -1;
		}

		int count = totalCount / pageSize;
		if (totalCount % pageSize > 0) {
			count++;
		}
		return count;
	}

	/**
	 * 是否还有下一页.
	 */
	public boolean isHasNext() {
		return (pageNo + 1 <= getTotalPages());
	}

	/**
	 * 取得下页的页号, 序号从1开始.
	 * 当前页为尾页时仍返回尾页序号.
	 */
	public int getNextPage() {
		if (isHasNext()) {
			return pageNo + 1;
		} else {
			return pageNo;
		}
	}

	/**
	 * 是否还有上一页.
	 */
	public boolean isHasPre() {
		return (pageNo - 1 >= 1);
	}

	/**
	 * 取得上页的页号, 序号从1开始.
	 * 当前页为首页时返回首页序号.
	 */
	public int getPrePage() {
		if (isHasPre()) {
			return pageNo - 1;
		} else {
			return pageNo;
		}
	}


    /**
     * 根据pageNo和pageSize计算当前页第一条记录在总结果集中的位置,序号从0开始.
     * 用于Mysql,Hibernate.
     */
    public int getOffset() {
         return ((pageNo - 1) * pageSize);
    	//return offset;
    }

    
    public void setOffset(int offset) {
        this.offset = offset;
    }
    
    /**
     * 根据pageNo和pageSize计算当前页第一条记录在总结果集中的位置,序号从1开始.
     * 用于Oracle.
     */
    public int getStartRow() {
            return getOffset() + 1;
    }

    /**
     * 根据pageNo和pageSize计算当前页最后一条记录在总结果集中的位置, 序号从1开始.
     * 用于Oracle.
     */
    public int getEndRow() {
        return pageSize * pageNo;
    }


	public int getPageCount() {
		//return pageCount;
		pageCount = ((int)this.totalCount + pageSize - 1) / pageSize;
		return pageCount;
	}


	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}


	
    public int getOffsetFromPageNo(){
    	return ((pageNo - 1) * pageSize);
    }
	
    public int getPageNoFromOffset(){
    	return offset/pageSize + 1;
    }
	
}
<file_sep>/src/main/java/com/xpown/utils/MapResult.java
package com.xpown.utils;
import java.util.HashMap;
import java.util.Map;

public class MapResult {

	public static Map<String, Object> initMap() {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("apicode", 10000);
		map.put("message", "成功");
		return map;
	}
	
	
	public static Map<String, Object> initMap(Integer apicode, String message) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("apicode", apicode);
		map.put("message", message);
		return map;
	}


	public static Map<String, Object> failMap() {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("apicode", 9999);
		map.put("message", "系统错误，请重试");
		return map;
	}
	
	
	
}
<file_sep>/src/main/java/com/xpown/controller/GoodsController.java
package com.xpown.controller;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
import java.util.Map;

import javax.annotation.Resource;

import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xpown.model.Goods;
import com.xpown.service.GoodsService;
import com.xpown.utils.MapResult;

@Controller
@RequestMapping("/goods")
public class GoodsController {

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

	@Resource
	private GoodsService goodsService;

	@RequestMapping(value = "getGoodsList", produces = "plain/text;charset=UTF-8")
	@ResponseBody
	public Map<String, Object> getGoodsList(
			@RequestParam(required = true) String appkey,
			@RequestParam(required = false) String category,
			@RequestParam(required = false) String goodsId,
			@RequestParam(defaultValue = "20") int pageSize) {
		try {
			Map<String, Object> ret = MapResult.initMap();
			ret.put("result", goodsService.getGoodsList(appkey,category,goodsId, pageSize));
			return ret;
		} catch (Exception e) {
			logger.error("", e);
			return MapResult.failMap();
		}
	}
	
	/**
	 * 定时器
	 */
	@RequestMapping(value = "insertData")
	@ResponseBody
	public void insertData() {
		importGoodsFromTao("5nkulide4r");
		importGoodsFromTao("021hjz3v3k");
	}

	/**
	 * 从大淘客后台导入数据
	 * @param appkey
	 * @return
	 */
	public void importGoodsFromTao(String appkey) {
		try {
			String result = getTaoData("http://api.dataoke.com/index.php",
					appkey);
			JSONObject jsonObj = new JSONObject(result);
			JSONObject data = jsonObj.getJSONObject("data");
			JSONArray goodsArray = data.getJSONArray("result");
			for (int i=0; i<goodsArray.length();i++) {
				JSONObject goodsObj = goodsArray.getJSONObject(i);
				Goods goods = new Goods();
				goods.setGoodsId(goodsObj.getString("GoodsID"));
				goods.setTitle(goodsObj.getString("Title"));
				goods.setPic(goodsObj.getString("Pic"));
				goods.setIntroduce(goodsObj.getString("Introduce"));
				goods.setPrice(goodsObj.getString("Org_Price"));
				goods.setCategory(goodsObj.getInt("Cid"));
				goods.setLink(goodsObj.getString("ali_click"));
				goods.setAppkey(appkey);
				goods.setCreateTime(new Date());
				goodsService.addGoods(goods);
			}
		} catch (Exception e) {
			logger.error("", e);
		}
	}

	/**
	 * 使用get方式登陆
	 * 
	 * @param username
	 * @param password
	 * @return
	 */
	public static String getTaoData(String url, String param) {
		HttpURLConnection conn = null;

		String data = "r=goodsLink/www&type=www_quan&appkey=" + param + "&v=2";
		url = url + "?" + data;
		try {
			URL mURL = new URL(url);
			conn = (HttpURLConnection) mURL.openConnection();

			conn.setRequestMethod("GET");
			conn.setReadTimeout(5000);
			conn.setConnectTimeout(10000);

			int responseCode = conn.getResponseCode();
			if (responseCode == 200) {
				InputStream is = conn.getInputStream();
				String result = getStringFromInputStream(is);
				return result;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (conn != null) {
				conn.disconnect();
			}
		}
		return null;
	}

	/**
	 * 根据流返回一个字符串信息 *
	 * 
	 * @param is
	 * @return
	 * @throws IOException
	 */
	private static String getStringFromInputStream(InputStream is)
			throws IOException {
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		byte[] buffer = new byte[1024];
		int len = -1;
		// 一定要写len=is.read(buffer)
		// 如果while((is.read(buffer))!=-1)则无法将数据写入buffer中
		while ((len = is.read(buffer)) != -1) {
			os.write(buffer, 0, len);
		}
		is.close();
		// 把流中的数据转换成字符串,采用的编码是utf-8(模拟器默认编码)
		String state = os.toString();
		os.close();
		return state;
	}
}
<file_sep>/src/main/java/com/xpown/model/User.java
package com.xpown.model;

import java.util.Date;

public class User {
	private int id;
	private String name;
	private String account;//淘宝账号
	private int unionId; // 微信unionId
	private Date createTime;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAccount() {
		return account;
	}
	public void setAccount(String account) {
		this.account = account;
	}
	public int getUnionId() {
		return unionId;
	}
	public void setUnionId(int unionId) {
		this.unionId = unionId;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
}
<file_sep>/src/main/java/com/xpown/service/UserService.java
package com.xpown.service;


import com.xpown.baseservice.BaseServiceMybatis;
import com.xpown.model.User;


public interface UserService extends BaseServiceMybatis<User, String>{

	
	
}
<file_sep>/src/main/resources/log4j.properties
log4j.rootCategory=INFO,stdout,conout,A,C

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Encoding=UTF-8
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{MM-dd HH:mm:ss} %p %l - %m%n

log4j.appender.conout=org.apache.log4j.DailyRollingFileAppender
log4j.appender.conout.Encoding=UTF-8
log4j.appender.conout.file=logs/info.log
log4j.appender.conout.DatePattern='.'yyyyMMdd
log4j.appender.conout.Threshold=INFO
log4j.appender.conout.layout=org.apache.log4j.PatternLayout
log4j.appender.conout.layout.ConversionPattern=%d{MM-dd HH:mm:ss} %p %l - %m%n


log4j.appender.A=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A.Encoding=UTF-8
log4j.appender.A.file=logs/error.log
log4j.appender.A.DatePattern='.'yyyyMMdd
log4j.appender.A.Threshold=error
log4j.appender.A.layout=org.apache.log4j.PatternLayout
log4j.appender.A.layout.ConversionPattern=%d{MM-dd HH:mm:ss} %p %l - %m%n

log4j.appender.C=org.apache.log4j.DailyRollingFileAppender
log4j.appender.C.Encoding=UTF-8
log4j.appender.C.file=logs/debug.log
log4j.appender.C.DatePattern='.'yyyyMMdd
log4j.appender.C.Threshold=debug
log4j.appender.C.layout=org.apache.log4j.PatternLayout
log4j.appender.C.layout.ConversionPattern=%d{MM-dd HH:mm:ss} %p %l - %m%n

log4j.logger.com.xpown=error<file_sep>/src/main/java/com/xpown/utils/ConfigUtil.java
package com.xpown.utils;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

public class ConfigUtil {

    private static PropertiesConfiguration config = null;
    
    static {
        try {
            config = new PropertiesConfiguration();
            config.setEncoding("UTF-8");
            config.load("app.properties");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static int getIntValue(final String key) {
        int reInt = 0;
        try {
            reInt = config.getInt(key);
        } catch (Exception ex) {
            ex.fillInStackTrace();
        }
        return reInt;
    }

    public static long getLongValue(final String key) {
        long reLong = 0;
        try {
            reLong = config.getLong(key);
        } catch (Exception ex) {
            ex.fillInStackTrace();
        }

        return reLong;
    }

    public static double getDoubleValue(final String key) {
        double reDouble = 0;
        try {
            reDouble = config.getDouble(key);
        } catch (Exception ex) {
            ex.fillInStackTrace();
        }

        return reDouble;
    }

    public static String getStringValue(String key) {
        String str = "";
        try {
            str = config.getString(key);
        } catch (Exception ex) {
            ex.fillInStackTrace();
        }
        return str;
    }

    public static boolean getBooleanValue(String key) {
        boolean flag = false;
        try {
            flag = config.getBoolean(key);
        } catch (Exception ex) {
            ex.fillInStackTrace();
        }

        return flag;
    }

    public static void save(String key, Object o) {
        config.setProperty(key, o);

        try {
            config.save("app.properties");
            config = new PropertiesConfiguration();
            config.setEncoding("UTF-8");
            config.load("app.properties");
        } catch (ConfigurationException e) {
            e.printStackTrace();
        }
    }
}
<file_sep>/src/main/java/com/xpown/utils/AppListener.java
package com.xpown.utils;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;


public class AppListener implements ServletContextListener {

	public void contextInitialized(ServletContextEvent sce) {
		ServletContext sc = sce.getServletContext();
		sc.setAttribute("wxappid", ConfigUtil.getStringValue("wxappid"));
		sc.setAttribute("domain", ConfigUtil.getStringValue("domain"));
	}

	public void contextDestroyed(ServletContextEvent sce) {
	}
}
<file_sep>/src/main/java/com/xpown/model/Goods.java
package com.xpown.model;

import java.util.Date;

public class Goods {
	
	private int id;
	private String goodsId;
	private String title;
	private String introduce;
	private String pic;
	private String price;
	private int category;
	private String link; //淘宝购物链接
	private String quanlink;
	private String appkey;
	private Date createTime;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getGoodsId() {
		return goodsId;
	}
	public void setGoodsId(String goodsId) {
		this.goodsId = goodsId;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getIntroduce() {
		return introduce;
	}
	public String getPic() {
		return pic;
	}
	public void setPic(String pic) {
		this.pic = pic;
	}
	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}
	public String getPrice() {
		return price;
	}
	public void setPrice(String price) {
		this.price = price;
	}
	public int getCategory() {
		return category;
	}
	public void setCategory(int category) {
		this.category = category;
	}
	public String getLink() {
		return link;
	}
	public void setLink(String link) {
		this.link = link;
	}
	public String getQuanlink() {
		return quanlink;
	}
	public void setQuanlink(String quanlink) {
		this.quanlink = quanlink;
	}
	public String getAppkey() {
		return appkey;
	}
	public void setAppkey(String appkey) {
		this.appkey = appkey;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
}
<file_sep>/src/main/java/com/xpown/dao/GoodsDao.java
package com.xpown.dao;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.xpown.model.Goods;
import com.xpown.mybatis.BaseMybatisDao;

@Repository
public class GoodsDao<E> extends BaseMybatisDao<Goods, String> {
	
	public String getMybatisMapperNamesapce() {
		return "com.xpown.model.GoodsMapper";
	}

	public List<Goods> getGoodsList(Map<String, Object> param) {
		return this.getSqlSession().selectList(this.getMybatisMapperNamesapce() + ".getGoodsList", param);
	}
}<file_sep>/src/main/java/com/xpown/serviceImpl/UserServiceImpl.java
package com.xpown.serviceImpl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xpown.baseservice.BaseServiceMybatisImpl;
import com.xpown.dao.UserDao;
import com.xpown.model.User;
import com.xpown.mybatis.EntityDao;
import com.xpown.service.UserService;

@Service
@Transactional
public class UserServiceImpl extends BaseServiceMybatisImpl<User, String>
		implements UserService {

	@Resource
	private UserDao<?> userDao;

	@Override
	protected EntityDao<User, Integer> getEntityDao() {
		return userDao;
	}

}
<file_sep>/src/main/java/com/xpown/service/GoodsService.java
package com.xpown.service;

import java.util.List;

import com.xpown.baseservice.BaseServiceMybatis;
import com.xpown.model.Goods;

public interface GoodsService extends BaseServiceMybatis<Goods, String> {

	List<Goods> getGoodsList(String keyword, String goodsId, String category, int pageSize);

	void addGoods(Goods goods);

}
<file_sep>/src/main/java/com/xpown/dao/UserDao.java
package com.xpown.dao;

import org.springframework.stereotype.Repository;

import com.xpown.model.User;
import com.xpown.mybatis.BaseMybatisDao;


@Repository("userDao")
public class UserDao<E> extends BaseMybatisDao<User, Integer> {

	@Override
	public String getMybatisMapperNamesapce() {
		return "com.xpown.model.UserMapper";
	}
	
}
