田源
2025-01-15 78fa1f005a9ec2581611e53d7eba8efeacb4df6e
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
91
92
93
94
95
96
97
98
99
100
101
102
create or replace trigger "SYNC_PERSON_PLUSER_COPY"
  before insert or update or delete on platformbtm_person
  for each row
/*************************************************************
author: liucq
create time: 2015.06.01
description: ÒµÎñÀàÐÍÈËÔ±£¨person£©ÉϵÄǰÖô¥·¢Æ÷£¬
             µ± ÀàÐÍÈËÔ±£¨person£© ±í·¢ÉúÌí¼Ó¡¢Ð޸ġ¢É¾³ýÊý¾Ýʱ£¬
             Í¬²½¸üе½ ÒµÎñÀàÐÍÓû§(user)±í£¬
logic rules: Ö»ÓРÈËÔ±µÄ isgenerateuserenum = '1' Ê±²Å½« ÈËԱͬ²½µ½ÒµÎñÀàÐÍÓû§£¨user£©
last modifyer: 2017.06.07
last modify time: 2017.06.07
change history:
       2017.06.07 xchao Ìí¼Ó×¢ÊÍ
*************************************************************/
--Ö»ÓÐͬ²½Óû§ isgenerateuserenum=¡®1¡¯Ê±²Å·¢Éúͬ²½²Ù×÷
declare
  usercount number;
  logoncount number;
begin
  if inserting then
    if :new.isgenerateuserenum = '1' then
      insert into pluser
    values
    (:new.oid,
    :new.id,--Óû§Ãû
    'ptbnYXdQMrY=',--ĬÈÏÃÜÂëΪ1
    :new.name,
    :new.email,
     '',
     2,--ĬÈÏÆÕͨÓû§
     0,--ĬÈÏÆôÓÃ
     to_timestamp('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),
     :new.createtime,
     :new.creator,
     :new.createtime,
     :new.creator,
     '',
     '',
     '0'--ĬÈϲ»ÊÇÁìµ¼
     );
     insert into pllogoninfo --ÉèÖÃĬÈϵĵǽÐÅÏ¢
     values(
     :new.oid,
     0,
     :new.createtime
     );
    end if;
  end if;
  if updating then
     if :old.isgenerateuserenum = '1' then
       --Èç¹ûÒÔǰµÄÊý¾ÝûÓеǽÐÅÏ¢£¬ÔòÔÚ¸üÐÂʱÌí¼ÓĬÈϵĵǽÐÅÏ¢
       select count(*) into logoncount from pllogoninfo pu where pu.pluserid = :old.oid;
       if logoncount = 0 then
          insert into pllogoninfo
           values(
           :new.oid,
           0,
           :new.createtime
           );
       end if;
       select count(*) into usercount from pluser pu where pu.plusername = :old.id;
      if usercount = 0 then
      insert into pluser
      values
        (:new.oid,
      :new.id,
      'ptbnYXdQMrY=',
      :new.name,
      :new.email,
       '',
       2,
       0,
       to_timestamp('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),
       :new.createtime,
       :new.creator,
       :new.createtime,
       :new.creator,
       '',
       '',
       '0'
         );
      else
      update pluser pu
         set pu.plusername        = :new.id,
             pu.pltruename        = :new.name,
             pu.plemail           = :new.email,
             pu.plupdateuser      = :new.lastmodifier,
             pu.plupdatetime      = :new.lastmodifytime,
             pu.plpwdupdatetime   = to_timestamp('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
         where pu.plusername = :old.id;
      end if;
     end if;
  end if;
  if deleting then
    if :old.isgenerateuserenum = '1' then
      delete from pluser pu
     where pu.plusername = :old.id;
    end if;
  end if;
end;
/