存储过程实例分析
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
USE [itvnet]
GO
/****** 对象: StoredProcedure [dbo].[AuthenticateV4] 脚本日期: 03/18/2011 10:55:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[AuthenticateV4]
(
@LoginName varchar(64),
@Password varchar(64),
@ADID varchar(64),
@DeviceInfo varchar(64),
@IP varchar(64),
@MAC varchar(64),
@RequestIP varchar(64),
@Result integer output,
@ResultDescription varchar(64) output,
@InnerUserId integer output,
@RegionId integer output,
@IPRegionId integer output,
@EPGDomain varchar(256) output,
@UpgradeDomain varchar(256) output,
@ManagementDomain varchar(256) output,
@NTPDomain varchar(256) output,
@AuthGUID varchar(128) output,
@UserTokenType integer output
)
AS
declare @tmpmerchantid integer
declare @tmpintip bigint
declare @tmpid integer
declare @tmppassword varchar(64)
declare @tmpusertypeid integer
declare @tmpusergrpid integer
declare @tmpsalesarea integer
declare @tmpareaid integer
declare @tmpuserid integer
declare @tmpisprepay integer
declare @tmpbalance float
declare @tmpcredit float
declare @tmpserviceid integer
declare @tmpoui varchar(16)
declare @tmpupgradedomain varchar(254)
declare @tmpmerchantepgdomain varchar(254)
declare @tmpmerchantupgradedomain varchar(254)
declare @tmpdeviceid varchar(64)
declare @tmptmtype integer
declare @tmpmodel varchar(64)
declare @tmptermmodelid integer
declare @tmpcmpregionid integer
declare @tmpfoundepg integer
declare @tmpuserstatus integer
set @Result =0
set @ResultDescription ='认证成功'
if datalength(@DeviceInfo) != 40
begin
set @Result = 1001001
set @ResultDescription = '设备编号长度不匹配,认证失败,错误代码:1001001'
goto Micet_ResultReturn
end
set @tmpdeviceid = substring(@DeviceInfo,1,32) --获取设备编号无版本信息
set @tmpoui = substring(@DeviceInfo,7,6) --获取OUI信息
set @tmpmodel = substring(@DeviceInfo,13,3) --获取终端型号
set @AuthGUID = NewId()
--是否在返回的EPGdomain增加usertoken=参数,这边可以用来针对各种情况处理
--如果为0,那么不携带usertoken如果为1 携带标准usertoken参数,如果为2,那么返回的为AuthGUID针对usertoken
set @UserTokenType = 1
--获取终端类型,现在根据终端号来获取相关参数
--一个厂家一至多个OUI
SELECT @tmptermmodelid=D_ID,@tmptmtype = D_TMTYPE,@UpgradeDomain = D_UPGRADEDOMAIN FROM TBL_TERMMODEL WHERE D_OUI=@tmpoui AND D_MODELNO=@tmpmodel
if @@ROWCOUNT<=0
begin
set @Result = 1001002
set @ResultDescription = '非法终端,该终端型号未在系统登记过,认证失败,错误代码:1001002'