예제 #1
0
파일: BLLCommRelation.cs 프로젝트: uvbs/mmp
        /// <summary>
        /// 添加关系
        /// </summary>
        /// <param name="rtype"></param>
        /// <param name="mainId"></param>
        /// <param name="relationId"></param>
        /// <returns></returns>
        public bool AddCommRelation(
            BLLJIMP.Enums.CommRelationType rtype,
            string mainId,
            string relationId,
            string expandId     = "",
            string ex1          = "",
            string ex2          = "",
            string ex3          = "",
            string ex4          = "",
            string ex5          = "",
            string websiteOwner = ""
            )
        {
            if (ExistRelation(rtype, mainId, relationId, expandId, ex1, ex2, ex3, ex4, ex5))
            {
                return(false);
            }

            Model.CommRelationInfo data = new Model.CommRelationInfo()
            {
                MainId       = mainId,
                RelationId   = relationId,
                RelationTime = DateTime.Now,
                RelationType = CommonPlatform.Helper.EnumStringHelper.ToString(rtype),
                ExpandId     = expandId,
                Ex1          = ex1,
                Ex2          = ex2,
                Ex3          = ex3,
                Ex4          = ex4,
                Ex5          = ex5,
                WebsiteOwner = websiteOwner
            };

            return(Add(data));
        }
예제 #2
0
파일: Collect.ashx.cs 프로젝트: uvbs/mmp
        /// <summary>
        /// 删除商品收藏
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string Delete(HttpContext context)
        {
            string collectType = context.Request["type"];
            string id          = context.Request["id"];

            BLLJIMP.Enums.CommRelationType relaType = BLLJIMP.Enums.CommRelationType.ProductCollect;
            if (!string.IsNullOrEmpty(collectType))
            {
                Enum.TryParse(collectType, out relaType);
            }
            if (bllCommRela.DelCommRelation(relaType, currentUserInfo.UserID, id))
            {
                resp.errmsg = "删除成功";
            }
            else
            {
                resp.errcode = 1;
                resp.errmsg  = "删除失败";
            }
            return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }
예제 #3
0
파일: Collect.ashx.cs 프로젝트: uvbs/mmp
        /// <summary>
        /// 增加商品收藏
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string Add(HttpContext context)
        {
            var collectType = context.Request["type"];
            var productInfo = bllMall.GetProduct(context.Request["id"]);//商品ID

            if (productInfo == null)
            {
                resp.errcode = 1;
                resp.errmsg  = "商品不存在";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            //检查是否已经收藏
            //CommRelationType.

            BLLJIMP.Enums.CommRelationType relaType = BLLJIMP.Enums.CommRelationType.ProductCollect;

            if (!string.IsNullOrEmpty(collectType))
            {
                Enum.TryParse(collectType, out relaType);
            }
            if (bllCommRela.ExistRelation(relaType, currentUserInfo.UserID, productInfo.PID))
            {
                resp.errcode = 1;
                resp.errmsg  = "已经收藏过了";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            //检查是否已经收藏

            if (bllCommRela.AddCommRelation(relaType, currentUserInfo.UserID, productInfo.PID))
            {
                resp.errcode = 0;
                resp.errmsg  = "收藏成功";
            }
            else
            {
                resp.errcode = 1;
                resp.errmsg  = "收藏失败,请重试";
            }
            return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }
예제 #4
0
        public void ProcessRequest(HttpContext context)
        {
            string rtype    = context.Request["rtype"],
                   mainId   = context.Request["mainId"],
                   exchange = context.Request["exchange"]; //1时mainId,relationId互换

            BLLJIMP.Enums.CommRelationType nType = new BLLJIMP.Enums.CommRelationType();
            if (!Enum.TryParse(rtype, out nType))
            {
                apiResp.code = 1;
                apiResp.msg  = "类型格式不能识别";
                bLLCommRelation.ContextResponse(context, apiResp);
                return;
            }
            if (mainId == "0" || string.IsNullOrWhiteSpace(mainId))
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.ContentNotFound;
                apiResp.msg  = "关联主Id错误";
                bLLCommRelation.ContextResponse(context, apiResp);
                return;
            }
            currentUserInfo = bLLCommRelation.GetCurrentUserInfo();
            if (this.currentUserInfo == null)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.UserIsNotLogin;
                apiResp.msg  = "请先登录";
                bLLCommRelation.ContextResponse(context, apiResp);
                return;
            }
            string relationId = this.currentUserInfo.AutoID.ToString();

            if (mainId == relationId)
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                apiResp.msg  = "不能跟自己建立关系";
                bLLCommRelation.ContextResponse(context, apiResp);
                return;
            }
            if (exchange == "1")
            {
                relationId = mainId;
                mainId     = this.currentUserInfo.AutoID.ToString();
            }

            if (!this.bLLCommRelation.ExistRelation(nType, mainId, relationId))
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.IsRepeat;
                apiResp.msg  = "关系不存在";
                bLLCommRelation.ContextResponse(context, apiResp);
                return;
            }

            if (this.bLLCommRelation.DelCommRelation(nType, mainId, relationId))
            {
                if (nType == CommRelationType.FriendApply)
                {
                    UserInfo toUser = bllUser.GetUserInfoByAutoID(int.Parse(mainId));
                    //拒绝好友申请删除申请关系
                    bLLCommRelation.DelCommRelation(CommRelationType.FriendApply, relationId, mainId);
                    bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.RejectFriendApply, this.currentUserInfo, null, new List <UserInfo>()
                    {
                        toUser
                    }, null);
                }
                else if (nType == CommRelationType.Friend)
                {
                    UserInfo toUser = bllUser.GetUserInfoByAutoID(int.Parse(mainId));
                    //删除好友关系
                    bLLCommRelation.DelCommRelation(CommRelationType.Friend, mainId, relationId);
                    bLLCommRelation.DelCommRelation(CommRelationType.Friend, relationId, mainId);

                    bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.DeleteFriend, this.currentUserInfo, null, new List <UserInfo>()
                    {
                        toUser
                    }, null);
                }
                else if (nType == CommRelationType.JuActivityPraise)
                {
                    JuActivityInfo article = bll.GetJuActivity(int.Parse(mainId), false);

                    //点赞数直接修改到主表
                    int praiseCount = bLLCommRelation.GetRelationCount(nType, mainId, null);
                    bll.Update(article, string.Format("PraiseCount={0}", praiseCount), string.Format("JuActivityID={0}", article.JuActivityID));
                    bllSystemNotice.SendNotice(BLLJIMP.BLLSystemNotice.NoticeType.DisJuActivityPraise, this.currentUserInfo, article, article.UserID, null);
                }

                apiResp.status = true;
                apiResp.msg    = "删除完成";
                apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
            }
            else
            {
                apiResp.code = (int)BLLJIMP.Enums.APIErrCode.OperateFail;
                apiResp.msg  = "删除失败";
            }
            bLLCommRelation.ContextResponse(context, apiResp);
        }
