天天看點

電商三十四、代碼生成器

①代碼生成器

電商三十四、代碼生成器

不要将代碼生成器的執行檔案(heima_code_util.exe)放在中文目錄下執行,否則會遇到很多坑。其他檔案可以放在中文目錄。

如下:

一、

D:\HeimaCodeUtil_V2.4change\模闆\SSM+dubbox+angularJS(服務層+WEB層)\工程模闆\[path_2]-[path_3]-interface\src\main\java\[path_1]\[path_2]\[path_3]\service

[path_1]是com

[path_2]是pinyougou

[path_3]是sellergoods

裡面有個檔案[Table2]Service.java  内容:

package [package].service;
import java.util.List;
import [path_1].[path_2].pojo.Tb[Table2];

import entity.PageAndSize;
import entity.PageAndSizeAndTb[Table2];
import entity.PageResult;
/**
 * [comment]服務層接口
 * @author Administrator
 *
 */
public interface [Table2]Service {

	/**
	 * 傳回全部清單
	 * @return
	 */
	public List<Tb[Table2]> findAll();
	
	
	/**
	 * 傳回分頁清單
	 * @return
	 */
	//public PageResult findPage(int pageNum,int pageSize);
    public PageResult findPage(PageAndSize pageAndSize);
	
	
	/**
	 * 增加
	*/
	public void add(Tb[Table2] [table2]);
	
	
	/**
	 * 修改
	 */
	public void update(Tb[Table2] [table2]);
	

	/**
	 * 根據ID擷取實體
	 * @param id
	 * @return
	 */
	public Tb[Table2] findOne(Long id);
	
	
	/**
	 * 批量删除
	 * @param ids
	 */
	//public void delete(Long [] ids);
	public void delete(List<Long> ids);


	/**
	 * 分頁
	 * @param pageNum 目前頁 碼
	 * @param pageSize 每頁記錄數
	 * @return
	 */
	//public PageResult findPage(Tb[Table2] [table2], int pageNum,int pageSize);
	public PageResult findPage(PageAndSizeAndTb[Table2] pageAndSizeAndTb[Table2]);
	
}
           

二、D:\HeimaCodeUtil_V2.4change\模闆\SSM+dubbox+angularJS(服務層+WEB層)\工程模闆\[path_2]-[path_3]-service\src\main\java\[path_1]\[path_2]\[path_3]\service\impl

[path_1]是com

[path_2]是pinyougou

[path_3]是sellergoods

裡面有個檔案[Table2]ServiceImpl.java 内容為:

package [package].service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import [path_1].[path_2].mapper.Tb[Table2]Mapper;
import [path_1].[path_2].pojo.Tb[Table2];
import com.pinyougou.pojo.Tb[Table2]Example;
import com.pinyougou.pojo.Tb[Table2]Example.Criteria;
import [package].service.[Table2]Service;

import entity.PageAndSize;
import entity.PageAndSizeAndTb[Table2];
import entity.PageResult;

/**
 * [comment]服務實作層
 * @author Administrator
 *
 */
@Service
public class [Table2]ServiceImpl implements [Table2]Service {

	@Autowired
	private Tb[Table2]Mapper [table2]Mapper;
	
	/**
	 * 查詢全部
	 */
	@Override
	public List<Tb[Table2]> findAll() {
		return [table2]Mapper.selectByExample(null);
	}

	/**
	 * 按分頁查詢
	 */
	@Override
	/**
	public PageResult findPage(int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);		
		Page<Tb[Table2]> page=   (Page<Tb[Table2]>) [table2]Mapper.selectByExample(null);
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
	public PageResult findPage(PageAndSize pageAndSize) {
		PageHelper.startPage(pageAndSize.getPageNum(), pageAndSize.getSizeNum());
		Page<Tb[Table2]> page = (Page<Tb[Table2]>)[table2]Mapper.selectByExample(null);
		return new PageResult(page.getTotal(),page.getResult());
	}






	/**
	 * 增加
	 */
	@Override
	public void add(Tb[Table2] [table2]) {
		[table2]Mapper.insert([table2]);		
	}

	
	/**
	 * 修改
	 */
	@Override
	public void update(Tb[Table2] [table2]){
		[table2]Mapper.updateByPrimaryKey([table2]);
	}	
	
	/**
	 * 根據ID擷取實體
	 * @param id
	 * @return
	 */
	@Override
	public Tb[Table2] findOne(Long id){
		return [table2]Mapper.selectByPrimaryKey(id);
	}

	/**
	 * 批量删除
	 */
	@Override
	/**
	public void delete(Long[] ids) {
		for(Long id:ids){
			[table2]Mapper.deleteByPrimaryKey(id);
		}		
	}
	**/
	public void delete(List<Long> ids) {
		for(Long id:ids) {	
			[table2]Mapper.deleteByPrimaryKey(id);
		}
	}



	
	
	@Override
	/**
	public PageResult findPage(Tb[Table2] [table2], int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		
		Tb[Table2]Example example=new Tb[Table2]Example();
		Criteria criteria = example.createCriteria();
		
		if([table2]!=null){			
			<條件查詢.String.txt>	
		}
		
		Page<Tb[Table2]> page= (Page<Tb[Table2]>)[table2]Mapper.selectByExample(example);		
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
		public PageResult findPage(PageAndSizeAndTb[Table2] pageAndSizeAndTb[Table2]) {
		PageHelper.startPage(pageAndSizeAndTb[Table2].getPageNum(), pageAndSizeAndTb[Table2].getSizeNum());
		Tb[Table2]Example example = new Tb[Table2]Example();
		Criteria criteria = example.createCriteria();
		if(pageAndSizeAndTb[Table2].get[Table2]() != null) {
			if(pageAndSizeAndTb[Table2].get[Table2]().getName() != null 
					&& pageAndSizeAndTb[Table2].get[Table2]().getName().length()>0) {
				criteria.andNameLike("%"+pageAndSizeAndTb[Table2].get[Table2]().getName()+"%");
			}
			
			if(pageAndSizeAndTb[Table2].get[Table2]().getFirstChar() != null 
					&& pageAndSizeAndTb[Table2].get[Table2]().getFirstChar().length()>0) {
				criteria.andFirstCharLike("%"+pageAndSizeAndTb[Table2].get[Table2]().getFirstChar()+"%");
			}
		}	
		Page<Tb[Table2]> page = (Page<Tb[Table2]>)[table2]Mapper.selectByExample(example);
		return new PageResult(page.getTotal(),page.getResult());
	}





	
}
           

三、D:\HeimaCodeUtil_V2.4change\模闆\SSM+dubbox+angularJS(服務層+WEB層)\工程模闆\[path_2]-[path_3]-web\src\main\java\[path_1]\[path_2]\[path_3]\controller

[path_1]是com

[path_2]是pinyougou

[path_3]是sellergoods

裡面有個檔案[Table2]Controller.java 内容為:

package [package].controller;
import java.util.List;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.dubbo.config.annotation.Reference;
import [path_1].[path_2].pojo.Tb[Table2];
import [path_1].[path_2].[path_3].service.[Table2]Service;


import entity.IdResult;
import entity.PageAndSize;
import entity.PageAndSizeAndTb[Table2];
import entity.PageResult;
import entity.Result;
/**
 * [comment]controller
 * @author Administrator
 *
 */
@RestController
@RequestMapping("/[table2]")
public class [Table2]Controller {

	@Reference
	private [Table2]Service [table2]Service;
	
	/**
	 * 傳回全部清單
	 * @return
	 */
	@RequestMapping("/findAll")
	public List<Tb[Table2]> findAll(){			
		return [table2]Service.findAll();
	}
	
	
	/**
	 * 傳回全部清單
	 * @return
	 */
	 /**
	@RequestMapping("/findPage")
	public PageResult  findPage(int page,int rows){			
		return [table2]Service.findPage(page, rows);
	}
	**/
	@RequestMapping("/findPage")
	public PageResult findPage(@RequestBody PageAndSize pageAndSize) {
	
		return [table2]Service.findPage(pageAndSize);
	}



	
	/**
	 * 增加
	 * @param [table2]
	 * @return
	 */
	@RequestMapping("/add")
	public Result add(@RequestBody Tb[Table2] [table2]){
		try {
			[table2]Service.add([table2]);
			return new Result(true, "增加成功");
		} catch (Exception e) {
			e.printStackTrace();
			return new Result(false, "增加失敗");
		}
	}
	
	/**
	 * 修改
	 * @param [table2]
	 * @return
	 */
	@RequestMapping("/update")
	public Result update(@RequestBody Tb[Table2] [table2]){
		try {
			[table2]Service.update([table2]);
			return new Result(true, "修改成功");
		} catch (Exception e) {
			e.printStackTrace();
			return new Result(false, "修改失敗");
		}
	}	
	
