public HttpResponseMessage Get(int id)
		{
			var entity =_categoryService.GetCategoryById(id);
          if(entity!=null)
          { 
			var model = new CategoryModel
			{
				Id = entity.Id,
                Father = entity.Father,
                Name = entity.Name,
                Sort = entity.Sort,
                AddUser = entity.AddUser,
                AddTime = entity.AddTime,
                UpdUser = entity.UpdUser,
                UpdTime = entity.UpdTime
                
            };
			return PageHelper.toJson(model);
          }
          return PageHelper.toJson(PageHelper.ReturnValue(false, "数据不存在!"));
		}
		public HttpResponseMessage Put(CategoryModel model)
		{
			var entity = _categoryService.GetCategoryById(model.Id);
			if(entity == null)
				return PageHelper .toJson (PageHelper .ReturnValue(false ,"不存在该数据!修改失败"));
			entity.Name = model.Name;
			entity.Sort = model.Sort;
            //entity.UpdUser = _workContent.CurrentUser.Id;
            entity.UpdUser = 1;
			entity.UpdTime = DateTime.Now;
            if (_categoryService.Update(entity) != null)
            { return PageHelper.toJson(PageHelper.ReturnValue(true, "修改成功")); }
			return PageHelper .toJson (PageHelper .ReturnValue (false ,"修改失败"));
		}
        public HttpResponseMessage Post(CategoryModel model)
		{
            //var entity = new CategoryEntity
            //{
            // //   FatherId = model.FatherId,
            //    Name = model.Name,
            //    Sort = model.Sort,
            //    AddUser = model.AddUser,
            //    AddTime = DateTime.Now,
            //    UpdUser = model.UpdUser,
            //    UpdTime = DateTime.Now,
            //};
            //if(_categoryService.Create(entity).Id > 0)
            //{
            //    return PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!"));
            //}
            //return PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加失败!"));
            Regex reg = new Regex(@"^[^ %@#!*~&',;=?$\x22]+$");
            var m = reg.IsMatch(model.Name);
            if (!m)
            {
                return PageHelper.toJson(PageHelper.ReturnValue(false, "存在非法字符!"));
            }
            CategoryEntity superCe = _categoryService.GetCategoryById(model.Id);
            int sort = 0;
            if (superCe != null)//有上级分类则次级排序加1;
            {
                sort = superCe.Sort + 1;
            }
            CategoryEntity ce = new CategoryEntity()
            {
                Father = superCe,
                Name = model.Name,
                Sort = sort,
                AddTime = DateTime.Now,
               // AddUser = _workContent.CurrentUser.Id,
               AddUser =1,
                UpdTime = DateTime.Now,
               // UpdUser = _workContent.CurrentUser.Id
               UpdUser =1

            };
            try
            {
                _categoryService.Create(ce);
                return PageHelper.toJson(PageHelper.ReturnValue(true, "添加分类成功!"));
            }
            catch (Exception error)
            {
                return PageHelper.toJson(PageHelper.ReturnValue(false, "添加分类失败!")); ;
            }
		}