123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?php
- // +—————————————————————————————————————————————————————————————————————
- // | Created by Yunbao
- // +—————————————————————————————————————————————————————————————————————
- // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
- // +—————————————————————————————————————————————————————————————————————
- // | Author: https://gitee.com/yunbaokeji
- // +—————————————————————————————————————————————————————————————————————
- // | Date: 2022-04-30
- // +—————————————————————————————————————————————————————————————————————
- namespace app\user\controller;
- use app\user\logic\UserActionLogic;
- use cmf\controller\AdminBaseController;
- use think\Db;
- /**
- * Class AdminUserActionController
- * @package app\user\controller
- */
- class AdminUserActionController extends AdminBaseController
- {
- /**
- * 用户操作管理
- * @adminMenu(
- * 'name' => '用户操作管理',
- * 'parent' => 'admin/Setting/default',
- * 'display'=> true,
- * 'hasView'=> true,
- * 'order' => 10000,
- * 'icon' => '',
- * 'remark' => '用户操作管理',
- * 'param' => ''
- * )
- */
- public function index()
- {
- $where = [];
- $request = input('request.');
- if (!empty($request['uid'])) {
- $where['id'] = intval($request['uid']);
- }
- $keywordComplex = [];
- if (!empty($request['keyword'])) {
- $keyword = $request['keyword'];
- $keywordComplex['user_login'] = ['like', "%$keyword%"];
- $keywordComplex['user_nicename'] = ['like', "%$keyword%"];
- $keywordComplex['user_email'] = ['like', "%$keyword%"];
- }
- $actions = Db::name('user_action')->paginate(20);
- // 获取分页显示
- $page = $actions->render();
- $this->assign('actions', $actions);
- $this->assign('page', $page);
- // 渲染模板输出
- return $this->fetch();
- }
- /**
- * 编辑用户操作
- * @adminMenu(
- * 'name' => '编辑用户操作',
- * 'parent' => 'index',
- * 'display'=> false,
- * 'hasView'=> true,
- * 'order' => 10000,
- * 'icon' => '',
- * 'remark' => '编辑用户操作',
- * 'param' => ''
- * )
- */
- public function edit()
- {
- $id = $this->request->param('id', 0, 'intval');
- $action = Db::name('user_action')->where('id', $id)->find();
- $this->assign($action);
- return $this->fetch();
- }
- /**
- * 编辑用户操作提交
- * @adminMenu(
- * 'name' => '编辑用户操作提交',
- * 'parent' => 'index',
- * 'display'=> false,
- * 'hasView'=> false,
- * 'order' => 10000,
- * 'icon' => '',
- * 'remark' => '编辑用户操作提交',
- * 'param' => ''
- * )
- */
- public function editPost()
- {
- $id = $this->request->param('id', 0, 'intval');
- $data = $this->request->param();
- Db::name('user_action')->where('id', $id)
- ->strict(false)
- ->field('score,coin,reward_number,cycle_type,cycle_time')
- ->update($data);
- $this->success('保存成功!');
- }
- /**
- * 同步用户操作
- * @adminMenu(
- * 'name' => '同步用户操作',
- * 'parent' => 'index',
- * 'display'=> false,
- * 'hasView'=> true,
- * 'order' => 10000,
- * 'icon' => '',
- * 'remark' => '同步用户操作',
- * 'param' => ''
- * )
- */
- public function sync()
- {
- $apps = cmf_scan_dir(APP_PATH . '*', GLOB_ONLYDIR);
- array_push($apps, 'admin', 'user');
- foreach ($apps as $app) {
- UserActionLogic::importUserActions($app);
- }
- return $this->fetch();
- }
- }
|