-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
293 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MessageModel<PageModel<Department>>> Get(int page = 1, string key = "",int intPageSize = 50) | ||
{ | ||
if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) | ||
{ | ||
key = ""; | ||
} | ||
|
||
Expression<Func<Department, bool>> whereExpression = a => true; | ||
|
||
return new MessageModel<PageModel<Department>>() | ||
{ | ||
msg = "获取成功", | ||
success = true, | ||
response = await _departmentServices.QueryPage(whereExpression, page, intPageSize) | ||
}; | ||
|
||
} | ||
|
||
[HttpGet("{id}")] | ||
public async Task<MessageModel<Department>> Get(string id) | ||
{ | ||
return new MessageModel<Department>() | ||
{ | ||
msg = "获取成功", | ||
success = true, | ||
response = await _departmentServices.QueryById(id) | ||
}; | ||
} | ||
|
||
[HttpPost] | ||
public async Task<MessageModel<string>> Post([FromBody] Department request) | ||
{ | ||
var data = new MessageModel<string>(); | ||
|
||
var id = await _departmentServices.Add(request); | ||
if (data.success) | ||
{ | ||
data.response = id.ObjToString(); | ||
data.msg = "添加成功"; | ||
} | ||
|
||
return data; | ||
} | ||
|
||
[HttpPut] | ||
public async Task<MessageModel<string>> Put([FromBody] Department request) | ||
{ | ||
var data = new MessageModel<string>(); | ||
data.success = await _departmentServices.Update(request); | ||
if (data.success) | ||
{ | ||
data.msg = "更新成功"; | ||
data.response = request?.Id.ObjToString(); | ||
} | ||
|
||
return data; | ||
} | ||
|
||
[HttpDelete("{id}")] | ||
public async Task<MessageModel<string>> Delete(string id) | ||
{ | ||
var data = new MessageModel<string>(); | ||
data.success = await _departmentServices.DeleteById(id); | ||
if (data.success) | ||
{ | ||
data.msg = "删除成功"; | ||
data.response = id; | ||
} | ||
|
||
return data; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Blog.Core.IServices.BASE; | ||
using Blog.Core.Model.Models; | ||
|
||
namespace Blog.Core.IServices | ||
{ | ||
/// <summary> | ||
/// IDepartmentServices | ||
/// </summary> | ||
public interface IDepartmentServices : IBaseServices<Department> | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using System; | ||
|
||
|
||
namespace Blog.Core.Model.Models | ||
{ | ||
///<summary> | ||
/// 部门表 | ||
///</summary> | ||
public class Department : RootEntityTkey<long> | ||
{ | ||
/// <summary> | ||
/// Desc:父部门 | ||
/// Nullable:True | ||
/// </summary> | ||
public long PId { get; set; } | ||
/// <summary> | ||
/// Desc:部门关系编码 | ||
/// Default: | ||
/// Nullable:True | ||
/// </summary> | ||
public string CodeRelationship { get; set; } | ||
/// <summary> | ||
/// Desc:部门名称 | ||
/// Default: | ||
/// Nullable:True | ||
/// </summary> | ||
public string DepartName { get; set; } | ||
/// <summary> | ||
/// Desc:负责人 | ||
/// Default: | ||
/// Nullable:True | ||
/// </summary> | ||
public string Leader { get; set; } | ||
/// <summary> | ||
/// Desc:排序 | ||
/// Default: | ||
/// Nullable:True | ||
/// </summary> | ||
public int? OrderNum { get; set; } = 0; | ||
/// <summary> | ||
/// Desc:部门状态(0正常 1停用) | ||
/// Default:0 | ||
/// Nullable:True | ||
/// </summary> | ||
public bool Status { get; set; } | ||
/// <summary> | ||
/// Desc:删除标志(0代表存在 2代表删除) | ||
/// Default:0 | ||
/// Nullable:True | ||
/// </summary> | ||
public bool IsDeleted { get; set; } = false; | ||
/// <summary> | ||
/// Desc:创建者 | ||
/// Default: | ||
/// Nullable:True | ||
/// </summary> | ||
public string CreateBy { get; set; } | ||
/// <summary> | ||
/// Desc:创建时间 | ||
/// Default: | ||
/// Nullable:True | ||
/// </summary> | ||
public DateTime? CreateTime { get; set; } | ||
/// <summary> | ||
/// Desc:更新者 | ||
/// Default: | ||
/// Nullable:True | ||
/// </summary> | ||
public string ModifyBy { get; set; } | ||
/// <summary> | ||
/// Desc:更新时间 | ||
/// Default: | ||
/// Nullable:True | ||
/// </summary> | ||
public DateTime? ModifyTime { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// DepartmentServices | ||
/// </summary> | ||
public class DepartmentServices : BaseServices<Department>, IDepartmentServices | ||
{ | ||
private readonly IBaseRepository<Department> _dal; | ||
public DepartmentServices(IBaseRepository<Department> dal) | ||
{ | ||
this._dal = dal; | ||
base.BaseDal = dal; | ||
} | ||
} | ||
} |