Exemplo n.º 1
0
        /// <summary>
        /// 保存素材信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public ReturnMsg SaveMaterialInfo(CmsMaterialMstrDto dto)
        {
            var rm     = new ReturnMsg();
            var entity = new CmsMaterialMstr();
            var isOk   = CheckMaterialInfo(dto, rm);

            if (!isOk.IsSuccess)
            {
                return(rm);
            }
            if (string.IsNullOrEmpty(dto.Id))
            {
                //新增
                dto.Id = Guid.NewGuid().ToString("N");
                _initHelper.InitAdd(dto, AbpSession.USR_ID, AbpSession.ORG_NO, AbpSession.BG_NO);
                dto.MATERIAL_STATUS = "待发布";
                entity = dto.ToEntity();
                _cmsMaterialMstrRepository.Insert(entity);
            }
            else
            {
                _initHelper.InitUpdate(dto, AbpSession.USR_ID);
                entity = dto.ToEntity();
                _cmsMaterialMstrRepository.Update(entity);
            }
            rm.IsSuccess = true;
            return(rm);
        }
 public ActionResult SaveMaterialInfo([FromBody] CmsMaterialMstrDto dto)
 {
     try
     {
         var result = _cmsMaterialMstrService.SaveMaterialInfo(dto);
         return(Success("保存成功"));
     }
     catch (Exception ex)
     {
         return(Fail(ex.Message));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 校验素材类型信息
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="rm"></param>
        /// <returns></returns>
        public ReturnMsg CheckMaterialInfo(CmsMaterialMstrDto dto, ReturnMsg rm)
        {
            if (string.IsNullOrEmpty(dto.MATERIAL_TITLE))
            {
                rm.IsSuccess = false;
                rm.msg       = "请输入标题";
                return(rm);
            }
            if (string.IsNullOrEmpty(dto.MATERIAL_TYPE_ID))
            {
                rm.IsSuccess = false;
                rm.msg       = "请选择分类";
                return(rm);
            }
            if (dto.MATERIAL_ATTR == "2")
            {
                if (string.IsNullOrEmpty(dto.MATERIAL_AUTHOR))
                {
                    rm.IsSuccess = false;
                    rm.msg       = "请填写作者";
                    return(rm);
                }
                if (dto.COMMENT_RULE == null)
                {
                    rm.IsSuccess = false;
                    rm.msg       = "请选择评论规则";
                    return(rm);
                }
                if (dto.IS_ROUND == null)
                {
                    rm.IsSuccess = false;
                    rm.msg       = "请选择是否轮播";
                    return(rm);
                }
                if (dto.SLT_MODULE_TYPE == null)
                {
                    rm.IsSuccess = false;
                    rm.msg       = "请选择模版";
                    return(rm);
                }
                if (dto.IS_ROUND == 1 && dto.SLT_MODULE_TYPE == 2)
                {
                    rm.IsSuccess = false;
                    rm.msg       = "模版选择错误,请更换模版";
                    return(rm);
                }
            }
            //商城素材
            if (dto.MATERIAL_ATTR == "3")
            {
                if (string.IsNullOrEmpty(dto.UDF2))
                {
                    rm.IsSuccess = false;
                    rm.msg       = "请选择关联项";
                    return(rm);
                }
            }
            if (string.IsNullOrEmpty(dto.MATERIAL_COVER_URL))
            {
                rm.IsSuccess = false;
                rm.msg       = "请上传封面图";
                return(rm);
            }

            rm.IsSuccess = true;

            return(rm);
        }