using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Datory;
using GxPress.Common.Tools;
using GxPress.Entity.WorkFlow;
using GxPress.Entity.WorkFlowDto;
using GxPress.Entity.WorkProcessDto;
using GxPress.EnumConst;
using GxPress.Result;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace GxPress.Api.AdminControllers
{
public partial class AdminFlowController
{
///
/// 动作 - 审批
///
/// 审批意见
///
[HttpPost("action/check")]
[AllowAnonymous]
public async Task ActionsCheck([FromBody] CheckRequest request)
{
await _flowService.CheckAsync(request.TodoId, request.IsChecked, request.Message);
return new DefaultResult
{
Value = true
};
}
///
/// 动作 - 下载
///
/// 请求
///
[HttpPost("action/download")]
[AllowAnonymous]
public async Task ActionsDownload([FromBody] ActionRequest request)
{
var url = await docService.MakeDoc(request.FlowId, _loginContext.AccountId);
var result = new DownloadResult
{
DownloadUrl = StringUtils.AddDomain(url),
PreviewUrl = StringUtils.GetPreviewDocUrl(url)
};
return new DefaultStringResult
{
Value = result.DownloadUrl
};
}
///
/// 动作 - 催办
///
/// 请求
///
[HttpPost("action/remind")]
[AllowAnonymous]
public DefaultResult ActionsRemind([FromBody] ActionRequest request)
{
return new DefaultResult
{
Value = true
};
}
///
/// 动作 - 上会
///
/// 请求
///
[HttpPost("action/meeting")]
[AllowAnonymous]
public async Task ActionsMeeting([FromBody] ActionRequest request)
{
//await _flowRepository.UpdateStateAsync(request.FlowId, nameof(FlowState.Meeting));
await _flowTodoRepository.UpdateAsync(Q.Where(nameof(Entity.WorkFlow.FlowTodo.FlowId), request.FlowId).Where(nameof(Entity.WorkFlow.FlowTodo.UserId), _loginContext.AccountId).Set(nameof(Entity.WorkFlow.FlowTodo.IsDone), true).Set(nameof(Entity.WorkFlow.FlowTodo.DoneType), 3));
return new DefaultResult
{
Value = true
};
}
}
}