Merge branch 'develop'
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\ApprovalRecordsValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\admin\model\ApprovalRecords;
|
||||
use support\Request;
|
||||
|
||||
class ApprovalRecordsService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = ApprovalRecords::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = ApprovalRecordsValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
|
||||
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
|
||||
{
|
||||
$p = $request->all();
|
||||
|
||||
$config = [];
|
||||
$config['model'] = $this->modelClass;
|
||||
switch ($scene) {
|
||||
case 'index':
|
||||
$config['order']['id'] = 'desc';
|
||||
|
||||
$config['with'] = [
|
||||
'approvalInstance',
|
||||
'approver',
|
||||
'approvalInstance.flows',
|
||||
'approvalInstance.initiator',
|
||||
'approvalInstance.bizInfo'
|
||||
];
|
||||
|
||||
// $config['dataLimit']['type'] = 'relation';
|
||||
// $config['dataLimit']['userId'] = $request->user->uid;
|
||||
// $config['dataLimit']['userField'] = 'approver_id';
|
||||
break;
|
||||
case 'show':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'store':
|
||||
break;
|
||||
case 'update':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'destroy':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'logs':
|
||||
$config['where']['instance_id'] = $p['instance_id'];
|
||||
$config['order']['id'] = 'desc';
|
||||
break;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
public function serviceApprove(Request $request)
|
||||
{
|
||||
$param = $request->all();
|
||||
$appro = new \app\common\utils\approval\service\ApprovalFlowService();
|
||||
return $appro->approve($param['instance_id'], $request->user->uid, $param['action'], $param['comment']);
|
||||
}
|
||||
|
||||
|
||||
public function serviceLogs(Request $request)
|
||||
{
|
||||
$config = $this->buildQueryConfig($request, 'logs');
|
||||
$item = $this->logicListAll($config);
|
||||
return $this->postProcess('Logs', $item);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user