	/**
	 * 擷取實體
	 * @param id
	 * @return
	 */
	 /**
	@RequestMapping("/findOne")
	public Tb[Table2] findOne(Long id){
		return [table2]Service.findOne(id);		
	}
	**/
    @RequestMapping("findOne")
	public Tb[Table2] findOne(@RequestBody IdResult idResult) {
		return [table2]Service.findOne(idResult.getId());
	}



	
	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	 /**
	@RequestMapping("/delete")
	public Result delete(Long [] ids){
		try {
			[table2]Service.delete(ids);
			return new Result(true, "删除成功"); 
		} catch (Exception e) {
			e.printStackTrace();
			return new Result(false, "删除失敗");
		}
	}
	**/
	@RequestMapping("/delete")
	public Result delete(@RequestBody List<IdResult> idResults) {	
		List<Long>  ids = new ArrayList<Long>();
		int i=0;
		if(idResults.size()>0) {
			for(IdResult idResult:idResults) {
				ids.add(idResult.getId());
				i++;
				
			}
		}		
		try {
			[table2]Service.delete(ids);
			return new Result(true,"删除成功");
		} catch (Exception e) {
			e.printStackTrace();
			return new Result(false,"删除失敗");
		}
		
	}
	





	
	/**
	 * 查詢+分頁
	 * @param brand
	 * @param page
	 * @param rows
	 * @return
	 */
	 /**
	@RequestMapping("/search")
	public PageResult search(@RequestBody Tb[Table2] [table2], int page, int rows  ){
		return [table2]Service.findPage([table2], page, rows);		
	}
	**/
	@RequestMapping("/search")
	public PageResult search(@RequestBody PageAndSizeAndTb[Table2]  pageAndSizeAndTb[Table2]) {
		return [table2]Service.findPage(pageAndSizeAndTb[Table2]);
	}


	
}
           

四、D:\HeimaCodeUtil_V2.4change\模闆\SSM+dubbox+angularJS(服務層+WEB層)\工程模闆\[path_2]-[path_3]-web\src\main\webapp\js\service

[path_1]是com

[path_2]是pinyougou

[path_3]是sellergoods

裡面有一個檔案[table2]Service.js(TFILE) 的内容為:

//[comment]服務層
/**
app.service('[table2]Service',function($http){
	    	
	//讀取清單資料綁定到表單中
	this.findAll=function(){
		return $http.get('../[table2]/findAll.do');		
	}
	//分頁 
	this.findPage=function(page,rows){
		return $http.get('../[table2]/findPage.do?page='+page+'&rows='+rows);
	}
	//查詢實體
	this.findOne=function(id){
		return $http.get('../[table2]/findOne.do?id='+id);
	}
	//增加 
	this.add=function(entity){
		return  $http.post('../[table2]/add.do',entity );
	}
	//修改 
	this.update=function(entity){
		return  $http.post('../[table2]/update.do',entity );
	}
	//删除
	this.dele=function(ids){
		return $http.get('../[table2]/delete.do?ids='+ids);
	}
	//搜尋
	this.search=function(page,rows,searchEntity){
		return $http.post('../[table2]/search.do?page='+page+"&rows="+rows, searchEntity);
	}    	
});
**/
		//app為子產品對象,控制器有控制器的名字,服務也要有服務的名字。
		//和控制器一樣也是有function并且可以接受參數和内容。
		//品牌服務
		app.service("[table2]Service",function($http){
			//不能用$scope,要用this,這是他本身。
			this.findAll = function(){
				//.success後面的内容,$scope.list = response;給了視圖
				//與視圖互動,又與後端互動
				//.success後面的内容是控制層的内容。
				//是以隻寫前面的内容$http.get('../brand/findAll.do');
				return $http.get('../[table2]/findAll.do');
			}
			
			this.findPage = function(entity08){
				return $http.post('../[table2]/findPage.do',entity08);
			}
			
		    this.findOne = function(entity09){
		    	return $http.post("../[table2]/findOne.do",entity09);
		    }
		    
		    
		    this.add = function(entity06){
		    	return $http.post('../[table2]/add.do', entity06);
		    }
		    
		    this.update = function(entity07){
				return $http.post('../[table2]/update.do', entity07);
			}
		    
		    this.dele = function(entity10){	
				return $http.post('../[table2]/delete.do',entity10);
			}
		    
		    this.search = function(entity11){	
				return $http.post("../[table2]/search.do",entity11);
			}
			
		});
           

五、D:\HeimaCodeUtil_V2.4change\模闆\SSM+dubbox+angularJS(服務層+WEB層)\工程模闆\[path_2]-[path_3]-web\src\main\webapp\js\controller

[path_1]是com

[path_2]是pinyougou

[path_3]是sellergoods

裡面有一個檔案[table2]Controller.js(TFILE) 的内容為:

//[comment]控制層 
 /**
app.controller('[table2]Controller' ,function($scope,$controller   ,[table2]Service){	
	
	$controller('baseController',{$scope:$scope});//繼承
	
    //讀取清單資料綁定到表單中  
	$scope.findAll=function(){
		[table2]Service.findAll().success(
			function(response){
				$scope.list=response;
			}			
		);
	}    
	
	//分頁
	$scope.findPage=function(page,rows){			
		[table2]Service.findPage(page,rows).success(
			function(response){
				$scope.list=response.rows;	
				$scope.paginationConf.totalItems=response.total;//更新總記錄數
			}			
		);
	}
	
	//查詢實體 
	$scope.findOne=function(id){				
		[table2]Service.findOne(id).success(
			function(response){
				$scope.entity= response;					
			}
		);				
	}
	
	//儲存 
	$scope.save=function(){				
		var serviceObject;//服務層對象  				
		if($scope.entity.id!=null){//如果有ID
			serviceObject=[table2]Service.update( $scope.entity ); //修改  
		}else{
			serviceObject=[table2]Service.add( $scope.entity  );//增加 
		}				
		serviceObject.success(
			function(response){
				if(response.success){
					//重新查詢 
		        	$scope.reloadList();//重新加載
				}else{
					alert(response.message);
				}
			}		
		);				
	}
	
	 
	//批量删除 
	$scope.dele=function(){			
		//擷取選中的複選框			
		[table2]Service.dele( $scope.selectIds ).success(
			function(response){
				if(response.success){
					$scope.reloadList();//重新整理清單
				}						
			}		
		);				
	}
	
	$scope.searchEntity={};//定義搜尋對象 
	
	//搜尋
	$scope.search=function(page,rows){			
		[table2]Service.search(page,rows,$scope.searchEntity).success(
			function(response){
				$scope.list=response.rows;	
				$scope.paginationConf.totalItems=response.total;//更新總記錄數
			}			
		);
	}
    
});
**/





app.controller('[table2]Controller',function($scope,$controller,[table2]Service){
		
		$controller('baseController',{$scope:$scope});//控制器的繼承
	
		/**
		$scope.$on('ngRepeatFinished', function(){				
			    	//可執行DOM操作
					  for(var i=0;i<  $scope.selectIds.length;i++){
					  for(var j=0;j<$scope.list.length;j++){
				      if( $scope.list[j].id ==  $scope.selectIds[i]){ 
		//在渲染 完成後,對複選框的 顯示進行更新,false表示不勾選,true表示勾選
				     document.getElementById(String($scope.list[j].id)).checked = $scope.boxes[$scope.list[j].id];
				           		}
				           }}
				});
		**/		
				
			
			
			//查詢品牌清單資料
			$scope.findAll = function(){
			//之前的通路json的路徑是http://localhost:9101/brand/findAll.do	
		    //則現在,在brand.html檔案../傳回根目錄,webapp根目錄,再尋找/brand/findAll.do	
			[table2]Service.findAll().success(
					function(response){
						$scope.list = response;
					}
			);	
			}
			
			
			
			/**
			$scope.paginationConf = {
					//目前頁
					currentPage : 1,
					//總記錄數
					totalItems : 10,
					//每頁記錄數
					itemsPerPage : 10,
					//分頁選項,下拉菜單
					perPageOptions : [ 10, 20, 30, 40, 50 ],
					//當頁碼重新變更後自動觸發的方法
					onChange : function() {
						$scope.reloadList();
						 }};
			**/
			
			
			
			
			
			//這個前端的方法名稱findPage不一定要和後端的findPage方法名稱一樣,可以随意取
			//隻不過去一樣的名稱好辨識一些。
			//分頁
			$scope.findPage = function(){
				$scope.entity02 = {
						
						pageNum: $scope.paginationConf.currentPage,
						sizeNum: $scope.paginationConf.itemsPerPage
				};
				[table2]Service.findPage($scope.entity02).success(
					function(response){
						//顯示目前一頁的[{},{},...{}]内容
						$scope.list = response.rows;
						
						//更改更新總記錄數,更改此變量值,前端分頁控件
						//自動獲得值
						$scope.paginationConf.totalItems = response.total;
					}		
				
				);
				
			}
			
			
			/**
			$scope.reloadList = function(){
				//$scope.findPage();
				$scope.search();//否則又會還原成全部的資料呈現
			}
			**/
			
			//儲存
		
			$scope.save = function(){
				var object = null;
				if($scope.entity.id != null){
					object = [table2]Service.update($scope.entity);
				}else{
					object = [table2]Service.add($scope.entity);
				}
				object.success(
						function(response){
							if(response.success){
								$scope.reloadList();//重新整理
							}else{
								alert(response.message);
							}
						}
				);
			}
			
			
			$scope.findOne = function($event){
				$scope.entity03= {id: $event.target.parentNode.parentNode.children[1].innerText}
				[table2]Service.findOne($scope.entity03).success(
						function(response){
							$scope.entity = response;
						}
					);
			}
			
			
			
			
			/**
			$scope.selectIds = [];//使用者勾選的ID集合
			$scope.boxes = [];//儲存複選框被選的狀态,true(勾選)或者false(不勾選)			
			$scope.updateSelectIds = function($event,id){	   
				if($event.target.checked){
					$scope.selectIds.push(id);//push向集合添加元素	
				}else{	
					var index = $scope.selectIds.indexOf(id);//查找id值在集合中的位置
					if(index != -1){
						$scope.selectIds.splice(index,1);//從某個位置移掉幾個元素
					}
				}
				$scope.saveStatus();
			}			
			//儲存CheckBox複選框的true和false的狀态
			$scope.saveStatus = function(){
				for(var j=0;j<$scope.list.length;j++){		
					 for(var i=0;i< $scope.selectIds.length;i++){
			//從第0位查找id為$scope.list[j].id的值,是否有這個id在$scope.selectIds裡
				           if($scope.selectIds.indexOf($scope.list[j].id,0)!=-1){
				               $scope.boxes[$scope.list[j].id] = true;
				           }else{
				               $scope.boxes[$scope.list[j].id]= false;
				           	} 
				           }	
				}
			}
			**/
			
			

			$scope.dele = function(){
				$scope.entity04=[];
				for(var i=0;i<$scope.selectIds.length;i++){
					$scope.entity04.push({id: $scope.selectIds[i]}) ;
				}
				[table2]Service.dele($scope.entity04).success(
					function(response){
						for(var i=0;i<$scope.selectIds.length;i++){
							//查找id值在集合中的位置
							var index = $scope.selectIds.indexOf($scope.selectIds[i]);
							if(index != -1){
								$scope.selectIds.splice(index,1);//從某個位置移掉幾個元素
							}	
						}
						if(response.success){
							$scope.reloadList();
						}else{
							alert(response.message);
						}
					}		
				);				
			}
			
			/**
			$scope.searchEntity = {};
			**/
			
			
			
			//條件查詢
			$scope.search = function(){		
				$scope.entity05 = {		
						pageNum: $scope.paginationConf.currentPage,
						sizeNum: $scope.paginationConf.itemsPerPage,
						brand: $scope.searchEntity
				};			
				[table2]Service.search($scope.entity05).success(
						function(response) {				
							$scope.list = response.rows;
							$scope.paginationConf.totalItems = response.total;
						}
						)		
			}
	
		});
	
           

六、D:\HeimaCodeUtil_V2.4change\模闆\SSM+dubbox+angularJS(服務層+WEB層)\工程模闆\pinyougou02-pojo\src\main\java\entity

裡面有個檔案PageAndSizeAndTb[Table2].java 内容為:

package entity;

import java.io.Serializable;

import com.pinyougou.pojo.Tb[Table2];

public class PageAndSizeAndTb[Table2] implements Serializable{

	private int pageNum;
	private int sizeNum;
	private Tb[Table2]  [table2];
	
	
	public PageAndSizeAndTb[Table2]() {
		super();
	}


	public PageAndSizeAndTb[Table2](int pageNum, int sizeNum, Tb[Table2]  [table2]) {
		super();
		this.pageNum = pageNum;
		this.sizeNum = sizeNum;
		this.[table2] = [table2];
	}


	public int getPageNum() {
		return pageNum;
	}


	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}


	public int getSizeNum() {
		return sizeNum;
	}


	public void setSizeNum(int sizeNum) {
		this.sizeNum = sizeNum;
	}


	public Tb[Table2]  get[Table2]() {
		return [table2];
	}


	public void set[Table2](Tb[Table2]  [table2]) {
		this.[table2] = [table2];
	}
	
	
	
	
	
	
	
}
           

七、D:\HeimaCodeUtil_V2.4change

電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器

八、複制相關代碼到目前工程内部

C:\Users\Administrator\Desktop\testcode\pinyougou-sellergoods-interface\src\main\java\com\pinyougou\sellergoods\service

先拿interface的相關内容,有選擇的拿。

電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器

九、複制相關代碼到目前工程内部

C:\Users\Administrator\Desktop\testcode\pinyougou02-pojo\src\main\java\entity

電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器

十、複制相關代碼到目前工程内部

C:\Users\Administrator\Desktop\testcode\pinyougou-sellergoods-service\src\main\java\com\pinyougou\sellergoods\service\impl

電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器

會報錯。

如:GoodsDescServiceImpl.java 出錯

package com.pinyougou.sellergoods.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pinyougou.mapper.TbGoodsDescMapper;
import com.pinyougou.pojo.TbGoodsDesc;
import com.pinyougou.pojo.TbGoodsDescExample;
import com.pinyougou.pojo.TbGoodsDescExample.Criteria;
import com.pinyougou.sellergoods.service.GoodsDescService;

