Java Code Examples for org.mybatis.generator.api.dom.java.Parameter#addAnnotation()

The following examples show how to use org.mybatis.generator.api.dom.java.Parameter#addAnnotation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenameExampleClassAndMethodsPlugin.java    From mybatis-generator-plugins with Apache License 2.0 6 votes vote down vote up
boolean renameMethod(Method method) {
	String oldMethodName = method.getName();
	Matcher matcher = classMethodPattern.matcher(oldMethodName);
	String newMethodName = matcher.replaceAll(classMethodReplaceString);
	method.setName(newMethodName);

	for (int i = 0; i < method.getParameters().size(); i++) {
		Parameter parameter = method.getParameters().get(i);
		String oldParamName = parameter.getName();
		matcher = parameterPattern.matcher(oldParamName);
		if (matcher.lookingAt()) {
			String newName = matcher.replaceAll(parameterReplaceString);
			Parameter newParam = new Parameter(parameter.getType(), newName, parameter.isVarargs());
			for (String annotation : parameter.getAnnotations()) {
				newParam.addAnnotation(annotation);
			}
			method.getParameters().set(i, newParam);
		}
	}

	return true;
}
 
Example 2
Source File: CreateSubPackagePlugin.java    From mybatis-generator-plugins with Apache License 2.0 6 votes vote down vote up
/**
 * Rename the method types.
 *
 * @param method
 *            the method
 * @return true
 */
boolean renameMethod(Method method) {
	method.setReturnType(modelProperties.renameType(method.getReturnType()));

	for (int i = 0; i < method.getParameters().size(); i++) {
		Parameter parameter = method.getParameters().get(i);
		FullyQualifiedJavaType parameterType = parameter.getType();
		FullyQualifiedJavaType newParameterType = modelProperties.renameType(parameterType);
		if (parameterType != newParameterType) {
			Parameter newParam = new Parameter(newParameterType, parameter.getName(), parameter.isVarargs());
			for (String annotation : parameter.getAnnotations()) {
				newParam.addAnnotation(annotation);
			}
			method.getParameters().set(i, newParam);
			log.debug("set new parameter: [{}][{}]", parameter, newParam);
		}
	}

	modelProperties.renameAnnotations(method.getAnnotations());
	mapperProperties.renameAnnotations(method.getAnnotations());

	return true;
}
 
Example 3
Source File: JavaElementTools.java    From mybatis-generator-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * clone
 * @param parameter
 * @return
 */
public static Parameter clone(Parameter parameter) {
    Parameter dest = new Parameter(parameter.getType(), parameter.getName(), parameter.isVarargs());
    for (String annotation : parameter.getAnnotations()) {
        dest.addAnnotation(annotation);
    }
    return dest;
}
 
Example 4
Source File: InsertControllerGenerator.java    From maven-archetype with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static List<Method> generator(FullyQualifiedJavaType beanType,String beanName,
		String businessFieldName){
	List<Method> methodList = new ArrayList<Method>();
	
	String beanFieldName = StringUtils.uncapitalize(beanName);
	
	Method method = new Method();
	method.addAnnotation("@RequestMapping(value = \"insert.do\")");
	method.setVisibility(JavaVisibility.PUBLIC);
	method.setReturnType(new FullyQualifiedJavaType(String.class.getName()));
	method.setName("insert");
	Parameter param = new Parameter(beanType, beanFieldName);
	param.addAnnotation("@ModelAttribute(\"" + beanFieldName + "\") ");
	Parameter paramModelMap = new Parameter(new FullyQualifiedJavaType(ModelMap.class.getName()), "map");
	method.addParameter(param); 
	method.addParameter(paramModelMap); 
	// 方法body
	method.addBodyLine("try {");
	method.addBodyLine("// 数据校验");
	method.addBodyLine("");
	method.addBodyLine("if(this." + businessFieldName + ".insertSelective(" + beanFieldName + ") == 1){");
	method.addBodyLine("map.put(\"message\",\"插入成功。\");");
	method.addBodyLine("}else{");
	method.addBodyLine("map.put(\"message\",\"插入失败。\");");
	method.addBodyLine("}");
	method.addBodyLine("} catch (Exception e) {");
	method.addBodyLine("logger.error(\"插入异常\" + e.getMessage());");
	method.addBodyLine("map.put(\"message\",\"插入异常\" + e.getMessage());");
	method.addBodyLine("}");
	method.addBodyLine(ControllerPluginUtil.RETURN);
	
	methodList.add(method);
       
       return methodList;
}
 
