Browse Source

测试api分组

lcl 10 months ago
parent
commit
91bdf0ff23

+ 122 - 0
Controllers/ApiGroupController.cs

@@ -0,0 +1,122 @@
+using Attribute;
+using Common;
+using Dto;
+using Vo;
+using Enums;
+using Filters;
+using Infrastructure;
+using Infrastructure.Model;
+using Mapster;
+using Microsoft.AspNetCore.Mvc;
+using Middleware;
+using Model;
+using Services;
+using Model.Base;
+
+namespace Controllers
+{
+    /// <summary>
+    /// ApiGroup)Controller
+    /// </summary>
+    // [Route("ApiGroup")]
+    // [ApiExplorerSettings(GroupName = "ApiGroup")]
+    public class ApiGroupController : BaseController
+    {
+        /// <summary>
+        /// api分组接口
+        /// </summary>
+        private readonly IApiGroupService _ApiGroupService;
+
+
+        public ApiGroupController(IApiGroupService ApiGroupService)
+        {
+            _ApiGroupService = ApiGroupService;
+
+        }
+
+        /// <summary>
+        /// api接口分组列表
+        /// </summary>
+        /// <param name="parm">请求参数</param>
+        /// <returns>api接口分组列表</returns>
+        [HttpGet]
+        [Route("/v1/api/ApiGroup/list")]
+        public IActionResult List([FromQuery] ApiGroupListDto parm)
+        {
+            var response = _ApiGroupService.List(parm);
+            return SUCCESS(response);
+        }
+
+
+
+
+        /// <summary>
+        /// api接口分组详情
+        /// </summary>
+        /// <param name="parm">请求参数</param>
+        /// <returns>api接口分组详情</returns>
+        [HttpGet]
+        [Route("/v1/api/ApiGroup/query")]
+        public IActionResult Query([FromQuery] ApiGroupQueryDto parm)
+        {
+            var response = _ApiGroupService.GetFirst(x => x.Id == parm.Id).Adapt<ApiGroupQueryVo>();
+            return SUCCESS(response);
+        }
+
+
+
+
+        /// <summary>
+        /// api接口分组添加
+        /// </summary>
+        /// <param name="parm">请求参数</param>
+        /// <returns>api接口分组添加</returns>
+        [HttpPost]
+        [Route("/v1/api/ApiGroup/add")]
+        public IActionResult Add([FromBody] ApiGroupAddDto parm)
+        {
+            var modal = parm.Adapt<ApiGroup>().ToCreate(HttpContext);
+            var response = _ApiGroupService.Add(modal);
+            return ToResponse(response);
+        }
+
+
+
+
+        /// <summary>
+        /// api接口分组修改
+        /// </summary>
+        /// <param name="parm">请求参数</param>
+        /// <returns>api接口分组修改</returns>
+        [HttpPut]
+        [Route("/v1/api/ApiGroup/update")]
+        public IActionResult Update([FromBody] ApiGroupUpdateDto parm)
+        {
+            var modal = parm.Adapt<ApiGroup>().ToUpdate(HttpContext);
+            var response = _ApiGroupService.Update(modal, true);
+            return ToResponse(response);
+        }
+
+
+
+
+        /// <summary>
+        /// api接口分组删除
+        /// </summary>
+        /// <param name="Id">ID</param>
+        /// <returns>api接口分组删除</returns>
+        [HttpDelete]
+        [Route("/v1/api/ApiGroup/delete/{Id}")]
+        public IActionResult Delete(int Id)
+        {
+            var response = _ApiGroupService.Delete(Id);
+            return ToResponse(response);
+        }
+
+
+
+
+
+
+    }
+}

+ 34 - 0
Model/Dto/ApiGroupAddDto.cs

@@ -0,0 +1,34 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using Model.Base;
+
+namespace Dto
+{
+    /// <summary>
+    /// 添加
+    /// </summary>
+    public class ApiGroupAddDto
+    {
+        /// <summary>
+        /// 名称
+        /// </summary>
+        [Required(ErrorMessage = "名称不能为空")]
+        public string GroupName { get; set; }
+
+
+        /// <summary>
+        /// 说明
+        /// </summary>
+        public string GroupRemark { get; set; }
+
+
+        /// <summary>
+        /// 版本号
+        /// </summary>
+        [Required(ErrorMessage = "版本号不能为空")]
+        public string GroupVersion { get; set; }
+
+
+
+    }
+}

+ 21 - 0
Model/Dto/ApiGroupListDto.cs

@@ -0,0 +1,21 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using Model.Base;
+
+namespace Dto
+{
+    /// <summary>
+    /// 列表
+    /// </summary>
+    public class ApiGroupListDto
+    {
+        /// <summary>
+        /// 名称
+        /// </summary>
+        [Required(ErrorMessage = "名称不能为空")]
+        public string GroupName { get; set; }
+
+
+
+    }
+}

+ 20 - 0
Model/Dto/ApiGroupQueryDto.cs

@@ -0,0 +1,20 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using Model.Base;
+
+namespace Dto
+{
+    /// <summary>
+    /// 详情
+    /// </summary>
+    public class ApiGroupQueryDto
+    {
+        /// <summary>
+        /// ID
+        /// </summary>
+        public int Id { get; set; }
+
+
+
+    }
+}

