using Microsoft.AspNetCore.Mvc;
|
using IStation.Model.Api;
|
using System.Net;
|
using System.Net.Http.Headers;
|
using Microsoft.Extensions.Hosting.Internal;
|
using Microsoft.AspNetCore.Http.Extensions;
|
using IStation.Untity;
|
|
namespace IStation.WebApi.Controllers.V1
|
{
|
/// <summary>
|
/// EmployeePosition 标准Api
|
/// </summary>
|
[ApiController]
|
[Route("V1/Standard/EmployeePosition")]
|
[ApiExplorerSettings(GroupName = "V1")]
|
public class EmployeePosition_StandardController : ControllerBase
|
{
|
private readonly Service.EmployeePosition _service = new Service.EmployeePosition();
|
|
#region Query
|
|
/// <summary>
|
/// 通过 CorpID 获取
|
/// </summary>
|
[Route("GetByCorpID")]
|
[HttpGet]
|
public Result GetByCorpID(long CorpID)
|
{
|
if (CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
var list = _service.GetByCorpID(CorpID);
|
return new Result<List<Model.EmployeePosition>>(list);
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
[Route("GetByID")]
|
[HttpGet]
|
public Result GetByID(long CorpID, long ID)
|
{
|
if (CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
if (ID < 1)
|
{
|
return new Result(Code.Error, "ID 参数错误");
|
}
|
var model = _service.GetByID(CorpID, ID);
|
return new Result<Model.EmployeePosition>(model);
|
}
|
|
/// <summary>
|
/// 通过 Ids 获取
|
/// </summary>
|
[Route("GetByIds")]
|
[HttpGet]
|
public Result GetByIds(long CorpID, string Ids)
|
{
|
if (CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
var ids = LongListHelper.ToList(Ids);
|
if (ids == null || ids.Count() < 1)
|
{
|
return new Result(Code.Error, "Ids 参数错误");
|
}
|
var list = _service.GetByIds(CorpID, ids);
|
return new Result<List<Model.EmployeePosition>>(list);
|
}
|
|
/// <summary>
|
/// 通过 DepartmentID 获取
|
/// </summary>
|
[Route("GetByDepartmentID")]
|
[HttpGet]
|
public Result GetByDepartmentID(long CorpID, long DepartmentID)
|
{
|
if (CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
if (DepartmentID < 1)
|
{
|
return new Result(Code.Error, "DepartmentID 参数错误");
|
}
|
|
var list = _service.GetByDepartmentID(CorpID, DepartmentID);
|
return new Result<List<Model.EmployeePosition>>(list);
|
}
|
|
/// <summary>
|
/// 通过 DepartmentIds 获取
|
/// </summary>
|
[Route("GetByDepartmentIds")]
|
[HttpGet]
|
public Result GetByDepartmentIds(long CorpID, string DepartmentIds)
|
{
|
if (CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
var ids = LongListHelper.ToList(DepartmentIds);
|
if (ids == null || ids.Count() < 1)
|
{
|
return new Result(Code.Error, "DepartmentIds 参数错误");
|
}
|
var list = _service.GetByDepartmentIds(CorpID, ids);
|
return new Result<List<Model.EmployeePosition>>(list);
|
}
|
|
|
#endregion
|
|
#region Insert
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
[Route("Insert")]
|
[HttpPost]
|
public Result Insert(Model.EmployeePosition model)
|
{
|
if (model == null)
|
{
|
return new Result(Code.Error, "参数错误");
|
}
|
|
var id = _service.Insert(model);
|
return new Result<long>(id);
|
}
|
|
/// <summary>
|
/// 插入多条
|
/// </summary>
|
[Route("Inserts")]
|
[HttpPost]
|
public Result Inserts(List<Model.EmployeePosition> list)
|
{
|
if (list == null || list.Count() < 1)
|
{
|
return new Result(Code.Error, "参数错误");
|
}
|
var bol = _service.Inserts(list);
|
return new Result<bool>(bol);
|
}
|
|
|
#endregion
|
|
#region Update
|
|
/// <summary>
|
/// 更新一条
|
/// </summary>
|
[Route("Update")]
|
[HttpPut]
|
public Result Update(Model.EmployeePosition model)
|
{
|
if (model == null)
|
{
|
return new Result(Code.Error, "参数错误");
|
}
|
|
var bol = _service.Update(model);
|
return new Result<bool>(bol);
|
}
|
|
/// <summary>
|
/// 更新多条
|
/// </summary>
|
[Route("Updates")]
|
[HttpPut]
|
public Result Updates(List<Model.EmployeePosition> list)
|
{
|
if (list == null || list.Count() < 1)
|
{
|
return new Result(Code.Error, "参数错误");
|
}
|
var bol = _service.Updates(list);
|
return new Result<bool>(bol);
|
}
|
|
/// <summary>
|
/// 更新排序码
|
/// </summary>
|
[Route("UpdateSortCode")]
|
[HttpPut]
|
public Result UpdateSortCode(Model.UpdateCorpSortCodeInput model)
|
{
|
if (model == null)
|
{
|
return new Result(Code.Error, "参数错误");
|
}
|
if (model.CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
if (model.ID < 1)
|
{
|
return new Result(Code.Error, "ID 参数错误");
|
}
|
var bol = _service.UpdateSortCode(model.CorpID, model.ID, model.SortCode);
|
return new Result<bool>(bol);
|
}
|
|
/// <summary>
|
/// 更新排序
|
/// </summary>
|
[Route("UpdateSorter")]
|
[HttpPut]
|
public Result UpdateSorter(Model.UpdateCorpSorterInput model)
|
{
|
if (model == null)
|
{
|
return new Result(Code.Error, "参数错误");
|
}
|
if (model.CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
var bol = _service.UpdateSorter(model.CorpID, model.Sorters);
|
return new Result<bool>(bol);
|
}
|
|
/// <summary>
|
/// 更新使用状态
|
/// </summary>
|
[Route("UpdateUseStatus")]
|
[HttpPut]
|
public Result UpdateUseStatus(Model.UpdateCorpUseStatusInput model)
|
{
|
if (model == null)
|
{
|
return new Result(Code.Error, "参数错误");
|
}
|
if (model.CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
if (model.ID < 1)
|
{
|
return new Result(Code.Error, "ID 参数错误");
|
}
|
var bol = _service.UpdateUseStatus(model.CorpID, model.ID, (Model.EmployeePosition.eUseStatus)model.UseStatus);
|
return new Result<bool>(bol);
|
}
|
|
/// <summary>
|
/// 更新TagName
|
/// </summary>
|
[Route("UpdateTagName")]
|
[HttpPut]
|
public Result UpdateTagName(Model.UpdateCorpTagNameInput model)
|
{
|
if (model == null)
|
{
|
return new Result(Code.Error, "参数错误");
|
}
|
if (model.CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
if (model.ID < 1)
|
{
|
return new Result(Code.Error, "ID 参数错误");
|
}
|
var bol = _service.UpdateTagName(model.CorpID, model.ID, model.TagName);
|
return new Result<bool>(bol);
|
}
|
|
/// <summary>
|
/// 更新 TerminalId
|
/// </summary>
|
[Route("UpdateTerminalId")]
|
[HttpPut]
|
public Result UpdateTerminalId(Model.UpdateCorpTerminalIdInput model)
|
{
|
if (model == null)
|
{
|
return new Result(Code.Error, "参数错误");
|
}
|
if (model.CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
if (model.ID < 1)
|
{
|
return new Result(Code.Error, "ID 参数错误");
|
}
|
var bol = _service.UpdateTerminalId(model.CorpID, model.ID, model.TerminalId);
|
return new Result<bool>(bol);
|
}
|
|
#endregion
|
|
#region Exist
|
|
/// <summary>
|
/// 是否存在编号
|
/// </summary>
|
[Route("IsExistNO")]
|
[HttpGet]
|
public Result IsExistNO(long CorpID, string NO)
|
{
|
if (CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
if (string.IsNullOrEmpty(NO))
|
{
|
return new Result("NO 参数错误");
|
}
|
var bol = _service.IsExistNO(CorpID, NO);
|
return new Result<bool>(bol);
|
}
|
|
/// <summary>
|
/// 是否存在编号
|
/// </summary>
|
[Route("IsExistNOExceptID")]
|
[HttpGet]
|
public Result IsExistNOExceptID(long CorpID, string NO, long ExceptID)
|
{
|
if (CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
if (string.IsNullOrEmpty(NO))
|
{
|
return new Result("NO 参数错误");
|
}
|
if (ExceptID < 1)
|
{
|
return new Result("ExceptID 参数错误");
|
}
|
var bol = _service.IsExistNOExceptID(CorpID, NO, ExceptID);
|
return new Result<bool>(bol);
|
}
|
|
/// <summary>
|
/// 判断TagName是否存在
|
/// </summary>
|
[Route("IsExistTagName")]
|
[HttpGet]
|
public Result IsExistTagName(long CorpID, string TagName)
|
{
|
if (CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
if (string.IsNullOrEmpty(TagName))
|
{
|
return new Result(Code.Error, "TagName 参数错误");
|
}
|
var bol = _service.IsExistTagName(CorpID, TagName);
|
return new Result<bool>(bol);
|
}
|
|
/// <summary>
|
/// 判断TagName是否存在 ExceptID
|
/// </summary>
|
[Route("IsExistTagNameExceptID")]
|
[HttpGet]
|
public Result IsExistTagNameExceptID(long CorpID, string TagName, long ExceptID)
|
{
|
if (CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
if (string.IsNullOrEmpty(TagName))
|
{
|
return new Result(Code.Error, "TagName 参数错误");
|
}
|
var bol = _service.IsExistTagNameExceptID(CorpID, TagName, ExceptID);
|
return new Result<bool>(bol);
|
}
|
|
#endregion
|
|
#region Delete
|
|
/// <summary>
|
/// 删除
|
/// </summary>
|
[Route("DeleteByID")]
|
[HttpDelete]
|
public Result DeleteByID(long CorpID, long ID)
|
{
|
if (CorpID < 1)
|
{
|
return new Result("CorpID 参数错误");
|
}
|
if (ID < 1)
|
{
|
return new Result("ID 参数错误");
|
}
|
var bol = _service.DeleteByID(CorpID, ID, out string Msg);
|
return new ResultReason<bool>(bol, Msg);
|
}
|
|
#endregion
|
|
}
|
}
|