From 836da9ffd7159fcf46442ec50af73f39def01706 Mon Sep 17 00:00:00 2001
From: qwj <qwjzorro@163.com>
Date: 星期三, 16 八月 2023 09:47:14 +0800
Subject: [PATCH] Merge branch 'master' of http://47.108.235.38:8080/r/DocumentService
---
DocumentServiceAPI.Application/DocManage/DocumentManageAppService.cs | 282 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 282 insertions(+), 0 deletions(-)
diff --git a/DocumentServiceAPI.Application/DocManage/DocumentManageAppService.cs b/DocumentServiceAPI.Application/DocManage/DocumentManageAppService.cs
new file mode 100644
index 0000000..fd87b88
--- /dev/null
+++ b/DocumentServiceAPI.Application/DocManage/DocumentManageAppService.cs
@@ -0,0 +1,282 @@
+锘縰sing DocumentServiceAPI.Application.DocManage.Dtos;
+using DocumentServiceAPI.Application.DocManage.Services;
+using DocumentServiceAPI.Application.System.Services;
+using DocumentServiceAPI.Model.cyDocumentModel;
+using DocumentServiceAPI.Utility;
+using System.Linq.Expressions;
+
+namespace DocumentServiceAPI.Application.DocManage
+{
+ /// <summary>
+ /// 璧勬枡绠$悊
+ /// </summary>
+ public class DocumentManageAppService : IDynamicApiController
+ {
+ private readonly DocClassificationService _classificationService;
+ private readonly DocumentManageService _docManageService;
+ private readonly OrganizationService _organizationService;
+ private readonly FileManageService _fileManageService;
+
+
+
+ public DocumentManageAppService(DocClassificationService classService, DocumentManageService docService, OrganizationService orgService,FileManageService fileManageService)
+ {
+ _classificationService = classService;
+ _docManageService = docService;
+ _organizationService = orgService;
+ _fileManageService = fileManageService;
+ }
+
+ /// <summary>
+ /// 妫�鏌ュ悕绉伴噸澶�
+ /// </summary>
+ /// <param name="model"></param>
+ /// <returns></returns>
+ public async Task<bool> CheckNameDuplicate(Document_Submit_Dto model)
+ {
+ var msg = false;
+ var ck =await _docManageService.GetFirstAsync(c=>c.doc_name==model.name && c.doc_code==model.code && c.classification_id==model.class_id && c.id!=model.id);
+ if (ck != null)
+ {
+ msg = true;
+ }
+ return msg;
+ }
+
+ /// <summary>
+ /// 鏍规嵁鍒嗛〉鏉′欢鏌ヨ鍒嗛〉鏁版嵁
+ /// </summary>
+ /// <param name="page"></param>
+ /// <returns></returns>
+ public async Task<IActionResult> PostListPage(DocumentPageSearch page)
+ {
+ PageResult<Document_List_Dto> result = new PageResult<Document_List_Dto>();
+
+ try
+ {
+ Expression<Func<Doc_Info, bool>> expression = t => true;
+
+ expression = expression.And(t => t.doc_code == page.Code && t.is_del==false);
+ if (page.ClassCode.HasValue)
+ {
+ expression = expression.And(t => t.classification_id == page.ClassCode);
+ }
+ if (!string.IsNullOrEmpty(page.Name))
+ {
+ expression = expression.And(t => t.doc_name.Contains(page.Name));
+ }
+ if (page.Status.HasValue)
+ {
+ expression = expression.And(t => t.status == page.Status);
+ }
+ if (page.OrganizationCode.HasValue)
+ {
+ expression = expression.And(t => t.org_id == page.OrganizationCode);
+ }
+ RefAsync<int> total = 0;
+ var data = await _docManageService.Context.Queryable<Doc_Info>()
+ .Includes(c => c.DocClassification)
+ .Includes(c=>c.DocOrganization)
+ .Where(expression)
+ .ToPageListAsync(page.PageIndex, page.PageSize, total);
+
+ if (data != null && total > 0)
+ {
+ result.Items = data.Select(c => new Document_List_Dto()
+ {
+ add_time = c.add_time,
+ class_id = c.classification_id,
+ class_name = c.DocClassification?.doc_classification,
+ doc_name = c.doc_name,
+ id = c.id,
+ org_id = c.org_id,
+ org_name = c.DocOrganization.UnitName,
+ project_id = c.project_id,
+ project_name = "",
+ status = c.status
+ }).ToList();
+
+ }
+ result.PageIndex = page.PageIndex;
+ result.PageSize = page.PageSize;
+ result.TotalCount = total;
+ }
+ catch (Exception er)
+ {
+ Log.Error(er.Message, er);
+ }
+
+ return new JsonResult(result);
+ }
+
+ /// <summary>
+ /// 娣诲姞鏁版嵁
+ /// </summary>
+ /// <param name="info"></param>
+ /// <returns></returns>
+ public async Task<bool> PostAddDocumentInfo(Document_Submit_Dto info)
+ {
+ bool msg = false;
+
+ Doc_Info doc = new Doc_Info();
+ doc.add_time = DateTime.Now;
+ doc.classification_id = info.class_id;
+ doc.doc_code = info.code;
+ doc.doc_name = info.name;
+ doc.is_del = false;
+ doc.org_id = info.org_id;
+ doc.status = info.status;
+ doc.tenant_code = info.tenant_id;
+
+ var id =await _docManageService.InsertReturnIdentityAsync(doc);
+ if (id > 0)
+ {
+ if(info.files!=null&& info.files.Count > 0)
+ {
+ foreach (var item in info.files)
+ {
+ File_Info file = new File_Info();
+ file.doc_id = id;
+ file.filenewname = item.filenewname.Length > 40 ? item.filenewname.Substring(item.filenewname.Length - 40) : item.filenewname;
+ file.fileoldname = item.fileoldname.Length > 40 ? item.fileoldname.Substring(item.fileoldname.Length - 40) : item.fileoldname;
+ file.filepath = item.filepath;
+ file.fileservername = item.fileservername;
+ file.filesize = item.filesize;
+ file.filetype = item.filetype;
+ file.status = 1;
+ file.suffix = item.suffix;
+ file.uptime = DateTime.Now;
+ file.up_userid = item.up_userid;
+ file.up_username = item.up_username;
+ await _fileManageService.InsertAsync(file);
+ }
+ }
+ msg = true;
+ }
+ return msg;
+ }
+
+
+
+
+
+ /// <summary>
+ /// 鏍规嵁绫诲瀷鏌ヨ鏁版嵁
+ /// </summary>
+ /// <param name="page"></param>
+ /// <returns></returns>
+ public async Task<IActionResult> PostItemList(DocClassificationSearch page)
+ {
+ var data = await _classificationService.GetListAsync(c => c.status == 1 && c.parent_code == page.Code);
+ return new JsonResult(data);
+ }
+
+
+ /// <summary>
+ /// 淇敼鏁版嵁
+ /// </summary>
+ /// <param name="info"></param>
+ /// <returns></returns>
+ public async Task<IActionResult> PostEdtInfo(Classification_Submit_Dto info)
+ {
+ var msg = false;
+ var model = await _classificationService.GetByIdAsync(info.id);
+ if (model != null)
+ {
+ model.add_time = DateTime.Now;
+ model.doc_classification = info.name;
+ model.status = info.status;
+
+ msg = await _classificationService.UpdateAsync(model);
+ }
+
+ return new JsonResult(msg);
+ }
+
+ /// <summary>
+ /// 鍒犻櫎鏁版嵁
+ /// </summary>
+ /// <param name="doc"></param>
+ /// <returns></returns>
+ public async Task<IActionResult> PostDelInfo(Document_Submit_Dto doc)
+ {
+ bool msg = false;
+ //鍋囧垹闄�
+ var model = await _docManageService.GetByIdAsync(doc.id);
+ if (model != null)
+ {
+ if(model.tenant_code==doc.tenant_id && !model.is_del)
+ {
+ model.is_del = true;
+ msg = await _docManageService.UpdateAsync(model);
+ }
+ }
+ return new JsonResult(msg);
+ }
+
+
+
+ /// <summary>
+ /// 娣诲姞鏁版嵁
+ /// </summary>
+ /// <param name="info"></param>
+ /// <returns></returns>
+ public async Task<IActionResult> PostAddFilesInfo(Classification_Submit_Dto info)
+ {
+ Doc_Classification doc = new Doc_Classification();
+ doc.add_time = DateTime.Now;
+ doc.doc_classification = info.name;
+ doc.doc_classification_code = "";
+ doc.is_system = false;
+ doc.parent_code = info.code;
+ doc.sort_id = 99;
+ doc.status = info.status;
+ doc.tenant_code = info.tenant_id;
+
+ var msg = await _classificationService.InsertAsync(doc);
+ return new JsonResult(msg);
+ }
+
+ /// <summary>
+ /// 淇敼鏁版嵁
+ /// </summary>
+ /// <param name="info"></param>
+ /// <returns></returns>
+ public async Task<IActionResult> PostEdtFileInfo(Classification_Submit_Dto info)
+ {
+ var msg = false;
+ var model = await _classificationService.GetByIdAsync(info.id);
+ if (model != null)
+ {
+ model.add_time = DateTime.Now;
+ model.doc_classification = info.name;
+ model.status = info.status;
+
+ msg = await _classificationService.UpdateAsync(model);
+ }
+
+ return new JsonResult(msg);
+ }
+
+ /// <summary>
+ /// 鍒犻櫎鏁版嵁
+ /// </summary>
+ /// <param name="doc"></param>
+ /// <returns></returns>
+ public async Task<IActionResult> PostDelFileInfo(Document_Submit_Dto doc)
+ {
+ bool msg = false;
+ //鍋囧垹闄�
+ var model = await _docManageService.GetByIdAsync(doc.id);
+ if (model != null)
+ {
+ if (model.tenant_code == doc.tenant_id && !model.is_del)
+ {
+ model.is_del = true;
+ msg = await _docManageService.UpdateAsync(model);
+ }
+ }
+ return new JsonResult(msg);
+ }
+ }
+}
--
Gitblit v1.9.1