using DocumentServiceAPI.Application.DocManage.Dtos;
|
using DocumentServiceAPI.Application.DocManage.Services;
|
using DocumentServiceAPI.Model.cyDocumentModel;
|
using DocumentServiceAPI.Utility;
|
|
namespace DocumentServiceAPI.Application.DocManage
|
{
|
/// <summary>
|
/// 资料分类管理
|
/// </summary>
|
public class DocManageAppService : IDynamicApiController
|
{
|
private readonly DocClassificationService _classificationService;
|
|
public DocManageAppService(DocClassificationService classificationService)
|
{
|
_classificationService = classificationService;
|
}
|
|
/// <summary>
|
/// 根据ID查询对象
|
/// </summary>
|
/// <param name="id"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> GetInfo(int id)
|
{
|
var model =await _classificationService.GetByIdAsync(id);
|
return new JsonResult(model);
|
}
|
|
/// <summary>
|
/// 根据分页条件查询分页数据
|
/// </summary>
|
/// <param name="page"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostListPage(DocClassificationPageSearch page)
|
{
|
PageModel pg = new PageModel();
|
pg.PageSize = page.PageSize;
|
pg.PageIndex = page.PageIndex;
|
|
PageResult<Doc_Classification> result = new PageResult<Doc_Classification>();
|
if (page.Status.HasValue)
|
{
|
result.Items = await _classificationService.GetPageListAsync(c => c.status ==page.Status && c.parent_code == page.Code, pg);
|
}
|
else
|
{
|
result.Items = await _classificationService.GetPageListAsync(c => c.parent_code == page.Code, pg);
|
}
|
result.TotalCount = pg.TotalCount;
|
result.PageIndex = pg.PageIndex;
|
result.PageSize = pg.PageSize;
|
return new JsonResult(result);
|
}
|
|
/// <summary>
|
/// 添加数据
|
/// </summary>
|
/// <param name="info"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostAddInfo(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 = "";
|
|
var msg =await _classificationService.InsertAsync(doc);
|
return new JsonResult(msg);
|
}
|
|
/// <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="id"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostDelInfo(int id)
|
{
|
var msg = await _classificationService.DeleteByIdAsync(id);
|
return new JsonResult(msg);
|
}
|
}
|
}
|