public NoticeCategoryBasicResponse Basic([FromBody] NoticeCategoryBasicRequest request)
        {
            NoticeCategoryBasicResponse response = new NoticeCategoryBasicResponse();

            if (request == null)
            {
                response.Status = -1;
                return(response);
            }

            NoticeCategoryEntity entity = null;

            if (request.Id > 0)
            {
                entity = noticeCategoryRepository.GetEntityById(request.Id);
            }

            if (entity == null)
            {
                var repositoryRequest = noticeCategoryConvertor.ToGetEntityByPrimaryProperty(request);
                entity = noticeCategoryRepository.GetEntityByPrimaryProperty(repositoryRequest);
            }

            if (entity == null)
            {
                response.Status = 404;
                return(response);
            }

            response.Item = noticeCategoryConvertor.ToBasicVo(entity);

            response.Status = 1;
            return(response);
        }
Example #2
0
        /// <summary>
        /// 将entity转换为vo
        /// </summary>
        public NoticeCategoryExtendedVo ToExtendedVo(NoticeCategoryEntity entity)
        {
            NoticeCategoryExtendedVo vo = new NoticeCategoryExtendedVo();

            CopyToVo(vo, entity);

            return(vo);
        }
Example #3
0
        /// <summary>
        /// 将entity转换为vo
        /// </summary>
        public NoticeCategoryBasicVo ToBasicVo(NoticeCategoryEntity entity)
        {
            NoticeCategoryBasicVo vo = new NoticeCategoryBasicVo();

            CopyToVo(vo, entity);


            return(vo);
        }
Example #4
0
 /// <summary>
 /// 将entity转换为vo。不包括来自元数据的属性
 /// </summary>
 private void CopyToVo(NoticeCategoryVo vo, NoticeCategoryEntity entity)
 {
     vo.Id             = entity.Id;
     vo.Name           = entity.Name;
     vo.Title          = entity.Title;
     vo.Remark         = entity.Remark;
     vo.DataStatus     = entity.DataStatus;
     vo.CreateTime     = entity.CreateTime;
     vo.LastUpdateTime = entity.LastUpdateTime;
 }
Example #5
0
        public NoticeCategoryEntity ToEntity(NoticeCategoryCreateRequest request)
        {
            NoticeCategoryEntity entity = new NoticeCategoryEntity();

            var item = request.Item;

            entity.Name           = item.Name;
            entity.Title          = item.Title;
            entity.Remark         = item.Remark;
            entity.DataStatus     = 1;
            entity.CreateTime     = TimeConvertor.FromMilliTicks(TimeConvertor.ToMilliTicks(DateTime.Now));
            entity.LastUpdateTime = TimeConvertor.FromMilliTicks(TimeConvertor.ToMilliTicks(DateTime.Now));

            return(entity);
        }
Example #6
0
        /// <summary>
        /// 根据主属性更新单个实体
        /// </summary>
        public void UpdateByPrimaryProperty(NoticeCategoryEntity entity)
        {
            string sql = @"
update `oam_notice_category`
set
  id = @Id,
  title = @Title,
  remark = @Remark,
  data_status = @DataStatus,
  create_time = @CreateTime,
  last_update_time = @LastUpdateTime
where
  name = @Name;";

            using (var mysqlConn = connectionProvider.GetConnection())
            {
                mysqlConn.Execute(sql, entity);
            }
        }
        public NoticeCategoryUpdateResponse Update([FromBody] NoticeCategoryUpdateRequest request)
        {
            NoticeCategoryUpdateResponse response = new NoticeCategoryUpdateResponse();

            if (request == null)
            {
                response.Status = -1;
                return(response);
            }

            if (request.Id > 0)
            {
                NoticeCategoryEntity entity = noticeCategoryRepository.GetEntityById(request.Id);
                if (entity != null)
                {
                    noticeCategoryRepository.UpdateById(noticeCategoryConvertor.ToEntity(request, entity));
                    response.Status = 1;
                }
            }

            if (response.Status == 0)
            {
                var repositoryRequest       = noticeCategoryConvertor.ToGetEntityByPrimaryProperty(request);
                NoticeCategoryEntity entity = noticeCategoryRepository.GetEntityByPrimaryProperty(repositoryRequest);
                if (entity != null)
                {
                    noticeCategoryRepository.UpdateByPrimaryProperty(noticeCategoryConvertor.ToEntity(request, entity));
                    response.Status = 1;
                }
            }

            if (response.Status == 0)
            {
                response.Status = 404;
                return(response);
            }

            metaNoticeCategoryProvider.Reload();

            response.Status = 1;
            return(response);
        }
Example #8
0
        /// <summary>
        /// 新增实体
        /// </summary>
        public void Create(NoticeCategoryEntity entity)
        {
            string sql = @"
insert into `oam_notice_category`(
  name,
  title,
  remark,
  data_status,
  create_time,
  last_update_time)
values(
  @Name,
  @Title,
  @Remark,
  @DataStatus,
  @CreateTime,
  @LastUpdateTime);";

            using (var mysqlConn = connectionProvider.GetConnection())
            {
                mysqlConn.Execute(sql, entity);
            }
        }