|
@@ -0,0 +1,192 @@
|
|
|
+
|
|
|
+
|
|
|
+namespace OASystem.API.Controllers
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 资料相关
|
|
|
+ /// </summary>
|
|
|
+ //[Authorize]
|
|
|
+ [Route("api/[controller]/[action]")]
|
|
|
+ public class ResourceController : ControllerBase
|
|
|
+ {
|
|
|
+ private readonly IMapper _mapper;
|
|
|
+ private readonly IConfiguration _config;
|
|
|
+ private readonly CarDataRepository _carDataRep;
|
|
|
+
|
|
|
+ public ResourceController(IMapper mapper, IConfiguration config,CarDataRepository carDataRep)
|
|
|
+ {
|
|
|
+ _mapper = mapper;
|
|
|
+ _config = config;
|
|
|
+ _carDataRep = carDataRep;
|
|
|
+ }
|
|
|
+ #region 车公司资料板块
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 车公司信息查询
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> QuerCarData(DtoBase dto)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (dto.PortType==1)
|
|
|
+ {
|
|
|
+ var carDada = _carDataRep.QueryDto<Res_CarData, CarDataView>().ToList();
|
|
|
+ if (carDada.Count == 0)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "暂无数据!"));
|
|
|
+ }
|
|
|
+ carDada = carDada.OrderByDescending(s => s.CreateTime).ToList();
|
|
|
+ return Ok(JsonView(true, "查询成功", carDada));
|
|
|
+ }
|
|
|
+ else if(dto.PortType==2)
|
|
|
+ {
|
|
|
+ var carDada = _carDataRep.QueryDto<Res_CarData, CarDataView>().ToList();
|
|
|
+ if (carDada.Count == 0)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "暂无数据!"));
|
|
|
+ }
|
|
|
+ carDada=carDada.OrderByDescending(s=>s.CreateTime).ToList();
|
|
|
+ return Ok(JsonView(true, "查询成功", carDada));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "程序错误!"));
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 车公司信息添加
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> AddCarData(AddCarDataDto dto)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (dto.UnitArea == "")
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "请检查单位区域是否填写!"));
|
|
|
+ }
|
|
|
+ if (dto.UnitName == "")
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "请检查单位名称是否填写!"));
|
|
|
+ }
|
|
|
+ if (dto.Contact == "")
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "请检查单位联系人是否填写!"));
|
|
|
+ }
|
|
|
+ if (dto.ContactTel == "")
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
|
|
|
+ }
|
|
|
+ Res_CarData _CarData = _mapper.Map<Res_CarData>(dto);
|
|
|
+ int id = await _carDataRep.AddAsyncReturnId(_CarData);
|
|
|
+ if (id == 0)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "添加失败!"));
|
|
|
+ }
|
|
|
+ return Ok(JsonView(true, "添加成功", new { Id = id }));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "程序错误!"));
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 车公司信息修改
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> UpCarData(UpCarDataDto dto)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (dto.UnitArea == "")
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "请检查单位区域是否填写!"));
|
|
|
+ }
|
|
|
+ if (dto.UnitName == "")
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "请检查单位名称是否填写!"));
|
|
|
+ }
|
|
|
+ if (dto.Contact == "")
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "请检查单位联系人是否填写!"));
|
|
|
+ }
|
|
|
+ if (dto.ContactTel == "")
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
|
|
|
+ }
|
|
|
+ bool res = await _carDataRep.UpdateAsync(a => a.Id == dto.Id, a => new Res_CarData
|
|
|
+ {
|
|
|
+ UnitArea = dto.UnitArea,
|
|
|
+ UnitName = dto.UnitName,
|
|
|
+ Address = dto.Address,
|
|
|
+ Contact = dto.Contact,
|
|
|
+ ContactTel = dto.ContactTel,
|
|
|
+ ContactEmail = dto.ContactEmail,
|
|
|
+ ContactFax = dto.ContactFax,
|
|
|
+ CarDes = dto.CarDes,
|
|
|
+ CarPicPaths = dto.CarPicPaths,
|
|
|
+ OtherInfo = dto.OtherInfo,
|
|
|
+ Score = dto.Score,
|
|
|
+ QualificationScore = dto.QualificationScore,
|
|
|
+ CarAgeScore = dto.CarAgeScore,
|
|
|
+ CleanImgScore = dto.CleanImgScore,
|
|
|
+ SmellScore = dto.SmellScore,
|
|
|
+ WaterPaperScore = dto.WaterPaperScore,
|
|
|
+ HardwareScore = dto.HardwareScore,
|
|
|
+ TimeScore = dto.TimeScore,
|
|
|
+ SafetyScore = dto.SafetyScore,
|
|
|
+ DrivingAgeScore = dto.DrivingAgeScore,
|
|
|
+ Remark = dto.Remark,
|
|
|
+ });
|
|
|
+ if (!res) { return Ok(JsonView(false, "修改失败!")); }
|
|
|
+ return Ok(JsonView(true, "修改成功"));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "程序错误!"));
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 车公司信息修改
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> DelCarData(DelCarDataDto dto)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ bool res = await _carDataRep.SoftDeleteByIdAsync<Res_CarData>(dto.Id.ToString(), dto.DeleteUserId);
|
|
|
+ if (!res) { return Ok(JsonView(false, "删除失败!")); }
|
|
|
+ return Ok(JsonView(true, "删除成功"));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "程序错误!"));
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ }
|
|
|
+}
|