135 lines
3.2 KiB
C#
135 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Infrastructure;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using OpenAuth.App;
|
|
using OpenAuth.App.Request;
|
|
using OpenAuth.App.Response;
|
|
using OpenAuth.Repository.Domain;
|
|
|
|
namespace OpenAuth.WebApi.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 车辆信息
|
|
/// </summary>
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
public class MiVehicleController : ControllerBase
|
|
{
|
|
private readonly MiVehicleApp _app;
|
|
public MiVehicleController(MiVehicleApp app)
|
|
{
|
|
_app = app;
|
|
}
|
|
|
|
#region 查询
|
|
|
|
#region 分页
|
|
/// <summary>
|
|
/// 分页
|
|
/// </summary>
|
|
[HttpGet]
|
|
public async Task<Response<PageInfo<List<MiVehicle>>>> LoadAllPage([FromQuery] PageReq request)
|
|
{
|
|
return await _app.LoadAllPage(request);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 实体
|
|
/// <summary>
|
|
/// 实体
|
|
/// </summary>
|
|
[HttpGet]
|
|
public async Task<Response<MiVehicle>> Get(object id)
|
|
{
|
|
var result = new Response<MiVehicle>();
|
|
try
|
|
{
|
|
result.Result =await _app.Get(id);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Code = 500;
|
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 增删改
|
|
|
|
#region 添加
|
|
/// <summary>
|
|
/// 添加
|
|
/// </summary>
|
|
[HttpPost]
|
|
public async Task<Response<bool>> Add(MiVehicle model)
|
|
{
|
|
var result = new Response<bool>();
|
|
try
|
|
{
|
|
result = await _app.Add(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Code = 500;
|
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 修改
|
|
/// <summary>
|
|
/// 修改
|
|
/// </summary>
|
|
[HttpPost]
|
|
public async Task<Response<bool>> Update(MiVehicle model)
|
|
{
|
|
var result = new Response<bool>();
|
|
try
|
|
{
|
|
result = await _app.Update(model);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Code = 500;
|
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
[HttpPost]
|
|
public async Task<Response<bool>> Delete([FromBody] List<MiVehicle> models)
|
|
{
|
|
var result = new Response<bool>();
|
|
try
|
|
{
|
|
result = await _app.Delete(models);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.Code = 500;
|
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
}
|
|
} |