徐总多门店
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.
 
 
 
 
 
 
jiuhaoshenghuo/app/controller/admin/v1/message/SystemNotification.php

110 lines
3.2 KiB

<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\message;
use app\controller\admin\AuthController;
use app\services\message\SystemNotificationServices;
use think\facade\App;
/**
* Class SystemNotification
* @package app\adminapi\controller\v1\message
*/
class SystemNotification extends AuthController
{
/**
* SystemRole constructor.
* @param App $app
* @param SystemNotificationServices $services
*/
public function __construct(App $app, SystemNotificationServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{
$where = $this->request->getMore([
['type', ''],
]);
return app('json')->success($this->services->getNotList($where));
}
/**
* 显示编辑
*
* @return \think\Response
*/
public function info()
{
$where = $this->request->getMore([
['type', ''],
['id', 0]
]);
if (!$where['id']) return app('json')->fail('参数错误');
return app('json')->success($this->services->getNotInfo($where));
}
/**
* 保存新建的资源
*
* @return \think\Response
*/
public function save()
{
$data = $this->request->postMore([
['id', 0],
['type', ''],
['name', ''],
['title', ''],
['is_system', 0],
['is_app', 0],
['is_wechat', 0],
['is_routine', 0],
['is_sms', 0],
['is_ent_wechat', 0],
['system_title', ''],
['system_text', ''],
['tempid', ''],
['ent_wechat_text', ''],
['url', ''],
['wechat_id', ''],
['routine_id', '']
]);
if (!$data['id']) return app('json')->fail('参数错误');
if ($this->services->saveData($data)) {
$this->services->clearTemplateCache();
return app('json')->success('修改成功!');
} else {
return app('json')->fail('修改失败,请稍候再试!');
}
}
/**
* 修改消息状态
*
* @return array
*/
public function set_status($type, $status, $id)
{
if ($type == '' || $status == '' || $id == 0) return $this->fail('参数错误');
$this->services->update($id, [$type => $status]);
$this->services->clearTemplateCache();
return $this->success($status == 1 ? '开启成功' : '关闭成功');
}
}