Example 5
Source File: BatchUpdateControllerGenerator.java    From maven-archetype with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static List<Method> generator(FullyQualifiedJavaType innerClassType,String beanName,
		String businessFieldName){
	List<Method> methodList = new ArrayList<Method>();
	
	String innerClassFiledName = StringUtils.uncapitalize(innerClassType.getShortName());
	
	Method method = new Method();
       method.addAnnotation("@RequestMapping(value = \"batchUpdateSave" + beanName + ".do\")");
       method.setVisibility(JavaVisibility.PUBLIC);
       method.setReturnType(new FullyQualifiedJavaType(String.class.getName()));
       method.setName("batchUpdateSave" + beanName);
       Parameter param1 = new Parameter(innerClassType, innerClassFiledName);
       param1.addAnnotation("@ModelAttribute ");
       Parameter paramModelMap = new Parameter(new FullyQualifiedJavaType(ModelMap.class.getName()), "map");
       method.addParameter(param1); 
       method.addParameter(paramModelMap); 
       // 方法body
       method.addBodyLine("try {");
       method.addBodyLine("if(" + innerClassFiledName + " != null && CollectionUtil.isNotNull(" + innerClassFiledName + ".get"+ beanName + "List())){");
       method.addBodyLine("int updateCount = this." + businessFieldName + ".update(" + innerClassFiledName + ".get"+ beanName + "List());");
       method.addBodyLine("if(updateCount >0 ){");
       method.addBodyLine("map.put(\"message\",\"更新成功。\");");
	method.addBodyLine("}else{");
	method.addBodyLine("map.put(\"message\",\"更新失败。\");");
       method.addBodyLine("}");
       method.addBodyLine("}");
       method.addBodyLine("} catch (Exception e) {");
       method.addBodyLine("logger.error(\"批量更新异常\" + e.getMessage());");
       method.addBodyLine("map.put(\"message\", \"批量更新异常\" + e.getMessage());");
       method.addBodyLine("}");
       method.addBodyLine(ControllerPluginUtil.RETURN);
       
	methodList.add(method);
	
    return methodList;
}
 
Example 6
Source File: UpdateControllerGenerator.java    From maven-archetype with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static List<Method> generator(FullyQualifiedJavaType beanType,String beanName,
		String businessFieldName){
	List<Method> methodList = new ArrayList<Method>();
	String beanFiledName = StringUtils.uncapitalize(beanName);
	
	Method method = new Method();
	method.addAnnotation("@RequestMapping(value = \"updateSave" + beanName + ".do\")");
	method.setVisibility(JavaVisibility.PUBLIC);
	method.setReturnType(new FullyQualifiedJavaType(String.class.getName()));
	method.setName("updateSave" + beanName);
	Parameter param1 = new Parameter(beanType, beanFiledName);
	param1.addAnnotation("@ModelAttribute ");
	Parameter paramModelMap = new Parameter(new FullyQualifiedJavaType(ModelMap.class.getName()), "map");
	method.addParameter(param1); 
	method.addParameter(paramModelMap); 
	// 方法body
	method.addBodyLine("try {");
	method.addBodyLine("if(" + beanFiledName + " == null ){");
	method.addBodyLine("// || NumberUtil.isNotPositive(" + beanFiledName + ".getId())){");
	method.addBodyLine("map.put(\"message\",\"更新对象为空。\");");
	method.addBodyLine(ControllerPluginUtil.RETURN);
	method.addBodyLine("}");
	method.addBodyLine("int updateCount = this." + businessFieldName + ".update(" + beanFiledName + ");");
	method.addBodyLine("if(updateCount == 1 ){");
	method.addBodyLine("map.put(\"message\",\"更新成功。\");");
	method.addBodyLine("}else{");
	method.addBodyLine("map.put(\"message\",\"更新失败。\");");
	method.addBodyLine("}");
	method.addBodyLine("} catch (Exception e) {");
	method.addBodyLine("logger.error(\"更新异常\" + e.getMessage());");
	method.addBodyLine("map.put(\"message\", \"查询异常\" + e.getMessage());");
	method.addBodyLine("}");	
	method.addBodyLine(ControllerPluginUtil.RETURN);
			
	methodList.add(method);
       
       return methodList;
}
 