+ 40 - 0
Model/Dto/ApiGroupUpdateDto.cs

@@ -0,0 +1,40 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using Model.Base;
+
+namespace Dto
+{
+    /// <summary>
+    /// 修改
+    /// </summary>
+    public class ApiGroupUpdateDto
+    {
+        /// <summary>
+        /// 名称
+        /// </summary>
+        [Required(ErrorMessage = "名称不能为空")]
+        public string GroupName { get; set; }
+
+
+        /// <summary>
+        /// 说明
+        /// </summary>
+        public string GroupRemark { get; set; }
+
+
+        /// <summary>
+        /// 版本号
+        /// </summary>
+        [Required(ErrorMessage = "版本号不能为空")]
+        public string GroupVersion { get; set; }
+
+
+        /// <summary>
+        /// ID
+        /// </summary>
+        public int Id { get; set; }
+
+
+
+    }
+}

+ 18 - 0
Model/Vo/ApiGroupAddVo.cs

@@ -0,0 +1,18 @@
+using Newtonsoft.Json;
+
+namespace Vo
+{
+    /// <summary>
+    /// 添加
+    /// </summary>
+    public class ApiGroupAddVo
+    {
+        /// <summary>
+        /// ID
+        /// </summary>
+        public int Id { get; set; }
+
+
+
+    }
+}

+ 30 - 0
Model/Vo/ApiGroupListVo.cs

@@ -0,0 +1,30 @@
+using Newtonsoft.Json;
+
+namespace Vo
+{
+    /// <summary>
+    /// 列表
+    /// </summary>
+    public class ApiGroupListVo
+    {
+        /// <summary>
+        /// 名称
+        /// </summary>
+        public string GroupName { get; set; }
+
+
+        /// <summary>
+        /// 版本号
+        /// </summary>
+        public string GroupVersion { get; set; }
+
+
+        /// <summary>
+        /// ID
+        /// </summary>
+        public int Id { get; set; }
+
+
+
+    }
+}

+ 24 - 0
Model/Vo/ApiGroupQueryVo.cs

@@ -0,0 +1,24 @@
+using Newtonsoft.Json;
+
+namespace Vo
+{
+    /// <summary>
+    /// 详情
+    /// </summary>
+    public class ApiGroupQueryVo
+    {
+        /// <summary>
+        /// 名称
+        /// </summary>
+        public string GroupName { get; set; }
+
+
+        /// <summary>
+        /// 版本号
+        /// </summary>
+        public string GroupVersion { get; set; }
+
+
+
+    }
+}

+ 3 - 3
Properties/launchSettings.json

@@ -4,7 +4,7 @@
     "windowsAuthentication": false,
     "anonymousAuthentication": true,
     "iisExpress": {
-      "applicationUrl": "http://192.168.1.151:49293",
+      "applicationUrl": "http://localhost:49293",
       "sslPort": 44376
     }
   },
@@ -14,7 +14,7 @@
       "dotnetRunMessages": true,
       "launchBrowser": true,
       "launchUrl": "swagger",
-      "applicationUrl": "http://192.168.1.151:5296",
+      "applicationUrl": "http://localhost:5296",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
@@ -24,7 +24,7 @@
       "dotnetRunMessages": true,
       "launchBrowser": true,
       "launchUrl": "swagger",
-      "applicationUrl": "http://192.168.1.151:5296",
+      "applicationUrl": "http://localhost:5296",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }

+ 39 - 0
Services/ApiGroupService.cs

@@ -0,0 +1,39 @@
+using Attribute;
+using Dto;
+using Vo;
+using Model;
+using Model.Base;
+using Repository;
+using Service;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Services
+{
+    /// <summary>
+    /// api接口分组Service业务层处理
+    /// </summary>
+    [AppService(ServiceType = typeof(IApiGroupService), ServiceLifetime = LifeTime.Transient)]
+    public class ApiGroupService : BaseService<ApiGroup>, IApiGroupService
+    {
+        /// <summary>
+        /// api接口分组-列表
+        /// </summary>
+        /// <param name="parm">请求参数</param>
+        /// <returns>api接口分组列表</returns>
+        public PagedInfo<ApiGroupListVo> List([FromQuery] ApiGroupListDto parm)
+        {
+            //开始拼装查询条件
+            var predicate = Expressionable.Create<ApiGroup>();
+            predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GroupName), m => m.GroupName.Contains(parm.GroupName));
+            var response = Queryable()
+                .Where(predicate.ToExpression())
+                .ToPage<ApiGroup, ApiGroupListVo>(new PagerInfo());
+            return response;
+        }
+
+
+
+
+
+    }
+}

+ 21 - 0
Services/IService/IApiGroupService.cs

@@ -0,0 +1,21 @@
+using Dto;
+using Vo;
+using Model;
+using Model.Base;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Services
+{
+    public interface IApiGroupService : IBaseService<ApiGroup>
+    {
+        /// <summary>
+        /// api接口分组-列表
+        /// </summary>
+        /// <param name="parm">请求参数</param>
+        /// <returns>api接口分组列表</returns>
+        PagedInfo<ApiGroupListVo> List([FromQuery] ApiGroupListDto parm);
+
+
+
+    }
+}