프론트 데스크톱 dao 인터페이스와 NeOrderFatherDao 구현
4729 단어 order
package cn.client.dao;
import java.util.List;
import cn.entity.NeOrderFather;
/*
* DAO
* */
public interface NeOrderFatherDao {
//
public int insertOrderFather(String orderFatherId, String username);
//
public int getTotalCount(String username);
//
public int getTotalCount(String username,int statusId);
//
public List<NeOrderFather> getNeOrderFatherByPage(int pageIndex, int pageSize,String username);
// , ,
public int update(String orderFatherId,int statusId);
}
package cn.client.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import cn.client.dao.BaseDao;
import cn.client.dao.NeOrderFatherDao;
import cn.entity.NeOrderFather;
/*
* DAO
* */
public class NeOrderFatherDaoImpl extends BaseDao implements NeOrderFatherDao {
Connection conn = null;//
PreparedStatement pstmt = null;//
ResultSet rs = null;//
//
public int insertOrderFather(String orderFatherId, String username) {
String sql = "insert into ne_order_father" +
" (ne_order_father_id, ne_user_id, ne_order_time, ne_status_id)" +
"values" +
" (?, ?, sysdate, 1)";
return this.executeUpdate(sql, new Object[]{
orderFatherId,
username
});
}
//
public int getTotalCount(String username){
int total = 0;
String sql = "select count(*) from ne_order_father where ne_user_id =?";
conn=this.getConnection();
try {
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, username);
rs = pstmt.executeQuery();
if(rs.next()){
total = rs.getInt(1);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
this.closeAll(conn, pstmt, rs);
}
return total;
}
//
public int getTotalCount(String username,int statusId){
int total = 0;
String sql = "select count(*) from ne_order_father where ne_user_id =? and ne_status_id=?";
conn=this.getConnection();
try {
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, username);
pstmt.setInt(2, statusId);
rs = pstmt.executeQuery();
if(rs.next()){
total = rs.getInt(1);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
this.closeAll(conn, pstmt, rs);
}
return total;
}
//
public List<NeOrderFather> getNeOrderFatherByPage(int pageIndex, int pageSize,String username){
int start = (pageIndex - 1) * pageSize; //
int end = pageIndex * pageSize; //
if(start>=1){
start++;
}
List<NeOrderFather> list = new ArrayList<NeOrderFather>();
NeOrderFather item = null;
String sql ="SELECT * FROM ( SELECT A.*, ROWNUM RN " +
"FROM (SELECT * FROM ne_order_father where " +
"ne_user_id =? " +
"order by ne_order_father.ne_order_time desc) A) WHERE RN BETWEEN ? AND ?";
conn=this.getConnection();
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, username);
pstmt.setInt(2, start);
pstmt.setInt(3, end);
rs = pstmt.executeQuery();
while(rs.next()){
item = new NeOrderFather(
rs.getString(1),
rs.getString(2),
rs.getString(3),
rs.getInt(4)
);
list.add(item);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
this.closeAll(conn, pstmt, rs);
}
return list;
}
// , ,
public int update(String orderFatherId,int statusId){
String sql= "update ne_order_father " +
" set ne_status_id = ? " +
" where ne_order_father_id = ?";
return this.executeUpdate(sql, new Object[]{
statusId,
orderFatherId
});
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
프론트 데스크톱 dao 인터페이스와 NePlan OrderDao 구현텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.