分頁存儲過程:
創(chuàng)新互聯(lián)長期為超過千家客戶提供的網站建設服務,團隊從業(yè)經驗10年,關注不同地域、不同群體,并針對不同對象提供差異化的產品和服務;打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網生態(tài)環(huán)境。為順平企業(yè)提供專業(yè)的成都做網站、網站建設,順平網站改版等技術服務。擁有十載豐富建站經驗和眾多成功案例,為您定制開發(fā)。
CREATE OR REPLACE PROCEDURE prc_query
(p_tableName in varchar2, --表名
p_strWhere in varchar2, --查詢條件
p_orderColumn in varchar2, --排序的列
p_orderStyle in varchar2, --排序方式
p_curPage in out number, --當前頁
p_pageSize in out number, --每頁顯示記錄條數
p_totalRecords out number, --總記錄數
p_totalPages out number, --總頁數
v_cur out pkg_query.cur_query) --返回的結果集
IS
v_sql VARCHAR2(1000) := ''; --sql語句
v_startRecord Number(4); --開始顯示的記錄條數
v_endRecord Number(4); --結束顯示的記錄條數
BEGIN
--記錄中總記錄條數
v_sql := 'SELECT TO_NUMBER(COUNT(*)) FROM ' || p_tableName || ' WHERE 1=1';
IF p_strWhere IS NOT NULL or p_strWhere <> '' THEN
v_sql := v_sql || p_strWhere;
END IF;
EXECUTE IMMEDIATE v_sql INTO p_totalRecords;
--驗證頁面記錄大小
IF p_pageSize < 0 THEN
p_pageSize := 0;
END IF;
--根據頁大小計算總頁數
IF MOD(p_totalRecords,p_pageSize) = 0 THEN
p_totalPages := p_totalRecords / p_pageSize;
ELSE
p_totalPages := p_totalRecords / p_pageSize + 1;
END IF;
--驗證頁號
IF p_curPage < 1 THEN
p_curPage := 1;
END IF;
IF p_curPage > p_totalPages THEN
p_curPage := p_totalPages;
END IF;
--實現(xiàn)分頁查詢
v_startRecord := (p_curPage - 1) * p_pageSize + 1;
v_endRecord := p_curPage * p_pageSize;
v_sql := 'SELECT * FROM (SELECT A.*, rownum r FROM ' ||
'(SELECT * FROM ' || p_tableName;
IF p_strWhere IS NOT NULL or p_strWhere <> '' THEN
v_sql := v_sql || ' WHERE 1=1' || p_strWhere;
END IF;
IF p_orderColumn IS NOT NULL or p_orderColumn <> '' THEN
v_sql := v_sql || ' ORDER BY ' || p_orderColumn || ' ' || p_orderStyle;
END IF;
v_sql := v_sql || ') A WHERE rownum <= ' || v_endRecord || ') B WHERE r >= '
|| v_startRecord;
DBMS_OUTPUT.put_line(v_sql);
OPEN v_cur FOR v_sql;
END prc_query;
controller:
@Controller
@RequestMapping("/userloginLog")
public class UserLoginLogController {
@Autowired
private IUserLoginLogService userLoginLogService;
@RequestMapping("/getAllUser")
public String getAllUser(HttpServletRequest request,HttpServletResponse response,Model model){
try {
String sql = "";
int pageNo =1;
Map
String StrpageNo = request.getParameter("pageNo");
if(StringUtils.isNotBlank(StrpageNo)){
pageNo = Integer.parseInt(StrpageNo);
}
String loginName = request.getParameter("loginName");
String resultCode = request.getParameter("resultCode");
String channelid = request.getParameter("channelid");
String startTime = request.getParameter("startTime");
String endTime = request.getParameter("endTime");
if(StringUtils.isNotBlank(loginName)){
sql+=" and login_name='" + loginName + "'";
model.addAttribute("loginName", loginName);
}
if(StringUtils.isNotBlank(resultCode)){
sql+=" and RESULT_CODE='" + resultCode + "'";
model.addAttribute("resultCode", resultCode);
}
if(StringUtils.isNotBlank(channelid)){
sql+=" and CHANNELID='" + channelid + "'";
model.addAttribute("channelid", channelid);
}
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime) ){
sql+=" and LOGIN_TIME between to_date('"+startTime+"', 'yyyy-mm-dd hh34:mi:ss') and to_date('"+endTime+"', 'yyyy-mm-dd hh34:mi:ss')";
model.addAttribute("startTime", startTime);
model.addAttribute("endTime", endTime);
}
param.put("tableName", "TL_USER_LOGIN_LOG");
param.put("strWhere", sql);
param.put("curPage", pageNo);
param.put("pageSize", 20);
userLoginLogService.getPrAllUser(param);
//result 為在mybatis xml文件時 寫的返回結果名
List
int curPage = (Integer) param.get("curPage");
int totalRecords = (Integer) param.get("totalRecords");
int totalPages = (Integer) param.get("totalPages");
model.addAttribute("myPage", curPage);
model.addAttribute("pageNo", curPage);
model.addAttribute("totalCount", totalRecords);
model.addAttribute("totalPage", totalPages);
model.addAttribute("userLoginLogList", LoginLogList);
return "prTest";
} catch (Exception e) {
e.printStackTrace();
model.addAttribute("InfoMessage",
"獲取信息失敗,異常:" + e.getMessage());
return "result";
}
}
}
IUserLoginLogService:
public List
UserLoginLogServiceImpl:
@Override
public List
// TODO Auto-generated method stub
return userLoginLogDao.getPrAllUser(map);
}
IUserLoginLogDao:
public List
mybitas:
{call prc_query(
#{tableName,mode=IN,jdbcType=VARCHAR},
#{strWhere,mode=IN,jdbcType=VARCHAR},
#{orderColumn,mode=IN,jdbcType=VARCHAR},
#{orderStyle,mode=IN,jdbcType=VARCHAR},
#{curPage,mode=IN,jdbcType=INTEGER},
#{pageSize,mode=IN,jdbcType=INTEGER},
#{totalRecords,mode=OUT,jdbcType=INTEGER},
#{totalPages,mode=OUT,jdbcType=INTEGER},
#{result,mode=OUT,javaType=java.sql.ResultSet,jdbcType=CURSOR,resultMap=com.ai.tyca.dao.IUserLoginLogDao.BaseResultMap}
)}
JSP:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
$(function(){
var pageNo = parseInt($("#currentPageNo").val());
var totalPage = parseInt($("#totalPage").val());
if(pageNo == 1 && totalPage == pageNo){
$("#previous").hide();
$("#next").hide();
}else if(pageNo == 1 && totalPage > 1){
$("#previous").hide();
$("#next").show();
}else if(pageNo > 1 && pageNo < totalPage){
$("#previous").show();
$("#next").show();
}else if(pageNo == totalPage && pageNo > 1){
$("#previous").show();
$("#next").hide();
}
$("#previous").click(function(){
$("#pageNo").val(--pageNo);
$("#form1").submit();
});
$("#next").click(function(){
$("#pageNo").val(++pageNo);
$("#form1").submit();
});
$("#firstPage").click(function(){
$("#pageNo").val(1);
$("#form1").submit();
});
$("#lastPage").click(function(){
$("#pageNo").val(totalPage);
$("#form1").submit();
});
$("#selectPage").change(function(){
$("#pageNo").val($(this).val());
$("#form1").submit();
});
$("#selectPage").val(pageNo);
$("#addItemNoteConfirm").click(function(){
//textarea可以使用val獲得值
var notes = $("#itemNote").val();
$("#notes").val(notes);
$("#showForm").submit();
});
$("#goSearch").click(function(){
var start = $("#startRequestTime").val();
var end = $("#endRequestTime").val();
if(start != null && end != null && $.trim(start) != '' && $.trim(end) != ''){
if(start >= end){
alert("開始時間不能大于結束時間!");
return false;
}
}
$("#form1").submit();
});
$("#reset").click(function(){
$('input').val('');
});
$('#dataID').datagrid({
onDblClickRow: function(rowIndex) {
$('#dataID').datagrid('selectRow',rowIndex);
var currentRow =$("#dataID").datagrid("getSelected");
$.ajax({
type:'post',
url:'Security/getSecurity.do',
type:"post",
dataType:"text",
data:{
originalxml:currentRow.originalxml
},
cache:false ,
success:function(orgXML){
$("#dialogorgxml").textbox('setValue',orgXML);
}
});
if(currentRow.loginUserType == "01"){
var loginUserType = "手機賬號";
}else if(currentRow.loginUserType == "02"){
var loginUserType = "別名賬號";
}
if(currentRow.loginAccountType == "01"){
var loginAccountType ="個人用戶";
}else if(currentRow.loginAccountType == "02"){
var loginAccountType ="企業(yè)用戶";
}
$("#dialogName").textbox('setValue',currentRow.loginName);
$("#dialogTime").textbox('setValue',currentRow.requestTime);
$("#dialogUserType").textbox('setValue',loginUserType);
$("#dialogAccountType").textbox('setValue',loginAccountType);
$("#dialogResult").textbox('setValue',currentRow.result);
$("#dialogDesc").textbox('setValue',currentRow.resultDesc);
$("#dialogRspxml").textbox('setValue',currentRow.rspxml);
$("#dialogChannelid").textbox('setValue',currentRow.channelid);
$("#dialogorgxml").textbox('setValue',currentRow.originalxml);
$('#roleDialog').show().dialog({
left:400,
top:50,
modal : true,
title : '詳細信息',
modal: true,
closable: true,
draggable: true,
width: 550,
height: 580
});
}
});
});
用戶名: | |
請求時間: | |
用戶類型: | |
賬號類型: | |
返回結果: | |
平臺系統(tǒng): | |
返回報文: | |
解密后報文: |