update
This commit is contained in:
parent
7576f74ff6
commit
e17852ad45
@ -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\marketing;
|
||||||
|
|
||||||
|
|
||||||
|
use app\adminapi\controller\BaseAdminController;
|
||||||
|
use app\adminapi\lists\marketing\MarketingCompetitorLists;
|
||||||
|
use app\adminapi\logic\marketing\MarketingCompetitorLogic;
|
||||||
|
use app\adminapi\validate\marketing\MarketingCompetitorValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 市场经营--投标管理--竞争对手控制器
|
||||||
|
* Class MarketingCompetitorController
|
||||||
|
* @package app\adminapi\controller\marketing
|
||||||
|
*/
|
||||||
|
class MarketingCompetitorController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取市场经营--投标管理--竞争对手列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new MarketingCompetitorLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加市场经营--投标管理--竞争对手
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$params = (new MarketingCompetitorValidate())->post()->goCheck('add');
|
||||||
|
$result = MarketingCompetitorLogic::add($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('添加成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(MarketingCompetitorLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑市场经营--投标管理--竞争对手
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new MarketingCompetitorValidate())->post()->goCheck('edit');
|
||||||
|
$result = MarketingCompetitorLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(MarketingCompetitorLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除市场经营--投标管理--竞争对手
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new MarketingCompetitorValidate())->post()->goCheck('delete');
|
||||||
|
MarketingCompetitorLogic::delete($params);
|
||||||
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取市场经营--投标管理--竞争对手详情
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
$params = (new MarketingCompetitorValidate())->goCheck('detail');
|
||||||
|
$result = MarketingCompetitorLogic::detail($params);
|
||||||
|
return $this->data($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
79
app/adminapi/lists/marketing/MarketingCompetitorLists.php
Normal file
79
app/adminapi/lists/marketing/MarketingCompetitorLists.php
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?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\marketing;
|
||||||
|
|
||||||
|
|
||||||
|
use app\adminapi\lists\BaseAdminDataLists;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\marketing\MarketingCompetitor;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 市场经营--投标管理--竞争对手列表
|
||||||
|
* Class MarketingCompetitorLists
|
||||||
|
* @package app\adminapi\listsmarketing
|
||||||
|
*/
|
||||||
|
class MarketingCompetitorLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['company_type'],
|
||||||
|
'%like%' => ['company_name', 'legal_representative', 'address'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取市场经营--投标管理--竞争对手列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return MarketingCompetitor::widthoutField('create_time,update_time,delete_time')->where($this->searchWhere)
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()->each(function ($data) {
|
||||||
|
$data['company_type_text'] = $data->company_type_text;
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取市场经营--投标管理--竞争对手数量
|
||||||
|
* @return int
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return MarketingCompetitor::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
128
app/adminapi/logic/marketing/MarketingCompetitorLogic.php
Normal file
128
app/adminapi/logic/marketing/MarketingCompetitorLogic.php
Normal 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\marketing;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\marketing\MarketingCompetitor;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 市场经营--投标管理--竞争对手逻辑
|
||||||
|
* Class MarketingCompetitorLogic
|
||||||
|
* @package app\adminapi\logic\marketing
|
||||||
|
*/
|
||||||
|
class MarketingCompetitorLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加市场经营--投标管理--竞争对手
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public static function add(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
MarketingCompetitor::create([
|
||||||
|
'company_name' => $params['company_name'],
|
||||||
|
'company_type' => $params['company_type'],
|
||||||
|
'legal_representative' => $params['legal_representative'] ?? '',
|
||||||
|
'creation_date' => !empty($params['creation_date']) ? strtotime($params['creation_date']) : 0,
|
||||||
|
'employee_num' => $params['employee_num'] ?? 0,
|
||||||
|
'telephone' => $params['telephone'] ?? '',
|
||||||
|
'address' => $params['address'] ?? '',
|
||||||
|
'website' => $params['website'] ?? '',
|
||||||
|
'qualifications' => $params['qualifications'] ?? '',
|
||||||
|
'business_scope' => $params['business_scope'] ?? '',
|
||||||
|
'competitive_edge' => $params['competitive_edge'] ?? '',
|
||||||
|
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||||
|
]);
|
||||||
|
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/04/12 15:26
|
||||||
|
*/
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
MarketingCompetitor::where('id', $params['id'])->update([
|
||||||
|
'company_name' => $params['company_name'],
|
||||||
|
'company_type' => $params['company_type'],
|
||||||
|
'legal_representative' => $params['legal_representative'] ?? '',
|
||||||
|
'creation_date' => !empty($params['creation_date']) ? strtotime($params['creation_date']) : 0,
|
||||||
|
'employee_num' => $params['employee_num'] ?? 0,
|
||||||
|
'telephone' => $params['telephone'] ?? '',
|
||||||
|
'address' => $params['address'] ?? '',
|
||||||
|
'website' => $params['website'] ?? '',
|
||||||
|
'qualifications' => $params['qualifications'] ?? '',
|
||||||
|
'business_scope' => $params['business_scope'] ?? '',
|
||||||
|
'competitive_edge' => $params['competitive_edge'] ?? '',
|
||||||
|
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||||
|
]);
|
||||||
|
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/04/12 15:26
|
||||||
|
*/
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
return MarketingCompetitor::destroy($params['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取市场经营--投标管理--竞争对手详情
|
||||||
|
* @param $params
|
||||||
|
* @return array
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public static function detail($params): array
|
||||||
|
{
|
||||||
|
$data = MarketingCompetitor::widthoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
||||||
|
$data['company_type_text'] = $data->company_type_text;
|
||||||
|
return $data->toArray();
|
||||||
|
}
|
||||||
|
}
|
126
app/adminapi/validate/marketing/MarketingCompetitorValidate.php
Normal file
126
app/adminapi/validate/marketing/MarketingCompetitorValidate.php
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
<?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\marketing;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\dict\DictData;
|
||||||
|
use app\common\model\marketing\MarketingCompetitor;
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 市场经营--投标管理--竞争对手验证器
|
||||||
|
* Class MarketingCompetitorValidate
|
||||||
|
* @package app\adminapi\validate\marketing
|
||||||
|
*/
|
||||||
|
class MarketingCompetitorValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置校验规则
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'id' => 'require|checkData',
|
||||||
|
'company_name' => 'require',
|
||||||
|
'company_type' => 'require|checkCompanyType',
|
||||||
|
'creation_date' => 'dateFormat:Y-m-d',
|
||||||
|
'employee_num' => 'integer|egt:0',
|
||||||
|
'website' => 'url',
|
||||||
|
'annex' => 'checkAnnex',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $field = [
|
||||||
|
'id' => 'id',
|
||||||
|
'company_name' => '单位名称',
|
||||||
|
'company_type' => '企业类型',
|
||||||
|
'legal_representative' => '法人代表',
|
||||||
|
'creation_date' => '成立日期',
|
||||||
|
'employee_num' => '员工人数',
|
||||||
|
'telephone' => '联系电话',
|
||||||
|
'address' => '单位地址',
|
||||||
|
'website' => '企业网址',
|
||||||
|
'qualifications' => '企业资质',
|
||||||
|
'business_scope' => '经营范围',
|
||||||
|
'competitive_edge' => '竞争优势',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加场景
|
||||||
|
* @return MarketingCompetitorValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public function sceneAdd()
|
||||||
|
{
|
||||||
|
return $this->remove('id', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑场景
|
||||||
|
* @return MarketingCompetitorValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public function sceneEdit()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除场景
|
||||||
|
* @return MarketingCompetitorValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public function sceneDelete()
|
||||||
|
{
|
||||||
|
return $this->only(['id'])->remove('id', 'checkData');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 详情场景
|
||||||
|
* @return MarketingCompetitorValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/12 15:26
|
||||||
|
*/
|
||||||
|
public function sceneDetail()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkData($value): bool|string
|
||||||
|
{
|
||||||
|
$data = MarketingCompetitor::where('id', $value)->findOrEmpty();
|
||||||
|
return $data->isEmpty() ? '数据不存在' : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkCompanyType($value): bool|string
|
||||||
|
{
|
||||||
|
$dict = DictData::where('type_value', 'company_type')->column('value');
|
||||||
|
if (!in_array($value, $dict)) {
|
||||||
|
return '企业类型数据值无效';
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
45
app/common/model/marketing/MarketingCompetitor.php
Normal file
45
app/common/model/marketing/MarketingCompetitor.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?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\marketing;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use app\common\model\dict\DictData;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 市场经营--投标管理--竞争对手模型
|
||||||
|
* Class MarketingCompetitor
|
||||||
|
* @package app\common\model\marketing
|
||||||
|
*/
|
||||||
|
class MarketingCompetitor extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
|
||||||
|
protected $name = 'marketing_competitor';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
public function getCompanyTypeTextAttr($value, $data)
|
||||||
|
{
|
||||||
|
$dict = DictData::where('type_value', 'company_type')->column('name', 'value');
|
||||||
|
return !empty($data['company_type']) ? $dict[$data['company_type']] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCreationDateAttr($value): string
|
||||||
|
{
|
||||||
|
return !empty($value) ? date('Y-m-d', $value) : '';
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user