protected async override Task <HandleResult> HandleCoreAsync(AddReviewRequest reqObj) { if (reqObj.Content.Length >= 500) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "评论信息不能超过500个字" }); } if (SensitiveWordDetective.getInstance().isContainsSensitiveWord(reqObj.Content)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "评论信息中包含敏感词语,请修正" }); } var review = new Review { AddTime = DateTime.Now, Content = reqObj.Content, MID = reqObj.MID, UID = reqObj.UserId, Up = 0, Down = 0 }; var rowAffected = await _mottoRepo.AddReviewAsync(review); if (rowAffected > 0) { _eventPublisher.Publish(new CreateReviewEvent { TheDay = reqObj.TheDay, Review = review }); return(new AddReviewResult { State = HandleStates.Success, Msg = "" }); } return(new AddReviewResult { State = HandleStates.NoDataFound, Msg = "评论的偶得已删除" }); }
protected async override Task <HandleResult> HandleCoreAsync(AddMottoRequest reqObj) { if (reqObj.Content.Length > 500) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "作品内容不能超过500个字符" }); } if (SensitiveWordDetective.getInstance().isContainsSensitiveWord(reqObj.Content)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "作品中包含敏感词语,请修正" }); } var motto = new Motto { AddTime = DateTime.Now, Content = reqObj.Content, RecruitID = 0, RecruitTitle = "", UID = reqObj.UserId }; var rowAffected = await _mottoRepo.AddMottoAsync(motto); if (rowAffected > 0) { _eventPublisher.Publish <CreateMottoEvent>(new CreateMottoEvent { Motto = motto }); return(new AddMottoResult { State = HandleStates.Success, Msg = "添加作品成功" }); } return(new AddMottoResult { State = HandleStates.UnkownError, Msg = "发生错误,请稍后重试。" }); }
protected async override Task <HandleResult> HandleCoreAsync(ReviewGiftRequest reqObj) { if (reqObj.Rate < 0 || reqObj.Rate > 5) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "评分必须介于0和5之间" }); } if (reqObj.Comment.Length >= 500) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "评价内容必须在500个字以内" }); } if (SensitiveWordDetective.getInstance().isContainsSensitiveWord(reqObj.Comment)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "评论内容中包含敏感字符,请修正" }); } int rowAfftected = await _giftRepo.ReviewGiftAsync(reqObj.UserId, reqObj.GiftId, reqObj.ExchangeId, reqObj.Rate, reqObj.Comment); if (rowAfftected > 0) { return(new HandleResult { State = HandleStates.Success, Msg = string.Empty }); } return(new HandleResult { State = HandleStates.NoDataFound, Msg = "未找到兑换记录,请刷新后重试" }); }
protected async override Task <HandleResult> HandleCoreAsync(UpdateCollectionRequest reqObj) { if (string.IsNullOrWhiteSpace(reqObj.Title)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "珍藏标题不能为空." }); } if (SensitiveWordDetective.getInstance().isContainsSensitiveWord(reqObj.Title)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "珍藏标题中包含敏感词语,请修正" }); } if (SensitiveWordDetective.getInstance().isContainsSensitiveWord(reqObj.Summary)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "珍藏说明中包含敏感词语,请修正" }); } int rowAffected = await _collectionRepo.UpdateCollectionAsync(reqObj.UserId, reqObj.CID, reqObj.Title, reqObj.Summary); if (rowAffected > 0) { return(new HandleResult { State = HandleStates.Success, Msg = string.Empty }); } return(new HandleResult { State = HandleStates.NoDataFound, Msg = "未找到要修改的记录" }); }
protected override async Task <HandleResult> HandleCoreAsync(SendMsgRequest reqObj) { if (string.IsNullOrEmpty(reqObj.Content)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "消息内容不能为空" }); } if (reqObj.UserId.Equals(reqObj.TUID)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "不能发私信给自已" }); } if (SensitiveWordDetective.getInstance().isContainsSensitiveWord(reqObj.Content)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "信息中包含敏感词语,请修正" }); } int rowAffected = await _msgRepo.SendMsgAsync(reqObj.UserId, reqObj.TUID, reqObj.Content, DateTime.Now); _eventPublisher.Publish(new SendPrivateMsgEvent { SUID = reqObj.UserId, TUID = reqObj.TUID, Msg = reqObj.Content }); return(new HandleResult { State = HandleStates.Success, Msg = string.Empty }); }
protected override async Task <HandleResult> HandleCoreAsync(ModifyUserNameRequest reqObj) { if (string.IsNullOrWhiteSpace(reqObj.UserName)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "用户名称不能为空" }); } if (SensitiveWordDetective.getInstance().isContainsSensitiveWord(reqObj.UserName)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "用户名中包含敏感词语,请修正" }); } var rowAffected = await _userRepo.UpdateUserNameAsync(reqObj.UserId, reqObj.UserName); if (rowAffected > 0) { _eventPublisher.Publish(new UpdateUserNameEvent { UID = reqObj.UserId, UserName = reqObj.UserName }); return(new HandleResult { State = HandleStates.Success, Msg = "用户名称修改成功" }); } return(new HandleResult { State = HandleStates.NoDataFound, Msg = "未找到要更新的用户信息" }); }
protected async override Task <HandleResult> HandleCoreAsync(AddTreasureRequest reqObj) { if (string.IsNullOrWhiteSpace(reqObj.Title)) { return(new AddCollectionResult { State = HandleStates.InvalidData, ID = 0, Msg = "珍藏标题不能为空." }); } if (SensitiveWordDetective.getInstance().isContainsSensitiveWord(reqObj.Title)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "珍藏标题中包含敏感词语,请修正" }); } if (SensitiveWordDetective.getInstance().isContainsSensitiveWord(reqObj.Summary)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "珍藏说明中包含敏感词语,请修正" }); } var collection = new Collection { CreateTime = DateTime.Now, Description = reqObj.Summary ?? string.Empty, Loves = 0, Mottos = 0, Score = 0, Tags = reqObj.Tags ?? string.Empty, Title = reqObj.Title, UID = reqObj.UserId }; var rowAffected = await _collectionRepo.AddCollectionAsync(collection); if (rowAffected > 0) { _eventPublisher.Publish(new CreateCollectionEvent { Collection = collection }); return(new AddCollectionResult { State = HandleStates.Success, Msg = "操作成功", ID = collection.ID }); } return(new AddCollectionResult { State = HandleStates.UnkownError, Msg = "发生未知错误", ID = 0 }); }
protected async override Task <HandleResult> HandleCoreAsync(AddUserRequest reqObj) { if (string.IsNullOrWhiteSpace(reqObj.Mobile) || string.IsNullOrWhiteSpace(reqObj.VerifyCode)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "手机号码或验证码不能为空" }); } else { var vcode = _cacheManager.GetCache <IVerifyCodeCache>().PeekVerifyCodeViaMobile(reqObj.Mobile); if (vcode == null) { return(new HandleResult { State = HandleStates.InvalidVerifyCode, Msg = "验证码无效或已过期" }); } if (!vcode.Code.Equals(reqObj.VerifyCode)) { return(new HandleResult { State = HandleStates.InvalidVerifyCode, Msg = "验证码不正确" }); } } if (string.IsNullOrWhiteSpace(reqObj.UserName) || string.IsNullOrWhiteSpace(reqObj.Password)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "用户名和密码不能为空" }); } if (SensitiveWordDetective.getInstance().isContainsSensitiveWord(reqObj.UserName)) { return(new HandleResult { State = HandleStates.InvalidData, Msg = "用户名中包含敏感词语,请修正" }); } var user = new IdentityUser(); user.Id = Utils.GenId(); user.Email = ""; user.EmailConfirmed = false; user.LockoutEnabled = false; user.LockoutEndDate = DateTime.Now; user.PhoneNumber = reqObj.Mobile; user.PhoneNumberConfirmed = true; user.SecurityStamp = string.Empty; user.TwoFactorAuthEnabled = false; user.UserName = reqObj.UserName; user.PasswordHash = Utils.HashPassword(reqObj.Password); user.DisplayName = string.IsNullOrWhiteSpace(reqObj.NickName) ? reqObj.UserName : reqObj.NickName; user.Thumb = string.IsNullOrEmpty(user.Thumb) ? string.Empty : user.Thumb; var rowAffected = await _userRepo.InsertAsync(user, reqObj.InviteCode); if (rowAffected > 0) { return(new AddUserResult { State = HandleStates.Success, Msg = string.Empty }); } return(new AddUserResult { State = HandleStates.InvalidData, Msg = "发生错误" }); }