import entity.PageAndSize;
import entity.PageAndSizeAndTbGoodsDesc;
import entity.PageResult;

/**
 * 服務實作層
 * @author Administrator
 *
 */
@Service
public class GoodsDescServiceImpl implements GoodsDescService {

	@Autowired
	private TbGoodsDescMapper goodsDescMapper;
	
	/**
	 * 查詢全部
	 */
	@Override
	public List<TbGoodsDesc> findAll() {
		return goodsDescMapper.selectByExample(null);
	}

	/**
	 * 按分頁查詢
	 */
	@Override
	/**
	public PageResult findPage(int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);		
		Page<TbGoodsDesc> page=   (Page<TbGoodsDesc>) goodsDescMapper.selectByExample(null);
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
	public PageResult findPage(PageAndSize pageAndSize) {
		PageHelper.startPage(pageAndSize.getPageNum(), pageAndSize.getSizeNum());
		Page<TbGoodsDesc> page = (Page<TbGoodsDesc>)goodsDescMapper.selectByExample(null);
		return new PageResult(page.getTotal(),page.getResult());
	}






	/**
	 * 增加
	 */
	@Override
	public void add(TbGoodsDesc goodsDesc) {
		goodsDescMapper.insert(goodsDesc);		
	}

	
	/**
	 * 修改
	 */
	@Override
	public void update(TbGoodsDesc goodsDesc){
		goodsDescMapper.updateByPrimaryKey(goodsDesc);
	}	
	
	/**
	 * 根據ID擷取實體
	 * @param id
	 * @return
	 */
	@Override
	public TbGoodsDesc findOne(Long id){
		return goodsDescMapper.selectByPrimaryKey(id);
	}

	/**
	 * 批量删除
	 */
	@Override
	/**
	public void delete(Long[] ids) {
		for(Long id:ids){
			goodsDescMapper.deleteByPrimaryKey(id);
		}		
	}
	**/
	public void delete(List<Long> ids) {
		for(Long id:ids) {	
			goodsDescMapper.deleteByPrimaryKey(id);
		}
	}



	
	
	@Override
	/**
	public PageResult findPage(TbGoodsDesc goodsDesc, int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		
		TbGoodsDescExample example=new TbGoodsDescExample();
		Criteria criteria = example.createCriteria();
		
		if(goodsDesc!=null){			
						if(goodsDesc.getIntroduction()!=null && goodsDesc.getIntroduction().length()>0){
				criteria.andIntroductionLike("%"+goodsDesc.getIntroduction()+"%");
			}
			if(goodsDesc.getSpecificationItems()!=null && goodsDesc.getSpecificationItems().length()>0){
				criteria.andSpecificationItemsLike("%"+goodsDesc.getSpecificationItems()+"%");
			}
			if(goodsDesc.getCustomAttributeItems()!=null && goodsDesc.getCustomAttributeItems().length()>0){
				criteria.andCustomAttributeItemsLike("%"+goodsDesc.getCustomAttributeItems()+"%");
			}
			if(goodsDesc.getItemImages()!=null && goodsDesc.getItemImages().length()>0){
				criteria.andItemImagesLike("%"+goodsDesc.getItemImages()+"%");
			}
			if(goodsDesc.getPackageList()!=null && goodsDesc.getPackageList().length()>0){
				criteria.andPackageListLike("%"+goodsDesc.getPackageList()+"%");
			}
			if(goodsDesc.getSaleService()!=null && goodsDesc.getSaleService().length()>0){
				criteria.andSaleServiceLike("%"+goodsDesc.getSaleService()+"%");
			}
	
		}
		
		Page<TbGoodsDesc> page= (Page<TbGoodsDesc>)goodsDescMapper.selectByExample(example);		
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
		public PageResult findPage(PageAndSizeAndTbGoodsDesc pageAndSizeAndTbGoodsDesc) {
		PageHelper.startPage(pageAndSizeAndTbGoodsDesc.getPageNum(), pageAndSizeAndTbGoodsDesc.getSizeNum());
		TbGoodsDescExample example = new TbGoodsDescExample();
		Criteria criteria = example.createCriteria();
		if(pageAndSizeAndTbGoodsDesc.getGoodsDesc() != null) {
			if(pageAndSizeAndTbGoodsDesc.getGoodsDesc().getName() != null 
					&& pageAndSizeAndTbGoodsDesc.getGoodsDesc().getName().length()>0) {
				criteria.andNameLike("%"+pageAndSizeAndTbGoodsDesc.getGoodsDesc().getName()+"%");
			}
			
			if(pageAndSizeAndTbGoodsDesc.getGoodsDesc().getFirstChar() != null 
					&& pageAndSizeAndTbGoodsDesc.getGoodsDesc().getFirstChar().length()>0) {
				criteria.andFirstCharLike("%"+pageAndSizeAndTbGoodsDesc.getGoodsDesc().getFirstChar()+"%");
			}
		}	
		Page<TbGoodsDesc> page = (Page<TbGoodsDesc>)goodsDescMapper.selectByExample(example);
		return new PageResult(page.getTotal(),page.getResult());
	}





	
}
           
電商三十四、代碼生成器
電商三十四、代碼生成器

每一個都根據之前的注釋更改。

更改之後GoodsDescServiceImpl.java 不出錯,内容為:

package com.pinyougou.sellergoods.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pinyougou.mapper.TbGoodsDescMapper;
import com.pinyougou.pojo.TbGoodsDesc;
import com.pinyougou.pojo.TbGoodsDescExample;
import com.pinyougou.pojo.TbGoodsDescExample.Criteria;
import com.pinyougou.sellergoods.service.GoodsDescService;

import entity.PageAndSize;
import entity.PageAndSizeAndTbGoodsDesc;
import entity.PageResult;

/**
 * 服務實作層
 * @author Administrator
 *
 */
@Service
public class GoodsDescServiceImpl implements GoodsDescService {

	@Autowired
	private TbGoodsDescMapper goodsDescMapper;
	
	/**
	 * 查詢全部
	 */
	@Override
	public List<TbGoodsDesc> findAll() {
		return goodsDescMapper.selectByExample(null);
	}

	/**
	 * 按分頁查詢
	 */
	@Override
	/**
	public PageResult findPage(int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);		
		Page<TbGoodsDesc> page=   (Page<TbGoodsDesc>) goodsDescMapper.selectByExample(null);
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
	public PageResult findPage(PageAndSize pageAndSize) {
		PageHelper.startPage(pageAndSize.getPageNum(), pageAndSize.getSizeNum());
		Page<TbGoodsDesc> page = (Page<TbGoodsDesc>)goodsDescMapper.selectByExample(null);
		return new PageResult(page.getTotal(),page.getResult());
	}






	/**
	 * 增加
	 */
	@Override
	public void add(TbGoodsDesc goodsDesc) {
		goodsDescMapper.insert(goodsDesc);		
	}

	
	/**
	 * 修改
	 */
	@Override
	public void update(TbGoodsDesc goodsDesc){
		goodsDescMapper.updateByPrimaryKey(goodsDesc);
	}	
	
	/**
	 * 根據ID擷取實體
	 * @param id
	 * @return
	 */
	@Override
	public TbGoodsDesc findOne(Long id){
		return goodsDescMapper.selectByPrimaryKey(id);
	}

	/**
	 * 批量删除
	 */
	@Override
	/**
	public void delete(Long[] ids) {
		for(Long id:ids){
			goodsDescMapper.deleteByPrimaryKey(id);
		}		
	}
	**/
	public void delete(List<Long> ids) {
		for(Long id:ids) {	
			goodsDescMapper.deleteByPrimaryKey(id);
		}
	}



	
	
	@Override
	/**
	public PageResult findPage(TbGoodsDesc goodsDesc, int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		
		TbGoodsDescExample example=new TbGoodsDescExample();
		Criteria criteria = example.createCriteria();
		
		if(goodsDesc!=null){			
						if(goodsDesc.getIntroduction()!=null && goodsDesc.getIntroduction().length()>0){
				criteria.andIntroductionLike("%"+goodsDesc.getIntroduction()+"%");
			}
			if(goodsDesc.getSpecificationItems()!=null && goodsDesc.getSpecificationItems().length()>0){
				criteria.andSpecificationItemsLike("%"+goodsDesc.getSpecificationItems()+"%");
			}
			if(goodsDesc.getCustomAttributeItems()!=null && goodsDesc.getCustomAttributeItems().length()>0){
				criteria.andCustomAttributeItemsLike("%"+goodsDesc.getCustomAttributeItems()+"%");
			}
			if(goodsDesc.getItemImages()!=null && goodsDesc.getItemImages().length()>0){
				criteria.andItemImagesLike("%"+goodsDesc.getItemImages()+"%");
			}
			if(goodsDesc.getPackageList()!=null && goodsDesc.getPackageList().length()>0){
				criteria.andPackageListLike("%"+goodsDesc.getPackageList()+"%");
			}
			if(goodsDesc.getSaleService()!=null && goodsDesc.getSaleService().length()>0){
				criteria.andSaleServiceLike("%"+goodsDesc.getSaleService()+"%");
			}
	
		}
		
		Page<TbGoodsDesc> page= (Page<TbGoodsDesc>)goodsDescMapper.selectByExample(example);		
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
		public PageResult findPage(PageAndSizeAndTbGoodsDesc pageAndSizeAndTbGoodsDesc) {
		PageHelper.startPage(pageAndSizeAndTbGoodsDesc.getPageNum(), pageAndSizeAndTbGoodsDesc.getSizeNum());
		TbGoodsDescExample example = new TbGoodsDescExample();
		Criteria criteria = example.createCriteria();
		/**
		if(pageAndSizeAndTbGoodsDesc.getGoodsDesc() != null) {
			if(pageAndSizeAndTbGoodsDesc.getGoodsDesc().getName() != null 
					&& pageAndSizeAndTbGoodsDesc.getGoodsDesc().getName().length()>0) {
				criteria.andNameLike("%"+pageAndSizeAndTbGoodsDesc.getGoodsDesc().getName()+"%");
			}
			
			if(pageAndSizeAndTbGoodsDesc.getGoodsDesc().getFirstChar() != null 
					&& pageAndSizeAndTbGoodsDesc.getGoodsDesc().getFirstChar().length()>0) {
				criteria.andFirstCharLike("%"+pageAndSizeAndTbGoodsDesc.getGoodsDesc().getFirstChar()+"%");
			}
		}
		**/
		
