|
@@ -1,10 +1,13 @@
|
|
|
using Aspose.Words;
|
|
|
+using EyeSoft.Extensions;
|
|
|
using OASystem.API.OAMethodLib;
|
|
|
using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
|
|
|
using OASystem.Domain.Dtos.Groups;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.ViewModels.Groups;
|
|
|
using OASystem.Infrastructure.Repositories.Groups;
|
|
|
+using Org.BouncyCastle.Utilities.Encoders;
|
|
|
+using static OASystem.API.OAMethodLib.JWTHelper;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
|
{
|
|
@@ -33,6 +36,7 @@ namespace OASystem.API.Controllers
|
|
|
private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
|
|
|
private readonly TourClientListRepository _tourClientListRep;
|
|
|
private readonly DelegationInfoRepository _delegationInfoRep;
|
|
|
+ private readonly TranslatorLibraryRepoository _translatorRep;
|
|
|
|
|
|
public ResourceController(IMapper mapper,
|
|
|
IConfiguration config,
|
|
@@ -51,7 +55,8 @@ namespace OASystem.API.Controllers
|
|
|
AskDataRepository askDataRep,
|
|
|
TicketBlackCodeRepository ticketBlackCodeRep,
|
|
|
TourClientListRepository tourClientListRep,
|
|
|
- DelegationInfoRepository delegationInfoRep)
|
|
|
+ DelegationInfoRepository delegationInfoRep,
|
|
|
+ TranslatorLibraryRepoository translatorRep)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_config = config;
|
|
@@ -71,6 +76,7 @@ namespace OASystem.API.Controllers
|
|
|
_ticketBlackCodeRep = ticketBlackCodeRep;
|
|
|
_tourClientListRep = tourClientListRep;
|
|
|
_delegationInfoRep = delegationInfoRep;
|
|
|
+ _translatorRep = translatorRep;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2788,6 +2794,241 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
+ #region 翻译人员
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 翻译人员库
|
|
|
+ /// Init
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet()]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> TranslatorLibraryInit()
|
|
|
+ {
|
|
|
+ var view = await _sqlSugar.Queryable<Sys_SetData>()
|
|
|
+ .Where(x => x.IsDel == 0 && x.STid == 66)
|
|
|
+ .Select(x => new {
|
|
|
+ x.Id,
|
|
|
+ x.Name,
|
|
|
+ })
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ return Ok(JsonView(view));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 翻译人员库
|
|
|
+ /// 详情
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("id")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> TranslatorLibraryInfo(int id)
|
|
|
+ {
|
|
|
+ if (id <1 ) return Ok(JsonView(false,"请传入有效的Id!"));
|
|
|
+
|
|
|
+ var view = await _translatorRep.Query(x => x.Id == id)
|
|
|
+ .Select(x => new {
|
|
|
+ x.Id,
|
|
|
+ x.Name,
|
|
|
+ x.Sex,
|
|
|
+ x.Photo,
|
|
|
+ x.Tel,
|
|
|
+ x.Email,
|
|
|
+ x.WechatNo,
|
|
|
+ x.OtherSocialAccounts,
|
|
|
+ x.Language,
|
|
|
+ x.Price,
|
|
|
+ x.Currency,
|
|
|
+ x.Files
|
|
|
+ })
|
|
|
+ .FirstAsync();
|
|
|
+
|
|
|
+ return Ok(JsonView(view));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 翻译人员库
|
|
|
+ /// Item
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> TranslatorLibraryItem(TranslatorLibraryItemDto dto)
|
|
|
+ {
|
|
|
+ if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
|
|
|
+
|
|
|
+ RefAsync<int> total = 0;
|
|
|
+ var view = await _sqlSugar.Queryable<Res_TranslatorLibrary>()
|
|
|
+ .Where(x => x.IsDel == 0)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Name), x => x.Name.Contains(dto.Name))
|
|
|
+ .Select(x => new
|
|
|
+ {
|
|
|
+ x.Id,
|
|
|
+ x.Area,
|
|
|
+ x.Name,
|
|
|
+ Sex = x.Sex == 0 ? "未设置" : x.Sex == 1 ? "男" : "女",
|
|
|
+ x.Tel,
|
|
|
+ x.Email,
|
|
|
+ x.WechatNo,
|
|
|
+ x.Language,
|
|
|
+ x.Price,
|
|
|
+ x.Currency,
|
|
|
+ //Currency = SqlFunc.Subqueryable<Sys_SetData>().Where(x1 => x1.Id == x.Currency).Select(x1 => x1.Name) ?? "-",
|
|
|
+ CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x1.Id == x.CreateUserId).Select(x1 => x1.CnName) ?? "-",
|
|
|
+ x.CreateTime
|
|
|
+ })
|
|
|
+ .OrderByDescending(x => x.CreateTime)
|
|
|
+ .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
|
+
|
|
|
+ return Ok(JsonView(view, total));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 翻译人员库
|
|
|
+ /// OP
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> TranslatorLibraryOp(TranslatorLibraryOpDto dto)
|
|
|
+ {
|
|
|
+ if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
|
|
|
+ if (dto.OpStatus < 1 || dto.OpStatus > 2) return Ok(JsonView(false, MsgTips.Status));
|
|
|
+
|
|
|
+ var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
|
|
|
+ if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
|
|
|
+
|
|
|
+ var fileNames = new List<string>();
|
|
|
+ //D:\FTP\File\OA2023\Office\GrpFile\TranslatorLibrary
|
|
|
+ var fileBasePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}TranslatorLibrary";
|
|
|
+ #region 保存文件
|
|
|
+ foreach (var item in dto.Files)
|
|
|
+ {
|
|
|
+ if (item.Length < 1) continue;
|
|
|
+
|
|
|
+ if (!System.IO.Directory.Exists(fileBasePath))
|
|
|
+ {
|
|
|
+ System.IO.Directory.CreateDirectory(fileBasePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ var file = item;
|
|
|
+
|
|
|
+ // 将文件保存到指定位置
|
|
|
+ var filePath = Path.Combine(fileBasePath, file.FileName);
|
|
|
+ using (var stream = new FileStream(filePath, FileMode.Create))
|
|
|
+ {
|
|
|
+ await file.CopyToAsync(stream);
|
|
|
+ }
|
|
|
+
|
|
|
+ //验证文件是否上传成功
|
|
|
+ if (!System.IO.File.Exists(filePath))
|
|
|
+ {
|
|
|
+ foreach (var filePathStr in fileNames)
|
|
|
+ {
|
|
|
+ System.IO.File.Delete(Path.Combine(fileBasePath, filePathStr));
|
|
|
+ }
|
|
|
+ return Ok(JsonView(false, "文件上传失败!"));
|
|
|
+ }
|
|
|
+ fileNames.Add(file.Name);
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 参数处理
|
|
|
+
|
|
|
+ var translatorInfo = _mapper.Map<Res_TranslatorLibrary>(dto);
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+ if (dto.OpStatus == 1)
|
|
|
+ {
|
|
|
+ translatorInfo.CreateUserId = currUserInfo.UserId;
|
|
|
+ if (fileNames.Count > 0)
|
|
|
+ {
|
|
|
+ translatorInfo.Files = JsonConvert.SerializeObject(fileNames);
|
|
|
+ }
|
|
|
+
|
|
|
+ var add = await _translatorRep.AddAsync(translatorInfo);
|
|
|
+ if (add > 0) return Ok(JsonView(true));
|
|
|
+ }
|
|
|
+ else if (dto.OpStatus == 2)
|
|
|
+ {
|
|
|
+ var info = await _translatorRep.Query(x => x.Id == dto.Id).FirstAsync();
|
|
|
+ if (info != null)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(info.Files))
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var selectFiles = JsonConvert.DeserializeObject<List<string>>(info.Files);
|
|
|
+ fileNames.AddRange(selectFiles);
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (fileNames.Count > 0)
|
|
|
+ {
|
|
|
+ translatorInfo.Files = JsonConvert.SerializeObject(fileNames);
|
|
|
+ }
|
|
|
+
|
|
|
+ var upd = await _translatorRep
|
|
|
+ .UpdateAsync(x => x.Id == dto.Id, x => new Res_TranslatorLibrary()
|
|
|
+ {
|
|
|
+ Area = translatorInfo.Area,
|
|
|
+ Name = translatorInfo.Name,
|
|
|
+ Sex = translatorInfo.Sex,
|
|
|
+ Photo = translatorInfo.Photo,
|
|
|
+ Tel = translatorInfo.Tel,
|
|
|
+ Email = translatorInfo.Email,
|
|
|
+ WechatNo = translatorInfo.WechatNo,
|
|
|
+ OtherSocialAccounts = translatorInfo.OtherSocialAccounts,
|
|
|
+ Language = translatorInfo.Language,
|
|
|
+ Price = translatorInfo.Price,
|
|
|
+ Currency = translatorInfo.Currency,
|
|
|
+ Remark = translatorInfo.Remark,
|
|
|
+ Files = translatorInfo.Files,
|
|
|
+ });
|
|
|
+
|
|
|
+ if (upd) Ok(JsonView(true));
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(JsonView(false));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 翻译人员库
|
|
|
+ /// Del
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpDelete("id")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> TranslatorLibraryDel(int id)
|
|
|
+ {
|
|
|
+ if (id < 1) return Ok(JsonView(false, MsgTips.Id));
|
|
|
+
|
|
|
+ var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
|
|
|
+ if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
|
|
|
+
|
|
|
+ var upd = await _translatorRep.SoftDeleteByIdAsync<Res_TranslatorLibrary>(id.ToString(), currUserInfo.UserId);
|
|
|
+ if (!upd) return Ok(JsonView(false));
|
|
|
+
|
|
|
+ return Ok(JsonView(true));
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|
|
|
|