using Common.DJYModel; using Common.Utilities; using djy.IService.Isf; using djy.Model.Isf; using djy.Model.IsfDto; using djy.Service.DjyService; using djy.Service.Isf; using djy_IsfApi; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Threading.Tasks; namespace djy_Isfpi.Controllers.ISF { public class IsfController : ApiBase { IIsfService ser = IOC.AddServer(); #region 查询接口 [HttpGet("Load")] public object Load([FromQuery] ISFQuery request) { UserAuthorityDto aut = GetUserAuthorityToFormDto("modIsfList"); if (!aut.IsPower) { var result = new Response(); result.Code = 201; result.Message = "没有权限!"; return result; } var user = GetUserInfo(); if (user == null) { var result = new Response(); result.Code = 401; result.Message = "登录过期,请重新登录!"; return result; } return ser.Load(request, user, aut); } #endregion #region 新增/编辑 [HttpPost("AddOrUpdate")] public Response AddOrUpdate(ISFDto Dto) { var result = new Response(); var user = GetUserInfo(); if (user == null) { result.Code = 401; result.Message = "登录过期,请重新登录!"; } if (Dto == null) { result.Code = 500; result.Message = "无效数据!"; } result.data = ser.SaveInfo(Dto, user); if (result.data == "-1") { result.Code = 201; result.Message = "提单号已存在!"; } return result; } #endregion #region 删除 /// /// 删除接口 /// /// /// [HttpGet("Del")] public Response Delete(string ids) { var result = new Response(); try { var user = GetUserInfo(); if (user == null) { result.Code = 401; result.Message = "登录过期,请重新登录!"; return result; } ser.Delete(ids, user); } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return result; } #endregion #region 获取模板 [HttpGet("GetTemplate")] public Response> GetTemplate(string InFoType, string CompanyType, string TemPlateName = null) { var result = new Response>(); try { var user = GetUserInfo(); if (user == null) { result.Code = 401; result.Message = "登录过期,请重新登录!"; return result; } result.Result = ser.GetTemplate(user, CompanyType, InFoType, TemPlateName); } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return result; } #endregion #region 保存模板 [HttpPost("SaveTemplate")] public Response SaveTemplate(ISF_CompanyTemplate Dto) { var result = new Response(); var user = GetUserInfo(); if (user == null) { result.Code = 401; result.Message = "登录过期,请重新登录!"; } if (Dto == null) { result.Code = 500; result.Message = "无效数据!"; } result.data = ser.SaveTemplate(Dto, user); if (result.data == "-1") { result.Code = 201; result.Message = "模板名称重复!"; } return result; } #endregion #region 删除模板 /// /// 删除接口 /// /// /// [HttpGet("DeleteTemplate")] public Response DeleteTemplate(string ids) { var result = new Response(); try { var user = GetUserInfo(); if (user == null) { result.Code = 401; result.Message = "登录过期,请重新登录!"; return result; } ser.DeleteTemplate(ids); } catch (Exception ex) { result.Code = 500; result.Message = ex.InnerException?.Message ?? ex.Message; } return result; } #endregion #region 第三方接口 [HttpGet("Send")] public async Task Send(string ids, string msgType) { Response req = new Response(); var user = GetUserInfo(); if (user == null) { req.Code = 401; req.Message = "登录过期,请重新登录!"; } var result = ser.SendDE(ids, user, msgType); req.Code = result.Result.Code; req.Message = result.Result.Message; return req; } [AllowAnonymous] [HttpPost("Receipt")] public Response SaveReceipt([FromForm] string msg) { return ser.SaveReceipt(msg); } #endregion } }