		if(pageAndSizeAndTbGoodsDesc.getGoodsDesc()!=null){			
		if(pageAndSizeAndTbGoodsDesc.getGoodsDesc().getIntroduction()!=null && pageAndSizeAndTbGoodsDesc.getGoodsDesc().getIntroduction().length()>0){
			criteria.andIntroductionLike("%"+pageAndSizeAndTbGoodsDesc.getGoodsDesc().getIntroduction()+"%");
		}
		if(pageAndSizeAndTbGoodsDesc.getGoodsDesc().getSpecificationItems()!=null && pageAndSizeAndTbGoodsDesc.getGoodsDesc().getSpecificationItems().length()>0){
			criteria.andSpecificationItemsLike("%"+pageAndSizeAndTbGoodsDesc.getGoodsDesc().getSpecificationItems()+"%");
		}
		if(pageAndSizeAndTbGoodsDesc.getGoodsDesc().getCustomAttributeItems()!=null && pageAndSizeAndTbGoodsDesc.getGoodsDesc().getCustomAttributeItems().length()>0){
			criteria.andCustomAttributeItemsLike("%"+pageAndSizeAndTbGoodsDesc.getGoodsDesc().getCustomAttributeItems()+"%");
		}
		if(pageAndSizeAndTbGoodsDesc.getGoodsDesc().getItemImages()!=null && pageAndSizeAndTbGoodsDesc.getGoodsDesc().getItemImages().length()>0){
			criteria.andItemImagesLike("%"+pageAndSizeAndTbGoodsDesc.getGoodsDesc().getItemImages()+"%");
		}
		if(pageAndSizeAndTbGoodsDesc.getGoodsDesc().getPackageList()!=null && pageAndSizeAndTbGoodsDesc.getGoodsDesc().getPackageList().length()>0){
			criteria.andPackageListLike("%"+pageAndSizeAndTbGoodsDesc.getGoodsDesc().getPackageList()+"%");
		}
		if(pageAndSizeAndTbGoodsDesc.getGoodsDesc().getSaleService()!=null && pageAndSizeAndTbGoodsDesc.getGoodsDesc().getSaleService().length()>0){
			criteria.andSaleServiceLike("%"+pageAndSizeAndTbGoodsDesc.getGoodsDesc().getSaleService()+"%");
		}
		
		}
		
		Page<TbGoodsDesc> page = (Page<TbGoodsDesc>)goodsDescMapper.selectByExample(example);
		return new PageResult(page.getTotal(),page.getResult());
	}





	
}
           

GoodsServiceImpl.java 更改後的内容為:

package com.pinyougou.sellergoods.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pinyougou.mapper.TbGoodsMapper;
import com.pinyougou.pojo.TbGoods;
import com.pinyougou.pojo.TbGoodsExample;
import com.pinyougou.pojo.TbGoodsExample.Criteria;
import com.pinyougou.sellergoods.service.GoodsService;

import entity.PageAndSize;
import entity.PageAndSizeAndTbGoods;
import entity.PageResult;

/**
 * 服務實作層
 * @author Administrator
 *
 */
@Service
public class GoodsServiceImpl implements GoodsService {

	@Autowired
	private TbGoodsMapper goodsMapper;
	
	/**
	 * 查詢全部
	 */
	@Override
	public List<TbGoods> findAll() {
		return goodsMapper.selectByExample(null);
	}

	/**
	 * 按分頁查詢
	 */
	@Override
	/**
	public PageResult findPage(int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);		
		Page<TbGoods> page=   (Page<TbGoods>) goodsMapper.selectByExample(null);
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
	public PageResult findPage(PageAndSize pageAndSize) {
		PageHelper.startPage(pageAndSize.getPageNum(), pageAndSize.getSizeNum());
		Page<TbGoods> page = (Page<TbGoods>)goodsMapper.selectByExample(null);
		return new PageResult(page.getTotal(),page.getResult());
	}






	/**
	 * 增加
	 */
	@Override
	public void add(TbGoods goods) {
		goodsMapper.insert(goods);		
	}

	
	/**
	 * 修改
	 */
	@Override
	public void update(TbGoods goods){
		goodsMapper.updateByPrimaryKey(goods);
	}	
	
	/**
	 * 根據ID擷取實體
	 * @param id
	 * @return
	 */
	@Override
	public TbGoods findOne(Long id){
		return goodsMapper.selectByPrimaryKey(id);
	}

	/**
	 * 批量删除
	 */
	@Override
	/**
	public void delete(Long[] ids) {
		for(Long id:ids){
			goodsMapper.deleteByPrimaryKey(id);
		}		
	}
	**/
	public void delete(List<Long> ids) {
		for(Long id:ids) {	
			goodsMapper.deleteByPrimaryKey(id);
		}
	}



	
	
	@Override
	/**
	public PageResult findPage(TbGoods goods, int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		
		TbGoodsExample example=new TbGoodsExample();
		Criteria criteria = example.createCriteria();
		
		if(goods!=null){			
						if(goods.getSellerId()!=null && goods.getSellerId().length()>0){
				criteria.andSellerIdLike("%"+goods.getSellerId()+"%");
			}
			if(goods.getGoodsName()!=null && goods.getGoodsName().length()>0){
				criteria.andGoodsNameLike("%"+goods.getGoodsName()+"%");
			}
			if(goods.getAuditStatus()!=null && goods.getAuditStatus().length()>0){
				criteria.andAuditStatusLike("%"+goods.getAuditStatus()+"%");
			}
			if(goods.getIsMarketable()!=null && goods.getIsMarketable().length()>0){
				criteria.andIsMarketableLike("%"+goods.getIsMarketable()+"%");
			}
			if(goods.getCaption()!=null && goods.getCaption().length()>0){
				criteria.andCaptionLike("%"+goods.getCaption()+"%");
			}
			if(goods.getSmallPic()!=null && goods.getSmallPic().length()>0){
				criteria.andSmallPicLike("%"+goods.getSmallPic()+"%");
			}
			if(goods.getIsEnableSpec()!=null && goods.getIsEnableSpec().length()>0){
				criteria.andIsEnableSpecLike("%"+goods.getIsEnableSpec()+"%");
			}
			if(goods.getIsDelete()!=null && goods.getIsDelete().length()>0){
				criteria.andIsDeleteLike("%"+goods.getIsDelete()+"%");
			}
	
		}
		
		Page<TbGoods> page= (Page<TbGoods>)goodsMapper.selectByExample(example);		
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
		public PageResult findPage(PageAndSizeAndTbGoods pageAndSizeAndTbGoods) {
		PageHelper.startPage(pageAndSizeAndTbGoods.getPageNum(), pageAndSizeAndTbGoods.getSizeNum());
		TbGoodsExample example = new TbGoodsExample();
		Criteria criteria = example.createCriteria();
		
		/**
		if(pageAndSizeAndTbGoods.getGoods() != null) {
			if(pageAndSizeAndTbGoods.getGoods().getName() != null 
					&& pageAndSizeAndTbGoods.getGoods().getName().length()>0) {
				criteria.andNameLike("%"+pageAndSizeAndTbGoods.getGoods().getName()+"%");
			}
			
			if(pageAndSizeAndTbGoods.getGoods().getFirstChar() != null 
					&& pageAndSizeAndTbGoods.getGoods().getFirstChar().length()>0) {
				criteria.andFirstCharLike("%"+pageAndSizeAndTbGoods.getGoods().getFirstChar()+"%");
			}
		}	
		**/
		
		if(pageAndSizeAndTbGoods.getGoods()!=null){			
		if(pageAndSizeAndTbGoods.getGoods().getSellerId()!=null && pageAndSizeAndTbGoods.getGoods().getSellerId().length()>0){
		criteria.andSellerIdLike("%"+pageAndSizeAndTbGoods.getGoods().getSellerId()+"%");
		}
		if(pageAndSizeAndTbGoods.getGoods().getGoodsName()!=null && pageAndSizeAndTbGoods.getGoods().getGoodsName().length()>0){
			criteria.andGoodsNameLike("%"+pageAndSizeAndTbGoods.getGoods().getGoodsName()+"%");
		}
		if(pageAndSizeAndTbGoods.getGoods().getAuditStatus()!=null && pageAndSizeAndTbGoods.getGoods().getAuditStatus().length()>0){
			criteria.andAuditStatusLike("%"+pageAndSizeAndTbGoods.getGoods().getAuditStatus()+"%");
		}
		if(pageAndSizeAndTbGoods.getGoods().getIsMarketable()!=null && pageAndSizeAndTbGoods.getGoods().getIsMarketable().length()>0){
			criteria.andIsMarketableLike("%"+pageAndSizeAndTbGoods.getGoods().getIsMarketable()+"%");
		}
		if(pageAndSizeAndTbGoods.getGoods().getCaption()!=null && pageAndSizeAndTbGoods.getGoods().getCaption().length()>0){
			criteria.andCaptionLike("%"+pageAndSizeAndTbGoods.getGoods().getCaption()+"%");
		}
		if(pageAndSizeAndTbGoods.getGoods().getSmallPic()!=null && pageAndSizeAndTbGoods.getGoods().getSmallPic().length()>0){
			criteria.andSmallPicLike("%"+pageAndSizeAndTbGoods.getGoods().getSmallPic()+"%");
		}
		if(pageAndSizeAndTbGoods.getGoods().getIsEnableSpec()!=null && pageAndSizeAndTbGoods.getGoods().getIsEnableSpec().length()>0){
			criteria.andIsEnableSpecLike("%"+pageAndSizeAndTbGoods.getGoods().getIsEnableSpec()+"%");
		}
		if(pageAndSizeAndTbGoods.getGoods().getIsDelete()!=null && pageAndSizeAndTbGoods.getGoods().getIsDelete().length()>0){
			criteria.andIsDeleteLike("%"+pageAndSizeAndTbGoods.getGoods().getIsDelete()+"%");
		}
		
		}
				
		
		
		Page<TbGoods> page = (Page<TbGoods>)goodsMapper.selectByExample(example);
		return new PageResult(page.getTotal(),page.getResult());
	}





	
}
           

ItemCatServiceImpl.java 更改以後的内容為:

package com.pinyougou.sellergoods.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pinyougou.mapper.TbItemCatMapper;
import com.pinyougou.pojo.TbItemCat;
import com.pinyougou.pojo.TbItemCatExample;
import com.pinyougou.pojo.TbItemCatExample.Criteria;
import com.pinyougou.sellergoods.service.ItemCatService;

import entity.PageAndSize;
import entity.PageAndSizeAndTbItemCat;
import entity.PageResult;

/**
 * 服務實作層
 * @author Administrator
 *
 */
@Service
public class ItemCatServiceImpl implements ItemCatService {

	@Autowired
	private TbItemCatMapper itemCatMapper;
	
	/**
	 * 查詢全部
	 */
	@Override
	public List<TbItemCat> findAll() {
		return itemCatMapper.selectByExample(null);
	}

	/**
	 * 按分頁查詢
	 */
	@Override
	/**
	public PageResult findPage(int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);		
		Page<TbItemCat> page=   (Page<TbItemCat>) itemCatMapper.selectByExample(null);
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
	public PageResult findPage(PageAndSize pageAndSize) {
		PageHelper.startPage(pageAndSize.getPageNum(), pageAndSize.getSizeNum());
		Page<TbItemCat> page = (Page<TbItemCat>)itemCatMapper.selectByExample(null);
		return new PageResult(page.getTotal(),page.getResult());
	}






	/**
	 * 增加
	 */
	@Override
	public void add(TbItemCat itemCat) {
		itemCatMapper.insert(itemCat);		
	}

	
	/**
	 * 修改
	 */
	@Override
	public void update(TbItemCat itemCat){
		itemCatMapper.updateByPrimaryKey(itemCat);
	}	
	
	/**
	 * 根據ID擷取實體
	 * @param id
	 * @return
	 */
	@Override
	public TbItemCat findOne(Long id){
		return itemCatMapper.selectByPrimaryKey(id);
	}

	/**
	 * 批量删除
	 */
	@Override
	/**
	public void delete(Long[] ids) {
		for(Long id:ids){
			itemCatMapper.deleteByPrimaryKey(id);
		}		
	}
	**/
	public void delete(List<Long> ids) {
		for(Long id:ids) {	
			itemCatMapper.deleteByPrimaryKey(id);
		}
	}



	
	
