更新售前项目成员
This commit is contained in:
parent
6c44769642
commit
88fe5eed6e
@ -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\project;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\project\ProjectPreSalesMembersLists;
|
||||
use app\adminapi\logic\project\ProjectPreSalesMembersLogic;
|
||||
use app\adminapi\validate\project\ProjectPreSalesMembersValidate;
|
||||
|
||||
|
||||
/**
|
||||
* ProjectPreSalesMembers控制器
|
||||
* Class ProjectPreSalesMembersController
|
||||
* @package app\adminapi\controller\project
|
||||
*/
|
||||
class ProjectPreSalesMembersController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new ProjectPreSalesMembersLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new ProjectPreSalesMembersValidate())->post()->goCheck('add');
|
||||
$result = ProjectPreSalesMembersLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ProjectPreSalesMembersLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new ProjectPreSalesMembersValidate())->post()->goCheck('edit');
|
||||
$result = ProjectPreSalesMembersLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ProjectPreSalesMembersLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ProjectPreSalesMembersValidate())->post()->goCheck('delete');
|
||||
ProjectPreSalesMembersLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new ProjectPreSalesMembersValidate())->goCheck('detail');
|
||||
$result = ProjectPreSalesMembersLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
77
app/adminapi/lists/project/ProjectPreSalesMembersLists.php
Normal file
77
app/adminapi/lists/project/ProjectPreSalesMembersLists.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?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\project;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\project\ProjectPreSalesMembers;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* ProjectPreSalesMembers列表
|
||||
* Class ProjectPreSalesMembersLists
|
||||
* @package app\adminapi\listsproject
|
||||
*/
|
||||
class ProjectPreSalesMembersLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['project_id', 'technician_ids', 'business_people_ids', 'cross_departmental_personnel_ids'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return ProjectPreSalesMembers::where($this->searchWhere)
|
||||
->field(['id', 'project_id', 'technician_ids', 'business_people_ids', 'cross_departmental_personnel_ids'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return ProjectPreSalesMembers::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
112
app/adminapi/logic/project/ProjectPreSalesMembersLogic.php
Normal file
112
app/adminapi/logic/project/ProjectPreSalesMembersLogic.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?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\project;
|
||||
|
||||
|
||||
use app\common\model\project\ProjectPreSalesMembers;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* ProjectPreSalesMembers逻辑
|
||||
* Class ProjectPreSalesMembersLogic
|
||||
* @package app\adminapi\logic\project
|
||||
*/
|
||||
class ProjectPreSalesMembersLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ProjectPreSalesMembers::create([
|
||||
'project_id' => $params['project_id'],
|
||||
'technician_ids' => $params['technician_ids'],
|
||||
'business_people_ids' => $params['business_people_ids'],
|
||||
'cross_departmental_personnel_ids' => $params['cross_departmental_personnel_ids']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ProjectPreSalesMembers::where('id', $params['id'])->update([
|
||||
'project_id' => $params['project_id'],
|
||||
'technician_ids' => $params['technician_ids'],
|
||||
'business_people_ids' => $params['business_people_ids'],
|
||||
'cross_departmental_personnel_ids' => $params['cross_departmental_personnel_ids']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return ProjectPreSalesMembers::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return ProjectPreSalesMembers::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
<?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\project;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* ProjectPreSalesMembers验证器
|
||||
* Class ProjectPreSalesMembersValidate
|
||||
* @package app\adminapi\validate\project
|
||||
*/
|
||||
class ProjectPreSalesMembersValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return ProjectPreSalesMembersValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return ProjectPreSalesMembersValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return ProjectPreSalesMembersValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return ProjectPreSalesMembersValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/11/14 10:15
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
34
app/common/model/project/ProjectPreSalesMembers.php
Normal file
34
app/common/model/project/ProjectPreSalesMembers.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?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\project;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* ProjectPreSalesMembers模型
|
||||
* Class ProjectPreSalesMembers
|
||||
* @package app\common\model\project
|
||||
*/
|
||||
class ProjectPreSalesMembers extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'project_pre_sales_members';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user