安徽博创起重服务端程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

184 lines
4.9 KiB

<?php
namespace app\admin\logic\community;
use app\common\basics\Logic;
use app\common\model\community\OrganTeam;
use app\common\model\content\Help;
use app\common\model\content\Resource;
use app\common\server\AreaServer;
use app\common\server\UrlServer;
use Exception;
class OrganTeamLogic extends Logic
{
/**
* 获取分类
* @param $get
* @return array
*/
public static function lists($get,$type=0)
{
try {
$where = [
['del', '=', 0]
];
$where[] = ['type', '=', $type];
if (!empty($get['name']) and $get['name'])
$where[] = ['name', 'like', '%'.$get['name'].'%'];
$model = new OrganTeam();
$lists = $model->field(true)
->where($where)
->order('sort', 'asc')
->paginate([
'page' => $get['page'],
'list_rows' => $get['limit'],
'var_page' => 'page'
])
->toArray();
foreach ($lists['data'] as &$item) {
$item['is_show'] = $item['is_show'] ? '显示' : '隐藏';
$item['address'] = $item['province_id']?AreaServer::getAddress([
$item['province_id'],
$item['city_id'],
]):'';
}
return ['count'=>$lists['total'], 'lists'=>$lists['data']];
} catch (Exception $e) {
return ['error'=>$e->getMessage()];
}
}
public static function getAddr(){
}
/**
* @Notes: 资料详细
* @Author:
* @param $id
* @return array
*/
public static function detail($id)
{
$model = new OrganTeam();
$detail = $model->field(true)->findOrEmpty($id)->toArray();
// $detail['path'] = UrlServer::getFileUrl($detail['path']);
return $detail;
}
/**
* @Notes: 添加帮助
* @Author:
* @param $post
* @return bool
*/
public static function add($post)
{
try {
OrganTeam::create([
'name' => $post['name'],
'image' => $post['image'] ?? '',
'intro' => $post['intro'] ?? '',
'content' => $post['content'] ?? '',
'type' => $post['type'] ?? 0,
'province_id' => $post['province_id'] ?? 0,
'city_id' => $post['city_id'] ?? 0,
'district_id' => $post['district_id'] ?? 0,
'visit' => 0,
'contact' => $post['contact'] ?? '',
'sort' => $post['sort'] ?? 0,
'is_show' => $post['is_show'],
'company' => $post['company'] ?? '',
]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
/**
* @Notes: 编辑帮助
* @Author: 张无忌
* @param $post
* @return bool
*/
public static function edit($post)
{
try {
OrganTeam::update([
'name' => $post['name'],
'image' => $post['image'] ?? '',
'intro' => $post['intro'] ?? '',
'content' => $post['content'] ?? '',
'company' => $post['company'] ?? '',
'type' => $post['type'] ?? 0,
'province_id' => $post['province_id'] ?? 0,
'city_id' => $post['city_id'] ?? 0,
'district_id' => $post['district_id'] ?? 0,
'visit' => 0,
'contact' => $post['contact'] ?? '',
'sort' => $post['sort'] ?? 0,
'is_show' => $post['is_show']
], ['id'=>$post['id']]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
/**
* @Notes: 删除
* @Author:
* @param $id
* @return bool
*/
public static function del($id)
{
try {
OrganTeam::update([
'del' => 1,
'update_time' => time()
], ['id'=>$id]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
/**
* @Notes: 隐藏
* @Author: 张无忌
* @param $id
* @return bool
*/
public static function hide($id)
{
try {
$model = new OrganTeam();
$article = $model->findOrEmpty($id)->toArray();
OrganTeam::update([
'is_show' => !$article['is_show'],
'update_time' => time()
], ['id'=>$id]);
return true;
} catch (\Exception $e) {
static::$error = $e->getMessage();
return false;
}
}
}