	@Override
	/**
	public PageResult findPage(TbItemCat itemCat, int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		
		TbItemCatExample example=new TbItemCatExample();
		Criteria criteria = example.createCriteria();
		
		if(itemCat!=null){			
						if(itemCat.getName()!=null && itemCat.getName().length()>0){
				criteria.andNameLike("%"+itemCat.getName()+"%");
			}
	
		}
		
		Page<TbItemCat> page= (Page<TbItemCat>)itemCatMapper.selectByExample(example);		
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
		public PageResult findPage(PageAndSizeAndTbItemCat pageAndSizeAndTbItemCat) {
		PageHelper.startPage(pageAndSizeAndTbItemCat.getPageNum(), pageAndSizeAndTbItemCat.getSizeNum());
		TbItemCatExample example = new TbItemCatExample();
		Criteria criteria = example.createCriteria();
		
		
		/**
		if(pageAndSizeAndTbItemCat.getItemCat() != null) {
			if(pageAndSizeAndTbItemCat.getItemCat().getName() != null 
					&& pageAndSizeAndTbItemCat.getItemCat().getName().length()>0) {
				criteria.andNameLike("%"+pageAndSizeAndTbItemCat.getItemCat().getName()+"%");
			}
			
			if(pageAndSizeAndTbItemCat.getItemCat().getFirstChar() != null 
					&& pageAndSizeAndTbItemCat.getItemCat().getFirstChar().length()>0) {
				criteria.andFirstCharLike("%"+pageAndSizeAndTbItemCat.getItemCat().getFirstChar()+"%");
			}
		}	
		**/
		
		if(pageAndSizeAndTbItemCat.getItemCat()!=null){			
		if(pageAndSizeAndTbItemCat.getItemCat().getName()!=null && pageAndSizeAndTbItemCat.getItemCat().getName().length()>0){
			criteria.andNameLike("%"+pageAndSizeAndTbItemCat.getItemCat().getName()+"%");
		}
		
		}
		
		
		
		Page<TbItemCat> page = (Page<TbItemCat>)itemCatMapper.selectByExample(example);
		return new PageResult(page.getTotal(),page.getResult());
	}





	
}
           

ItemServiceImpl.java 更改後的内容為:

package com.pinyougou.sellergoods.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pinyougou.mapper.TbItemMapper;
import com.pinyougou.pojo.TbItem;
import com.pinyougou.pojo.TbItemExample;
import com.pinyougou.pojo.TbItemExample.Criteria;
import com.pinyougou.sellergoods.service.ItemService;

import entity.PageAndSize;
import entity.PageAndSizeAndTbItem;
import entity.PageResult;

/**
 * 服務實作層
 * @author Administrator
 *
 */
@Service
public class ItemServiceImpl implements ItemService {

	@Autowired
	private TbItemMapper itemMapper;
	
	/**
	 * 查詢全部
	 */
	@Override
	public List<TbItem> findAll() {
		return itemMapper.selectByExample(null);
	}

	/**
	 * 按分頁查詢
	 */
	@Override
	/**
	public PageResult findPage(int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);		
		Page<TbItem> page=   (Page<TbItem>) itemMapper.selectByExample(null);
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
	public PageResult findPage(PageAndSize pageAndSize) {
		PageHelper.startPage(pageAndSize.getPageNum(), pageAndSize.getSizeNum());
		Page<TbItem> page = (Page<TbItem>)itemMapper.selectByExample(null);
		return new PageResult(page.getTotal(),page.getResult());
	}






	/**
	 * 增加
	 */
	@Override
	public void add(TbItem item) {
		itemMapper.insert(item);		
	}

	
	/**
	 * 修改
	 */
	@Override
	public void update(TbItem item){
		itemMapper.updateByPrimaryKey(item);
	}	
	
	/**
	 * 根據ID擷取實體
	 * @param id
	 * @return
	 */
	@Override
	public TbItem findOne(Long id){
		return itemMapper.selectByPrimaryKey(id);
	}

	/**
	 * 批量删除
	 */
	@Override
	/**
	public void delete(Long[] ids) {
		for(Long id:ids){
			itemMapper.deleteByPrimaryKey(id);
		}		
	}
	**/
	public void delete(List<Long> ids) {
		for(Long id:ids) {	
			itemMapper.deleteByPrimaryKey(id);
		}
	}



	
	
	@Override
	/**
	public PageResult findPage(TbItem item, int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		
		TbItemExample example=new TbItemExample();
		Criteria criteria = example.createCriteria();
		
		if(item!=null){			
						if(item.getTitle()!=null && item.getTitle().length()>0){
				criteria.andTitleLike("%"+item.getTitle()+"%");
			}
			if(item.getSellPoint()!=null && item.getSellPoint().length()>0){
				criteria.andSellPointLike("%"+item.getSellPoint()+"%");
			}
			if(item.getBarcode()!=null && item.getBarcode().length()>0){
				criteria.andBarcodeLike("%"+item.getBarcode()+"%");
			}
			if(item.getImage()!=null && item.getImage().length()>0){
				criteria.andImageLike("%"+item.getImage()+"%");
			}
			if(item.getStatus()!=null && item.getStatus().length()>0){
				criteria.andStatusLike("%"+item.getStatus()+"%");
			}
			if(item.getItemSn()!=null && item.getItemSn().length()>0){
				criteria.andItemSnLike("%"+item.getItemSn()+"%");
			}
			if(item.getIsDefault()!=null && item.getIsDefault().length()>0){
				criteria.andIsDefaultLike("%"+item.getIsDefault()+"%");
			}
			if(item.getSellerId()!=null && item.getSellerId().length()>0){
				criteria.andSellerIdLike("%"+item.getSellerId()+"%");
			}
			if(item.getCartThumbnail()!=null && item.getCartThumbnail().length()>0){
				criteria.andCartThumbnailLike("%"+item.getCartThumbnail()+"%");
			}
			if(item.getCategory()!=null && item.getCategory().length()>0){
				criteria.andCategoryLike("%"+item.getCategory()+"%");
			}
			if(item.getBrand()!=null && item.getBrand().length()>0){
				criteria.andBrandLike("%"+item.getBrand()+"%");
			}
			if(item.getSpec()!=null && item.getSpec().length()>0){
				criteria.andSpecLike("%"+item.getSpec()+"%");
			}
			if(item.getSeller()!=null && item.getSeller().length()>0){
				criteria.andSellerLike("%"+item.getSeller()+"%");
			}
	
		}
		
		Page<TbItem> page= (Page<TbItem>)itemMapper.selectByExample(example);		
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
		public PageResult findPage(PageAndSizeAndTbItem pageAndSizeAndTbItem) {
		PageHelper.startPage(pageAndSizeAndTbItem.getPageNum(), pageAndSizeAndTbItem.getSizeNum());
		TbItemExample example = new TbItemExample();
		Criteria criteria = example.createCriteria();
		
		
		/**
		if(pageAndSizeAndTbItem.getItem() != null) {
			if(pageAndSizeAndTbItem.getItem().getName() != null 
					&& pageAndSizeAndTbItem.getItem().getName().length()>0) {
				criteria.andNameLike("%"+pageAndSizeAndTbItem.getItem().getName()+"%");
			}
			
			if(pageAndSizeAndTbItem.getItem().getFirstChar() != null 
					&& pageAndSizeAndTbItem.getItem().getFirstChar().length()>0) {
				criteria.andFirstCharLike("%"+pageAndSizeAndTbItem.getItem().getFirstChar()+"%");
			}
		}
		**/
		
		
		if(pageAndSizeAndTbItem.getItem()!=null){			
		if(pageAndSizeAndTbItem.getItem().getTitle()!=null && pageAndSizeAndTbItem.getItem().getTitle().length()>0){
			criteria.andTitleLike("%"+pageAndSizeAndTbItem.getItem().getTitle()+"%");
		}
		if(pageAndSizeAndTbItem.getItem().getSellPoint()!=null && pageAndSizeAndTbItem.getItem().getSellPoint().length()>0){
			criteria.andSellPointLike("%"+pageAndSizeAndTbItem.getItem().getSellPoint()+"%");
		}
		if(pageAndSizeAndTbItem.getItem().getBarcode()!=null && pageAndSizeAndTbItem.getItem().getBarcode().length()>0){
			criteria.andBarcodeLike("%"+pageAndSizeAndTbItem.getItem().getBarcode()+"%");
		}
		if(pageAndSizeAndTbItem.getItem().getImage()!=null && pageAndSizeAndTbItem.getItem().getImage().length()>0){
			criteria.andImageLike("%"+pageAndSizeAndTbItem.getItem().getImage()+"%");
		}
		if(pageAndSizeAndTbItem.getItem().getStatus()!=null && pageAndSizeAndTbItem.getItem().getStatus().length()>0){
			criteria.andStatusLike("%"+pageAndSizeAndTbItem.getItem().getStatus()+"%");
		}
		if(pageAndSizeAndTbItem.getItem().getItemSn()!=null && pageAndSizeAndTbItem.getItem().getItemSn().length()>0){
			criteria.andItemSnLike("%"+pageAndSizeAndTbItem.getItem().getItemSn()+"%");
		}
		if(pageAndSizeAndTbItem.getItem().getIsDefault()!=null && pageAndSizeAndTbItem.getItem().getIsDefault().length()>0){
			criteria.andIsDefaultLike("%"+pageAndSizeAndTbItem.getItem().getIsDefault()+"%");
		}
		if(pageAndSizeAndTbItem.getItem().getSellerId()!=null && pageAndSizeAndTbItem.getItem().getSellerId().length()>0){
			criteria.andSellerIdLike("%"+pageAndSizeAndTbItem.getItem().getSellerId()+"%");
		}
		if(pageAndSizeAndTbItem.getItem().getCartThumbnail()!=null && pageAndSizeAndTbItem.getItem().getCartThumbnail().length()>0){
			criteria.andCartThumbnailLike("%"+pageAndSizeAndTbItem.getItem().getCartThumbnail()+"%");
		}
		if(pageAndSizeAndTbItem.getItem().getCategory()!=null && pageAndSizeAndTbItem.getItem().getCategory().length()>0){
			criteria.andCategoryLike("%"+pageAndSizeAndTbItem.getItem().getCategory()+"%");
		}
		if(pageAndSizeAndTbItem.getItem().getBrand()!=null && pageAndSizeAndTbItem.getItem().getBrand().length()>0){
			criteria.andBrandLike("%"+pageAndSizeAndTbItem.getItem().getBrand()+"%");
		}
		if(pageAndSizeAndTbItem.getItem().getSpec()!=null && pageAndSizeAndTbItem.getItem().getSpec().length()>0){
			criteria.andSpecLike("%"+pageAndSizeAndTbItem.getItem().getSpec()+"%");
		}
		if(pageAndSizeAndTbItem.getItem().getSeller()!=null && pageAndSizeAndTbItem.getItem().getSeller().length()>0){
			criteria.andSellerLike("%"+pageAndSizeAndTbItem.getItem().getSeller()+"%");
		}
		
		}

		
		
			
			
		Page<TbItem> page = (Page<TbItem>)itemMapper.selectByExample(example);
		return new PageResult(page.getTotal(),page.getResult());
	}





	
}
           

SpecificationOptionServiceImpl.java  更改後的内容為:

package com.pinyougou.sellergoods.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pinyougou.mapper.TbSpecificationOptionMapper;
import com.pinyougou.pojo.TbSpecificationOption;
import com.pinyougou.pojo.TbSpecificationOptionExample;
import com.pinyougou.pojo.TbSpecificationOptionExample.Criteria;
import com.pinyougou.sellergoods.service.SpecificationOptionService;

import entity.PageAndSize;
import entity.PageAndSizeAndTbSpecificationOption;
import entity.PageResult;

/**
 * 服務實作層
 * @author Administrator
 *
 */
