diff --git a/Blog.Core.Api/Blog.Core.Model.xml b/Blog.Core.Api/Blog.Core.Model.xml index 3b4fd36..6eb3c6a 100644 --- a/Blog.Core.Api/Blog.Core.Model.xml +++ b/Blog.Core.Api/Blog.Core.Model.xml @@ -271,6 +271,93 @@ 逻辑删除 + + + 部门表 + + + + + Desc:部门Code + Nullable:True + + + + + Desc:父部门Code + Nullable:True + + + + + Desc:部门关系编码 + Default: + Nullable:True + + + + + Desc:部门名称 + Default: + Nullable:True + + + + + Desc:负责人 + Default: + Nullable:True + + + + + Desc:排序 + Default: + Nullable:True + + + + + Desc:部门状态(0正常 1停用) + Default:0 + Nullable:True + + + + + Desc:删除标志(0代表存在 2代表删除) + Default:0 + Nullable:True + + + + + Desc:创建者 + Default: + Nullable:True + + + + + Desc:创建时间 + Default: + Nullable:True + + + + + Desc:更新者 + Default: + Nullable:True + + + + + Desc:更新时间 + Default: + Nullable:True + + 博客ID diff --git a/Blog.Core.Api/Controllers/DepartmentController.cs b/Blog.Core.Api/Controllers/DepartmentController.cs new file mode 100644 index 0000000..efa4c16 --- /dev/null +++ b/Blog.Core.Api/Controllers/DepartmentController.cs @@ -0,0 +1,97 @@ +using Blog.Core.IServices; +using Blog.Core.Model; +using Blog.Core.Model.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Linq.Expressions; +using System.Threading.Tasks; + +namespace Blog.Core.Api.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize(Permissions.Name)] + public class DepartmentController : ControllerBase + { + private readonly IDepartmentServices _departmentServices; + + public DepartmentController(IDepartmentServices departmentServices) + { + _departmentServices = departmentServices; + } + + [HttpGet] + public async Task>> Get(int page = 1, string key = "",int intPageSize = 50) + { + if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) + { + key = ""; + } + + Expression> whereExpression = a => true; + + return new MessageModel>() + { + msg = "获取成功", + success = true, + response = await _departmentServices.QueryPage(whereExpression, page, intPageSize) + }; + + } + + [HttpGet("{id}")] + public async Task> Get(string id) + { + return new MessageModel() + { + msg = "获取成功", + success = true, + response = await _departmentServices.QueryById(id) + }; + } + + [HttpPost] + public async Task> Post([FromBody] Department request) + { + var data = new MessageModel(); + + var id = await _departmentServices.Add(request); + if (data.success) + { + data.response = id.ObjToString(); + data.msg = "添加成功"; + } + + return data; + } + + [HttpPut] + public async Task> Put([FromBody] Department request) + { + var data = new MessageModel(); + data.success = await _departmentServices.Update(request); + if (data.success) + { + data.msg = "更新成功"; + data.response = request?.Id.ObjToString(); + } + + return data; + } + + [HttpDelete("{id}")] + public async Task> Delete(string id) + { + var data = new MessageModel(); + data.success = await _departmentServices.DeleteById(id); + if (data.success) + { + data.msg = "删除成功"; + data.response = id; + } + + return data; + } + } +} \ No newline at end of file diff --git a/Blog.Core.IServices/IDepartmentServices.cs b/Blog.Core.IServices/IDepartmentServices.cs new file mode 100644 index 0000000..fdd650d --- /dev/null +++ b/Blog.Core.IServices/IDepartmentServices.cs @@ -0,0 +1,12 @@ +using Blog.Core.IServices.BASE; +using Blog.Core.Model.Models; + +namespace Blog.Core.IServices +{ + /// + /// IDepartmentServices + /// + public interface IDepartmentServices : IBaseServices + { + } +} \ No newline at end of file diff --git a/Blog.Core.Model/Models/Department.cs b/Blog.Core.Model/Models/Department.cs new file mode 100644 index 0000000..e9cd214 --- /dev/null +++ b/Blog.Core.Model/Models/Department.cs @@ -0,0 +1,77 @@ +using System; + + +namespace Blog.Core.Model.Models +{ + /// + /// 部门表 + /// + public class Department : RootEntityTkey + { + /// + /// Desc:父部门 + /// Nullable:True + /// + public long PId { get; set; } + /// + /// Desc:部门关系编码 + /// Default: + /// Nullable:True + /// + public string CodeRelationship { get; set; } + /// + /// Desc:部门名称 + /// Default: + /// Nullable:True + /// + public string DepartName { get; set; } + /// + /// Desc:负责人 + /// Default: + /// Nullable:True + /// + public string Leader { get; set; } + /// + /// Desc:排序 + /// Default: + /// Nullable:True + /// + public int? OrderNum { get; set; } = 0; + /// + /// Desc:部门状态(0正常 1停用) + /// Default:0 + /// Nullable:True + /// + public bool Status { get; set; } + /// + /// Desc:删除标志(0代表存在 2代表删除) + /// Default:0 + /// Nullable:True + /// + public bool IsDeleted { get; set; } = false; + /// + /// Desc:创建者 + /// Default: + /// Nullable:True + /// + public string CreateBy { get; set; } + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + public DateTime? CreateTime { get; set; } + /// + /// Desc:更新者 + /// Default: + /// Nullable:True + /// + public string ModifyBy { get; set; } + /// + /// Desc:更新时间 + /// Default: + /// Nullable:True + /// + public DateTime? ModifyTime { get; set; } + } +} \ No newline at end of file diff --git a/Blog.Core.Services/DepartmentServices.cs b/Blog.Core.Services/DepartmentServices.cs new file mode 100644 index 0000000..a6f1eed --- /dev/null +++ b/Blog.Core.Services/DepartmentServices.cs @@ -0,0 +1,20 @@ +using Blog.Core.IServices; +using Blog.Core.Model.Models; +using Blog.Core.Services.BASE; +using Blog.Core.IRepository.Base; + +namespace Blog.Core.Services +{ + /// + /// DepartmentServices + /// + public class DepartmentServices : BaseServices, IDepartmentServices + { + private readonly IBaseRepository _dal; + public DepartmentServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file