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

264 lines
7.4 KiB
C#

using Common.Tools;
using Common.Utilities;
using djy.IService.Afr;
using djy.Model.AmsDto;
using djy_AfrApi.Attributes;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace djy_AfrApi.Controllers.Common
{
[Route("api/[controller]")]
[ApiController]
[Authorize]
public class CommonController : ApiBase
{
private readonly IAfrService ser;
public CommonController(IAfrService service)
{
this.ser = service;
}
#region 下拉接口
/// <summary>
/// 下拉获取国家
/// </summary>
/// <returns></returns>
[HttpGet("GetCountry")]
[RedisCaching]
public Response<List<CommonCNEN>> GetCountry()
{
var result = new Response<List<CommonCNEN>>();
try
{
result.Result = ser.GetCountry("", 0, 0);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
/// <summary>
/// 下拉获取船公司
/// </summary>
/// <returns></returns>
[HttpGet("GetCARRIER")]
[RedisCaching]
public Response<List<CommonMappiCode>> GetCARRIER()
{
var result = new Response<List<CommonMappiCode>>();
try
{
result.Result = ser.GetCARRIER();
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
/// <summary>
/// 下拉获取箱型
/// </summary>
/// <returns></returns>
[HttpGet("GetCTNALL")]
[RedisCaching]
public Response<List<CommonMappiCode>> GetCTNALL()
{
var result = new Response<List<CommonMappiCode>>();
try
{
result.Result = ser.GetCTNALL();
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
/// <summary>
/// 下拉获取包装单位
/// </summary>
/// <returns></returns>
[HttpGet("GetPackage")]
[RedisCaching]
public Response<List<CommonMappiCode>> GetPackage()
{
var result = new Response<List<CommonMappiCode>>();
try
{
result.Result = ser.GetPackage();
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
/// <summary>
/// 下拉获取危品等级及 CODE
/// </summary>
/// <returns></returns>
[HttpGet("GetDangerousGoods")]
[RedisCaching]
public Response<List<CodeDangerGradeDto>> GetDangerousGoods()
{
var result = new Response<List<CodeDangerGradeDto>>();
try
{
result.Result = ser.GetDangerousGoods("");
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
///// <summary>
///// 下拉获取起运港口
///// </summary>
///// <returns></returns>
//[HttpGet("GetCodePortLoad")]
//public Response<List<CommonCodeValue>> GetCodePortLoad()
//{
// var result = new Response<List<CommonCodeValue>>();
// try
// {
// result.Result = ser.GetCodePortLoad();
// }
// catch (Exception ex)
// {
// result.Code = 500;
// result.Message = ex.InnerException?.Message ?? ex.Message;
// }
// return result;
//}
/// <summary>
/// 下拉获取港口
/// </summary>
/// <returns></returns>
[HttpGet("GetPort")]
[RedisCaching]
public Response<List<CommonMappiCode>> GetPort()
{
var result = new Response<List<CommonMappiCode>>();
try
{
result.Result = ser.GetPort("", 0, 0);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
/// <summary>
/// 下拉获取船名
/// </summary>
/// <returns></returns>
[HttpGet("GetVessel")]
[RedisCaching]
public Response<List<CommonCodeValue>> GetVessel()
{
var result = new Response<List<CommonCodeValue>>();
try
{
result.Result = ser.GetVessel("", 0, 0);
}
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.InnerException?.Message ?? ex.Message;
}
return result;
}
/// <summary>
/// 清除所有Redis缓存
/// </summary>
[AllowAnonymous]
[HttpGet("[action]")]
public Response ClearCache()
{
var type = typeof(CommonController);
MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public);
foreach (MethodInfo item in methods)
{
var attr = item.GetCustomAttributes(typeof(RedisCachingAttribute));
if (attr.Any())
{
YsRedisHelp.RedisClena(item.Name + "Cache");
}
}
return SuccessResp();
}
///// <summary>
///// 下拉获取省份
///// </summary>
///// <returns></returns>
//[HttpGet("GetCodeProvince")]
//public Response<List<CommonCodeValue>> GetCodeProvince(string code)
//{
// var result = new Response<List<CommonCodeValue>>();
// try
// {
// result.Result = ser.GetCodeProvince(code);
// }
// catch (Exception ex)
// {
// result.Code = 500;
// result.Message = ex.InnerException?.Message ?? ex.Message;
// }
// return result;
//}
///// <summary>
///// 下拉获取城市 邮编
///// </summary>
///// <returns></returns>
//[HttpGet("GetCodeCity")]
//public Response<List<CodeCityDto>> GetCodeCity(string provinceCode)
//{
// var result = new Response<List<CodeCityDto>>();
// try
// {
// result.Result = ser.GetCodeCity(provinceCode);
// }
// catch (Exception ex)
// {
// result.Code = 500;
// result.Message = ex.InnerException?.Message ?? ex.Message;
// }
// return result;
//}
#endregion
}
}