Example 7
Source File: GetByKeyControllerGenerator.java    From maven-archetype with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static List<Method> generator(FullyQualifiedJavaType beanType,String beanName,
		String businessFieldName,FullyQualifiedJavaType keyType, String keyFiledName){
	List<Method> methodList = new ArrayList<Method>();
	
	Method method = new Method();
       method.addAnnotation("@RequestMapping(value = \"get" + beanName + "ByKey.do\")");
       method.setVisibility(JavaVisibility.PUBLIC);
       method.setReturnType(new FullyQualifiedJavaType(String.class.getName()));
       method.setName("get" + beanName + "ByKey");
       Parameter param = new Parameter(keyType, keyFiledName);
       Parameter paramModelMap = new Parameter(new FullyQualifiedJavaType(ModelMap.class.getName()), "map");
       param.addAnnotation("@RequestParam(\"" + keyFiledName + "\") ");
       method.addParameter(param); 
       method.addParameter(paramModelMap); 
       // 方法body
       method.addBodyLine("try {");
       method.addBodyLine("if(" + keyFiledName + " == null || " + keyFiledName + " < 0){");
       method.addBodyLine("map.put(\"message\",\"ID 错误。\"); ");
       method.addBodyLine(ControllerPluginUtil.RETURN);
       method.addBodyLine("}");
       method.addBodyLine(beanName + " result = this."+ businessFieldName +".get"+ beanName +"ByKey(" + keyFiledName + ");");
       method.addBodyLine("map.put(\"message\",result);");
       method.addBodyLine("} catch (Exception e) {");
       method.addBodyLine("logger.error(\"主键获取详情异常;key=\"+" + keyFiledName + " + e.getMessage());");
       method.addBodyLine("map.put(\"message\",\"主键获取详情异常;key=\"+" + keyFiledName + " + e.getMessage());");
       method.addBodyLine("}");
       method.addBodyLine(ControllerPluginUtil.RETURN);
       
	methodList.add(method);
       
       return methodList;
}
 
Example 8
Source File: InsertControllerGenerator.java    From maven-archetype with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static List<Method> generator(FullyQualifiedJavaType beanType,String beanName,
		String businessFieldName){
	List<Method> methodList = new ArrayList<Method>();
	
	String beanFieldName = StringUtils.uncapitalize(beanName);
	
	Method method = new Method();
	method.addAnnotation("@RequestMapping(value = \"insert.do\")");
	method.addAnnotation("@ResponseBody");
	method.setVisibility(JavaVisibility.PUBLIC);
	method.setReturnType(new FullyQualifiedJavaType(AjaxResponseBean.class.getName()));
	method.setName("insert");
	Parameter param = new Parameter(beanType, beanFieldName);
	param.addAnnotation("@ModelAttribute(\"" + beanFieldName + "\") ");
	method.addParameter(param); 
	// 方法body
	method.addBodyLine("try {");
	method.addBodyLine("// 数据校验");
	method.addBodyLine("");
	method.addBodyLine("this." + businessFieldName + ".insertSelective(" + beanFieldName + ");");
	method.addBodyLine("return AjaxResponseBean.Const.SUCCESS_RESPONSE_BEAN;");
	method.addBodyLine("} catch (Exception e) {");
	method.addBodyLine("logger.error(\"插入异常\" + e.getMessage());");
	method.addBodyLine("return AjaxResponseBean.getErrorResponseBean(\"插入异常\" + e.getMessage());");
	method.addBodyLine("}");
	
	methodList.add(method);
       
       return methodList;
}
 