@Service
public class SpecificationOptionServiceImpl implements SpecificationOptionService {

	@Autowired
	private TbSpecificationOptionMapper specificationOptionMapper;
	
	/**
	 * 查詢全部
	 */
	@Override
	public List<TbSpecificationOption> findAll() {
		return specificationOptionMapper.selectByExample(null);
	}

	/**
	 * 按分頁查詢
	 */
	@Override
	/**
	public PageResult findPage(int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);		
		Page<TbSpecificationOption> page=   (Page<TbSpecificationOption>) specificationOptionMapper.selectByExample(null);
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
	public PageResult findPage(PageAndSize pageAndSize) {
		PageHelper.startPage(pageAndSize.getPageNum(), pageAndSize.getSizeNum());
		Page<TbSpecificationOption> page = (Page<TbSpecificationOption>)specificationOptionMapper.selectByExample(null);
		return new PageResult(page.getTotal(),page.getResult());
	}






	/**
	 * 增加
	 */
	@Override
	public void add(TbSpecificationOption specificationOption) {
		specificationOptionMapper.insert(specificationOption);		
	}

	
	/**
	 * 修改
	 */
	@Override
	public void update(TbSpecificationOption specificationOption){
		specificationOptionMapper.updateByPrimaryKey(specificationOption);
	}	
	
	/**
	 * 根據ID擷取實體
	 * @param id
	 * @return
	 */
	@Override
	public TbSpecificationOption findOne(Long id){
		return specificationOptionMapper.selectByPrimaryKey(id);
	}

	/**
	 * 批量删除
	 */
	@Override
	/**
	public void delete(Long[] ids) {
		for(Long id:ids){
			specificationOptionMapper.deleteByPrimaryKey(id);
		}		
	}
	**/
	public void delete(List<Long> ids) {
		for(Long id:ids) {	
			specificationOptionMapper.deleteByPrimaryKey(id);
		}
	}



	
	
	@Override
	/**
	public PageResult findPage(TbSpecificationOption specificationOption, int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		
		TbSpecificationOptionExample example=new TbSpecificationOptionExample();
		Criteria criteria = example.createCriteria();
		
		if(specificationOption!=null){			
						if(specificationOption.getOptionName()!=null && specificationOption.getOptionName().length()>0){
				criteria.andOptionNameLike("%"+specificationOption.getOptionName()+"%");
			}
	
		}
		
		Page<TbSpecificationOption> page= (Page<TbSpecificationOption>)specificationOptionMapper.selectByExample(example);		
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
		public PageResult findPage(PageAndSizeAndTbSpecificationOption pageAndSizeAndTbSpecificationOption) {
		PageHelper.startPage(pageAndSizeAndTbSpecificationOption.getPageNum(), pageAndSizeAndTbSpecificationOption.getSizeNum());
		TbSpecificationOptionExample example = new TbSpecificationOptionExample();
		Criteria criteria = example.createCriteria();
		
		/**
		if(pageAndSizeAndTbSpecificationOption.getSpecificationOption() != null) {
			if(pageAndSizeAndTbSpecificationOption.getSpecificationOption().getName() != null 
					&& pageAndSizeAndTbSpecificationOption.getSpecificationOption().getName().length()>0) {
				criteria.andNameLike("%"+pageAndSizeAndTbSpecificationOption.getSpecificationOption().getName()+"%");
			}
			
			if(pageAndSizeAndTbSpecificationOption.getSpecificationOption().getFirstChar() != null 
					&& pageAndSizeAndTbSpecificationOption.getSpecificationOption().getFirstChar().length()>0) {
				criteria.andFirstCharLike("%"+pageAndSizeAndTbSpecificationOption.getSpecificationOption().getFirstChar()+"%");
			}
		}
		**/
		
		if(pageAndSizeAndTbSpecificationOption.getSpecificationOption()!=null){			
		if(pageAndSizeAndTbSpecificationOption.getSpecificationOption().getOptionName()!=null && pageAndSizeAndTbSpecificationOption.getSpecificationOption().getOptionName().length()>0){
			criteria.andOptionNameLike("%"+pageAndSizeAndTbSpecificationOption.getSpecificationOption().getOptionName()+"%");
		}
		
		}
		
			
			
		Page<TbSpecificationOption> page = (Page<TbSpecificationOption>)specificationOptionMapper.selectByExample(example);
		return new PageResult(page.getTotal(),page.getResult());
	}





	
}
           

SpecificationServiceImpl.java   更改後的内容為:

package com.pinyougou.sellergoods.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pinyougou.mapper.TbSpecificationMapper;
import com.pinyougou.pojo.TbSpecification;
import com.pinyougou.pojo.TbSpecificationExample;
import com.pinyougou.pojo.TbSpecificationExample.Criteria;
import com.pinyougou.sellergoods.service.SpecificationService;

import entity.PageAndSize;
import entity.PageAndSizeAndTbSpecification;
import entity.PageResult;

/**
 * 服務實作層
 * @author Administrator
 *
 */
@Service
public class SpecificationServiceImpl implements SpecificationService {

	@Autowired
	private TbSpecificationMapper specificationMapper;
	
	/**
	 * 查詢全部
	 */
	@Override
	public List<TbSpecification> findAll() {
		return specificationMapper.selectByExample(null);
	}

	/**
	 * 按分頁查詢
	 */
	@Override
	/**
	public PageResult findPage(int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);		
		Page<TbSpecification> page=   (Page<TbSpecification>) specificationMapper.selectByExample(null);
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
	public PageResult findPage(PageAndSize pageAndSize) {
		PageHelper.startPage(pageAndSize.getPageNum(), pageAndSize.getSizeNum());
		Page<TbSpecification> page = (Page<TbSpecification>)specificationMapper.selectByExample(null);
		return new PageResult(page.getTotal(),page.getResult());
	}






	/**
	 * 增加
	 */
	@Override
	public void add(TbSpecification specification) {
		specificationMapper.insert(specification);		
	}

	
	/**
	 * 修改
	 */
	@Override
	public void update(TbSpecification specification){
		specificationMapper.updateByPrimaryKey(specification);
	}	
	
	/**
	 * 根據ID擷取實體
	 * @param id
	 * @return
	 */
	@Override
	public TbSpecification findOne(Long id){
		return specificationMapper.selectByPrimaryKey(id);
	}

	/**
	 * 批量删除
	 */
	@Override
	/**
	public void delete(Long[] ids) {
		for(Long id:ids){
			specificationMapper.deleteByPrimaryKey(id);
		}		
	}
	**/
	public void delete(List<Long> ids) {
		for(Long id:ids) {	
			specificationMapper.deleteByPrimaryKey(id);
		}
	}



	
	
	@Override
	/**
	public PageResult findPage(TbSpecification specification, int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		
		TbSpecificationExample example=new TbSpecificationExample();
		Criteria criteria = example.createCriteria();
		
		if(specification!=null){			
						if(specification.getSpecName()!=null && specification.getSpecName().length()>0){
				criteria.andSpecNameLike("%"+specification.getSpecName()+"%");
			}
	
		}
		
		Page<TbSpecification> page= (Page<TbSpecification>)specificationMapper.selectByExample(example);		
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
		public PageResult findPage(PageAndSizeAndTbSpecification pageAndSizeAndTbSpecification) {
		PageHelper.startPage(pageAndSizeAndTbSpecification.getPageNum(), pageAndSizeAndTbSpecification.getSizeNum());
		TbSpecificationExample example = new TbSpecificationExample();
		Criteria criteria = example.createCriteria();
		
		
		
		/**
		if(pageAndSizeAndTbSpecification.getSpecification() != null) {
			if(pageAndSizeAndTbSpecification.getSpecification().getName() != null 
					&& pageAndSizeAndTbSpecification.getSpecification().getName().length()>0) {
				criteria.andNameLike("%"+pageAndSizeAndTbSpecification.getSpecification().getName()+"%");
			}
			
			if(pageAndSizeAndTbSpecification.getSpecification().getFirstChar() != null 
					&& pageAndSizeAndTbSpecification.getSpecification().getFirstChar().length()>0) {
				criteria.andFirstCharLike("%"+pageAndSizeAndTbSpecification.getSpecification().getFirstChar()+"%");
			}
		}
		**/
		
		
		if(pageAndSizeAndTbSpecification.getSpecification()!=null){			
		if(pageAndSizeAndTbSpecification.getSpecification().getSpecName()!=null && pageAndSizeAndTbSpecification.getSpecification().getSpecName().length()>0){
			criteria.andSpecNameLike("%"+pageAndSizeAndTbSpecification.getSpecification().getSpecName()+"%");
		}
		
		}
			
			
		Page<TbSpecification> page = (Page<TbSpecification>)specificationMapper.selectByExample(example);
		return new PageResult(page.getTotal(),page.getResult());
	}





	
}
           

TypeTemplateServiceImpl.java  更改後的内容為:

package com.pinyougou.sellergoods.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pinyougou.mapper.TbTypeTemplateMapper;
import com.pinyougou.pojo.TbTypeTemplate;
import com.pinyougou.pojo.TbTypeTemplateExample;
import com.pinyougou.pojo.TbTypeTemplateExample.Criteria;
import com.pinyougou.sellergoods.service.TypeTemplateService;

import entity.PageAndSize;
import entity.PageAndSizeAndTbTypeTemplate;
import entity.PageResult;

/**
 * 服務實作層
 * @author Administrator
 *
 */
@Service
public class TypeTemplateServiceImpl implements TypeTemplateService {

	@Autowired
	private TbTypeTemplateMapper typeTemplateMapper;
	
	/**
	 * 查詢全部
	 */
	@Override
	public List<TbTypeTemplate> findAll() {
		return typeTemplateMapper.selectByExample(null);
	}

	/**
	 * 按分頁查詢
	 */
	@Override
	/**
	public PageResult findPage(int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);		
		Page<TbTypeTemplate> page=   (Page<TbTypeTemplate>) typeTemplateMapper.selectByExample(null);
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
	public PageResult findPage(PageAndSize pageAndSize) {
		PageHelper.startPage(pageAndSize.getPageNum(), pageAndSize.getSizeNum());
		Page<TbTypeTemplate> page = (Page<TbTypeTemplate>)typeTemplateMapper.selectByExample(null);
		return new PageResult(page.getTotal(),page.getResult());
	}






	/**
	 * 增加
	 */
	@Override
	public void add(TbTypeTemplate typeTemplate) {
		typeTemplateMapper.insert(typeTemplate);		
	}

	
	/**
	 * 修改
	 */
	@Override
	public void update(TbTypeTemplate typeTemplate){
		typeTemplateMapper.updateByPrimaryKey(typeTemplate);
	}	
	
	/**
	 * 根據ID擷取實體
	 * @param id
	 * @return
	 */
	@Override
	public TbTypeTemplate findOne(Long id){
		return typeTemplateMapper.selectByPrimaryKey(id);
	}

	/**
	 * 批量删除
	 */
	@Override
	/**
	public void delete(Long[] ids) {
		for(Long id:ids){
			typeTemplateMapper.deleteByPrimaryKey(id);
		}		
	}
	**/
	public void delete(List<Long> ids) {
		for(Long id:ids) {	
			typeTemplateMapper.deleteByPrimaryKey(id);
		}
	}



	
	
