public IActionResult Add(AddCategoryRequest model)
        {
            if (model == null)
            {
                return this.BadRequest();
            }

            var result = this.CategoryService.Add(model);

            return this.ApiResponse(result);
        }
        public OperationResult<int?> Add(AddCategoryRequest model)
        {
            if (!this.CheckCategoryName(model.Name, null))
            {
                return OperationResult<int?>.ErrorResult("分类名称重复");
            }
            if (model.ParentID.HasValue && !this.CheckParentID(model.ParentID.Value))
            {
                return OperationResult<int?>.ErrorResult("错误的上级分类");
            }

            using (var conn = this.OpenConnection())
            {
                string sql = @"
INSERT INTO [Category] ( Name, ParentID )
VALUES ( @Name, @ParentID );

SELECT @@IDENTITY;
";

                var para = new
                {
                    Name = model.Name,
                    ParentID = model.ParentID
                };

                var id = conn.ExecuteScalar<int>(sql, para);

                this.ClearCache();

                return OperationResult<int?>.SuccessResult(id);
            }
        }