WokerTask/app/middleapi/controller/DictDataController.php

77 lines
2.1 KiB
PHP

<?php
namespace app\middleapi\controller;
use app\common\model\dict\DictData;
use app\adminapi\logic\setting\dict\DictDataLogic;
use app\common\controller\BaseLikeAdminController;
/**
* 字典数据
* Class DictDataController
* @package app\adminapi\controller\dictionary
*/
class DictDataController extends BaseLikeAdminController
{
/**
* @notes 获取字典数据列表
* @return \think\response\Json
* @author 段誉
* @date 2022/6/20 16:35
*/
public function lists()
{
if(!$this->request->isPost()){
return $this->fail('请求方式错误');
}
$params=$this->request->post(['page_no','page_size','name','type_id','type_value']);
$where = [];
if(!empty($params['name'])){
$where[] = ['name','like','%' . $params['name'] . '%'];
}
if(!empty($params['type_id'])){
$where[] = ['type_id', '=', $params['type_id']];
}
if(!empty($params['type_value'])){
$where[] = ['type_value', '=', $params['type_value']];
}
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
$data = DictData::where($where)
->append(['status_desc'])
->page($pageNo, $pageSize)
->order(['sort' => 'desc', 'id' => 'desc'])
->select()
->toArray();
$count = DictData::where($where)->count();
$result = [
'lists' => $data,
'count' => $count,
'page_no' => $pageNo,
'page_size' => $pageSize
];
return $this->success('请求成功',$result);
}
/**
* @notes 获取字典详情
* @return \think\response\Json
* @author 段誉
* @date 2022/6/20 17:14
*/
public function detail()
{
$params = (new DictDataValidate())->goCheck('id');
$result = DictDataLogic::detail($params);
return $this->data($result);
}
public function getTaskApproveTypeList()
{
$result = DictDataLogic::getTaskApproveTypeList();
return $this->data($result);
}
}