IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_insert_forum_like]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_insert_forum_like]
GO
create proc [dbo].[mps_insert_forum_like] 
--点赞与不点赞存储
@cmpid int,
@branchid int,
@branchname nvarchar(200),
@userdpid int,
@userdepart nvarchar(200),
@usertype int,
@useruid int,
@username nvarchar(200),
@like int,
@fmid bigint
as 
begin
set nocount on
declare @fmlid int
--检查是否点过赞
select @fmlid = fml_id  from mps_forum_like 
where fml_fmid = @fmid and fml_cmpid = @cmpid and fml_bcid=@branchid and fml_usertype = @usertype and fml_cuid = @useruid and fml_like = @like
if (@fmlid >0 )
begin
select '已点' error, '已点' errorinfo
end else
begin
insert into mps_forum_like(fml_fmid,fml_cmpid,fml_bcid,fml_branch,fml_dpid,fml_depart,fml_usertype,
fml_cuid,fml_cuname,fml_date,fml_like,fml_location)
values(@fmid,@cmpid,@branchid,@branchname,@userdpid,@userdepart,@usertype,@useruid,@username,getdate(),@like,'')
--更新评论表
if(@like=0) update mps_forum set fm_like = fm_like +1 where fm_id = @fmid
else update mps_forum set fm_dislike = fm_dislike +1 where fm_id = @fmid
end
 
set nocount off
end