whyclj
2020-07-22 a5729100cb1eaa3584b3a194e46e1b8b52b3ed1a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.fgkj.dao.impl;
 
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import com.fgkj.dao.BaseDAO;
import com.fgkj.dao.CallBack;
import com.fgkj.dao.DAOHelper;
import com.fgkj.db.DBUtil;
import com.fgkj.db.IDatabaseName;
import com.fgkj.dto.Batt_devdischarge_param;
 
public class Batt_devdischarge_paramImpl implements BaseDAO,CallBack{
 
    public List getResults(ResultSet rs) {
        List list=new ArrayList();
        try {
            while(rs.next()){
                Batt_devdischarge_param bdparam=new Batt_devdischarge_param();
                bdparam.setNum(rs.getInt("num"));
                bdparam.setDev_param_type(rs.getInt("dev_param_type"));
                bdparam.setDev_param_value(rs.getInt("dev_param_value"));
                bdparam.setNote(rs.getString("note"));
                list.add(bdparam);
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return list;
    }
 
    public boolean add(Object obj) {
        Batt_devdischarge_param bdparam=(Batt_devdischarge_param) obj;
        String sql="insert into web_site.tb_batt_devdischarge_param(dev_param_type,dev_param_value) values(?,?)";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{bdparam.getDev_param_type(),bdparam.getDev_param_value()});
        return bl;
    }
    
    public boolean update(Object obj) {
        Batt_devdischarge_param bdparam=(Batt_devdischarge_param) obj;
        String sql="update web_site.tb_batt_devdischarge_param set dev_param_value=?  where dev_param_type=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{bdparam.getDev_param_value(),bdparam.getDev_param_type()});
        return bl;
    }
 
    public boolean del(Object obj) {
        Batt_devdischarge_param bdparam=(Batt_devdischarge_param) obj;
        String sql="delete from web_site.tb_batt_devdischarge_param where dev_param_type=?";
        Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{bdparam.getDev_param_type()});
        return bl;
    }
 
    public List searchAll() {
        String sql="select num,dev_param_type,dev_param_value,note from web_site.tb_batt_devdischarge_param  ";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new BattDischarge_paramImpl() );
        return list;
    }
    //11.1根据参数类型dev_param_type查询参数值dev_param_value
    public List serchByCondition(Object obj) {
        Batt_devdischarge_param bdparam=(Batt_devdischarge_param) obj;
        String sql="select dev_param_value from web_site.tb_batt_devdischarge_param where dev_param_type=? limit 1 ";
        List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{bdparam.getDev_param_type()}, new CallBack() {
            
            public List getResults(ResultSet rs) {
                List list=new ArrayList();
                try {
                    while(rs.next()){
                        Batt_devdischarge_param bdparam =new Batt_devdischarge_param();
                        bdparam.setDev_param_value(rs.getInt("dev_param_value"));
                        list.add(bdparam);
                    }
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return list;
            }
        } );
        return list;
    }
 
    public List serchByInfo(Object obj) {
        // TODO Auto-generated method stub
        return null;
    }
 
}