123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace app\admin\controller\base;
- /**
- * @title: 打印模板控制器
- * @Description:
- * @Author: goldenrock 112049337@qq.com
- * @Date: 2024-09-23 15:18:34
- * @LastEditTime: 2024-11-20 09:43:21
- * @LastEditors: goldenrock
- * @FilePath: \OA_hbdrwhe:\HBDRWHCODE\DRSERVER_dev\app\admin\controller\base\SystemPrintTpl.php
- */
- use app\admin\controller\Base;
- use app\common\model\base\SystemPrintTpl as PrintModel;
- class SystemPrintTpl extends Base
- {
- private $model = null;
- public function initialize()
- {
- parent::initialize();
- $this->model = new PrintModel;
- }
- /**
- * 获取
- */
- private function createWhere()
- {
- $data = $this->request->param();
- $where = [];
- if(!empty($data['keyword'])){
- $where[] = ['title|code','LIKE',"%{$data['keyword']}%"];
- }
- return ['where'=>$where,'whereOr'=>[]];
- }
- /**
- *获取列表
- */
- public function getList(int $pageNo=0,int $pageSize=10)
- {
- $whereAry = $this->createWhere();
- if(!empty($pageNo)){
- $res = $this->model->where($whereAry['where'])->where(function($query)use($whereAry){
- $query->where($whereAry['whereOr']);
- })->with([])->paginate(['page'=>$pageNo,'list_rows'=>$pageSize]);
- return pageRes(1,'获取成功',$res->total(),$res->items());
- }else{
- $list = $this->model->where($whereAry['where'])->where(function($query)use($whereAry){
- $query->where($whereAry['whereOr']);
- })->with([])->select();
- return res(1,'获取成功',$list);
- }
- }
- public function doEdit()
- {
- $data = $this->request->param();
- $this->model->replace()->save($data);
- slog(1,"编辑了打印模板".$data['title']);
- return res(1,"保存成功");
- }
- public function getInfo(string $code='')
- {
- $info = $this->model->where('code',$code)->find();
- return res(1,"获取成功",$info);
- }
- public function doDelete(int $id=0)
- {
- $info = $this->model->where("id",$id)->find();
- if(empty($info)){
- return res(1,"删除成功");
- }
- $info->delete();
- slog(1,"删除了打印模板".$info->title);
- return res(1,"删除成功");
- }
- public function getOptions()
- {
- $option = [];
- return res(1,"获取成功",$option);
- }
- public function __call($name,$arguments)
- {
- return res(2,"控制器方法{$name}不存在");
- }
- }
|