	@Override
	/**
	public PageResult findPage(TbTypeTemplate typeTemplate, int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		
		TbTypeTemplateExample example=new TbTypeTemplateExample();
		Criteria criteria = example.createCriteria();
		
		if(typeTemplate!=null){			
						if(typeTemplate.getName()!=null && typeTemplate.getName().length()>0){
				criteria.andNameLike("%"+typeTemplate.getName()+"%");
			}
			if(typeTemplate.getSpecIds()!=null && typeTemplate.getSpecIds().length()>0){
				criteria.andSpecIdsLike("%"+typeTemplate.getSpecIds()+"%");
			}
			if(typeTemplate.getBrandIds()!=null && typeTemplate.getBrandIds().length()>0){
				criteria.andBrandIdsLike("%"+typeTemplate.getBrandIds()+"%");
			}
			if(typeTemplate.getCustomAttributeItems()!=null && typeTemplate.getCustomAttributeItems().length()>0){
				criteria.andCustomAttributeItemsLike("%"+typeTemplate.getCustomAttributeItems()+"%");
			}
	
		}
		
		Page<TbTypeTemplate> page= (Page<TbTypeTemplate>)typeTemplateMapper.selectByExample(example);		
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
		public PageResult findPage(PageAndSizeAndTbTypeTemplate pageAndSizeAndTbTypeTemplate) {
		PageHelper.startPage(pageAndSizeAndTbTypeTemplate.getPageNum(), pageAndSizeAndTbTypeTemplate.getSizeNum());
		TbTypeTemplateExample example = new TbTypeTemplateExample();
		Criteria criteria = example.createCriteria();
		
		
		/**
		if(pageAndSizeAndTbTypeTemplate.getTypeTemplate() != null) {
			if(pageAndSizeAndTbTypeTemplate.getTypeTemplate().getName() != null 
					&& pageAndSizeAndTbTypeTemplate.getTypeTemplate().getName().length()>0) {
				criteria.andNameLike("%"+pageAndSizeAndTbTypeTemplate.getTypeTemplate().getName()+"%");
			}
			
			if(pageAndSizeAndTbTypeTemplate.getTypeTemplate().getFirstChar() != null 
					&& pageAndSizeAndTbTypeTemplate.getTypeTemplate().getFirstChar().length()>0) {
				criteria.andFirstCharLike("%"+pageAndSizeAndTbTypeTemplate.getTypeTemplate().getFirstChar()+"%");
			}
		}
		**/
		
		if(pageAndSizeAndTbTypeTemplate.getTypeTemplate()!=null){			
		if(pageAndSizeAndTbTypeTemplate.getTypeTemplate().getName()!=null && pageAndSizeAndTbTypeTemplate.getTypeTemplate().getName().length()>0){
			criteria.andNameLike("%"+pageAndSizeAndTbTypeTemplate.getTypeTemplate().getName()+"%");
		}
		if(pageAndSizeAndTbTypeTemplate.getTypeTemplate().getSpecIds()!=null && pageAndSizeAndTbTypeTemplate.getTypeTemplate().getSpecIds().length()>0){
			criteria.andSpecIdsLike("%"+pageAndSizeAndTbTypeTemplate.getTypeTemplate().getSpecIds()+"%");
		}
		if(pageAndSizeAndTbTypeTemplate.getTypeTemplate().getBrandIds()!=null && pageAndSizeAndTbTypeTemplate.getTypeTemplate().getBrandIds().length()>0){
			criteria.andBrandIdsLike("%"+pageAndSizeAndTbTypeTemplate.getTypeTemplate().getBrandIds()+"%");
		}
		if(pageAndSizeAndTbTypeTemplate.getTypeTemplate().getCustomAttributeItems()!=null && pageAndSizeAndTbTypeTemplate.getTypeTemplate().getCustomAttributeItems().length()>0){
			criteria.andCustomAttributeItemsLike("%"+pageAndSizeAndTbTypeTemplate.getTypeTemplate().getCustomAttributeItems()+"%");
		}
		
		}
		
			
			
		Page<TbTypeTemplate> page = (Page<TbTypeTemplate>)typeTemplateMapper.selectByExample(example);
		return new PageResult(page.getTotal(),page.getResult());
	}





	
}
           

SellerServiceImpl.java  更改後的内容為:

電商三十四、代碼生成器

别的表的主鍵id,都是bigint類型,對應Java的Long類型

但是seller這張表有點特殊,是varchar類型,對應Java是String類型

電商三十四、代碼生成器

先改接口:SellerService.java  更改後的内容為:

電商三十四、代碼生成器
電商三十四、代碼生成器
package com.pinyougou.sellergoods.service;
import java.util.List;
import com.pinyougou.pojo.TbSeller;

import entity.PageAndSize;
import entity.PageAndSizeAndTbSeller;
import entity.PageResult;
/**
 * 服務層接口
 * @author Administrator
 *
 */
public interface SellerService {

	/**
	 * 傳回全部清單
	 * @return
	 */
	public List<TbSeller> findAll();
	
	
	/**
	 * 傳回分頁清單
	 * @return
	 */
	//public PageResult findPage(int pageNum,int pageSize);
    public PageResult findPage(PageAndSize pageAndSize);
	
	
	/**
	 * 增加
	*/
	public void add(TbSeller seller);
	
	
	/**
	 * 修改
	 */
	public void update(TbSeller seller);
	

	/**
	 * 根據ID擷取實體
	 * @param id
	 * @return
	 */
	public TbSeller findOne(String id);
	
	
	/**
	 * 批量删除
	 * @param ids
	 */
	//public void delete(String [] ids);
	public void delete(List<String> ids);


	/**
	 * 分頁
	 * @param pageNum 目前頁 碼
	 * @param pageSize 每頁記錄數
	 * @return
	 */
	//public PageResult findPage(TbSeller seller, int pageNum,int pageSize);
	public PageResult findPage(PageAndSizeAndTbSeller pageAndSizeAndTbSeller);
	
}
           

再看SellerServiceImpl.java  更改後的内容為:

電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器
package com.pinyougou.sellergoods.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pinyougou.mapper.TbSellerMapper;
import com.pinyougou.pojo.TbSeller;
import com.pinyougou.pojo.TbSellerExample;
import com.pinyougou.pojo.TbSellerExample.Criteria;
import com.pinyougou.sellergoods.service.SellerService;

import entity.PageAndSize;
import entity.PageAndSizeAndTbSeller;
import entity.PageResult;

/**
 * 服務實作層
 * @author Administrator
 *
 */
@Service
public class SellerServiceImpl implements SellerService {

	@Autowired
	private TbSellerMapper sellerMapper;
	
	/**
	 * 查詢全部
	 */
	@Override
	public List<TbSeller> findAll() {
		return sellerMapper.selectByExample(null);
	}

	/**
	 * 按分頁查詢
	 */
	@Override
	/**
	public PageResult findPage(int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);		
		Page<TbSeller> page=   (Page<TbSeller>) sellerMapper.selectByExample(null);
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
	public PageResult findPage(PageAndSize pageAndSize) {
		PageHelper.startPage(pageAndSize.getPageNum(), pageAndSize.getSizeNum());
		Page<TbSeller> page = (Page<TbSeller>)sellerMapper.selectByExample(null);
		return new PageResult(page.getTotal(),page.getResult());
	}






	/**
	 * 增加
	 */
	@Override
	public void add(TbSeller seller) {
		sellerMapper.insert(seller);		
	}

	
	/**
	 * 修改
	 */
	@Override
	public void update(TbSeller seller){
		sellerMapper.updateByPrimaryKey(seller);
	}	
	
	/**
	 * 根據ID擷取實體
	 * @param id
	 * @return
	 */
	@Override
	public TbSeller findOne(String id){
		return sellerMapper.selectByPrimaryKey(id);
	}

	/**
	 * 批量删除
	 */
	@Override
	/**
	public void delete(String[] ids) {
		for(String id:ids){
			sellerMapper.deleteByPrimaryKey(id);
		}		
	}
	**/
	public void delete(List<String> ids) {
		for(String id:ids) {	
			sellerMapper.deleteByPrimaryKey(id);
		}
	}



	
	
