// +---------------------------------------------------------------------- namespace app\controller\admin; use app\model\Wechat as WechatM; /** * @title 微信模块 * @description 微信公众号、小程序管理 */ class Wechat extends Base { /** * @title 微信列表 * @author huajie */ public function index() { $map = []; $order = "id desc"; //获取列表数据 $list = WechatM::where($map)->order($order)->paginate($this->request->pageConfig); $this->data = array( 'list' => $list, 'page' => '', ); return $this->fetch(); } /** * @title 添加微信 * @author colin */ public function add() { if ($this->request->isPost()) { $data = $this->request->post(); $result = WechatM::create($data); if (false != $result) { return $this->success('添加成功!', url('/admin/wechat/index')); } else { return $this->error('添加失败!'); } } else { $this->data = array( 'keyList' => WechatM::$fieldlist ); return $this->fetch('admin/public/edit'); } } /** * @title 修改微信 * @author colin */ public function edit($id = null) { if ($this->request->isPost()) { $data = $this->request->post(); $result = WechatM::update($data, ['id' => $data['id']]); if ($result !== false) { return $this->success('编辑成功!', url('/admin/wechat/index')); } else { return $this->error('修改失败!'); } } else { $info = WechatM::find($id); if (!$info) { return $this->error("非法操作!"); } $this->data = array( 'info' => $info, 'keyList' => WechatM::$fieldlist ); return $this->fetch('admin/public/edit'); } } /** * @title 删除用户行为 * @author colin */ public function del() { $id = $this->getArrayParam('id'); if (empty($id)) { return $this->error("非法操作!", ''); } $map['id'] = array('IN', $id); $result = db('Action')->where($map)->delete(); if ($result) { action_log('delete_action', 'Action', $id, session('user_auth.uid')); return $this->success('删除成功!'); } else { return $this->error('删除失败!'); } } /** * @title 修改用户行为状态 * @author colin */ public function setstatus() { $id = $this->getArrayParam('id'); if (empty($id)) { return $this->error("非法操作!", ''); } $status = input('get.status', '', 'trim,intval'); $message = !$status ? '禁用' : '启用'; $map['id'] = array('IN', $id); $result = db('Action')->where($map)->setField('status', $status); if ($result !== false) { action_log('setstatus_action', 'Action', $id, session('user_auth.uid')); return $this->success('设置' . $message . '状态成功!'); } else { return $this->error('设置' . $message . '状态失败!'); } } /** * @title 小程序列表 * @author huajie */ public function pay() { return $this->fetch(); } /** * @title 查看行为日志 * @author huajie */ public function detail($id = 0) { $model = model('ActionLog'); if (empty($id)) { return $this->error('参数错误!'); } $info = $model::get($id); $info['title'] = get_action($info['action_id'], 'title'); $info['user_id'] = get_username($info['user_id']); $info['action_ip'] = long2ip($info['action_ip']); $info['create_time'] = date('Y-m-d H:i:s', $info['create_time']); $data = array( 'info' => $info, 'keyList' => $model->keyList, ); $this->assign($data); $this->setMeta('查看行为日志'); return $this->fetch(); } /** * @title 删除日志 * @param mixed $id * @author huajie */ public function dellog() { $id = $this->getArrayParam('id'); if (empty($id)) { return $this->error("非法操作!", ''); } $map['id'] = array('IN', $id); $res = db('ActionLog')->where($map)->delete(); if ($res !== false) { action_log('delete_actionlog', 'ActionLog', $id, session('user_auth.uid')); return $this->success('删除成功!'); } else { return $this->error('删除失败!'); } } /** * @title 清空日志 */ public function clear($id = '') { $res = db('ActionLog')->where('1=1')->delete(); if ($res !== false) { //记录行为 action_log('clear_actionlog', 'ActionLog', $id, session('user_auth.uid')); return $this->success('日志清空成功!'); } else { return $this->error('日志清空失败!'); } } }