Example 9
Source File: BatchUpdateControllerGenerator.java    From maven-archetype with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static List<Method> generator(FullyQualifiedJavaType innerClassType,String beanName,
		String businessFieldName){
	List<Method> methodList = new ArrayList<Method>();
	
	String innerClassFiledName = StringUtils.uncapitalize(innerClassType.getShortName());
	
	Method method = new Method();
       method.addAnnotation("@RequestMapping(value = \"batchUpdateSave" + beanName + ".do\")");
       method.addAnnotation("@ResponseBody");
       method.setVisibility(JavaVisibility.PUBLIC);
       method.setReturnType(new FullyQualifiedJavaType(AjaxResponseBean.class.getName()));
       method.setName("batchUpdateSave" + beanName);
       Parameter param1 = new Parameter(innerClassType, innerClassFiledName);
       param1.addAnnotation("@ModelAttribute ");
       method.addParameter(param1); 
       // 方法body
       method.addBodyLine("try {");
       method.addBodyLine("if(" + innerClassFiledName + " != null && CollectionUtil.isNotNull(" + innerClassFiledName + ".get"+ beanName + "List())){");
       method.addBodyLine("int updateCount = this." + businessFieldName + ".update(" + innerClassFiledName + ".get"+ beanName + "List());");
       method.addBodyLine("if(updateCount >0 ){");
       method.addBodyLine("return AjaxResponseBean.Const.SUCCESS_RESPONSE_BEAN;");
       method.addBodyLine("}");
       method.addBodyLine("}");
       method.addBodyLine("return AjaxResponseBean.Const.ERROR_RESPONSE_BEAN;");
       method.addBodyLine("} catch (Exception e) {");
       method.addBodyLine("logger.error(\"批量更新异常\" + e.getMessage());");
       method.addBodyLine("return AjaxResponseBean.getErrorResponseBean(\"批量更新异常\" + e.getMessage());");
       method.addBodyLine("}");
	methodList.add(method);
	
    return methodList;
}
 
Example 10
Source File: UpdateControllerGenerator.java    From maven-archetype with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static List<Method> generator(FullyQualifiedJavaType beanType,String beanName,
		String businessFieldName){
	List<Method> methodList = new ArrayList<Method>();
	String beanFiledName = StringUtils.uncapitalize(beanName);
	
	Method method = new Method();
	method.addAnnotation("@RequestMapping(value = \"updateSave" + beanName + ".do\")");
	method.addAnnotation("@ResponseBody");
	method.setVisibility(JavaVisibility.PUBLIC);
	method.setReturnType(new FullyQualifiedJavaType(AjaxResponseBean.class.getName()));
	method.setName("updateSave" + beanName);
	Parameter param1 = new Parameter(beanType, beanFiledName);
	param1.addAnnotation("@ModelAttribute ");
	method.addParameter(param1); 
	// 方法body
	method.addBodyLine("try {");
	method.addBodyLine("if(" + beanFiledName + " == null ){");
	method.addBodyLine("// || NumberUtil.isNotPositive(" + beanFiledName + ".getId())){");
	method.addBodyLine("return AjaxResponseBean.Const.PARAMETER_INVALID_ERROR_RESPONSE_BEAN;");
	method.addBodyLine("}");
	method.addBodyLine("int updateCount = this." + businessFieldName + ".update(" + beanFiledName + ");");
	method.addBodyLine("if(updateCount >0 ){");
	method.addBodyLine("return AjaxResponseBean.Const.SUCCESS_RESPONSE_BEAN;");
	method.addBodyLine("}");
	method.addBodyLine("return AjaxResponseBean.Const.ERROR_RESPONSE_BEAN;");
	method.addBodyLine("} catch (Exception e) {");
	method.addBodyLine("logger.error(\"更新异常\" + e.getMessage());");
	method.addBodyLine("return AjaxResponseBean.getErrorResponseBean(\"更新异常\" + e.getMessage());");
	method.addBodyLine("}");		
			
	methodList.add(method);
       
       return methodList;
}
 
