130 lines
4.1 KiB
PHP
130 lines
4.1 KiB
PHP
<?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\custom;
|
||
|
||
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\custom\Custom;
|
||
use app\common\model\custom\CustomFollow;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* CustomFollow逻辑
|
||
* Class CustomFollowLogic
|
||
* @package app\adminapi\logic\custom_follow
|
||
*/
|
||
class CustomFollowLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/11/12 13:40
|
||
*/
|
||
public static function add(array $params,$admin_id): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
CustomFollow::create([
|
||
'custom_id' => $params['custom_id'],
|
||
'name' => $params['name'],
|
||
'contacts' => $params['contacts'] ?? '',
|
||
'date' => strtotime($params['date']),
|
||
'types' => $params['types'],
|
||
'description' => $params['description'] ?? '',
|
||
'annex' => $params['annex'] ?? null,
|
||
'coordinate' => $params['coordinate'] ?? '',
|
||
'executor' => $params['executor'] ?? '',
|
||
'next_follow_date' => strtotime($params['next_follow_date']),
|
||
'add_user' => $admin_id,
|
||
'update_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 2023/11/12 13:40
|
||
*/
|
||
public static function edit(array $params,$admin_id): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
CustomFollow::where('id', $params['id'])->update([
|
||
'custom_id' => $params['custom_id'],
|
||
'name' => $params['name'],
|
||
'contacts' => $params['contacts'] ?? '',
|
||
'date' => strtotime($params['date']),
|
||
'types' => $params['types'],
|
||
'description' => $params['description'] ?? '',
|
||
'annex' => $params['annex']? json_encode($params['annex']) : null,
|
||
'coordinate' => $params['coordinate'] ?? '',
|
||
'executor' => $params['executor'] ?? '',
|
||
'next_follow_date' => strtotime($params['next_follow_date']),
|
||
'update_user' => $admin_id,
|
||
'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 2023/11/12 13:40
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return CustomFollow::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/11/12 13:40
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = CustomFollow::field('id,custom_id,name,contacts,date,types,description,annex,coordinate,next_follow_date,executor')->findOrEmpty($params['id']);
|
||
$custom = Custom::field('name')->where('id',$data['custom_id'])->findOrEmpty();
|
||
$data['custom_name'] = $custom['name'];
|
||
return $data->toArray();
|
||
}
|
||
} |