src/ZKEACMS.Product/ApiControllers/ProductCategoryApiController.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZKEACMS.Api;
using ZKEACMS.Product.Models;
using ZKEACMS.Product.Service;

namespace ZKEACMS.Product.ApiControllers
{
    [ApiController]
    [Route("api/productcategory")]
    public class ProductCategoryApiController : ControllerBase
    {
        private readonly IProductCategoryApiService _productCategoryApiService;

        public ProductCategoryApiController(IProductCategoryApiService productCategoryApiService)
        {
            _productCategoryApiService = productCategoryApiService;
        }

        [HttpGet("Get/{id}")]
        public IActionResult Get(int id)
        {
            var productCategory = _productCategoryApiService.Get(id);
            if (productCategory != null) return Ok(productCategory);

            return NotFound();
        }
        [HttpGet("GetByName/{name}")]
        public IActionResult GetByName(string name)
        {
            var productCategory = _productCategoryApiService.GetByName(name);
            if (productCategory != null) return Ok(productCategory);

            return NotFound();
        }
        [HttpPost("Create"), ApiAuthorize(Policy = PermissionKeys.ManageProductCategory)]
        public IActionResult Create([FromBody] ProductCategory productCategory)
        {
            return Ok(_productCategoryApiService.Create(productCategory));
        }

        [HttpPut("Update"), ApiAuthorize(Policy = PermissionKeys.ManageProductCategory)]
        public IActionResult Update([FromBody] ProductCategory productCategory)
        {
            return Ok(_productCategoryApiService.Update(productCategory));
        }

        [HttpDelete("Delete/{id}"), ApiAuthorize(Policy = PermissionKeys.ManageProductCategory)]
        public IActionResult Delete(int id)
        {
            _productCategoryApiService.Delete(id);
            return Ok();
后面还有 3 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。