优化代码

master
星期八 6 years ago
parent 44cfb15445
commit a3dc9ecb2d
  1. 12
      src/main/java/com/lq/code/interceptor/PageInteceptor.java
  2. 5
      src/main/java/com/lq/code/util/sql/SqlConstant.java
  3. 5
      src/main/webapp/WEB-INF/views/jsp/cms/sys/user/index.jsp

@ -1,10 +1,7 @@
package com.lq.code.interceptor; package com.lq.code.interceptor;
import com.lq.code.util.StringUtil; import com.lq.code.util.StringUtil;
import com.lq.code.util.sql.AbstractDbBuiler; import com.lq.code.util.sql.*;
import com.lq.code.util.sql.MysqlBuilder;
import com.lq.code.util.sql.OracleBuiler;
import com.lq.code.util.sql.PageInterface;
import org.apache.ibatis.executor.Executor; import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.executor.statement.StatementHandler; import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.mapping.BoundSql; import org.apache.ibatis.mapping.BoundSql;
@ -52,13 +49,12 @@ public class PageInteceptor implements Interceptor {
String sql=boundSql.getSql(); String sql=boundSql.getSql();
PageInterface pageInterface=(PageInterface)boundSql.getParameterObject(); PageInterface pageInterface=(PageInterface)boundSql.getParameterObject();
AbstractDbBuiler db = null; AbstractDbBuiler db = null;
if (dialect.equals("mysql")){ if (SqlConstant.DB_TYPE_MYSQL.equals(dialect)){
db = new MysqlBuilder(); db = new MysqlBuilder();
} }
if (dialect.equals("oracle")){ if (SqlConstant.DB_TYPE_ORACLE.equals(dialect)){
db = new OracleBuiler(); db = new OracleBuiler();
} }
// String countSql= db.countSql(sql);
String pageSql=db.concatPageSql(sql,pageInterface); String pageSql=db.concatPageSql(sql,pageInterface);
metaStatementHandler.setValue("delegate.boundSql.sql",pageSql); metaStatementHandler.setValue("delegate.boundSql.sql",pageSql);

@ -8,4 +8,9 @@ package com.lq.code.util.sql;
public class SqlConstant { public class SqlConstant {
public static final String SQL_SYMBOL = "_"; public static final String SQL_SYMBOL = "_";
public static final String DB_TYPE_MYSQL = "mysql";
public static final String DB_TYPE_ORACLE = "oracle";
} }

@ -20,7 +20,6 @@
<script type="text/javascript" src="${ctx}/resources/code/js/ajaxfileupload.js"></script> <script type="text/javascript" src="${ctx}/resources/code/js/ajaxfileupload.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(function() {// 初始化内容 $(function() {// 初始化内容
$("#dataList").datagrid({ $("#dataList").datagrid({
url:'list', url:'list',
pagination :"true", pagination :"true",
@ -154,14 +153,10 @@
}else{ }else{
$.messager.alert('操作失败','删除失败','error'); $.messager.alert('操作失败','删除失败','error');
} }
}}); }});
} }
}) })
} }
function getRoleArray() { function getRoleArray() {
var roleList=new Array(); var roleList=new Array();
$("input[name='roleIds']").each(function() { $("input[name='roleIds']").each(function() {

Loading…
Cancel
Save