Beispiel #1
0
        public JsonResult Attention([FromForm] string token, [FromForm] int userId)
        {
            DataResult dr = new DataResult();

            try
            {
                if (userId < 10000)
                {
                    dr.code = "201";
                    dr.msg  = "参数错误";
                    return(Json(dr));
                }
                UserEntity userEntity = this.GetUserByToken(token);
                FansBLL    fansBLL    = new FansBLL();

                FansEntity fansEntity = fansBLL.GetByUserIdAndAttentionId(userEntity.userId, userId);

                if (fansEntity != null)
                {
                    dr.data = true;
                }
                else
                {
                    dr.data = false;
                }

                dr.code = "200";
            }
            catch (Exception ex)
            {
                dr.code = "999";
                dr.msg  = ex.Message;
            }
            return(Json(dr));
        }
Beispiel #2
0
        public JsonResult Create([FromForm] string token, [FromForm] int userId)
        {
            DataResult dr = new DataResult();

            try
            {
                if (userId < 10000 || userId < 1)
                {
                    dr.code = "201";
                    dr.msg  = "参数错误";
                    return(Json(dr));
                }

                UserEntity userEntity = this.GetUserByToken(token);

                if (userEntity.userId == userId)
                {
                    dr.code = "201";
                    dr.msg  = "不能关注自己";
                    return(Json(dr));
                }

                FansBLL fansBLL = new FansBLL();

                FansEntity fansEntity = fansBLL.GetByUserIdAndAttentionId(userEntity.userId, userId);
                if (fansEntity != null)
                {
                    dr.code = "201";
                    dr.msg  = "已关注关注";
                    return(Json(dr));
                }

                int rows = fansBLL.Create(userEntity.userId, userId);

                if (rows > 0)
                {
                    dr.code = "200";
                    dr.msg  = "成功";
                }
                else
                {
                    dr.code = "201";
                    dr.msg  = "失败";
                }
            }
            catch (Exception ex)
            {
                dr.code = "999";
                dr.msg  = ex.Message;
            }
            return(Json(dr));
        }
Beispiel #3
0
        public JsonResult Delete([FromForm] string token, [FromForm] int userId)
        {
            DataResult dr = new DataResult();

            try
            {
                if (userId < 10000 || userId < 1)
                {
                    dr.code = "201";
                    dr.msg  = "参数错误";
                    return(Json(dr));
                }

                UserEntity userEntity = this.GetUserByToken(token);

                FansBLL    fansBLL    = new FansBLL();
                FansEntity fansEntity = fansBLL.GetByUserIdAndAttentionId(userEntity.userId, userId);

                if (fansEntity == null)
                {
                    dr.code = "201";
                    dr.msg  = "不存在关注";
                    return(Json(dr));
                }

                fansEntity.isDel      = true;
                fansEntity.modifyDate = DateTime.Now;

                int rows = fansBLL.ActionDal.ActionDBAccess.Updateable(fansEntity).ExecuteCommand();

                if (rows > 0)
                {
                    dr.code = "200";
                    dr.msg  = "成功";
                }
                else
                {
                    dr.code = "201";
                    dr.msg  = "失败";
                }
            }
            catch (Exception ex)
            {
                dr.code = "999";
                dr.msg  = ex.Message;
            }
            return(Json(dr));
        }