Explorar el Código

数据库持久层操作范例

huangbo %!s(int64=6) %!d(string=hace) años
padre
commit
146abf2e95

+ 30 - 0
ipu-rest-demo/sql/ipu_db_demo.sql

@ -0,0 +1,30 @@
1
/*
2
Navicat MySQL Data Transfer
3

4
Source Server         : ipu测试-121.42.183.206
5
Source Server Version : 50625
6
Source Host           : 121.42.183.206:3307
7
Source Database       : test
8

9
Target Server Type    : MYSQL
10
Target Server Version : 50625
11
File Encoding         : 65001
12

13
Date: 2019-03-03 00:08:09
14
*/
15

16
SET FOREIGN_KEY_CHECKS=0;
17

18
-- ----------------------------
19
-- Table structure for ipu_db_demo
20
-- ----------------------------
21
DROP TABLE IF EXISTS `ipu_db_demo`;
22
CREATE TABLE `ipu_db_demo` (
23
  `pk` int(255) NOT NULL COMMENT '主键',
24
  `string_type` varchar(255) NOT NULL COMMENT '字符串字段',
25
  `int_type` int(255) NOT NULL COMMENT '整型字段',
26
  `decimal_type` decimal(4,2) NOT NULL COMMENT '小数值字段',
27
  `date_type` date NOT NULL COMMENT '日期字段',
28
  `datetime_type` datetime NOT NULL COMMENT '日期时间字段',
29
  PRIMARY KEY (`pk`)
30
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

+ 0 - 52
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/db/DbController.java

@ -1,52 +0,0 @@
1
package com.ai.ipu.server.demo.control.db;
2

3
import java.util.List;
4
import java.util.Map;
5

6
import org.springframework.stereotype.Controller;
7
import org.springframework.web.bind.annotation.RequestMapping;
8
import org.springframework.web.bind.annotation.ResponseBody;
9

10
import com.ai.ipu.database.dao.IpuDaoManager;
11
import com.ai.ipu.server.demo.dao.DemoBizDao;
12
import com.ai.ipu.server.demo.dao.DemoDao;
13
import com.ailk.common.data.IData;
14
import com.ailk.common.data.impl.DataMap;
15

16
@Controller
17
@RequestMapping("/db")
18
public class DbController {
19

20
    @ResponseBody
21
    @RequestMapping("/insert")
22
    public IData insert(IData params) {
23
        return null;
24
    }
25
    
26
    @ResponseBody
27
    @RequestMapping("/delete")
28
    public IData delete(IData params) {
29
        return null;
30
    }
31
    
32
    @ResponseBody
33
    @RequestMapping("/update")
34
    public IData update(IData params) throws Exception {
35
        DemoDao dao = IpuDaoManager.takeDao(DemoDao.class, "test");
36
        int dbResult = dao.update();
37
        IData result = new DataMap();
38
        result.put("UPDATE_NUM", dbResult);
39
        return result;
40
    }
41
    
42
    @ResponseBody
43
    @RequestMapping("/select")
44
    public IData select(IData params) throws Exception {
45
        DemoBizDao dao = IpuDaoManager.takeDao(DemoBizDao.class, "test");
46
        List<Map<String, Object>> dbResult = dao.select();
47
        IData result = new DataMap();
48
        /*dbResult需要转化成json字符串*/
49
        result.put("IPU_MEMBERS", dbResult);
50
        return result;
51
    }
52
}

+ 40 - 0
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/db/DbSqlController.java

@ -0,0 +1,40 @@
1
package com.ai.ipu.server.demo.control.db;
2

3
import java.util.List;
4
import java.util.Map;
5

6
import org.springframework.stereotype.Controller;
7
import org.springframework.web.bind.annotation.RequestMapping;
8
import org.springframework.web.bind.annotation.ResponseBody;
9

10
import com.ai.ipu.data.JMap;
11
import com.ai.ipu.data.impl.JsonMap;
12
import com.ai.ipu.database.dao.IpuDaoManager;
13
import com.ai.ipu.server.demo.dao.BizSqlDao;
14

15
/**
16
 * @author huangbo@asiainfo.com
17
 * @team IPU
18
 * @date 2019年3月2日下午8:35:22
19
 * @desc 基于SQL的操作范例
20
 */
21
@Controller
22
@RequestMapping("/db/sql")
23
public class DbSqlController {
24
    private String connName = "test";
25
    
26
    /**
27
     * @author huangbo@asiainfo.com
28
     * @title: executeSql
29
     * @desc: 执行SQL查询的范例
30
     */
31
    @ResponseBody
32
    @RequestMapping("/execute")
33
    public JMap executeSql(JMap param) throws Exception {
34
        BizSqlDao dao = IpuDaoManager.takeDao(BizSqlDao.class, connName);
35
        List<Map<String, Object>> dataResult = dao.executeSql();
36
        JMap result = new JsonMap();
37
        result.put("result", dataResult);
38
        return result;
39
    }
40
}

+ 113 - 74
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/db/DbTableController.java

@ -1,6 +1,5 @@
1 1
package com.ai.ipu.server.demo.control.db;
2 2

3
import java.util.HashMap;
4 3
import java.util.List;
5 4
import java.util.Map;
6 5

@ -9,150 +8,190 @@ import org.springframework.web.bind.annotation.RequestMapping;
9 8
import org.springframework.web.bind.annotation.ResponseBody;
10 9

11 10
import com.ai.ipu.common.date.TimeUtil;
11
import com.ai.ipu.data.JMap;
12
import com.ai.ipu.data.impl.JsonMap;
12 13
import com.ai.ipu.database.dao.IpuDaoManager;
13
import com.ai.ipu.server.demo.dao.DemoTableBizDao;
14
import com.ai.ipu.server.demo.dao.BizSqlDao;
15
import com.ai.ipu.server.demo.dao.CommonTableDao;
14 16
import com.ailk.common.data.IData;
15
import com.ailk.common.data.impl.DataMap;
16 17

17 18
/**
18 19
 * @author huangbo@asiainfo.com
19 20
 * @team IPU
20 21
 * @date 2018年9月13日下午4:14:55
21
 * @desc 单表快捷操作范例
22
 * 建表语句
23
 CREATE TABLE `ipu_db_test` (
24
  `pk` varchar(20) CHARACTER SET utf8 NOT NULL COMMENT '键主',
25
  `string_type1` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '字符串(可为空)',
26
  `string_type2` varchar(255) CHARACTER SET utf8 NOT NULL COMMENT '字符串(不为空)',
27
  `int_type1` int(11) DEFAULT NULL COMMENT '整型(可为空)',
28
  `int_type2` int(11) NOT NULL COMMENT '整型(不为空)',
29
  `date_type1` datetime DEFAULT NULL COMMENT '日期(不为空)',
30
  `date_type2` datetime NOT NULL COMMENT '日期(不为空)',
31
  `decimal_type1` decimal(10,0) DEFAULT NULL COMMENT '小数(可为空)',
32
  `decimal_type2` decimal(10,0) NOT NULL COMMENT '小数(不为空)',
33
  PRIMARY KEY (`pk`)
34
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
22
 * @desc 基于单表CRUD的操作范例
35 23
 */
36 24
@Controller
37 25
@RequestMapping("/db/table")
38 26
public class DbTableController {
39 27
    private String connName = "test";
40 28
    private String druidConnName = "test_druid";
41
    private String tableName = "ipu_db_test";
29
    private String tableName = "ipu_db_demo";
42 30
    
31
    /**
32
     * @author huangbo@asiainfo.com
33
     * @title: select
34
     * @desc: 基于主键查询数据的范例
35
     */
43 36
    @ResponseBody
44 37
    @RequestMapping("/select")
45
    public IData select(IData params) throws Exception {
46
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
47
        Map<String, Object> data = new HashMap<String, Object>();
38
    public JMap select(JMap param) throws Exception {
39
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
40
        JMap data = new JsonMap();
48 41
        data.put("pk", 0);
49
        
50 42
        Map<String, Object> re = dao.select(tableName, data);
51
        IData result = new DataMap();
52
        result.put("result_number", re);
43
        JMap result = new JsonMap();
44
        result.put("result", re);
53 45
        return result;
54 46
    }
55 47
    
48
    /**
49
     * @author huangbo@asiainfo.com
50
     * @title: selectByCond
51
     * @desc: 基于条件查询数据的范例
52
     */
56 53
    @ResponseBody
57 54
    @RequestMapping("/selectby")
58
    public IData selectByCond(IData params) throws Exception {
59
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
60
        Map<String, Object> condition = new HashMap<String, Object>();
61
        condition.put("int_type1", "111111");
62
        
55
    public JMap selectByCond(IData param) throws Exception {
56
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
57
        JMap condition = new JsonMap();
58
        condition.put("int_type", "0");
63 59
        List<Map<String, Object>> re = dao.selectByCond(tableName, condition);
64
        IData result = new DataMap();
65
        result.put("RESULT", re);
60
        JMap result = new JsonMap();
61
        result.put("result", re);
66 62
        return result;
67 63
    }
68 64
    
65
    /**
66
     * @author huangbo@asiainfo.com
67
     * @title: insert
68
     * @desc: 新增数据的范例
69
     */
69 70
    @ResponseBody
70 71
    @RequestMapping("/insert")
71
    public IData insert(IData params) throws Exception {
72
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
73
        Map<String, Object> data = new HashMap<String, Object>();
74
        data.put("pk", 0);
75
        data.put("string_type1", "字符串1");
76
        data.put("string_type2", "字符串2");
77
        data.put("int_type1", "111111");
78
        data.put("int_type2", "222222");
79
        data.put("date_type1", TimeUtil.getSysTime());
80
        data.put("date_type2", TimeUtil.getSysTime());
81
        data.put("decimal_type1", "9.99");
82
        data.put("decimal_type2", "99.9");
72
    public JMap insert(JMap param) throws Exception {
73
        BizSqlDao bizDao = IpuDaoManager.takeDao(BizSqlDao.class, connName);
74
        int pk = bizDao.takePK();
83 75
        
76
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
77
        JMap data = new JsonMap();
78
        data.put("pk", pk);
79
        data.put("string_type", "字符串"+pk);
80
        data.put("int_type", pk);
81
        data.put("decimal_type", "10."+pk);
82
        data.put("date_type", TimeUtil.getSysDate());
83
        data.put("datetime_type", TimeUtil.getSysTime());
84 84
        int re = dao.insert(tableName, data);
85
        IData result = new DataMap();
85
        
86
        JMap result = new JsonMap();
86 87
        result.put("result_number", re);
88
        result.put("content", dao.select(tableName, data));
87 89
        return result;
88 90
    }
89 91
    
92
    /**
93
     * @author huangbo@asiainfo.com
94
     * @title: update
95
     * @desc: 基于主键修改数据的范例
96
     */
90 97
    @ResponseBody
91 98
    @RequestMapping("/update")
92
    public IData update(IData params) throws Exception {
93
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
94
        Map<String, Object> data = new HashMap<String, Object>();
99
    public JMap update(JMap param) throws Exception {
100
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
101
        JMap data = new JsonMap();
95 102
        data.put("pk", 0);
96
        data.put("int_type2", "111111");
97
        
103
        data.put("int_type", System.currentTimeMillis()%100);
98 104
        int re = dao.update(tableName, data);
99
        IData result = new DataMap();
105
        JMap result = new JsonMap();
100 106
        result.put("result_number", re);
107
        result.put("content", dao.select(tableName, data));
101 108
        return result;
102 109
    }
103 110
    
111
    /**
112
     * @author huangbo@asiainfo.com
113
     * @title: updateByCond
114
     * @desc: 基于条件修改数据的范例
115
     */
104 116
    @ResponseBody
105 117
    @RequestMapping("/updateby")
106
    public IData updateByCond(IData params) throws Exception {
107
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
108
        Map<String, Object> data = new HashMap<String, Object>();
109
        data.put("string_type2", "字符串1");
110
        data.put("int_type2", "111111");
111
        Map<String, Object> condition = new HashMap<String, Object>();
112
        condition.put("int_type1", "111111");
118
    public JMap updateByCond(JMap param) throws Exception {
119
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
120
        JMap data = new JsonMap();
121
        data.put("int_type", System.currentTimeMillis()%100);
122
        JMap condition = new JsonMap();
123
        condition.put("string_type", "字符串0");
113 124
        
114 125
        int re = dao.updateByCond(tableName, data, condition);
115
        IData result = new DataMap();
126
        JMap result = new JsonMap();
116 127
        result.put("result_number", re);
128
        condition.put("pk", 0);
129
        result.put("content", dao.select(tableName, condition));
117 130
        return result;
118 131
    }
119 132
    
133
    /**
134
     * @author huangbo@asiainfo.com
135
     * @title: delete
136
     * @desc: 基于主键删除数据的范例
137
     */
120 138
    @ResponseBody
121 139
    @RequestMapping("/delete")
122
    public IData delete(IData params) throws Exception {
123
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
124
        Map<String, Object> data = new HashMap<String, Object>();
125
        data.put("pk", 0);
140
    public JMap delete(JMap params) throws Exception {
141
        BizSqlDao bizDao = IpuDaoManager.takeDao(BizSqlDao.class, connName);
142
        int pk = bizDao.takePK();
143
        
144
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
145
        JMap data = new JsonMap();
146
        data.put("pk", pk-1);
126 147
        
148
        Map<String, Object> content = dao.select(tableName, data);
127 149
        int re = dao.delete(tableName, data);
128
        IData result = new DataMap();
150
        JMap result = new JsonMap();
129 151
        result.put("result_number", re);
152
        result.put("content", content);
130 153
        return result;
131 154
    }
132 155
    
156
    /**
157
     * @author huangbo@asiainfo.com
158
     * @title: deleteByCond
159
     * @desc: 基于条件删除数据的范例
160
     */
133 161
    @ResponseBody
134 162
    @RequestMapping("/deleteby")
135
    public IData deleteByCond(IData params) throws Exception {
136
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, connName);
137
        Map<String, Object> data = new HashMap<String, Object>();
138
        data.put("string_type1", "字符串1");
139
        data.put("int_type1", "111111");
163
    public JMap deleteByCond(JMap params) throws Exception {
164
        BizSqlDao bizDao = IpuDaoManager.takeDao(BizSqlDao.class, connName);
165
        int pk = bizDao.takePK();
166
        
167
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, connName);
168
        JMap data = new JsonMap();
169
        data.put("string_type", "字符串"+(pk-1));
170

171
        List<Map<String, Object>> contents = dao.selectByCond(tableName, data);
172
        Map<String, Object> content = (contents!=null&&contents.size()>0)?contents.get(0):null;
140 173
        int re = dao.deleteByCond(tableName, data);
141
        IData result = new DataMap();
174
        JMap result = new JsonMap();
142 175
        result.put("result_number", re);
176
        result.put("content", content);
143 177
        return result;
144 178
    }
145 179
    
180
    /**
181
     * @author huangbo@asiainfo.com
182
     * @title: selectByDruid
183
     * @desc: 基于主键查询数据的范例,使用druid连接池
184
     */
146 185
    @ResponseBody
147 186
    @RequestMapping("druid/select")
148
    public IData selectByDruid(IData params) throws Exception {
149
        DemoTableBizDao dao = IpuDaoManager.takeDao(DemoTableBizDao.class, druidConnName);
150
        Map<String, Object> data = new HashMap<String, Object>();
187
    public JMap selectByDruid(JMap params) throws Exception {
188
        CommonTableDao dao = IpuDaoManager.takeDao(CommonTableDao.class, druidConnName);
189
        JMap data = new JsonMap();
151 190
        data.put("pk", 0);
152 191
        
153 192
        Map<String, Object> re = dao.select(tableName, data);
154
        IData result = new DataMap();
155
        result.put("result_number", re);
193
        JMap result = new JsonMap();
194
        result.put("result", re);
156 195
        return result;
157 196
    }
158 197
}

+ 16 - 0
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/dubbo/DubboControl.java

@ -10,10 +10,21 @@ import com.ai.ipu.restful.spring.SpringManager;
10 10
import com.ai.ipu.service.demo.IBizService;
11 11
import com.ailk.common.data.IData;
12 12

13
/**
14
 * @author huangbo@asiainfo.com
15
 * @team IPU
16
 * @date 2018年10月24日上午00:13:37
17
 * @desc Dubbo客户端的使用范例
18
 */
13 19
@Controller
14 20
@RequestMapping("/dubbo")
15 21
public class DubboControl {
16 22

23
    /**
24
     * @author huangbo@asiainfo.com
25
     * @title: callBizService
26
     * @desc: Dubbo客户端调用服务范例
27
     */
17 28
    @ResponseBody
18 29
    @RequestMapping("/biz")
19 30
    public IData callBizService(IData params) {
@ -23,6 +34,11 @@ public class DubboControl {
23 34
        return result;
24 35
    }
25 36
    
37
    /**
38
     * @author huangbo@asiainfo.com
39
     * @title: callCommonService
40
     * @desc: Dubbo客户端调用通用服务范例
41
     */
26 42
    @ResponseBody
27 43
    @RequestMapping("/common")
28 44
    public IData callCommonService(IData params) {

+ 12 - 1
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/other/MsgFrameController.java

@ -1,4 +1,4 @@
1
package com.ai.ipu.server.demo.control.other;
1
package com.ai.ipu.server.demo.control.mq;
2 2

3 3
import org.springframework.stereotype.Controller;
4 4
import org.springframework.web.bind.annotation.RequestMapping;
@ -11,10 +11,21 @@ import com.ai.ipu.restful.util.IpuRestConstant;
11 11
import com.ailk.common.data.IData;
12 12
import com.ailk.common.data.impl.DataMap;
13 13

14
/**
15
 * @author huangbo@asiainfo.com
16
 * @team IPU
17
 * @date 2018年4月30日下午3:17:49
18
 * @desc MsgFrame的使用范例
19
 */
14 20
@Controller
15 21
@RequestMapping("/msgframe")
16 22
public class MsgFrameController{
17 23

24
    /**
25
     * @author huangbo@asiainfo.com
26
     * @title: produceMessage
27
     * @desc: MsgFrame消息生产者范例
28
     */
18 29
    @ResponseBody
19 30
    @RequestMapping("/produce")
20 31
    public IData produceMessage(IData params){

+ 40 - 0
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/dao/BizSqlDao.java

@ -0,0 +1,40 @@
1
package com.ai.ipu.server.demo.dao;
2

3
import java.io.IOException;
4
import java.util.List;
5
import java.util.Map;
6

7
import com.ai.ipu.database.dao.impl.AbstractBizDao;
8

9
/**
10
 * @author huangbo@asiainfo.com
11
 * @team IPU
12
 * @date 2018年1月26日下午5:27:35
13
 * @desc 基于SQL的操作范例
14
 * 业务dao不暴露和业务无关的方法.
15
 */
16
public class BizSqlDao extends AbstractBizDao{
17

18
    public BizSqlDao(String connName) throws IOException {
19
        super(connName);
20
    }
21

22
    public List<Map<String, Object>> executeSql() throws Exception {
23
        String sql = "SELECT * FROM ipu_db_demo";
24
        List<Map<String, Object>> dataResult = getBasicDao().executeSelect(sql);
25
        return dataResult;
26
    }
27
    
28
    public int takePK() throws Exception {
29
        String sql = "SELECT * FROM ipu_db_demo order by datetime_type desc";
30
        Map<String, Object> dataResult = getBasicDao().executeSelectFirst(sql);
31
        int pk;
32
        if(dataResult==null||dataResult.isEmpty()){
33
            pk = 0;
34
        }else{
35
            pk = Integer.parseInt(dataResult.get("pk").toString());
36
            pk++;
37
        }
38
        return pk;
39
    }
40
}

+ 3 - 16
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/dao/DemoTableBizDao.java

@ -10,24 +10,11 @@ import com.ai.ipu.database.dao.impl.AbstractBizDao;
10 10
 * @author huangbo@asiainfo.com
11 11
 * @team IPU
12 12
 * @date 2018年9月6日下午10:05:42
13
 * @desc 单表增删改查测试
14
 * 建表语句
15
 CREATE TABLE `ipu_db_test` (
16
  `pk` varchar(20) CHARACTER SET utf8 NOT NULL COMMENT '键主',
17
  `string_type1` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '字符串(可为空)',
18
  `string_type2` varchar(255) CHARACTER SET utf8 NOT NULL COMMENT '字符串(不为空)',
19
  `int_type1` int(11) DEFAULT NULL COMMENT '整型(可为空)',
20
  `int_type2` int(11) NOT NULL COMMENT '整型(不为空)',
21
  `date_type1` datetime DEFAULT NULL COMMENT '日期(不为空)',
22
  `date_type2` datetime NOT NULL COMMENT '日期(不为空)',
23
  `decimal_type1` decimal(10,0) DEFAULT NULL COMMENT '小数(可为空)',
24
  `decimal_type2` decimal(10,0) NOT NULL COMMENT '小数(不为空)',
25
  PRIMARY KEY (`pk`)
26
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
13
 * @desc 通用基于单表CRUD的操作范例
27 14
 */
28
public class DemoTableBizDao extends AbstractBizDao{
15
public class CommonTableDao extends AbstractBizDao{
29 16

30
    public DemoTableBizDao(String connName) throws IOException {
17
    public CommonTableDao(String connName) throws IOException {
31 18
        super(connName);
32 19
    }
33 20


+ 0 - 40
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/dao/DemoBizDao.java

@ -1,40 +0,0 @@
1
package com.ai.ipu.server.demo.dao;
2

3
import java.io.IOException;
4
import java.util.List;
5
import java.util.Map;
6

7
import com.ai.ipu.database.dao.impl.AbstractBizDao;
8

9
/**
10
 * @author huangbo@asiainfo.com
11
 * @team IPU
12
 * @date 2018年1月26日下午5:27:35
13
 * @desc 内置一个BasicDao,让业务dao不暴露和业务无关的方法.
14
 */
15
public class DemoBizDao extends AbstractBizDao{
16

17
    public DemoBizDao(String connName) throws IOException {
18
        super(connName);
19
    }
20

21
    public int insert() {
22
        return -1;
23
    }
24

25
    public int delete() {
26
        return -1;
27
    }
28

29
    public int update() throws Exception {
30
        String sql = "update TAB_IPU_MEMBER set PASSWORD='000002'";
31
        int result = dao.executeUpdate(sql, null);
32
        return result;
33
    }
34

35
    public List<Map<String, Object>> select() throws Exception {
36
        String sql = "SELECT * FROM tab_ipu_member";
37
        List<Map<String, Object>> dbResult = getBasicDao().executeSelect(sql);
38
        return dbResult;
39
    }
40
}

+ 0 - 42
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/dao/DemoDao.java

@ -1,42 +0,0 @@
1
package com.ai.ipu.server.demo.dao;
2

3
import java.io.IOException;
4
import java.util.List;
5
import java.util.Map;
6

7
import com.ai.ipu.database.conn.SqlSessionManager;
8
import com.ai.ipu.database.dao.impl.BasicDao;
9
import com.ai.ipu.database.dao.impl.SqlDao;
10

11
/**
12
 * @author huangbo@asiainfo.com
13
 * @team IPU
14
 * @date 2018年1月26日下午5:27:43
15
 * @desc 继承BasicDao,让每个业务dao具备全量方法.
16
 */
17
public class DemoDao extends BasicDao {
18

19
    public DemoDao(String connName) throws IOException {
20
        super(connName);
21
    }
22

23
    public int insert() {
24
        return -1;
25
    }
26

27
    public int delete() {
28
        return -1;
29
    }
30

31
    public int update() throws Exception {
32
        String sql = "update TAB_IPU_MEMBER set PASSWORD='000002'";
33
        int result = executeUpdate(sql, null);
34
        return result;
35
    }
36

37
    public List<Map<String, Object>> select() throws Exception {
38
        String sql = "SELECT * FROM tab_ipu_member";
39
        List<Map<String, Object>> dbResult = executeSelect(sql);
40
        return dbResult;
41
    }
42
}