first commit
This commit is contained in:
86
application/system/controller/Article.php
Normal file
86
application/system/controller/Article.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Article as ArticleModel;
|
||||
use app\common\service\Article as ArticleService;
|
||||
use think\Request;
|
||||
|
||||
class Article extends _Init
|
||||
{
|
||||
/**
|
||||
* 文章列表
|
||||
* @param string $title 要搜索的文章标题
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index($title = '')
|
||||
{
|
||||
$map['status'] = ['egt', 0];
|
||||
if (!empty($title)) {
|
||||
$map['title'] = ['like', "%$title%"];
|
||||
}
|
||||
$this->list = ArticleModel::where($map)->paginate();
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文章
|
||||
* @param Request $Request 数据集
|
||||
*/
|
||||
public function add(Request $Request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = ArticleService::create($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->list = ArticleService::categoryList();
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 编辑文章
|
||||
* @param Request $Request 数据集
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] 返回 编辑的结果
|
||||
*/
|
||||
public function edit(Request $Request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = ArticleService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->list = ArticleService::categoryList();
|
||||
$this->info = ArticleModel::get($id);
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 删除文章
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = ArticleService::del($id);
|
||||
return $this->back($result);
|
||||
}
|
||||
/**
|
||||
* 修改文章状态
|
||||
* @param [type] $id 文章id
|
||||
* @param [type] $status 状态
|
||||
* @return [type] 修改文章结果
|
||||
*/
|
||||
public function status($id, $status)
|
||||
{
|
||||
$result = ArticleService::status($id, $status);
|
||||
return $this->back($result);
|
||||
}
|
||||
}
|
||||
84
application/system/controller/Articlemodel.php
Normal file
84
application/system/controller/Articlemodel.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\ArticleModel as ArticleModelModel;
|
||||
use app\common\service\ArticleModel as ArticleModelService;
|
||||
use think\Request;
|
||||
|
||||
class Articlemodel extends _Init
|
||||
{
|
||||
/**
|
||||
* 文章列表
|
||||
* @param string $title 要搜索的文章标题
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index($title = '')
|
||||
{
|
||||
$map['status'] = ['egt', 0];
|
||||
$this->list = ArticleModelModel::where($map)->paginate();
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文章
|
||||
* @param Request $Request 数据集
|
||||
*/
|
||||
public function add(Request $Request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = ArticleModelService::create($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑文章
|
||||
* @param Request $Request 数据集
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] 返回 编辑的结果
|
||||
*/
|
||||
public function edit(Request $Request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = ArticleModelService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->info = ArticleModelModel::get($id);
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = ArticleModelService::del($id);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文章状态
|
||||
* @param [type] $id 文章id
|
||||
* @param [type] $status 状态
|
||||
* @return [type] 修改文章结果
|
||||
*/
|
||||
public function status($id, $status)
|
||||
{
|
||||
$result = ArticleModelService::status($id, $status);
|
||||
return $this->back($result);
|
||||
}
|
||||
}
|
||||
148
application/system/controller/Auth.php
Normal file
148
application/system/controller/Auth.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Auth as AuthModel;
|
||||
use app\common\model\Member as MemberModel;
|
||||
use app\common\service\Auth as AuthService;
|
||||
use think\Request;
|
||||
|
||||
class Auth extends _Init
|
||||
{
|
||||
/**
|
||||
* 授权列表
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$map['status'] = ['egt', 0];
|
||||
|
||||
$this->list = AuthModel::where($map)->paginate();
|
||||
return $this->fetch();
|
||||
}
|
||||
/**
|
||||
* 添加授权分组
|
||||
* @param Request $request 要添加的分组数据
|
||||
*/
|
||||
public function add(Request $request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $request->post();
|
||||
$result = AuthService::add($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 编辑授权分组
|
||||
* @param [type] $id 授权分组id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $request->post();
|
||||
$result = AuthService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->info = AuthModel::get($id);
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分组
|
||||
* @param [type] $id 授权分组 id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = AuthService::del($id);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置分组状态 正常 和 禁用
|
||||
* @param [type] $id 授权分组 id
|
||||
* @param [type] $status 成功 还是 失败 失败返回失败的信息
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function status($id, $status)
|
||||
{
|
||||
$result = AuthService::status($id, $status);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单授权
|
||||
* @param [type] $id 授权分组id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function menu(Request $request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$rules = $request->post('rules/a');
|
||||
$result = AuthService::setAuthRuels($id, $rules);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->assign('node_list', AuthService::getAuthRules($id));
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权页面
|
||||
* @param Request $request 提交的信息
|
||||
* @param [type] $id 分组id
|
||||
* @return [type] 用户列表
|
||||
*/
|
||||
public function user(Request $request, $id)
|
||||
{
|
||||
$authed = AuthService::getAuthedUids($id);
|
||||
|
||||
if (IS_POST) {
|
||||
$username = $request->post('username');
|
||||
$list = MemberModel::field('id,username')->whereOr(function ($query) use ($username) {
|
||||
$query->whereOr('id', $username)->whereOr('username', 'like', "%{$username}%");
|
||||
})->where('status', 1)->where('id', 'notin', $authed)->limit(10)->select();
|
||||
foreach ($list as $key => &$value) {
|
||||
$value['nickname'] = $value->info->nickname;
|
||||
}
|
||||
return $this->success('', '', $list);
|
||||
} else {
|
||||
$this->list = MemberModel::where('status', 1)->where('id', 'in', $authed)->paginate();
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 把用户移除分组
|
||||
* @param [type] $id 分组id
|
||||
* @param [type] $uid 用户id
|
||||
* @return [type] 返回结果
|
||||
*/
|
||||
public function remove($id, $uid)
|
||||
{
|
||||
$result = AuthService::removeAuthUser($id, $uid);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户授权
|
||||
* @param [type] $id 分组id
|
||||
* @param [type] $uid 用户ids
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function insert($id, $uid)
|
||||
{
|
||||
$result = AuthService::setAuthUser($id, $uid);
|
||||
return $this->back($result);
|
||||
}
|
||||
}
|
||||
113
application/system/controller/Banner.php
Normal file
113
application/system/controller/Banner.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Advert as AdvertModel;
|
||||
use app\common\model\AdvertDetail as AdvertDetailModel;
|
||||
use app\common\service\Advert as AdvertService;
|
||||
use app\common\service\AdvertDetail as AdvertDetailService;
|
||||
|
||||
class Banner extends _Init
|
||||
{
|
||||
|
||||
public function index($title = '')
|
||||
{
|
||||
$map['status'] = ['egt', 0];
|
||||
if ($title) {
|
||||
$map['title'] = ['like', "%{$title}%"];
|
||||
}
|
||||
$this->list = AdvertModel::where($map)->paginate();
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $this->request->post();
|
||||
$res = AdvertService::add($data);
|
||||
return $this->back($res);
|
||||
} else {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $this->request->post();
|
||||
$res = AdvertService::edit($data);
|
||||
return $this->back($res);
|
||||
} else {
|
||||
$this->assign('info', AdvertModel::get($id));
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
|
||||
public function del($id)
|
||||
{
|
||||
$res = AdvertService::del($id);
|
||||
return $this->back($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param [type] $id [description]
|
||||
* @param [type] $status [description]
|
||||
* @param [type] $type [description]
|
||||
*/
|
||||
public function status($id, $status, $type)
|
||||
{
|
||||
$res = AdvertService::status($id, $status, $type);
|
||||
return $this->back($res);
|
||||
}
|
||||
|
||||
public function detail($advert_id)
|
||||
{
|
||||
$this->info = AdvertModel::get($advert_id);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function banadd($advert_id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $this->request->post();
|
||||
$data['advert_id'] = $advert_id;
|
||||
unset($data['image']);
|
||||
$res = AdvertDetailService::add($data);
|
||||
return $this->back($res);
|
||||
} else {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
public function banedit($id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $this->request->post();
|
||||
unset($data['image']);
|
||||
$res = AdvertDetailService::edit($data);
|
||||
return $this->back($res);
|
||||
} else {
|
||||
$this->assign('info', AdvertDetailModel::get($id));
|
||||
return $this->fetch('banadd');
|
||||
}
|
||||
}
|
||||
|
||||
public function bandel($id)
|
||||
{
|
||||
$res = AdvertDetailService::del($id);
|
||||
return $this->back($res);
|
||||
}
|
||||
|
||||
public function banstatus($id, $status, $type)
|
||||
{
|
||||
$res = AdvertDetailService::status($id, $status, $type);
|
||||
return $this->back($res);
|
||||
}
|
||||
}
|
||||
93
application/system/controller/Category.php
Normal file
93
application/system/controller/Category.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Category as CategoryModel;
|
||||
use app\common\service\Category as CategoryService;
|
||||
use think\Request;
|
||||
|
||||
class Category extends _Init
|
||||
{
|
||||
/**
|
||||
* 分类列表
|
||||
* @param string $pid 上级分类id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index($pid = '')
|
||||
{
|
||||
if (is_numeric($pid)) {
|
||||
$map['pid'] = $pid;
|
||||
} else {
|
||||
$map['pid'] = 0;
|
||||
}
|
||||
$map['status'] = ['egt', 0];
|
||||
|
||||
$this->list = CategoryModel::where($map)->order('sort desc,update_time desc')->paginate();
|
||||
$this->info = CategoryModel::get($pid);
|
||||
$this->menu = CategoryService::tree();
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加分类
|
||||
* @param Request $Request [description]
|
||||
* @param integer $pid 上级id
|
||||
*/
|
||||
public function add(Request $Request, $pid = 0)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = CategoryService::add($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$info['pid'] = $pid;
|
||||
$this->info = $info;
|
||||
$this->up_cates = CategoryService::treeList();
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 编辑分类
|
||||
* @param [type] $id 分类id
|
||||
*/
|
||||
public function edit(Request $Request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = CategoryService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->up_cates = CategoryService::treeList($id);
|
||||
$this->info = CategoryModel::get($id);
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 删除分类
|
||||
* @param [type] $id 分类id
|
||||
* @return [type] 返回删除的结果
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = CategoryService::del($id);
|
||||
$this->back($result);
|
||||
}
|
||||
/**
|
||||
* 设置分类状态
|
||||
* @param [type] $id 分类id
|
||||
* @param [type] $status 状态
|
||||
* @param [type] $type 要设置的字段 status
|
||||
* @return [type] 返回结果
|
||||
*/
|
||||
public function status($id, $status, $type)
|
||||
{
|
||||
$result = CategoryService::status($id, $status, $type);
|
||||
return $this->back($result);
|
||||
}
|
||||
}
|
||||
90
application/system/controller/Cause.php
Normal file
90
application/system/controller/Cause.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Content as ContentModel;
|
||||
use app\common\service\Content as ContentService;
|
||||
use think\Request;
|
||||
|
||||
class Cause extends _Init
|
||||
{
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
* @param string $title 要搜索的文章标题
|
||||
* @return [type] [description]
|
||||
*/
|
||||
|
||||
public function index($title = '')
|
||||
{
|
||||
$CategoryIds = ContentService::getCategoryIds('cause');
|
||||
$map = [
|
||||
'status' => ['egt', 0],
|
||||
'title' => ['like', "%$title%"],
|
||||
'category_id' => ['in', $CategoryIds],
|
||||
];
|
||||
$this->list = ContentModel::where($map)->order('id desc')->paginate();
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文章
|
||||
* @param Request $Request 数据集
|
||||
*/
|
||||
public function add(Request $Request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = ContentService::create($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->list = ContentService::categoryList('cause');
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 编辑文章
|
||||
* @param Request $Request 数据集
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] 返回 编辑的结果
|
||||
*/
|
||||
public function edit(Request $Request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = ContentService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->list = ContentService::categoryList('Cause');
|
||||
$this->info = ContentModel::get($id);
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 删除文章
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = ContentService::del($id);
|
||||
return $this->back($result);
|
||||
}
|
||||
/**
|
||||
* 修改文章状态
|
||||
* @param [type] $id 文章id
|
||||
* @param [type] $status 状态
|
||||
* @return [type] 修改文章结果
|
||||
*/
|
||||
public function status($id, $status)
|
||||
{
|
||||
$result = ContentService::status($id, $status);
|
||||
return $this->back($result);
|
||||
}
|
||||
}
|
||||
114
application/system/controller/Config.php
Normal file
114
application/system/controller/Config.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Config as ConfigModel;
|
||||
use app\common\service\Config as ConfigService;
|
||||
use think\Cache;
|
||||
use think\Request;
|
||||
|
||||
class Config extends _Init
|
||||
{
|
||||
|
||||
/**
|
||||
* 批量设置的页面
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if (IS_POST) {
|
||||
$config = $this->request->post('config/a');
|
||||
$result = ConfigService::batchEdit($config);
|
||||
$this->back($result);
|
||||
} else {
|
||||
$map = [
|
||||
'status' => 1,
|
||||
];
|
||||
$this->list = ConfigModel::where($map)->order('sort asc')->select();
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有参数页面
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function params()
|
||||
{
|
||||
$map = [
|
||||
'status' => ['egt', 0],
|
||||
];
|
||||
$this->list = ConfigModel::where($map)->order('sort asc,create_time desc,update_time desc')->paginate(10);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除缓存
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
if (Cache::clear()) {
|
||||
return $this->success('清除缓存成功');
|
||||
} else {
|
||||
return $this->error();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配置
|
||||
*/
|
||||
public function add(Request $request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $request->post();
|
||||
$result = ConfigService::add($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑配置
|
||||
* @param [type] $id [description]
|
||||
*/
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $request->post();
|
||||
$result = ConfigService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->assign('info', ConfigModel::find($id));
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
* @param [type] $id [description]
|
||||
* @param [type] $status [description]
|
||||
* @param [type] $type [description]
|
||||
*/
|
||||
public function status($id, $status, $type)
|
||||
{
|
||||
$result = ConfigService::status($id, $status, $type);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param [type] $id [description]
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = ConfigService::del($id);
|
||||
return $this->back($result);
|
||||
}
|
||||
}
|
||||
67
application/system/controller/Database.php
Normal file
67
application/system/controller/Database.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\service\Database as DatabaseService;
|
||||
|
||||
class Database extends _Init
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
$list = DatabaseService::getTables();
|
||||
$this->assign('list', $list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 备份的方法
|
||||
* @param [type] $tables [description]
|
||||
* @param [type] $id [description]
|
||||
* @param [type] $start [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function backup($tables = null, $id = null, $start = null)
|
||||
{
|
||||
$result = DatabaseService::backup($tables, $id, $start);
|
||||
if (is_array($result) && !empty($result)) {
|
||||
return $this->success($result['msg'], '', $result['data']);
|
||||
} else {
|
||||
return $this->error($result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 备份列表
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function import()
|
||||
{
|
||||
$list = DatabaseService::backupList();
|
||||
$this->assign('list', $list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除备份文件
|
||||
* @param [type] $time [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function del($time)
|
||||
{
|
||||
if (IS_POST && is_array($time)) {
|
||||
$result = DatabaseService::del($time);
|
||||
if ($result === true) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->error($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
113
application/system/controller/Direct.php
Normal file
113
application/system/controller/Direct.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Direct as DirectModel;
|
||||
use app\common\service\Direct as DirectService;
|
||||
use think\Request;
|
||||
|
||||
class Direct extends _Init
|
||||
{
|
||||
/**
|
||||
* 文章列表
|
||||
* @param string $title 要搜索的文章标题
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index($type = '', $title = '')
|
||||
{
|
||||
$map['status'] = ['egt', 0];
|
||||
if (!empty($type)) {
|
||||
$map['type'] = $type;
|
||||
}
|
||||
if (!empty($title)) {
|
||||
$map['title'] = ['like', "%$title%"];
|
||||
}
|
||||
$this->list = DirectModel::where($map)->order("sort asc,create_time desc")->paginate();
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文章
|
||||
* @param Request $Request 数据集
|
||||
*/
|
||||
public function add(Request $Request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = DirectService::create($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 编辑文章
|
||||
* @param Request $Request 数据集
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] 返回 编辑的结果
|
||||
*/
|
||||
public function edit(Request $Request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = DirectService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->info = DirectModel::get($id);
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 删除文章
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = DirectService::del($id);
|
||||
return $this->back($result);
|
||||
}
|
||||
/**
|
||||
* 修改文章状态
|
||||
* @param [type] $id 文章id
|
||||
* @param [type] $status 状态
|
||||
* @return [type] 修改文章结果
|
||||
*/
|
||||
public function status($id, $status)
|
||||
{
|
||||
$result = DirectService::status($id, $status);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
public function upload($type = '')
|
||||
{
|
||||
if (!in_array($type, ['image', 'file', 'video', 'audio'])) {
|
||||
$result = ['code' => 0, 'msg' => '不支持的上传类型'];
|
||||
} else {
|
||||
$file = request()->file($type);
|
||||
dump($file);die();
|
||||
// $result = StorageService::upload($type);
|
||||
}
|
||||
|
||||
if (is_array($result) && !empty($result)) {
|
||||
$ret = [
|
||||
'code' => 1,
|
||||
'data' => $result,
|
||||
];
|
||||
} else {
|
||||
$ret = [
|
||||
'code' => 0,
|
||||
'msg' => $result,
|
||||
];
|
||||
}
|
||||
|
||||
return Response::create($ret, 'json');
|
||||
}
|
||||
}
|
||||
87
application/system/controller/Help.php
Normal file
87
application/system/controller/Help.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Help as HelpModel;
|
||||
use app\common\service\Help as HelpService;
|
||||
use think\Request;
|
||||
|
||||
class Help extends _Init
|
||||
{
|
||||
/**
|
||||
* 文章列表
|
||||
* @param string $title 要搜索的文章标题
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index($title = '')
|
||||
{
|
||||
$map['status'] = ['egt', 0];
|
||||
if (!empty($title)) {
|
||||
$map['title'] = ['like', "%$title%"];
|
||||
}
|
||||
$this->list = HelpModel::where($map)->paginate();
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文章
|
||||
* @param Request $Request 数据集
|
||||
*/
|
||||
public function add(Request $Request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = HelpService::create($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑文章
|
||||
* @param Request $Request 数据集
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] 返回 编辑的结果
|
||||
*/
|
||||
public function edit(Request $Request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = HelpService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->info = HelpModel::get($id);
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = HelpService::del($id);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文章状态
|
||||
* @param [type] $id 文章id
|
||||
* @param [type] $status 状态
|
||||
* @return [type] 修改文章结果
|
||||
*/
|
||||
public function status($id, $status)
|
||||
{
|
||||
$result = HelpService::status($id, $status);
|
||||
return $this->back($result);
|
||||
}
|
||||
}
|
||||
69
application/system/controller/Index.php
Normal file
69
application/system/controller/Index.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\service\Member as MemberService;
|
||||
use app\common\service\Menu as MenuService;
|
||||
use think\Request;
|
||||
|
||||
class Index extends _Init
|
||||
{
|
||||
/**
|
||||
* 后台首页
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->user = MemberService::info(UID);
|
||||
$this->menu = MenuService::show(UID);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人信息
|
||||
* @param Request $request 提交的信息 用户名
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function info(Request $request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $request->post();
|
||||
if (MemberService::editInfo(UID, $data, 'nickname') === true) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error(MemberService::getError());
|
||||
}
|
||||
} else {
|
||||
$this->assign('info', MemberService::info(UID));
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 修改密码
|
||||
* @param Request $request 数据集
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function password(Request $request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$old = $request->post('oldpass');
|
||||
$new = $request->post('newpass');
|
||||
$repass = $request->post('repass');
|
||||
$result = MemberService::changePassword(UID, $old, $new, $repass);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
public function main()
|
||||
{
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
67
application/system/controller/Login.php
Normal file
67
application/system/controller/Login.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\service\Member as MemberService;
|
||||
use think\Cookie;
|
||||
use think\Request;
|
||||
use tools\Initialize;
|
||||
|
||||
class Login extends Initialize
|
||||
{
|
||||
/**
|
||||
* 登录页面 和 登录操作
|
||||
* @param Request $request 提交的信息 用户名 密码 验证码 是否记住帐号
|
||||
* @return [type] 返回登录结果信息
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $request->post();
|
||||
|
||||
$res = $this->validate($data, [
|
||||
'verify|验证码' => 'require|captcha',
|
||||
]);
|
||||
if ($res !== true) {
|
||||
return $this->error($res);
|
||||
}
|
||||
|
||||
$username = $request->post('username');
|
||||
$password = $request->post('password');
|
||||
$remember = $request->post('rememberMe');
|
||||
if ($remember == true) {
|
||||
Cookie::set('remember_username', $username);
|
||||
}
|
||||
if (MemberService::login($username, $password) === true) {
|
||||
return ['code' => 1, 'msg' => '登录成功'];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '登录失败'];
|
||||
}
|
||||
} else {
|
||||
if (self::isLogin()) {
|
||||
$this->redirect('/');
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登陆
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
$result = MemberService::logout();
|
||||
|
||||
if (MemberService::logout() === true) {
|
||||
return ['code' => 1, 'msg' => '退出成功'];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '退出失败'];
|
||||
}
|
||||
}
|
||||
}
|
||||
23
application/system/controller/Logs.php
Normal file
23
application/system/controller/Logs.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
class Logs extends _Init
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
#Todo...
|
||||
}
|
||||
|
||||
public function system()
|
||||
{
|
||||
#Todo..
|
||||
}
|
||||
}
|
||||
79
application/system/controller/Member.php
Normal file
79
application/system/controller/Member.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Member as MemberModel;
|
||||
use app\common\model\MemberList as MemberListModel;
|
||||
use app\common\service\Member as MemberService;
|
||||
use think\Request;
|
||||
|
||||
class Member extends _Init
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
$model = new MemberModel();
|
||||
$model->alias('Member');
|
||||
$model = $model->hasWhere('info');
|
||||
$map = [
|
||||
'Member.status' => ['gt', 0],
|
||||
];
|
||||
$this->list = $model->where($map)->order('Member.update_time desc')->paginate();
|
||||
return $this->fetch();
|
||||
}
|
||||
/**
|
||||
* 添加用户
|
||||
* @param Request $request 用户的信息 username password
|
||||
*/
|
||||
public function add(Request $request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$username = $request->post('username');
|
||||
$password = $request->post('password');
|
||||
$result = MemberService::register($username, $password);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 设置用户状态
|
||||
* @param [type] $uid 用户id
|
||||
* @param [type] $status 要设置的状态 true false 正常 禁用
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function status($uid, $status)
|
||||
{
|
||||
$result = MemberService::status($uid, $status);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
* @param [type] $uid 用户id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function password(Request $request, $uid)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$password = $request->post('password');
|
||||
$result = MemberService::updatePassword($uid, $password);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->info = MemberModel::get($uid);
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
public function junior($pid)
|
||||
{
|
||||
$this->list = MemberListModel::where('uid', $pid)->paginate();
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
102
application/system/controller/Menu.php
Normal file
102
application/system/controller/Menu.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Menu as MenuModel;
|
||||
use app\common\service\Menu as MenuService;
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
use tools\Tree;
|
||||
|
||||
class Menu extends _Init
|
||||
{
|
||||
/**
|
||||
* 菜单列表
|
||||
* @param integer $pid 上级id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index($pid = 0)
|
||||
{
|
||||
$this->list = MenuModel::where('status', 'egt', 0)->where('pid', $pid)->order('sort asc')->paginate();
|
||||
$this->menu = MenuService::tree();
|
||||
$this->info = MenuModel::get($pid);
|
||||
return $this->fetch();
|
||||
}
|
||||
/**
|
||||
* 添加菜单
|
||||
* @param integer $pid 上级id
|
||||
*/
|
||||
public function add(Request $request, $pid = 0)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $request->post();
|
||||
$result = MenuService::add($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$info['pid'] = $pid;
|
||||
$this->info = $info;
|
||||
$this->up_menus = self::_treeShow();
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 编辑菜单
|
||||
* @param [type] $id 菜单id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $request->post();
|
||||
$result = MenuService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->info = MenuModel::get($id);
|
||||
$this->up_menus = self::_treeShow($id);
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
* @param [type] $id 要删除的菜单id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = MenuService::del($id);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置菜单状态
|
||||
* @param [type] $id 要设置的菜单id
|
||||
* @param [type] $status 要设置的状态 正常 和 禁用 true false
|
||||
* @param [type] $type 要设置的字段 status
|
||||
* @return [type] 返回操作的结果 成功 true 失败 返回失败的信息
|
||||
*/
|
||||
public function status($id, $status, $type)
|
||||
{
|
||||
$result = MenuService::status($id, $status, $type);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
private function _treeShow($id = 0)
|
||||
{
|
||||
$map = [];
|
||||
if ($id) {
|
||||
$map['id'] = ['neq', $id];
|
||||
}
|
||||
|
||||
$menus = Db::name('Menu')->where($map)->order('sort asc')->select();
|
||||
$menus = Tree::toFormatTree($menus);
|
||||
$menus = array_merge([0 => ['id' => 0, 'title_show' => '顶级菜单']], $menus);
|
||||
return $menus;
|
||||
}
|
||||
}
|
||||
95
application/system/controller/Score.php
Normal file
95
application/system/controller/Score.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Score as ScoreModel;
|
||||
use app\common\model\ScoreRules as ScoreRulesModel;
|
||||
use app\common\service\ScoreRules as ScoreRulesService;
|
||||
use think\Request;
|
||||
|
||||
/**
|
||||
* 积分
|
||||
*/
|
||||
class Score extends _Init
|
||||
{
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->list = ScoreModel::where('')->order('id desc')->paginate();
|
||||
return $this->fetch('');
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
$this->list = ScoreRulesModel::where('status', 1)->paginate();
|
||||
return $this->fetch('');
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加规则
|
||||
* @param Request $Request 数据集
|
||||
*/
|
||||
public function add(Request $Request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = ScoreRulesService::create($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑规则
|
||||
* @param Request $Request 数据集
|
||||
* @param [type] $id 规则id
|
||||
* @return [type] 返回 编辑的结果
|
||||
*/
|
||||
public function edit(Request $Request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = ScoreRulesService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->info = ScoreRulesModel::get($id);
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除规则
|
||||
* @param [type] $id 规则id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = ScoreRulesService::del($id);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改规则状态
|
||||
* @param [type] $id 规则id
|
||||
* @param [type] $status 状态
|
||||
* @return [type] 修改规则结果
|
||||
*/
|
||||
public function status($id, $status)
|
||||
{
|
||||
$result = ScoreRulesService::status($id, $status);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
}
|
||||
90
application/system/controller/Share.php
Normal file
90
application/system/controller/Share.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Content as ContentModel;
|
||||
use app\common\service\Content as ContentService;
|
||||
use think\Request;
|
||||
|
||||
class Share extends _Init
|
||||
{
|
||||
|
||||
/**
|
||||
* 文章列表
|
||||
* @param string $title 要搜索的文章标题
|
||||
* @return [type] [description]
|
||||
*/
|
||||
|
||||
public function index($title = '')
|
||||
{
|
||||
$CategoryIds = ContentService::getCategoryIds('share');
|
||||
$map = [
|
||||
'status' => ['egt', 0],
|
||||
'title' => ['like', "%$title%"],
|
||||
'category_id' => ['in', $CategoryIds],
|
||||
];
|
||||
$this->list = ContentModel::where($map)->order('create_time desc')->paginate();
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文章
|
||||
* @param Request $Request 数据集
|
||||
*/
|
||||
public function add(Request $Request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = ContentService::create($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->list = ContentService::categoryList('share');
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 编辑文章
|
||||
* @param Request $Request 数据集
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] 返回 编辑的结果
|
||||
*/
|
||||
public function edit(Request $Request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = ContentService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->list = ContentService::categoryList('share');
|
||||
$this->info = ContentModel::get($id);
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 删除文章
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = ContentService::del($id);
|
||||
return $this->back($result);
|
||||
}
|
||||
/**
|
||||
* 修改文章状态
|
||||
* @param [type] $id 文章id
|
||||
* @param [type] $status 状态
|
||||
* @return [type] 修改文章结果
|
||||
*/
|
||||
public function status($id, $status)
|
||||
{
|
||||
$result = ContentService::status($id, $status);
|
||||
return $this->back($result);
|
||||
}
|
||||
}
|
||||
106
application/system/controller/Storage.php
Normal file
106
application/system/controller/Storage.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\JobLog as JobLogModel;
|
||||
use app\common\model\Logs as LogsModel;
|
||||
use app\common\model\Storage as StorageModel;
|
||||
use app\common\service\Storage as StorageService;
|
||||
use think\Response;
|
||||
|
||||
class Storage extends _Init
|
||||
{
|
||||
/**
|
||||
* 资源管理
|
||||
* @param string $type [description]
|
||||
*/
|
||||
public function index($type = '')
|
||||
{
|
||||
$map = [];
|
||||
if ($type) {
|
||||
$map['type'] = $type;
|
||||
}
|
||||
|
||||
$this->assign('total', StorageService::total($map));
|
||||
$this->assign('types', StorageService::types());
|
||||
$this->assign('disk_use', StorageService::diskUse());
|
||||
|
||||
$list = StorageModel::where($map)->order('id desc')->paginate();
|
||||
$this->assign('list', $list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志管理
|
||||
*/
|
||||
public function logs()
|
||||
{
|
||||
$list = LogsModel::order('id desc')->paginate();
|
||||
$this->assign('list', $list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function queue()
|
||||
{
|
||||
$list = JobLogModel::order('id desc')->paginate();
|
||||
$this->assign('list', $list);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传单文件
|
||||
* @param string $type [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function upload($type = '')
|
||||
{
|
||||
if (!in_array($type, ['image', 'file', 'video', 'audio'])) {
|
||||
$result = ['code' => 0, 'msg' => '不支持的上传类型'];
|
||||
} else {
|
||||
$result = StorageService::upload($type);
|
||||
}
|
||||
|
||||
if (is_array($result) && !empty($result) && !isset($result['code'])) {
|
||||
$ret = [
|
||||
'code' => 1,
|
||||
'data' => $result,
|
||||
];
|
||||
} else {
|
||||
$ret = [
|
||||
'code' => 0,
|
||||
'msg' => $result,
|
||||
];
|
||||
}
|
||||
|
||||
return Response::create($ret, 'json');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑器上传文件
|
||||
*/
|
||||
public function editor()
|
||||
{
|
||||
$result = StorageService::upload('file');
|
||||
if (is_array($result) && !empty($result)) {
|
||||
$res = [
|
||||
'code' => 0,
|
||||
'data' => [
|
||||
'src' => $result['path'],
|
||||
'title' => $result['name'],
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$res = [
|
||||
'code' => 1,
|
||||
'msg' => $result,
|
||||
];
|
||||
}
|
||||
return Response::create($res, 'json');
|
||||
}
|
||||
}
|
||||
28
application/system/controller/Suggest.php
Normal file
28
application/system/controller/Suggest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Suggest as SuggestModel;
|
||||
|
||||
class Suggest extends _Init
|
||||
{
|
||||
|
||||
/**
|
||||
* 反馈列表
|
||||
* @return [type] [description]
|
||||
*/
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->list = SuggestModel::where('')->paginate();
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
32
application/system/controller/Vip.php
Normal file
32
application/system/controller/Vip.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\VipOrder;
|
||||
use app\common\service\Vip as VipService;
|
||||
|
||||
class Vip extends _Init
|
||||
{
|
||||
public function index($title = '')
|
||||
{
|
||||
$map = [];
|
||||
if (!empty($title)) {
|
||||
$ids = VipService::getIds($title);
|
||||
$map['uid'] = ['in', $ids];
|
||||
}
|
||||
$this->list = VipOrder::where($map)->order('create_time desc')->paginate();
|
||||
return $this->fetch('');
|
||||
}
|
||||
|
||||
public function info($id)
|
||||
{
|
||||
$this->list = VipOrder::where('uid', $id)->paginate();
|
||||
return $this->fetch('');
|
||||
}
|
||||
}
|
||||
109
application/system/controller/_Init.php
Normal file
109
application/system/controller/_Init.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Auth as AuthModel;
|
||||
use app\common\model\AuthUser as AuthUserModel;
|
||||
use think\Config;
|
||||
use think\Db;
|
||||
use tools\Initialize;
|
||||
|
||||
class _Init extends Initialize
|
||||
{
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
define('UID', self::isLogin());
|
||||
|
||||
if (!UID) {
|
||||
$this->redirect('login/index');
|
||||
}
|
||||
if (!$this->checkAuth(UID, CONTROLLER_NAME . '/' . ACTION_NAME)) {
|
||||
return $this->error('没有操作权限');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作成功跳转的快捷方法
|
||||
* @access protected
|
||||
* @param mixed $msg 提示信息
|
||||
* @param string $url 跳转的URL地址
|
||||
* @param mixed $data 返回的数据
|
||||
* @param integer $wait 跳转等待时间
|
||||
* @param array $header 发送的Header信息
|
||||
* @return void
|
||||
*/
|
||||
protected function success($msg = '', $url = null, $data = '', $wait = 3, array $header = [])
|
||||
{
|
||||
$msg = $msg ?: '操作成功';
|
||||
return parent::success($msg, $url, $data, $wait, $header);
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作错误跳转的快捷方法
|
||||
* @access protected
|
||||
* @param mixed $msg 提示信息
|
||||
* @param string $url 跳转的URL地址
|
||||
* @param mixed $data 返回的数据
|
||||
* @param integer $wait 跳转等待时间
|
||||
* @param array $header 发送的Header信息
|
||||
* @return void
|
||||
*/
|
||||
protected function error($msg = '', $url = null, $data = '', $wait = 3, array $header = [])
|
||||
{
|
||||
$msg = $msg ?: '未知错误';
|
||||
return parent::error($msg, $url, $data, $wait, $header);
|
||||
}
|
||||
|
||||
protected function back($result)
|
||||
{
|
||||
if ($result === true) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error($result);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 检查授权
|
||||
* @param [type] $uid 用户id
|
||||
* @param [type] $node 节点名 menu/index
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function checkAuth($uid, $node)
|
||||
{
|
||||
//查询设置的超级管理的ids
|
||||
$adminUsers = Config::get('administrator');
|
||||
if (!in_array($uid, $adminUsers)) {
|
||||
//获取当前页的菜单id
|
||||
$nodes = Db::name('Menu')->where('url', $node)->value('id');
|
||||
if ($nodes) {
|
||||
//获取当前用户的授权节点
|
||||
$authId = AuthUserModel::where('uid', $uid)->column('auth_id');
|
||||
$rules = AuthModel::where('id', 'in', $authId)->column('rules');
|
||||
if ($rules) {
|
||||
$rules = implode($rules, ',');
|
||||
$rules = explode(',', $rules);
|
||||
$rules = array_unique($rules);
|
||||
if (in_array($nodes, $rules)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user