1
00:00:00,940 --> 00:00:04,890
接下来,就是要把这个列表输出到控制台
2
00:00:06,490 --> 00:00:12,280
这里面有3个
3
00:00:15,420 --> 00:00:17,480
Id有了,姓
4
00:00:18,600 --> 00:00:28,500
一个一个取,ID,姓有了,名有了,家属数量
5
00:00:30,130 --> 00:00:30,760
这里有一个
6
00:00:33,620 --> 00:00:38,630
就是获取,计算免税金额的
7
00:00:39,190 --> 00:00:40,420
免税金额
8
00:00:40,430 --> 00:00:41,940
这显然是一个领域逻辑了
9
00:00:42,070 --> 00:00:43,220
放在这里
10
00:00:44,510 --> 00:00:48,330
其他是不用算的,就免税金额要算,怎么算
11
00:00:50,370 --> 00:00:52,830
同样,用的是
12
00:00:56,860 --> 00:00:59,050
Person类里面
13
00:00:59,060 --> 00:01:00,290
放在Person类里面
14
00:01:00,980 --> 00:01:04,600
免税额,它用了money这个类
15
00:01:04,610 --> 00:01:09,250
基本免税额,1500刀,750刀
16
00:01:09,500 --> 00:01:11,370
每个家属可以免税那么多
17
00:01:12,760 --> 00:01:15,520
所以总的免税额是什么
18
00:01:15,530 --> 00:01:19,490
基本免税额加上家属免税额乘以家属人数
19
00:01:19,820 --> 00:01:20,990
但是用的是什么
20
00:01:21,000 --> 00:01:23,420
用的是
21
00:01:23,590 --> 00:01:25,580
money的加法乘法
22
00:01:25,590 --> 00:01:29,900
不能用我们这个东西
23
00:01:30,770 --> 00:01:38,840
用这个类定义的加法乘法
24
00:01:46,850 --> 00:01:48,130
好,出来
25
00:01:48,140 --> 00:01:49,930
这个就是它的结果
26
00:01:50,570 --> 00:01:50,890
对
27
00:01:54,890 --> 00:01:57,450
后面基本免税额多少,免税多少,这样
28
00:02:07,210 --> 00:02:12,910
好,这是查询
29
00:02:13,560 --> 00:02:16,600
我们看插入怎么做
1
00:00:00,800 --> 00:00:03,220
然后我们就来插入一个记录了
2
00:00:03,530 --> 00:00:07,580
比如说,这里是它的值,ID
3
00:00:08,750 --> 00:00:10,900
它现在是先把它设为0
4
00:00:10,910 --> 00:00:12,900
因为这个是用来占位置的
5
00:00:14,080 --> 00:00:15,600
ID是多少并不知道
6
00:00:15,610 --> 00:00:19,520
因为你还没插入,后面才是插入的
7
00:00:20,710 --> 00:00:22,620
你看插入的这里
8
00:00:23,020 --> 00:00:27,960
new一个这个,然后再调用它的插入的操作
9
00:00:30,330 --> 00:00:32,890
new这里,ID就是0
10
00:00:34,920 --> 00:00:36,220
然后我们看这几个属性
11
00:00:37,150 --> 00:00:39,900
这里,姓、名在这里定义
12
00:00:40,440 --> 00:00:44,680
然后ID是在超类里面定义的
13
00:00:46,040 --> 00:00:51,160
标识在这里定义
14
00:00:52,940 --> 00:00:53,230
好
15
00:00:53,760 --> 00:00:56,140
把它复制到属性上
16
00:00:58,540 --> 00:01:02,270
然后再调用它的插入的操作
17
00:01:05,630 --> 00:01:09,990
跟昨天PersonGateway一样的
18
00:01:10,200 --> 00:01:11,950
本来应该在入口里面的
19
00:01:11,960 --> 00:01:17,710
上一个模式的入口
20
00:01:18,290 --> 00:01:20,510
行数据入口那个是一样的
21
00:01:20,640 --> 00:01:24,360
创建数据库连接
22
00:01:25,690 --> 00:01:26,260
这一样
23
00:01:27,450 --> 00:01:31,610
然后打开
24
00:01:33,700 --> 00:01:34,070
好
25
00:01:34,880 --> 00:01:36,160
ID现在是0
26
00:01:38,510 --> 00:01:42,400
这一句,上一个模式已经见过了
27
00:01:46,000 --> 00:01:47,880
取下一个标识最大值
28
00:01:47,890 --> 00:01:51,000
然后+1,这种方式,我们就直接跳过去了
29
00:01:51,660 --> 00:01:52,570
直接跳过去
30
00:01:54,990 --> 00:01:57,110
这时候你看ID已经变成4了
31
00:01:57,460 --> 00:01:58,560
刚才有3条记录
32
00:01:59,230 --> 00:02:00,030
现在是4条记录
33
00:02:00,040 --> 00:02:02,540
然后就把它先插入数据库
34
00:02:06,330 --> 00:02:08,650
执行之后,再把它添加到注册表
35
00:02:08,740 --> 00:02:12,070
就把自身对象添加到注册表
36
00:02:14,390 --> 00:02:14,630
37
00:02:16,850 --> 00:02:19,240
然后Id作为键
38
00:02:19,250 --> 00:02:20,800
然后这个是对象
39
00:02:28,400 --> 00:02:30,790
好,这是插入,下面一样的
40
00:02:30,920 --> 00:02:34,800
下面查找人,一样的
41
00:02:36,610 --> 00:02:44,720
我们看更新,也是把人找出来
42
00:02:45,910 --> 00:02:49,000
那么这里面根据ID来找
43
00:02:49,330 --> 00:02:52,800
假设我们要更新1这个人
44
00:02:55,930 --> 00:02:57,880
那么根据ID查找人员
45
00:02:59,710 --> 00:03:00,830
这个代码,之前
46
00:03:00,840 --> 00:03:04,110
就放在finder里面
47
00:03:04,440 --> 00:03:05,390
查找器里面
48
00:03:08,750 --> 00:03:14,470
然后这里,在注册表中查找
49
00:03:14,480 --> 00:03:17,030
根据ID来查找这个Person有没有
50
00:03:17,040 --> 00:03:17,350
51
00:03:17,950 --> 00:03:20,270
有就返回来了
52
00:03:21,540 --> 00:03:29,770
去查找,有,就返回来,没有
53
00:03:32,760 --> 00:03:33,910
有的
54
00:03:33,920 --> 00:03:38,910
因为刚才啪啪啪已经添加了
55
00:03:38,920 --> 00:03:42,230
里面有4个,有的
56
00:03:42,570 --> 00:03:43,580
返回来
57
00:03:46,940 --> 00:03:48,680
好,得到这个之后
58
00:03:49,900 --> 00:03:56,240
然后把它的名字改成Jack
59
00:03:58,530 --> 00:04:03,830
然后调用这个更新,执行更新操作
60
00:04:10,010 --> 00:04:11,160
更新也是一样的
61
00:04:11,450 --> 00:04:14,610
也是跟昨天入口一模一样
62
00:04:15,860 --> 00:04:16,890
这段代码
63
00:04:16,900 --> 00:04:19,680
昨天应该在入口里面的
64
00:04:21,260 --> 00:04:22,330
照搬过来而已
65
00:04:23,020 --> 00:04:27,360
更新的,跟昨天一样的
66
00:04:28,670 --> 00:04:30,450
这是更新的SQL
67
00:04:31,050 --> 00:04:32,840
这是插入的SQL
68
00:04:34,360 --> 00:04:37,000
这些本来是放在Gateway里面的
69
00:04:39,520 --> 00:04:45,620
而这些是放在查找器里面
70
00:04:45,750 --> 00:04:47,540
添加参数,执行
71
00:04:53,850 --> 00:04:54,440
就这样
72
00:04:55,140 --> 00:04:56,570
下面都差不多了
73
00:04:56,580 --> 00:04:59,070
下面就没有什么
74
00:04:59,570 --> 00:05:02,500
没有什么新鲜的东西了
75
00:05:03,000 --> 00:05:05,380
都已经看过了
76
00:05:06,010 --> 00:05:08,460
或者说,在之前的模式里面也看过
77
00:05:08,470 --> 00:05:11,640
就没有更多新的