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
{
///
/// UserRoleMapping标准Api
///
[ApiController]
[Route("v1/Standard/UserRoleMapping")]
[ApiExplorerSettings(GroupName = "v1")]
public class UserRoleMapping_StandardController : ControllerBase
{
private Service.UserRoleMapping _service = new Service.UserRoleMapping();
#region Query
///
/// 获取所有
///
[Route("GetAll")]
[HttpGet]
public Result GetAll()
{
var list = _service.GetAll();
return new Result>(list);
}
///
/// 通过 ID 获取
///
[Route("GetByID")]
[HttpGet]
public Result GetByID(long ID)
{
if (ID < 1)
{
return new Result(Code.Error, "ID 参数错误");
}
var model = _service.GetByID(ID);
return new Result(model);
}
///
/// 通过 Ids 获取
///
[Route("GetByIds")]
[HttpGet]
public Result GetByIds(string Ids)
{
var ids = LongListHelper.ToList(Ids);
if (ids == null || ids.Count() < 1)
{
return new Result(Code.Error, "Ids 参数错误");
}
var list = _service.GetByIds(ids);
return new Result>(list);
}
///
/// 通过 RoleID 获取
///
[Route("GetByRoleID")]
[HttpGet]
public Result GetByRoleID(long RoleID)
{
if (RoleID < 1)
{
return new Result(Code.Error, "RoleID 参数错误");
}
var list = _service.GetByRoleID(RoleID);
return new Result>(list);
}
///
/// 通过 UserID 获取
///
[Route("GetByUserID")]
[HttpGet]
public Result GetByUserID(long UserID)
{
if (UserID < 1)
{
return new Result(Code.Error, "UserID 参数错误");
}
var list = _service.GetByUserID(UserID);
return new Result>(list);
}
#endregion
#region Insert
///
/// 插入一条数据
///
[Route("Insert")]
[HttpPost]
public Result Insert(Model.UserRoleMappingPure model)
{
if (model == null)
{
return new Result(Code.Error, "参数错误");
}
var id = _service.Insert(model);
return new Result(id);
}
///
/// 插入多条数据
///
[Route("Inserts")]
[HttpPost]
public Result Inserts(List list)
{
if (list == null || list.Count() < 1)
{
return new Result(Code.Error, "参数错误");
}
var bol = _service.Inserts(list);
return new Result(bol);
}
#endregion
#region Update
///
/// 更新一条
///
[Route("Update")]
[HttpPut]
public Result Update(Model.UserRoleMapping model)
{
if (model == null)
{
return new Result(Code.Error, "参数错误");
}
var bol = _service.Update(model);
return new Result(bol);
}
///
/// 更新多条
///
[Route("Updates")]
[HttpPut]
public Result Updates(List list)
{
if (list == null || list.Count() < 1)
{
return new Result(Code.Error, "参数错误");
}
var bol = _service.Updates(list);
return new Result(bol);
}
#endregion
#region Set
///
/// 设置
///
[Route("Set")]
[HttpPost]
public Result Set(List list)
{
if (list == null || list.Count() < 1)
{
return new Result(Code.Error, "参数错误");
}
var bol = _service.Set(list);
return new Result(bol);
}
#endregion
}
}