예제 #5
0
        public void ProcessRequest(HttpContext context)
        {
            int    pageIndex  = int.Parse(context.Request["pageIndex"]);
            int    pageSize   = int.Parse(context.Request["pageSize"]);
            string userAutoId = context.Request["userAutoId"];
            string keyword    = context.Request["keyword"];  //昵称搜索
            string type       = context.Request["type"];     //昵称搜索
            string exchange   = context.Request["exchange"]; //1时mainId,relationId互换
            string isid       = context.Request["isid"];     //AutoID建立的关系

            BLLJIMP.Enums.CommRelationType nType = BLLJIMP.Enums.CommRelationType.FollowUser;
            if (!string.IsNullOrWhiteSpace(type))
            {
                if (!Enum.TryParse(type, out nType))
                {
                    apiResp.code = 1;
                    apiResp.msg  = "类型格式不能识别";
                    bLLCommRelation.ContextResponse(context, apiResp);
                    return;
                }
            }
            currentUserInfo = bLLCommRelation.GetCurrentUserInfo();

            string mainId     = "";
            string relationId = "";

            if (isid == "1")
            {
                relationId = userAutoId;
            }
            else
            {
                UserInfo user = bllUser.GetUserInfoByAutoID(int.Parse(userAutoId));
                relationId = user.UserID;
            }
            if (exchange == "1")
            {
                mainId     = relationId;
                relationId = "";
            }

            int             TCount = 0;
            List <UserInfo> users  = bllUser.GetRelationUserList(pageSize, pageIndex, nType, mainId, relationId, keyword, out TCount, isid == "1");

            var list = from p in users
                       select new
            {
                id              = p.AutoID,
                avatar          = bllUser.GetUserDispalyAvatar(p),
                userName        = bllUser.GetUserDispalyName(p),
                describe        = p.Description,
                phone           = p.ViewType == 1?"": p.Phone,
                score           = p.TotalScore,
                times           = p.OnlineTimes,
                userHasRelation = this.currentUserInfo == null ? false : (isid == "1" ? bLLCommRelation.ExistRelation(nType, p.AutoID.ToString(), this.currentUserInfo.AutoID.ToString()) : bLLCommRelation.ExistRelation(nType, p.UserID, this.currentUserInfo.UserID)),
                relationTime    = p.LastLoginDate.ToString("yyyy/MM/dd hh:mm:ss")
            };

            apiResp.code   = (int)BLLJIMP.Enums.APIErrCode.IsSuccess;
            apiResp.msg    = "查询完成";
            apiResp.status = true;
            apiResp.result = new
            {
                totalcount = TCount,
                list       = list
            };
            bLLCommRelation.ContextResponse(context, apiResp);
        }
예제 #6
0
파일: BLLCommRelation.cs 프로젝트: uvbs/mmp
 /// <summary>
 /// 删除单个关系
 /// </summary>
 /// <param name="rtype"></param>
 /// <param name="mainId"></param>
 /// <param name="relationId"></param>
 /// <returns></returns>
 public bool DelCommRelation(BLLJIMP.Enums.CommRelationType rtype, string mainId, string relationId, string expandId = "")
 {
     return(Delete(new Model.CommRelationInfo(), GetSqlWhereByParm(rtype, mainId, relationId, expandId)) > 0);
 }
예제 #7
0
파일: BLLCommRelation.cs 프로젝트: uvbs/mmp
 /// <summary>
 /// 关系是否已存在
 /// </summary>
 /// <param name="rtype"></param>
 /// <param name="mainId"></param>
 /// <param name="relationId"></param>
 /// <returns></returns>
 public bool ExistRelation(BLLJIMP.Enums.CommRelationType rtype, string mainId, string relationId, string expandId = "", string ex1 = "", string ex2 = "", string ex3 = "", string ex4 = "", string ex5 = "", string websiteOwnner = "")
 {
     return(Get <Model.CommRelationInfo>(GetSqlWhereByParm(rtype, mainId, relationId, expandId, ex1, ex2, ex3, ex4, ex5, websiteOwnner)) != null);
 }