using System.Collections.Generic; using System.Threading.Tasks; using GxPress.Entity.WorkCar; using GxPress.Repository.Interface.WorkCar; using GxPress.Request.App.WorkCar; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace GxPress.Api.AdminControllers { /// /// 会议 /// [Route("api/admin/car")] [ApiController] [Authorize] public class AdminCarController : ControllerBase { private readonly ICarTypeRepository _carTypeRepository; private readonly ICarOrderRepository _carOrderRepository; private readonly ICarRepository _carRepository; public AdminCarController(ICarTypeRepository carTypeRepository, ICarOrderRepository carOrderRepository, ICarRepository carRepository) { _carTypeRepository = carTypeRepository; _carOrderRepository = carOrderRepository; _carRepository = carRepository; } /// /// 新增车辆类型 /// /// /// [HttpPost("type")] public async Task TypeAdd([FromBody] CarType request) { request.Id = await _carTypeRepository.InsertAsync(request); return request; } /// /// 修改车辆类型 /// /// /// [HttpPut("type")] public async Task TypeEdit([FromBody] CarType request) { await _carTypeRepository.UpdateAsync(request); } /// /// 获取车辆类型列表 /// /// [HttpGet("type")] public async Task> TypeList() { return await _carTypeRepository.GetListAsync(); } /// /// 删除车辆类型 /// /// [HttpDelete("type/{id}")] public async Task TypeRemove([FromRoute]int id) { return await _carTypeRepository.DeleteAsync(id); } /// /// 新增车辆 /// /// /// [HttpPost("")] public async Task CarAdd([FromBody] Car request) { request.Id = await _carRepository.InsertAsync(request); return request; } /// /// 修改车辆 /// /// /// [HttpPut("")] public async Task CarEdit([FromBody] Car request) { await _carRepository.UpdateAsync(request); } /// /// 获取车辆列表 /// /// [HttpGet("")] public async Task> CarList([FromQuery] CarRequest request) { return await _carRepository.GetListAsync(request.TypeId); } /// /// 删除车辆 /// /// [HttpDelete("{id}")] public async Task CarRemove([FromRoute]int id) { return await _carRepository.DeleteAsync(id); } } }