Example 11
Source File: GetByKeyControllerGenerator.java    From maven-archetype with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static List<Method> generator(FullyQualifiedJavaType beanType,String beanName,
		String businessFieldName,FullyQualifiedJavaType keyType, String keyFiledName){
	List<Method> methodList = new ArrayList<Method>();
	
	Method method = new Method();
       method.addAnnotation("@RequestMapping(value = \"get" + beanName + "ByKey.do\")");
       method.addAnnotation("@ResponseBody");
       method.setVisibility(JavaVisibility.PUBLIC);
       method.setReturnType(new FullyQualifiedJavaType(AjaxResponseBean.class.getName()));
       method.setName("get" + beanName + "ByKey");
       Parameter param = new Parameter(keyType, keyFiledName);
       param.addAnnotation("@RequestParam(\"" + keyFiledName + "\") ");
       method.addParameter(param); 
       // 方法body
       method.addBodyLine("try {");
       method.addBodyLine("if(" + keyFiledName + " == null || " + keyFiledName + " < 0){");
       method.addBodyLine("return AjaxResponseBean.Const.PARAMETER_INVALID_ERROR_RESPONSE_BEAN; ");
       method.addBodyLine("}");
       method.addBodyLine(beanName + " result = this."+ businessFieldName +".get"+ beanName +"ByKey(" + keyFiledName + ");");
       method.addBodyLine("return AjaxResponseBean.getReturnValueResponseBean(result);");
       method.addBodyLine("} catch (Exception e) {");
       method.addBodyLine("logger.error(\"主键获取详情异常;key=\"+" + keyFiledName + " + e.getMessage());");
       method.addBodyLine("return AjaxResponseBean.getErrorResponseBean(\"主键获取详情异常;key=\"+" + keyFiledName + " + e.getMessage());");
       method.addBodyLine("}");
	
	methodList.add(method);
       
       return methodList;
}
 
