123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- 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
- {
- /// <summary>
- /// 会议
- /// </summary>
- [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;
- }
- /// <summary>
- /// 新增车辆类型
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("type")]
- public async Task<CarType> TypeAdd([FromBody] CarType request)
- {
- request.Id = await _carTypeRepository.InsertAsync(request);
- return request;
- }
- /// <summary>
- /// 修改车辆类型
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPut("type")]
- public async Task TypeEdit([FromBody] CarType request)
- {
- await _carTypeRepository.UpdateAsync(request);
- }
- /// <summary>
- /// 获取车辆类型列表
- /// </summary>
- /// <returns></returns>
- [HttpGet("type")]
- public async Task<IEnumerable<CarType>> TypeList()
- {
- return await _carTypeRepository.GetListAsync();
- }
- /// <summary>
- /// 删除车辆类型
- /// </summary>
- /// <returns></returns>
- [HttpDelete("type/{id}")]
- public async Task<bool> TypeRemove([FromRoute]int id)
- {
- return await _carTypeRepository.DeleteAsync(id);
- }
- /// <summary>
- /// 新增车辆
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("")]
- public async Task<Car> CarAdd([FromBody] Car request)
- {
- request.Id = await _carRepository.InsertAsync(request);
- return request;
- }
- /// <summary>
- /// 修改车辆
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPut("")]
- public async Task CarEdit([FromBody] Car request)
- {
- await _carRepository.UpdateAsync(request);
- }
- /// <summary>
- /// 获取车辆列表
- /// </summary>
- /// <returns></returns>
- [HttpGet("")]
- public async Task<IEnumerable<Car>> CarList([FromQuery] CarRequest request)
- {
- return await _carRepository.GetListAsync(request.TypeId);
- }
- /// <summary>
- /// 删除车辆
- /// </summary>
- /// <returns></returns>
- [HttpDelete("{id}")]
- public async Task<bool> CarRemove([FromRoute]int id)
- {
- return await _carRepository.DeleteAsync(id);
- }
- }
- }
|