Exemple #1
0
        /// <summary>
        /// 保存回复信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public ReturnMsg SaveReplyInfo(WctReplyMstrDto dto)
        {
            var rm     = new ReturnMsg();
            var entity = new WctReplyMstr();
            var isOk   = CheckReplyInfo(dto, rm);

            if (!isOk.IsSuccess)
            {
                return(rm);
            }
            if (string.IsNullOrEmpty(dto.Id))
            {
                dto.Id           = Guid.NewGuid().ToString("N");
                dto.REPLY_STATUS = "未发布";
                dto.REPLY_ID_NO  = AbpSession.ORG_NO;
                _initHelper.InitAdd(dto, AbpSession.USR_ID, AbpSession.ORG_NO, AbpSession.BG_NO);
                entity = dto.ToEntity();
                _wctReplyMstrRepository.Insert(entity);
            }
            else
            {
                _initHelper.InitUpdate(dto, AbpSession.USR_ID);
                entity = dto.ToEntity();
                _wctReplyMstrRepository.Update(entity);
            }
            rm.IsSuccess = true;

            return(rm);
        }
Exemple #2
0
 public ActionResult SaveReplyInfo([FromBody] WctReplyMstrDto dto)
 {
     try
     {
         var result = _wctReplyMstrService.SaveReplyInfo(dto);
         if (!result.IsSuccess)
         {
             return(Fail(result.msg));
         }
         return(Success("保存成功"));
     }
     catch (Exception ex)
     {
         return(Fail(ex.Message));
     }
 }
Exemple #3
0
        /// <summary>
        /// 校验回复信息
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="rm"></param>
        /// <returns></returns>
        public ReturnMsg CheckReplyInfo(WctReplyMstrDto dto, ReturnMsg rm)
        {
            if (dto.REPLY_TYPE == 0)
            {
                rm.IsSuccess = false;
                rm.msg       = "请选择回复类型";
                return(rm);
            }
            if (dto.REPLY_TYPE == 3 && (string.IsNullOrEmpty(dto.REPLY_KEYWORD) || string.IsNullOrEmpty(dto.REPLY_KEYWORD.Trim())))
            {
                rm.IsSuccess = false;
                rm.msg       = "请输入关键字";
                return(rm);
            }
            if (dto.REPLY_CONTENT_TYPE == 0 && (string.IsNullOrEmpty(dto.REPLY_TEXT) || string.IsNullOrEmpty(dto.REPLY_TEXT.Trim())))
            {
                rm.IsSuccess = false;
                rm.msg       = "请输入回复内容";
                return(rm);
            }
            if (dto.REPLY_CONTENT_TYPE != 0)
            {
                if (string.IsNullOrEmpty(dto.MATERIAL_IDS))
                {
                    rm.IsSuccess = false;
                    rm.msg       = "请选择回复的图文信息";
                    return(rm);
                }
                var list = dto.MATERIAL_IDS.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                if (list.Count > 8)
                {
                    rm.IsSuccess = false;
                    rm.msg       = "图文消息不可超过8条";
                    return(rm);
                }
            }
            var result = new List <WctReplyMstr>();

            if (dto.REPLY_TYPE == 1 || dto.REPLY_TYPE == 2 || dto.REPLY_TYPE == 4)
            {
                result = GetExpressionResult(dto.Id, c => c.REPLY_TYPE == dto.REPLY_TYPE);
                if (result.Count > 0)
                {
                    var msg = dto.REPLY_TYPE == 1 ? "关注" : dto.REPLY_TYPE == 2 ? "默认" : "新用户关注";
                    rm.IsSuccess = false;
                    rm.msg       = "" + msg + "回复已存在,请重新输入";
                    return(rm);
                }
            }
            else
            {
                result = GetExpressionResult(dto.Id, c => c.REPLY_TYPE == dto.REPLY_TYPE && c.REPLY_KEYWORD == dto.REPLY_KEYWORD);
                if (result.Count > 0)
                {
                    rm.IsSuccess = false;
                    rm.msg       = "该关键词已存在,请重新输入";
                    return(rm);
                }
            }

            rm.IsSuccess = true;

            return(rm);
        }