Example 12
Source File: SelectListControllerGenerator.java    From maven-archetype with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static List<Method> generator(FullyQualifiedJavaType beanType,String beanName,
		String businessFieldName,String criteriaType){
	List<Method> methodList = new ArrayList<Method>();
	
	Method method = new Method();
       method.addAnnotation("@RequestMapping(value = \"select" + beanName + "List.do\")");
       method.setVisibility(JavaVisibility.PUBLIC);
       method.setReturnType(new FullyQualifiedJavaType(String.class.getName()));
       method.setName("select" + beanName + "List");
       Parameter param1 = new Parameter(new FullyQualifiedJavaType(Short.class.getName()), "conditionType");
       param1.addAnnotation("@RequestParam(\"conditionType\") ");
       Parameter param2 = new Parameter(FullyQualifiedJavaType.getStringInstance(), "conditionValue");
       param2.addAnnotation("@RequestParam(\"conditionValue\") ");
       Parameter param3 = new Parameter(new FullyQualifiedJavaType(PaginationBean.class.getName()), "paginationBean");
       param3.addAnnotation("@ModelAttribute ");
       Parameter paramModelMap = new Parameter(new FullyQualifiedJavaType(ModelMap.class.getName()), "map");
       method.addParameter(param1); 
       method.addParameter(param2); 
       method.addParameter(param3); 
       method.addParameter(paramModelMap); 
       // 方法body
       method.addBodyLine("try {");
       method.addBodyLine("int currentPage = paginationBean.getPageNum();");
       method.addBodyLine("int pageSize = paginationBean.getNumPerPage(); ");
       method.addBodyLine("");
       method.addBodyLine("if(pageSize < 1){");
       method.addBodyLine("map.put(\"message\",\"pageSize 错误。\"); ");
       method.addBodyLine(ControllerPluginUtil.RETURN);
       method.addBodyLine("}");
       method.addBodyLine("if(currentPage<1){");
       method.addBodyLine("map.put(\"message\",\"currentPage 错误。\"); ");
       method.addBodyLine(ControllerPluginUtil.RETURN);
       method.addBodyLine("}");
       method.addBodyLine("// 构造查询参数");
       method.addBodyLine(""+criteriaType + " param =new " + criteriaType + "();");
       method.addBodyLine("//"+criteriaType + ".Criteria criteria = param.createCriteria();");
       method.addBodyLine("");
       method.addBodyLine("// 根据参数设置查询条件");
       method.addBodyLine("");
       method.addBodyLine("// 取得当前查询的总记录结果");
       method.addBodyLine("int total = this." + businessFieldName + ".count" + beanName + "List(param);");
       method.addBodyLine("if(total == 0){");
       method.addBodyLine("// 没有记录数");
       method.addBodyLine("map.put(\"message\",\"没有记录。\"); ");
       method.addBodyLine(ControllerPluginUtil.RETURN);
       method.addBodyLine("}");
       method.addBodyLine("paginationBean.setTotalCount(total);");
       method.addBodyLine("// 判断当前请求的页码有没有超过总页数");
       method.addBodyLine("int totalPages = PaginationUtil.getPages(total, pageSize);");
       method.addBodyLine("paginationBean.setTotalPages(totalPages);");
       method.addBodyLine("");
       method.addBodyLine("if(currentPage > totalPages){");
       method.addBodyLine("// 当前页超过总页数,取最大数");
       method.addBodyLine("currentPage = totalPages;");
       method.addBodyLine("paginationBean.setPageNum(currentPage);");
       method.addBodyLine("}");
       method.addBodyLine("");
       method.addBodyLine("// 设置排序");
       method.addBodyLine("// param.setOrderByClause(\" id asc \");");
       method.addBodyLine("");
       method.addBodyLine("int start = (currentPage - 1) * pageSize;");
       method.addBodyLine("param.setStart(start);");
       method.addBodyLine("param.setCount(pageSize);");
       method.addBodyLine("");
       method.addBodyLine("List<" + beanName + "> " + StringUtils.uncapitalize(beanName) +"List = this." + businessFieldName + ".select" + beanName + "List(param);");
       method.addBodyLine("");
       method.addBodyLine("paginationBean.setResult(" + StringUtils.uncapitalize(beanName) +"List);  // 返回数据结果");
       method.addBodyLine("map.put(\"message\",JSON.toJSONString(" + StringUtils.uncapitalize(beanName) +"List));");
       method.addBodyLine("} catch (Exception e) {");
       method.addBodyLine("logger.error(\"查询异常\" + e.getMessage());");
       method.addBodyLine("map.put(\"message\", \"查询异常\" + e.getMessage());");
       method.addBodyLine("}"); 
       method.addBodyLine(ControllerPluginUtil.RETURN);
       
	methodList.add(method);
       
       return methodList;
}
 
