新增项目大事记模块
This commit is contained in:
parent
8c908d14ec
commit
8fa6babeff
@ -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_connect;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\supervision_connect\SupervisionProjectMilestonesLists;
|
||||
use app\adminapi\logic\supervision_connect\SupervisionProjectMilestonesLogic;
|
||||
use app\adminapi\validate\supervision_connect\SupervisionProjectMilestonesValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--项目大事记控制器
|
||||
* Class SupervisionProjectMilestonesController
|
||||
* @package app\adminapi\controller\supervision_connect
|
||||
*/
|
||||
class SupervisionProjectMilestonesController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--项目大事记列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new SupervisionProjectMilestonesLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--项目大事记
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new SupervisionProjectMilestonesValidate())->post()->goCheck('add');
|
||||
$result = SupervisionProjectMilestonesLogic::add($params,$this->adminId);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionProjectMilestonesLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑工程监理--项目大事记
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new SupervisionProjectMilestonesValidate())->post()->goCheck('edit');
|
||||
$result = SupervisionProjectMilestonesLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionProjectMilestonesLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除工程监理--项目大事记
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new SupervisionProjectMilestonesValidate())->post()->goCheck('delete');
|
||||
SupervisionProjectMilestonesLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--项目大事记详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new SupervisionProjectMilestonesValidate())->goCheck('detail');
|
||||
$result = SupervisionProjectMilestonesLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
<?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_connect;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\supervision_connect\SupervisionProjectMilestones;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--项目大事记列表
|
||||
* Class SupervisionProjectMilestonesLists
|
||||
* @package app\adminapi\listssupervision_connect
|
||||
*/
|
||||
class SupervisionProjectMilestonesLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['project_id'],
|
||||
'%like%' => ['title'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--项目大事记列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return SupervisionProjectMilestones::widthoutField('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();
|
||||
$create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
|
||||
$data['project_name'] = $project['project_name'];
|
||||
$data['create_user_name'] = $create_user['name'];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--项目大事记数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return SupervisionProjectMilestones::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
<?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_connect;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\supervision_connect\SupervisionProjectMilestones;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--项目大事记逻辑
|
||||
* Class SupervisionProjectMilestonesLogic
|
||||
* @package app\adminapi\logic\supervision_connect
|
||||
*/
|
||||
class SupervisionProjectMilestonesLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--项目大事记
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public static function add(array $params,$admin_id): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionProjectMilestones::create([
|
||||
'project_id' => $params['project_id'],
|
||||
'title' => $params['title'],
|
||||
'content' => $params['content'],
|
||||
'remark' => $params['remark'],
|
||||
'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/05 10:28
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionProjectMilestones::where('id', $params['id'])->update([
|
||||
'project_id' => $params['project_id'],
|
||||
'title' => $params['title'],
|
||||
'content' => $params['content'],
|
||||
'remark' => $params['remark'],
|
||||
'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/05 10:28
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return SupervisionProjectMilestones::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--项目大事记详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = SupervisionProjectMilestones::widthoutField('update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
|
||||
$data['project_name'] = $project['project_name'];
|
||||
$data['create_user_name'] = $create_user['name'];
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
<?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_connect;
|
||||
|
||||
|
||||
use app\common\model\supervision_connect\SupervisionProjectMilestones;
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--项目大事记验证器
|
||||
* Class SupervisionProjectMilestonesValidate
|
||||
* @package app\adminapi\validate\supervision_connect
|
||||
*/
|
||||
class SupervisionProjectMilestonesValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'project_id' => 'require|checkProject',
|
||||
'title' => 'require',
|
||||
'content' => 'require',
|
||||
'remark' => 'require',
|
||||
'annex' => 'checkAnnex'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'project_id' => '项目id',
|
||||
'title' => '标题',
|
||||
'content' => '正文内容',
|
||||
'remark' => '备注',
|
||||
'create_user' => '发布人',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return SupervisionProjectMilestonesValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id',true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return SupervisionProjectMilestonesValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return SupervisionProjectMilestonesValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return SupervisionProjectMilestonesValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:28
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = SupervisionProjectMilestones::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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?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_connect;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--项目大事记模型
|
||||
* Class SupervisionProjectMilestones
|
||||
* @package app\common\model\supervision_connect
|
||||
*/
|
||||
class SupervisionProjectMilestones extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'supervision_project_milestones';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getAnnexAttr($value){
|
||||
return !empty($value) ? json_decode($value,true) : '';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user