	@Override
	/**
	public PageResult findPage(TbSeller seller, int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		
		TbSellerExample example=new TbSellerExample();
		Criteria criteria = example.createCriteria();
		
		if(seller!=null){			
						if(seller.getSellerId()!=null && seller.getSellerId().length()>0){
				criteria.andSellerIdLike("%"+seller.getSellerId()+"%");
			}
			if(seller.getName()!=null && seller.getName().length()>0){
				criteria.andNameLike("%"+seller.getName()+"%");
			}
			if(seller.getNickName()!=null && seller.getNickName().length()>0){
				criteria.andNickNameLike("%"+seller.getNickName()+"%");
			}
			if(seller.getPassword()!=null && seller.getPassword().length()>0){
				criteria.andPasswordLike("%"+seller.getPassword()+"%");
			}
			if(seller.getEmail()!=null && seller.getEmail().length()>0){
				criteria.andEmailLike("%"+seller.getEmail()+"%");
			}
			if(seller.getMobile()!=null && seller.getMobile().length()>0){
				criteria.andMobileLike("%"+seller.getMobile()+"%");
			}
			if(seller.getTelephone()!=null && seller.getTelephone().length()>0){
				criteria.andTelephoneLike("%"+seller.getTelephone()+"%");
			}
			if(seller.getStatus()!=null && seller.getStatus().length()>0){
				criteria.andStatusLike("%"+seller.getStatus()+"%");
			}
			if(seller.getAddressDetail()!=null && seller.getAddressDetail().length()>0){
				criteria.andAddressDetailLike("%"+seller.getAddressDetail()+"%");
			}
			if(seller.getLinkmanName()!=null && seller.getLinkmanName().length()>0){
				criteria.andLinkmanNameLike("%"+seller.getLinkmanName()+"%");
			}
			if(seller.getLinkmanQq()!=null && seller.getLinkmanQq().length()>0){
				criteria.andLinkmanQqLike("%"+seller.getLinkmanQq()+"%");
			}
			if(seller.getLinkmanMobile()!=null && seller.getLinkmanMobile().length()>0){
				criteria.andLinkmanMobileLike("%"+seller.getLinkmanMobile()+"%");
			}
			if(seller.getLinkmanEmail()!=null && seller.getLinkmanEmail().length()>0){
				criteria.andLinkmanEmailLike("%"+seller.getLinkmanEmail()+"%");
			}
			if(seller.getLicenseNumber()!=null && seller.getLicenseNumber().length()>0){
				criteria.andLicenseNumberLike("%"+seller.getLicenseNumber()+"%");
			}
			if(seller.getTaxNumber()!=null && seller.getTaxNumber().length()>0){
				criteria.andTaxNumberLike("%"+seller.getTaxNumber()+"%");
			}
			if(seller.getOrgNumber()!=null && seller.getOrgNumber().length()>0){
				criteria.andOrgNumberLike("%"+seller.getOrgNumber()+"%");
			}
			if(seller.getLogoPic()!=null && seller.getLogoPic().length()>0){
				criteria.andLogoPicLike("%"+seller.getLogoPic()+"%");
			}
			if(seller.getBrief()!=null && seller.getBrief().length()>0){
				criteria.andBriefLike("%"+seller.getBrief()+"%");
			}
			if(seller.getLegalPerson()!=null && seller.getLegalPerson().length()>0){
				criteria.andLegalPersonLike("%"+seller.getLegalPerson()+"%");
			}
			if(seller.getLegalPersonCardId()!=null && seller.getLegalPersonCardId().length()>0){
				criteria.andLegalPersonCardIdLike("%"+seller.getLegalPersonCardId()+"%");
			}
			if(seller.getBankUser()!=null && seller.getBankUser().length()>0){
				criteria.andBankUserLike("%"+seller.getBankUser()+"%");
			}
			if(seller.getBankName()!=null && seller.getBankName().length()>0){
				criteria.andBankNameLike("%"+seller.getBankName()+"%");
			}
	
		}
		
		Page<TbSeller> page= (Page<TbSeller>)sellerMapper.selectByExample(example);		
		return new PageResult(page.getTotal(), page.getResult());
	}
	**/
		public PageResult findPage(PageAndSizeAndTbSeller pageAndSizeAndTbSeller) {
		PageHelper.startPage(pageAndSizeAndTbSeller.getPageNum(), pageAndSizeAndTbSeller.getSizeNum());
		TbSellerExample example = new TbSellerExample();
		Criteria criteria = example.createCriteria();
		
		
		/**
		if(pageAndSizeAndTbSeller.getSeller() != null) {
			if(pageAndSizeAndTbSeller.getSeller().getName() != null 
					&& pageAndSizeAndTbSeller.getSeller().getName().length()>0) {
				criteria.andNameLike("%"+pageAndSizeAndTbSeller.getSeller().getName()+"%");
			}
			
			if(pageAndSizeAndTbSeller.getSeller().getFirstChar() != null 
					&& pageAndSizeAndTbSeller.getSeller().getFirstChar().length()>0) {
				criteria.andFirstCharLike("%"+pageAndSizeAndTbSeller.getSeller().getFirstChar()+"%");
			}
		}
		**/
		

		if(pageAndSizeAndTbSeller.getSeller()!=null){			
						if(pageAndSizeAndTbSeller.getSeller().getSellerId()!=null && pageAndSizeAndTbSeller.getSeller().getSellerId().length()>0){
				criteria.andSellerIdLike("%"+pageAndSizeAndTbSeller.getSeller().getSellerId()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getName()!=null && pageAndSizeAndTbSeller.getSeller().getName().length()>0){
				criteria.andNameLike("%"+pageAndSizeAndTbSeller.getSeller().getName()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getNickName()!=null && pageAndSizeAndTbSeller.getSeller().getNickName().length()>0){
				criteria.andNickNameLike("%"+pageAndSizeAndTbSeller.getSeller().getNickName()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getPassword()!=null && pageAndSizeAndTbSeller.getSeller().getPassword().length()>0){
				criteria.andPasswordLike("%"+pageAndSizeAndTbSeller.getSeller().getPassword()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getEmail()!=null && pageAndSizeAndTbSeller.getSeller().getEmail().length()>0){
				criteria.andEmailLike("%"+pageAndSizeAndTbSeller.getSeller().getEmail()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getMobile()!=null && pageAndSizeAndTbSeller.getSeller().getMobile().length()>0){
				criteria.andMobileLike("%"+pageAndSizeAndTbSeller.getSeller().getMobile()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getTelephone()!=null && pageAndSizeAndTbSeller.getSeller().getTelephone().length()>0){
				criteria.andTelephoneLike("%"+pageAndSizeAndTbSeller.getSeller().getTelephone()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getStatus()!=null && pageAndSizeAndTbSeller.getSeller().getStatus().length()>0){
				criteria.andStatusLike("%"+pageAndSizeAndTbSeller.getSeller().getStatus()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getAddressDetail()!=null && pageAndSizeAndTbSeller.getSeller().getAddressDetail().length()>0){
				criteria.andAddressDetailLike("%"+pageAndSizeAndTbSeller.getSeller().getAddressDetail()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getLinkmanName()!=null && pageAndSizeAndTbSeller.getSeller().getLinkmanName().length()>0){
				criteria.andLinkmanNameLike("%"+pageAndSizeAndTbSeller.getSeller().getLinkmanName()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getLinkmanQq()!=null && pageAndSizeAndTbSeller.getSeller().getLinkmanQq().length()>0){
				criteria.andLinkmanQqLike("%"+pageAndSizeAndTbSeller.getSeller().getLinkmanQq()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getLinkmanMobile()!=null && pageAndSizeAndTbSeller.getSeller().getLinkmanMobile().length()>0){
				criteria.andLinkmanMobileLike("%"+pageAndSizeAndTbSeller.getSeller().getLinkmanMobile()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getLinkmanEmail()!=null && pageAndSizeAndTbSeller.getSeller().getLinkmanEmail().length()>0){
				criteria.andLinkmanEmailLike("%"+pageAndSizeAndTbSeller.getSeller().getLinkmanEmail()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getLicenseNumber()!=null && pageAndSizeAndTbSeller.getSeller().getLicenseNumber().length()>0){
				criteria.andLicenseNumberLike("%"+pageAndSizeAndTbSeller.getSeller().getLicenseNumber()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getTaxNumber()!=null && pageAndSizeAndTbSeller.getSeller().getTaxNumber().length()>0){
				criteria.andTaxNumberLike("%"+pageAndSizeAndTbSeller.getSeller().getTaxNumber()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getOrgNumber()!=null && pageAndSizeAndTbSeller.getSeller().getOrgNumber().length()>0){
				criteria.andOrgNumberLike("%"+pageAndSizeAndTbSeller.getSeller().getOrgNumber()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getLogoPic()!=null && pageAndSizeAndTbSeller.getSeller().getLogoPic().length()>0){
				criteria.andLogoPicLike("%"+pageAndSizeAndTbSeller.getSeller().getLogoPic()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getBrief()!=null && pageAndSizeAndTbSeller.getSeller().getBrief().length()>0){
				criteria.andBriefLike("%"+pageAndSizeAndTbSeller.getSeller().getBrief()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getLegalPerson()!=null && pageAndSizeAndTbSeller.getSeller().getLegalPerson().length()>0){
				criteria.andLegalPersonLike("%"+pageAndSizeAndTbSeller.getSeller().getLegalPerson()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getLegalPersonCardId()!=null && pageAndSizeAndTbSeller.getSeller().getLegalPersonCardId().length()>0){
				criteria.andLegalPersonCardIdLike("%"+pageAndSizeAndTbSeller.getSeller().getLegalPersonCardId()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getBankUser()!=null && pageAndSizeAndTbSeller.getSeller().getBankUser().length()>0){
				criteria.andBankUserLike("%"+pageAndSizeAndTbSeller.getSeller().getBankUser()+"%");
			}
			if(pageAndSizeAndTbSeller.getSeller().getBankName()!=null && pageAndSizeAndTbSeller.getSeller().getBankName().length()>0){
				criteria.andBankNameLike("%"+pageAndSizeAndTbSeller.getSeller().getBankName()+"%");
			}
	
		}
		
			
			
		Page<TbSeller> page = (Page<TbSeller>)sellerMapper.selectByExample(example);
		return new PageResult(page.getTotal(),page.getResult());
	}





	
}
           

十一、複制相關代碼到目前工程内部(控制層即web層)

C:\Users\Administrator\Desktop\testcode\pinyougou-sellergoods-web\src\main\java\com\pinyougou\sellergoods\controller

電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器

但是SellerController.java  的内容更改的不同:

首先在pojo增加一個類IdStringResult.java

電商三十四、代碼生成器

IdStringResult.java  的内容為:

package entity;

import java.io.Serializable;

public class IdStringResult implements Serializable{
	
	private String id;

	public IdStringResult(String id) {
		super();
		this.id = id;
	}

	public IdStringResult() {
		super();
	}

	public String getId() {
		return id;
	}

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

	
	

}
           

再然後SellerController.java  更改後的内容為:

package com.pinyougou.manager.controller;
import java.util.ArrayList;
import java.util.List;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.dubbo.config.annotation.Reference;
import com.pinyougou.pojo.TbSeller;
import com.pinyougou.sellergoods.service.SellerService;


import entity.IdResult;
import entity.IdStringResult;
import entity.PageAndSize;
import entity.PageAndSizeAndTbSeller;
import entity.PageResult;
import entity.Result;
/**
 * controller
 * @author Administrator
 *
 */
@RestController
@RequestMapping("/seller")
public class SellerController {

	@Reference
	private SellerService sellerService;
	
	/**
	 * 傳回全部清單
	 * @return
	 */
	@RequestMapping("/findAll")
	public List<TbSeller> findAll(){			
		return sellerService.findAll();
	}
	
	
	/**
	 * 傳回全部清單
	 * @return
	 */
	 /**
	@RequestMapping("/findPage")
	public PageResult  findPage(int page,int rows){			
		return sellerService.findPage(page, rows);
	}
	**/
	@RequestMapping("/findPage")
	public PageResult findPage(@RequestBody PageAndSize pageAndSize) {
	
		return sellerService.findPage(pageAndSize);
	}



	
	/**
	 * 增加
	 * @param seller
	 * @return
	 */
	@RequestMapping("/add")
	public Result add(@RequestBody TbSeller seller){
		try {
			sellerService.add(seller);
			return new Result(true, "增加成功");
		} catch (Exception e) {
			e.printStackTrace();
			return new Result(false, "增加失敗");
		}
	}
	
	/**
	 * 修改
	 * @param seller
	 * @return
	 */
	@RequestMapping("/update")
	public Result update(@RequestBody TbSeller seller){
		try {
			sellerService.update(seller);
			return new Result(true, "修改成功");
		} catch (Exception e) {
			e.printStackTrace();
			return new Result(false, "修改失敗");
		}
	}	
	
	/**
	 * 擷取實體
	 * @param id
	 * @return
	 */
	 /**
	@RequestMapping("/findOne")
	public TbSeller findOne(Long id){
		return sellerService.findOne(id);		
	}
	**/
    @RequestMapping("findOne")
	public TbSeller findOne(@RequestBody IdStringResult idStringResult) {
		return sellerService.findOne(idStringResult.getId());
	}



	
	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	 /**
	@RequestMapping("/delete")
	public Result delete(Long [] ids){
		try {
			sellerService.delete(ids);
			return new Result(true, "删除成功"); 
		} catch (Exception e) {
			e.printStackTrace();
			return new Result(false, "删除失敗");
		}
	}
	**/
	@RequestMapping("/delete")
	public Result delete(@RequestBody List<IdStringResult> idStringResults) {	
		List<String>  ids = new ArrayList<String>();
		int i=0;
		if(idStringResults.size()>0) {
			for(IdStringResult idStringResult:idStringResults) {
				ids.add(idStringResult.getId());
				i++;
				
			}
		}		
		try {
			sellerService.delete(ids);
			return new Result(true,"删除成功");
		} catch (Exception e) {
			e.printStackTrace();
			return new Result(false,"删除失敗");
		}
		
	}
	





	
	/**
	 * 查詢+分頁
	 * @param brand
	 * @param page
	 * @param rows
	 * @return
	 */
	 /**
	@RequestMapping("/search")
	public PageResult search(@RequestBody TbSeller seller, int page, int rows  ){
		return sellerService.findPage(seller, page, rows);		
	}
	**/
	@RequestMapping("/search")
	public PageResult search(@RequestBody PageAndSizeAndTbSeller  pageAndSizeAndTbSeller) {
		return sellerService.findPage(pageAndSizeAndTbSeller);
	}


	
}
           

十二、複制相關代碼到目前工程内部(前端層面的service層)

C:\Users\Administrator\Desktop\testcode\pinyougou-sellergoods-web\src\main\webapp\js\service

電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器

十三、複制相關代碼到目前工程内部(前端層面的controller層)

C:\Users\Administrator\Desktop\testcode\pinyougou-sellergoods-web\src\main\webapp\js\controller

電商三十四、代碼生成器
電商三十四、代碼生成器
電商三十四、代碼生成器

十四、整個代碼結構變化比較大,整體install一下。

電商三十四、代碼生成器