You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.3 KiB

using System.ComponentModel.DataAnnotations;
using Entity.DbModel.System.App;
using Entity.Dto.Req;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Service.Station;
namespace WebStarter.Controllers;
/// <summary>
/// 车队
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class CarTeamController
{
private readonly CarTeamService _carTeamService;
/// <summary>
///
/// </summary>
/// <param name="carTeamService"></param>
public CarTeamController(CarTeamService carTeamService)
{
_carTeamService = carTeamService;
}
/// <summary>
/// 查询车队分页
/// </summary>
/// <param name="req"> 查询参数</param>
/// <returns></returns>
[HttpPost]
[Route("GetTeamPage")]
public async Task<PageResult<CarTeam>> GetTeamPage(
[FromBody] PageCarTeamReq req)
{
return await _carTeamService.Page(req);
}
/// <summary>
/// 获取所有车队
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("GetTeamList")]
public async Task<Result<List<CarTeam>>> GetTeamList()
{
return Result<List<CarTeam>>.Success(await _carTeamService.GetTeamList());
}
/// <summary>
/// 新增车队
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("add")]
public async Task<Result<string>> AddTeam([FromBody] [Required] AddCarTeamReq input)
{
var data = await _carTeamService.AddCarTeamReq(input);
return Result<string>.Success(data);
}
/// <summary>
/// 修改车队
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
[HttpPost]
[Route("UpdateTeam")]
public async Task<Result<string>> UpdateTeam([FromBody] UpdateCarTeamReq user)
{
return await _carTeamService.UpdateTeam(user);
}
/// <summary>
/// 删除车队
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("delete")]
public async Task<Result<bool>> DeleteTeam([FromBody] [Required] DeleteCarTeamReq input)
{
var data = await _carTeamService.DeleteTeam(input);
if (data)
return Result<bool>.Success(data);
else
return Result<bool>.Fail(data);
}
}