项目

一般

简介

支持 #839

张 丽丽 更新于 10 个月 之前

h1. INSERT_NOTIFY *RoleId =7是 用户; RoleId=8是 站长* 

 update_notify 

 <pre> 
 BEGIN   
     
		 DECLARE newUserName varchar(190); 
		 SELECT UserName INTO @NewUserName newUserName FROM userprofile WHERE UserId = NEW.UserId;   
		 SELECT RoleId INTO @RoleId_User 
		
		 IF OLD.RoleId=8 THEN 
			 DELETE FROM webpages_roles `表_站长` WHERE RoleName = '用户' LIMIT 1;   
		 SELECT RoleId ID=OLD.UserId; 
		 end IF; 
		 IF NEW.RoleId=7 THEN 
     INSERT INTO @RoleId_StationManager FROM webpages_roles WHERE RoleName = '站长' LIMIT 1;  
		
     `表_用户` (ID,`用户_用户名`, `注册时间`) VALUES (NEW.UserId,newUserName, NOW()); 
		 end IF; 
		
		 IF NEW.RoleId = @RoleId_User OLD.RoleId=7 THEN 
			   SELECT count(*) INTO @IsExist 
			 DELETE FROM 表_用户 `表_用户` WHERE 用户_用户名 = @NewUserName;  
				 ID=OLD.UserId; 
		 end IF; 
		 IF @IsExist = 0 NEW.RoleId=8 THEN 
					 
     INSERT INTO 表_用户 (用户_用户名, 注册时间) `表_站长` (ID,`站长_用户名`, `注册时间`) VALUES (@NewUserName, (NEW.UserId,newUserName, NOW());   
				 END 
		 end IF;   
     END 
 end 
 </pre> 

 delete_notify 
 <pre> 
 BEGIN 
		 IF OLD.RoleId=7 THEN 
			 DELETE FROM `表_用户` WHERE ID=OLD.UserId; 
		 end IF;   
		
		 
		 IF NEW.RoleId = @RoleId_StationManager OLD.RoleId=8 THEN   
		     
			 DELETE FROM `表_站长` WHERE ID=OLD.UserId; 
		 end IF; 
 end 
 </pre> 

 insert_notify 
 <pre> 
 BEGIN 
 DECLARE tmp varchar(190); 
     SELECT count(*) UserName INTO @IsExist tmp FROM 表_站长 userprofile WHERE 站长_用户名 UserId = @NewUserName; 
				 NEW.UserId; 
		 IF @IsExist = 0 NEW.RoleId=7 THEN 
             
     INSERT INTO 表_站长 (站长_用户名, 注册时间) `表_用户` (ID,`用户_用户名`, `注册时间`) VALUES (@NewUserName, (NEW.UserId,tmp, NOW());   
				 END 
		 end IF;   
     END 
		 IF NEW.RoleId=8 THEN 
     INSERT INTO `表_站长` (ID,`站长_用户名`, `注册时间`) VALUES (NEW.UserId,tmp, NOW()); 
		 end IF;   
 END 

 
 end 
 </pre> 



返回