123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- using Attribute;
- using Common;
- using Enums;
- using Filters;
- using Infrastructure;
- using Microsoft.AspNetCore.Mvc;
- using Middleware;
- using Model;
- using Model.Base;
- using Services;
- using Util;
- namespace Controllers
- {
- /// <summary>
- /// 岗位管理
- /// </summary>
- [Verify]
- public class SysPostController : BaseController
- {
- private readonly ISysPostService PostService;
- public SysPostController(ISysPostService postService)
- {
- PostService = postService;
- }
- /// <summary>
- /// 岗位列表查询
- /// </summary>
- /// <returns></returns>
- [HttpGet("/v1/tel/sysServer/post/page")]
- public IActionResult List([FromQuery] SysPost post, [FromQuery] PagerInfo pagerInfo)
- {
- var predicate = Expressionable.Create<SysPost>();
- predicate.AndIF(!string.IsNullOrEmpty(post.postName), u => u.postName.Contains(post.postName));
- var list = PostService.GetPages(predicate.ToExpression(), pagerInfo, s => new { s.postSort });
- return SUCCESS(list);
- }
- /// <summary>
- /// 获取所有岗位列表
- /// </summary>
- /// <returns></returns>
- [HttpGet("/v1/tel/sysServer/post/list")]
- public IActionResult AllList()
- {
- return SUCCESS(PostService.GetList(), TIME_FORMAT_FULL);
- }
- /// <summary>
- /// 岗位查询
- /// </summary>
- /// <param name="postId"></param>
- /// <returns></returns>
- [HttpGet("{postId}")]
- [ActionPermissionFilter(Permission = "system:post:query")]
- public IActionResult Query(long postId = 0)
- {
- return SUCCESS(PostService.GetId(postId));
- }
- /// <summary>
- /// 岗位管理
- /// </summary>
- /// <param name="post"></param>
- /// <returns></returns>
- [HttpPost("/v1/tel/sysServer/post/add")]
- public IActionResult Add([FromBody] SysPost post)
- {
- if (UserConstants.NOT_UNIQUE.Equals(PostService.CheckPostNameUnique(post)))
- {
- return ToResponse(ResultCode.CUSTOM_ERROR, $"修改岗位{post.postName}失败,岗位名已存在");
- }
- if (UserConstants.NOT_UNIQUE.Equals(PostService.CheckPostCodeUnique(post)))
- {
- return ToResponse(ResultCode.CUSTOM_ERROR, $"修改岗位{post.postName}失败,岗位编码已存在");
- }
- TokenModel loginUser = JwtUtil.GetLoginUser(HttpContext);
- post.CreateBy = loginUser.username;
- post.UpdateBy = loginUser.username;
- post.CreateTime = DateTime.Now;
- post.UpdateTime = DateTime.Now;
- post.DelFlag = "0";
- return SUCCESS(PostService.Add(post, true));
- }
- /// <summary>
- /// 岗位管理
- /// </summary>
- /// <param name="post"></param>
- /// <returns></returns>
- [HttpPut("/v1/tel/sysServer/post/update")]
- public IActionResult Update([FromBody] SysPost post)
- {
- if (UserConstants.NOT_UNIQUE.Equals(PostService.CheckPostNameUnique(post)))
- {
- return ToResponse(ResultCode.CUSTOM_ERROR, $"修改岗位{post.postName}失败,岗位名已存在");
- }
- if (UserConstants.NOT_UNIQUE.Equals(PostService.CheckPostCodeUnique(post)))
- {
- return ToResponse(ResultCode.CUSTOM_ERROR, $"修改岗位{post.postName}失败,岗位编码已存在");
- }
- TokenModel loginUser = JwtUtil.GetLoginUser(HttpContext);
- post.UpdateBy = loginUser.username;
- post.UpdateTime = DateTime.Now;
- return SUCCESS(PostService.Update(post, true));
- }
- /// <summary>
- /// 岗位删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("/v1/tel/sysServer/post/removeById/{id}")]
- public IActionResult Delete(int id)
- {
- return SUCCESS(PostService.Delete(id));
- }
- /// <summary>
- /// 获取岗位选择框列表
- /// </summary>
- [HttpGet("optionselect")]
- public IActionResult Optionselect()
- {
- List<SysPost> posts = PostService.GetAll();
- return SUCCESS(posts);
- }
- /// <summary>
- /// 岗位导出
- /// </summary>
- /// <returns></returns>
- [Log(BusinessType = BusinessType.EXPORT, IsSaveResponseData = false, Title = "岗位导出")]
- [HttpGet("export")]
- [ActionPermissionFilter(Permission = "system:post:export")]
- public IActionResult Export()
- {
- var list = PostService.GetAll();
- var result = ExportExcelMini(list, "post", "岗位列表");
- return ExportExcel(result.Item2, result.Item1);
- }
- }
- }
|