package com.Finacing.service;
import com.Finacing.dao.BaseDao;
import com.Finacing.dao.FinancingproductDao;
import com.Finacing.entity.Financingproduct;
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class FinancingproductService extends BaseDao implements FinancingproductDao {
@Override
public List<Financingproduct> getAll() {
String sql = "select * from financingproduct order by salestarting";
List<Financingproduct> pros = new ArrayList<>();
ResultSet rs = super.executeQuery(sql);
try {
while (rs.next()){
Financingproduct pro = new Financingproduct();
Field[] fs = pro.getClass().getDeclaredFields();
for (int i = 0; i < fs.length; i++) {
fs[i].setAccessible(true);
fs[i].set(pro,rs.getObject(i+1));
}
pros.add(pro);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} finally {
try {
super.closeConn(rs,rs.getStatement(),rs.getStatement().getConnection());
} catch (SQLException e) {
e.printStackTrace();
}
}
return pros;
}
public List<Financingproduct> search(String id,int risk) {
String sql = "select * from financingproduct where 1=1 ";
List<Object> objs = new ArrayList<>();
if (id!=null&&id.length()!=0){
sql+=" and id like CONCAT('%',?,'%') ";
objs.add(id);
}
if (risk>0){
sql+= " and risk = ? ";
objs.add(risk);
}
ResultSet rs = null;
sql+= " order by salestarting";
if (!objs.isEmpty()){
rs = super.executeQuery(sql,objs.toArray());
}else{
rs = super.executeQuery(sql);
}
List<Financingproduct> pros = new ArrayList<>();
System.out.println(sql);
try {
while (rs.next()){
Financingproduct pro = new Financingproduct();
Field[] fs = pro.getClass().getDeclaredFields();
for (int i = 0; i < fs.length; i++) {
fs[i].setAccessible(true);
fs[i].set(pro,rs.getObject(i+1));
}
pros.add(pro);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} finally {
try {
super.closeConn(rs,rs.getStatement(),rs.getStatement().getConnection());
} catch (SQLException e) {
e.printStackTrace();
}
}
return pros;
}
@Override
public Financingproduct getProduct(String id) {
String sql = "select * from financingproduct where id=?";
Financingproduct pro = null;
ResultSet rs = super.executeQuery(sql,id);
try {
while (rs.next()){
pro = new Financingproduct();
Field[] fs = pro.getClass().getDeclaredFields();
for (int i = 0; i < fs.length; i++) {
fs[i].setAccessible(true);
fs[i].set(pro,rs.getObject(i+1));
}
}
} catch (SQLException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} finally {
try {
super.closeConn(rs,rs.getStatement(),rs.getStatement().getConnection());
} catch (SQLException e) {
e.printStackTrace();
}
}
return pro;
}
@Override
public boolean addProduct(Financingproduct financingproduct) {
String sql = "insert financingproduct values(";
Field[] fs = financingproduct.getClass().getDeclaredFields();
Object[] os = new Object[fs.length] ;
for (int i = 0; i < fs.length; i++) {
if (i==fs.length-1){
sql+="?)";
}else{
sql+="?,";
}
fs[i].setAccessible(true);
try {
os[i] = fs[i].get(financingproduct);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
return super.executeUpdate(sql,os);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
IT类课程习题-FinancingProduct-master.zip
共36个文件
java:8个
js:6个
xml:5个
需积分: 5 0 下载量 148 浏览量
2024-09-22
09:49:12
上传
评论
收藏 464KB ZIP 举报
温馨提示
IT类课程习题-FinancingProduct-master.zip
资源推荐
资源详情
资源评论
收起资源包目录
FinancingProduct-master.zip (36个子文件)
FinancingProduct-master
pom.xml 3KB
src
数据库.sql 554B
main
resources
rebel.xml 739B
java
com
Finacing
servlet
CheckIdServlet.java 1KB
SearchServlet.java 2KB
AddProductServlet.java 2KB
GetListServlet.java 1KB
dao
FinancingproductDao.java 278B
BaseDao.java 2KB
service
FinancingproductService.java 4KB
entity
Financingproduct.java 2KB
webapp
WEB-INF
web.xml 4KB
log4j.xml 2KB
applicationContext.xml 2KB
index.jsp 2KB
js
jquery-3.3.1.js 265KB
addProduct.js 2KB
index.js 2KB
bootstrap-3.3.7-dist
js
bootstrap.js 68KB
npm.js 484B
bootstrap.min.js 36KB
css
bootstrap-theme.min.css.map 25KB
bootstrap.min.css 118KB
bootstrap-theme.css.map 47KB
bootstrap-theme.css 26KB
bootstrap.css.map 380KB
bootstrap.css 143KB
bootstrap-theme.min.css 23KB
bootstrap.min.css.map 529KB
fonts
glyphicons-halflings-regular.svg 106KB
glyphicons-halflings-regular.ttf 44KB
glyphicons-halflings-regular.woff 23KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.woff2 18KB
addProduct.jsp 2KB
.gitignore 19B
共 36 条
- 1
资源评论
蜡笔小流
- 粉丝: 2344
- 资源: 1198
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功