Example 13
Source File: SelectListControllerGenerator.java    From maven-archetype with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static List<Method> generator(FullyQualifiedJavaType beanType,String beanName,
		String businessFieldName,String criteriaType){
	List<Method> methodList = new ArrayList<Method>();
	
	Method method = new Method();
       method.addAnnotation("@RequestMapping(value = \"select" + beanName + "List.do\")");
       method.addAnnotation("@ResponseBody");
       method.setVisibility(JavaVisibility.PUBLIC);
       method.setReturnType(new FullyQualifiedJavaType(AjaxResponseBean.class.getName()));
       method.setName("select" + beanName + "List");
       Parameter param1 = new Parameter(new FullyQualifiedJavaType(Short.class.getName()), "conditionType");
       param1.addAnnotation("@RequestParam(\"conditionType\") ");
       Parameter param2 = new Parameter(FullyQualifiedJavaType.getStringInstance(), "conditionValue");
       param2.addAnnotation("@RequestParam(\"conditionValue\") ");
       Parameter param3 = new Parameter(new FullyQualifiedJavaType(PaginationBean.class.getName()), "paginationBean");
       param3.addAnnotation("@ModelAttribute ");
       method.addParameter(param1); 
       method.addParameter(param2); 
       method.addParameter(param3); 
       // 方法body
       method.addBodyLine("try {");
       method.addBodyLine("int currentPage = paginationBean.getPageNum();");
       method.addBodyLine("int pageSize = paginationBean.getNumPerPage(); ");
       method.addBodyLine("");
       method.addBodyLine("if(pageSize < 1){");
       method.addBodyLine("return AjaxResponseBean.Const.PARAMETER_INVALID_ERROR_RESPONSE_BEAN; ");
       method.addBodyLine("}");
       method.addBodyLine("if(currentPage<1){");
       method.addBodyLine("return AjaxResponseBean.Const.PARAMETER_INVALID_ERROR_RESPONSE_BEAN; ");
       method.addBodyLine("}");
       method.addBodyLine("// 构造查询参数");
       method.addBodyLine(""+criteriaType + " param =new " + criteriaType + "();");
       method.addBodyLine("//"+criteriaType + ".Criteria criteria = param.createCriteria();");
       method.addBodyLine("");
       method.addBodyLine("// 根据参数设置查询条件");
       method.addBodyLine("");
       method.addBodyLine("// 取得当前查询的总记录结果");
       method.addBodyLine("int total = this." + businessFieldName + ".count" + beanName + "List(param);");
       method.addBodyLine("if(total == 0){");
       method.addBodyLine("// 没有记录数");
       method.addBodyLine("return AjaxResponseBean.getNoDataReturnValueResponseBean();");
       method.addBodyLine("}");
       method.addBodyLine("paginationBean.setTotalCount(total);");
       method.addBodyLine("// 判断当前请求的页码有没有超过总页数");
       method.addBodyLine("int totalPages = PaginationUtil.getPages(total, pageSize);");
       method.addBodyLine("paginationBean.setTotalPages(totalPages);");
       method.addBodyLine("");
       method.addBodyLine("if(currentPage > totalPages){");
       method.addBodyLine("// 当前页超过总页数,取最大数");
       method.addBodyLine("currentPage = totalPages;");
       method.addBodyLine("paginationBean.setPageNum(currentPage);");
       method.addBodyLine("}");
       method.addBodyLine("");
       method.addBodyLine("// 设置排序");
       method.addBodyLine("// param.setOrderByClause(\" id asc \");");
       method.addBodyLine("");
       method.addBodyLine("int start = (currentPage - 1) * pageSize;");
       method.addBodyLine("param.setStart(start);");
       method.addBodyLine("param.setCount(pageSize);");
       method.addBodyLine("");
       method.addBodyLine("List<" + beanName + "> " + StringUtils.uncapitalize(beanName) +"List = this." + businessFieldName + ".select" + beanName + "List(param);");
       method.addBodyLine("");
       method.addBodyLine("paginationBean.setResult(" + StringUtils.uncapitalize(beanName) +"List);  // 返回数据结果");
       method.addBodyLine("return AjaxResponseBean.getReturnValueResponseBean(paginationBean);");
       method.addBodyLine("} catch (Exception e) {");
       method.addBodyLine("logger.error(\"查询异常\" + e.getMessage());");
       method.addBodyLine("return AjaxResponseBean.getErrorResponseBean(\"查询异常\" + e.getMessage());");
       method.addBodyLine("}"); 
	
	methodList.add(method);
       
       return methodList;
}