Пример #1
0
        public HttpResponseMessage accountEnter([FromBody] EnterRequest nEnterRequest)
        {
            AccountInfo accountInfo_ = AccountAspect.getAccountId(nEnterRequest.mAccountName, nEnterRequest.mPassword, nEnterRequest.mAccountType);
            EnterResult enterResult_ = new EnterResult();

            enterResult_.mErrorCode = ConstAspect.mFail;
            enterResult_.mAuthority = 0;
            enterResult_.mRoleItem  = null;
            if ((null == accountInfo_) || (accountInfo_.mAccountId <= 0) || (accountInfo_.mAccountId != nEnterRequest.mAccountId))
            {
                enterResult_.mErrorCode = ConstAspect.mAccount;
                return(ConstAspect.toJson(enterResult_));
            }
            enterResult_.mAuthority = accountInfo_.mAuthority;
            RoleItem roleItem_ = RoleAspect.getRoleInfo(nEnterRequest.mOperatorName, nEnterRequest.mVersionNo, nEnterRequest.mAccountId, nEnterRequest.mRoleId, nEnterRequest.mServerId);

            if (null == roleItem_)
            {
                enterResult_.mErrorCode = ConstAspect.mRole;
                return(ConstAspect.toJson(enterResult_));
            }
            enterResult_.mErrorCode = ConstAspect.mSucess;
            enterResult_.mRoleItem  = roleItem_;
            if (nEnterRequest.mStart)
            {
                RoleAspect.updateRoleStart(nEnterRequest.mOperatorName, nEnterRequest.mVersionNo, nEnterRequest.mAccountId, nEnterRequest.mServerId, nEnterRequest.mRoleId);
            }
            return(ConstAspect.toJson(enterResult_));
        }
Пример #2
0
        public HttpResponseMessage createRole([FromBody] RoleRequest nRoleRequest)
        {
            AccountInfo accountInfo_ = AccountAspect.getAccountId(nRoleRequest.mAccountName, nRoleRequest.mPassword, nRoleRequest.mAccountType);
            RoleResult  roleResult_  = new RoleResult();

            roleResult_.mErrorCode  = ConstAspect.mFail;
            roleResult_.mAccountId  = 0;
            roleResult_.mRoleItem   = null;
            roleResult_.mServerItem = null;
            if ((null == accountInfo_) || (0 == accountInfo_.mAccountId) || (nRoleRequest.mAccountId != accountInfo_.mAccountId))
            {
                roleResult_.mErrorCode = ConstAspect.mAccount;
                return(toJson(roleResult_));
            }
            roleResult_.mAccountId = accountInfo_.mAccountId;
            int roleCount_ = RoleAspect.getRoleCount(nRoleRequest.mOperatorName, nRoleRequest.mVersionNo, accountInfo_.mAccountId, nRoleRequest.mServerId);

            if (roleCount_ > 0)
            {
                roleResult_.mErrorCode = ConstAspect.mRole;
                return(toJson(roleResult_));
            }
            if (RoleAspect.createRole(nRoleRequest.mOperatorName, nRoleRequest.mVersionNo, accountInfo_.mAccountId, nRoleRequest.mServerId, nRoleRequest.mRoleName, nRoleRequest.mRoleRace))
            {
                roleResult_.mErrorCode           = ConstAspect.mSucess;
                roleResult_.mAccountId           = accountInfo_.mAccountId;
                roleResult_.mRoleItem            = new RoleItem();
                roleResult_.mRoleItem.mRoleId    = nRoleRequest.mServerId;
                roleResult_.mRoleItem.mServerId  = nRoleRequest.mServerId;
                roleResult_.mRoleItem.mRoleName  = nRoleRequest.mRoleName;
                roleResult_.mRoleItem.mRoleRace  = nRoleRequest.mRoleRace;
                roleResult_.mRoleItem.mRoleStep  = 1;
                roleResult_.mRoleItem.mRoleLevel = 1;
                roleResult_.mRoleItem.mRoleType  = 1;
                roleResult_.mServerItem          = ServerAspect.getServerItem(nRoleRequest.mOperatorName, nRoleRequest.mVersionNo, nRoleRequest.mServerId);
            }
            else
            {
                roleResult_.mErrorCode = ConstAspect.mCreate;
            }
            if (nRoleRequest.mUpdate)
            {
                RoleAspect.updateRoleStart(nRoleRequest.mOperatorName, nRoleRequest.mVersionNo, accountInfo_.mAccountId, nRoleRequest.mServerId, nRoleRequest.mServerId);
            }
            else
            {
                RoleAspect.insertRoleStart(nRoleRequest.mOperatorName, nRoleRequest.mVersionNo, accountInfo_.mAccountId, nRoleRequest.mServerId, nRoleRequest.mServerId);
            }
            return(toJson(roleResult_));
        }