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>
|
/// UserAttention 标准Api
|
/// </summary>
|
[ApiController]
|
[Route("v1/Standard/UserAttention")]
|
[ApiExplorerSettings(GroupName = "v1")]
|
public class UserAttention_StandardController : ControllerBase
|
{
|
private readonly Service.UserAttention _service = new Service.UserAttention();
|
|
#region Query
|
|
/// <summary>
|
/// 获取所有
|
/// </summary>
|
[Route("GetAll")]
|
[HttpGet]
|
public Result GetAll()
|
{
|
var list = _service.GetAll();
|
return new Result<List<Model.UserAttention>>(list);
|
}
|
|
/// <summary>
|
/// 通过 ID 获取
|
/// </summary>
|
[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.UserAttention>(model);
|
}
|
|
/// <summary>
|
/// 通过 Ids 获取
|
/// </summary>
|
[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<Model.UserAttention>>(list);
|
}
|
|
/// <summary>
|
/// 通过 UserID 获取
|
/// </summary>
|
[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<Model.UserAttention>>(list);
|
}
|
|
/// <summary>
|
/// 通过 UserID 和 ObjectType 获取
|
/// </summary>
|
[Route("GetByUserIDAndObjectType")]
|
[HttpGet]
|
public Result GetByUserIDAndObjectType(long UserID, string ObjectType)
|
{
|
if (UserID < 1)
|
{
|
return new Result(Code.Error, "UserID 参数错误");
|
}
|
var list = _service.GetByUserIDAndObjectType(UserID,ObjectType);
|
return new Result<List<Model.UserAttention>>(list);
|
}
|
|
/// <summary>
|
/// 通过 UserID 和 ObjectType 获取
|
/// </summary>
|
[Route("GetByUserIDAndObjectTypeUnderCorpID")]
|
[HttpGet]
|
public Result GetByUserIDAndObjectTypeUnderCorpID(long UserID, long CorpID, string ObjectType)
|
{
|
if (UserID < 1)
|
{
|
return new Result(Code.Error, "UserID 参数错误");
|
}
|
var list = _service.GetByUserIDAndObjectTypeUnderCorpID(UserID,CorpID, ObjectType);
|
return new Result<List<Model.UserAttention>>(list);
|
}
|
|
/// <summary>
|
/// 通过 UserID 和 Object 获取
|
/// </summary>
|
[Route("GetByUserIDAndObject")]
|
[HttpGet]
|
public Result GetByUserIDAndObject(long UserID, long CorpID, string ObjectType,long ObjectID)
|
{
|
if (UserID < 1)
|
{
|
return new Result(Code.Error, "UserID 参数错误");
|
}
|
var model = _service.GetByUserIDAndObject(UserID, CorpID, ObjectType,ObjectID);
|
return new Result<Model.UserAttention>(model);
|
}
|
|
#endregion
|
|
#region Insert
|
|
/// <summary>
|
/// 插入一条
|
/// </summary>
|
[Route("Insert")]
|
[HttpPost]
|
public Result Insert(Model.UserAttentionPure 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.UserAttentionPure> 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.UserAttention 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.UserAttention> list)
|
{
|
if (list == null || list.Count() < 1)
|
{
|
return new Result(Code.Error, "参数错误");
|
}
|
var bol = _service.Updates(list);
|
return new Result<bool>(bol);
|
}
|
|
#endregion
|
|
#region
|
|
/// <summary>
|
/// 更新多条
|
/// </summary>
|
[Route("Set")]
|
[HttpPost]
|
public Result Set(Model.UserAttentionSet model)
|
{
|
if (model == null)
|
{
|
return new Result(Code.Alert, "参数错误");
|
}
|
if (model.UserID < 1)
|
{
|
return new Result(Code.Alert, "UserID 参数错误");
|
}
|
if (model.Attentions == null || model.Attentions.Count < 1)
|
{
|
return new Result(Code.Alert, "Attentions 参数错误");
|
}
|
var bol = _service.Set(model.UserID,model.Attentions);
|
return new Result<bool>(bol);
|
}
|
|
#endregion
|
|
#region Delete
|
|
/// <summary>
|
/// 通过 ID 删除
|
/// </summary>
|
[Route("DeleteByID")]
|
[HttpDelete]
|
public Result DeleteByID(long ID)
|
{
|
if (ID < 1)
|
{
|
return new Result(Code.Error, "ID 参数错误");
|
}
|
var bol = _service.DeleteByID(ID, out string msg);
|
return new ResultReason<bool>(bol, msg);
|
}
|
|
/// <summary>
|
/// 通过 UserID 和 Object 删除
|
/// </summary>
|
[Route("DeleteByUserIDAndObject")]
|
[HttpDelete]
|
public Result DeleteByUserIDAndObject(long UserID, long CorpID, string ObjectType, long ObjectID)
|
{
|
if (UserID < 1)
|
{
|
return new Result(Code.Error, "UserID 参数错误");
|
}
|
if (CorpID < 1)
|
{
|
return new Result(Code.Error, "CorpID 参数错误");
|
}
|
if (ObjectID < 1)
|
{
|
return new Result(Code.Error, "ObjectID 参数错误");
|
}
|
|
var bol = _service.DeleteByUserIDAndObject(UserID,CorpID,ObjectType,ObjectID,out string msg);
|
return new ResultReason<bool>(bol, msg);
|
}
|
|
#endregion
|
}
|
}
|