新增会议纪要模块

This commit is contained in:
weiz 2024-03-01 15:04:09 +08:00
parent 7e8f5d440e
commit e3f68fb903
6 changed files with 496 additions and 2 deletions

View File

@ -0,0 +1,108 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\supervision_work;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\supervision_work\SupervisionMeetingMinutesLists;
use app\adminapi\logic\supervision_work\SupervisionMeetingMinutesLogic;
use app\adminapi\validate\supervision_work\SupervisionMeetingMinutesValidate;
/**
* 工程监理--会议纪要控制器
* Class SupervisionMeetingMinutesController
* @package app\adminapi\controller\supervision_work
*/
class SupervisionMeetingMinutesController extends BaseAdminController
{
/**
* @notes 获取工程监理--会议纪要列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/01 14:31
*/
public function lists()
{
return $this->dataLists(new SupervisionMeetingMinutesLists());
}
/**
* @notes 添加工程监理--会议纪要
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/01 14:31
*/
public function add()
{
$params = (new SupervisionMeetingMinutesValidate())->post()->goCheck('add');
$result = SupervisionMeetingMinutesLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(SupervisionMeetingMinutesLogic::getError());
}
/**
* @notes 编辑工程监理--会议纪要
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/01 14:31
*/
public function edit()
{
$params = (new SupervisionMeetingMinutesValidate())->post()->goCheck('edit');
$result = SupervisionMeetingMinutesLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SupervisionMeetingMinutesLogic::getError());
}
/**
* @notes 删除工程监理--会议纪要
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/01 14:31
*/
public function delete()
{
$params = (new SupervisionMeetingMinutesValidate())->post()->goCheck('delete');
SupervisionMeetingMinutesLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取工程监理--会议纪要详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/01 14:31
*/
public function detail()
{
$params = (new SupervisionMeetingMinutesValidate())->goCheck('detail');
$result = SupervisionMeetingMinutesLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,81 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\supervision_work;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionMeetingMinutes;
use app\common\lists\ListsSearchInterface;
/**
* 工程监理--会议纪要列表
* Class SupervisionMeetingMinutesLists
* @package app\adminapi\listssupervision_work
*/
class SupervisionMeetingMinutesLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/03/01 14:31
*/
public function setSearch(): array
{
return [
'=' => ['project_id'],
'%like%' => ['theme', 'type', 'emcee', 'recorder'],
];
}
/**
* @notes 获取工程监理--会议纪要列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/03/01 14:31
*/
public function lists(): array
{
return SupervisionMeetingMinutes::withoutField('create_user,create_time,update_time,delete_time')->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
$data['project_name'] = $project['project_name'];
})
->toArray();
}
/**
* @notes 获取工程监理--会议纪要数量
* @return int
* @author likeadmin
* @date 2024/03/01 14:31
*/
public function count(): int
{
return SupervisionMeetingMinutes::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,128 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\supervision_work;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionMeetingMinutes;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 工程监理--会议纪要逻辑
* Class SupervisionMeetingMinutesLogic
* @package app\adminapi\logic\supervision_work
*/
class SupervisionMeetingMinutesLogic extends BaseLogic
{
/**
* @notes 添加工程监理--会议纪要
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/03/01 14:31
*/
public static function add(array $params,$admin_id): bool
{
Db::startTrans();
try {
SupervisionMeetingMinutes::create([
'project_id' => $params['project_id'],
'theme' => $params['theme'],
'type' => $params['type'],
'time' => !empty($params['time']) ? strtotime($params['time']) : 0,
'emcee' => $params['emcee'],
'recorder' => $params['recorder'],
'location' => $params['location'],
'attendees' => $params['attendees'],
'content' => $params['content'],
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'create_user' => $admin_id,
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑工程监理--会议纪要
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/03/01 14:31
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
SupervisionMeetingMinutes::where('id', $params['id'])->update([
'project_id' => $params['project_id'],
'theme' => $params['theme'],
'type' => $params['type'],
'time' => !empty($params['time']) ? strtotime($params['time']) : 0,
'emcee' => $params['emcee'],
'recorder' => $params['recorder'],
'location' => $params['location'],
'attendees' => $params['attendees'],
'content' => $params['content'],
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'update_time' => time()
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除工程监理--会议纪要
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/03/01 14:31
*/
public static function delete(array $params): bool
{
return SupervisionMeetingMinutes::destroy($params['id']);
}
/**
* @notes 获取工程监理--会议纪要详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/03/01 14:31
*/
public static function detail($params): array
{
$data = SupervisionMeetingMinutes::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
$data['project_name'] = $project['project_name'];
return $data->toArray();
}
}

View File

@ -0,0 +1,134 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\supervision_work;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionMeetingMinutes;
use app\common\validate\BaseValidate;
/**
* 工程监理--会议纪要验证器
* Class SupervisionMeetingMinutesValidate
* @package app\adminapi\validate\supervision_work
*/
class SupervisionMeetingMinutesValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'project_id' => 'require|checkProject',
'theme' => 'require',
'time' => 'dateFormat:Y-m-d',
'annex' => 'checkAnnex',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'project_id' => '项目id',
'theme' => '会议主题',
'type' => '会议类型',
'time' => '会议时间',
'emcee' => '主持人',
'recorder' => '记录人',
'location' => '会议地点',
'attendees' => '与会人员',
'content' => '会议内容',
'create_user' => 'create_user',
];
/**
* @notes 添加场景
* @return SupervisionMeetingMinutesValidate
* @author likeadmin
* @date 2024/03/01 14:31
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return SupervisionMeetingMinutesValidate
* @author likeadmin
* @date 2024/03/01 14:31
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return SupervisionMeetingMinutesValidate
* @author likeadmin
* @date 2024/03/01 14:31
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionMeetingMinutesValidate
* @author likeadmin
* @date 2024/03/01 14:31
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionMeetingMinutes::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkProject($value): bool|string
{
$data = SupervisionProject::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '项目信息不存在';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != '' && !is_array($value)){
return '附件格式错误';
}
return true;
}
}

View File

@ -16,7 +16,7 @@ namespace app\common\model\supervision_work;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
@ -26,8 +26,9 @@ use app\common\model\BaseModel;
*/
class SupervisionDiary extends BaseModel
{
use SoftDelete;
protected $name = 'supervision_diary';
protected $deleteTime = 'delete_time';
public function getAnnexAttr($value)
{

View File

@ -0,0 +1,42 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\supervision_work;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 工程监理--会议纪要模型
* Class SupervisionMeetingMinutes
* @package app\common\model\supervision_work
*/
class SupervisionMeetingMinutes extends BaseModel
{
use SoftDelete;
protected $name = 'supervision_meeting_minutes';
protected $deleteTime = 'delete_time';
public function getAnnexAttr($value)
{
return !empty($value) ? json_decode($value,true) : '';
}
public function getTimeAttr($value)
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
}