Files
huangjingfen/pro_v3.5.1/app/controller/admin/v1/message/SystemNotification.php
panchengyong 7acbf45ff7 new files
2026-03-07 22:29:07 +08:00

108 lines
3.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\message;
use think\annotation\Inject;
use app\controller\admin\AuthController;
use app\services\message\SystemNotificationServices;
/**
* Class SystemRole
* @package app\adminapi\controller\v1\setting
*/
class SystemNotification extends AuthController
{
/**
* @var SystemNotificationServices
*/
#[Inject]
protected SystemNotificationServices $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],
['sms_id', 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 ? '开启成功' : '关闭成功');
}
}