mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-06 01:52:48 +08:00
项目完成服务器信息和配置文件;
This commit is contained in:
226
app/admin/controller/App.php
Normal file
226
app/admin/controller/App.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Request;
|
||||
use think\facade\View;
|
||||
use app\model\App as ModelApp;
|
||||
use app\model\UploadFiles;
|
||||
|
||||
class App extends Common
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
|
||||
$app_list = ModelApp::paginate(10);
|
||||
|
||||
View::assign('app_list',$app_list);
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
|
||||
$installed_app_list = ModelApp::column('mark_id');
|
||||
|
||||
$app_list = get_app_info();
|
||||
|
||||
View::assign('app_list',$app_list);
|
||||
View::assign('installed_app_list',$installed_app_list);
|
||||
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
//
|
||||
$post_data = $request->post();
|
||||
|
||||
$model_app = ModelApp::where('mark_id',$post_data['mark_id'])->find();
|
||||
|
||||
if(!empty($model_app)){
|
||||
return json_message('应用已存在,不能重复创建');
|
||||
}
|
||||
|
||||
$model_app = new ModelApp();
|
||||
|
||||
if(!empty($post_data['poster'])){
|
||||
UploadFiles::update(['userd_time'=>time()],['save_name'=>$post_data['poster']]);
|
||||
}
|
||||
|
||||
if(!empty($post_data['detail'])){
|
||||
|
||||
foreach ($post_data['detail'] as $key => $value) {
|
||||
if(isset($value['insert'])){
|
||||
if(isset($value['insert']['image'])){
|
||||
$full_save_name = $value['insert']['image'];
|
||||
$save_name = de_source_link($full_save_name);
|
||||
if($save_name){
|
||||
UploadFiles::update(['used_time'=>time()],['save_name'=>$save_name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$model_app->data($post_data,true);
|
||||
|
||||
$model_app->save();
|
||||
|
||||
return json_message();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
$model_app = ModelApp::find($id);
|
||||
$app_list = get_app_info();
|
||||
|
||||
View::assign('app_list',$app_list);
|
||||
View::assign('app',$model_app);
|
||||
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
//
|
||||
$post_data = $request->post();
|
||||
|
||||
$model_app = ModelApp::where('id',$id)->find();
|
||||
|
||||
if(empty($model_app)){
|
||||
return json_message('应用不存在');
|
||||
}
|
||||
|
||||
if(!empty($post_data['poster'])){
|
||||
if($post_data['poster'] != $model_app->getData('poster')){
|
||||
UploadFiles::destroy(['save_name'=>$model_app->getData('poster')]);
|
||||
UploadFiles::update(['userd_time'=>time()],['save_name'=>$post_data['poster']]);
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($post_data['detail'])){
|
||||
$image_list = [];
|
||||
$new_image_list = [];
|
||||
foreach ($model_app->detail as $key => $value) {
|
||||
if(isset($value['insert'])){
|
||||
if(isset($value['insert']['image'])){
|
||||
$full_save_name = $value['insert']['image'];
|
||||
$save_name = de_source_link($full_save_name);
|
||||
if($save_name){
|
||||
$image_list[] = $save_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($post_data['detail'] as $key => $value) {
|
||||
if(isset($value['insert'])){
|
||||
if(isset($value['insert']['image'])){
|
||||
$full_save_name = $value['insert']['image'];
|
||||
$save_name = de_source_link($full_save_name);
|
||||
if($save_name){
|
||||
$new_image_list[] = $save_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$del_image_list = array_diff($image_list,$new_image_list);
|
||||
|
||||
foreach ($del_image_list as $key => $value) {
|
||||
UploadFiles::destroy(['save_name'=>$value]);
|
||||
}
|
||||
|
||||
$add_image_list = array_diff($new_image_list,$image_list);
|
||||
|
||||
foreach ($add_image_list as $key => $value) {
|
||||
UploadFiles::update(['used_time'=>time()],['save_name'=>$value]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$model_app->data($post_data,true);
|
||||
|
||||
$model_app->save();
|
||||
|
||||
return json_message();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
//
|
||||
$model_app = ModelApp::find($id);
|
||||
|
||||
if(!empty($model_app->getData('poster'))){
|
||||
UploadFiles::udpate(['delete_time'=>time()],['save_name'=>$model_app->getData('poster')]);
|
||||
}
|
||||
|
||||
if(!empty($model_app->getData('detail'))){
|
||||
foreach ($model_app->detail as $key => $value) {
|
||||
if(isset($value['insert'])){
|
||||
if(isset($value['insert']['image'])){
|
||||
$full_save_name = $value['insert']['image'];
|
||||
$save_name = de_source_link($full_save_name);
|
||||
if($save_name){
|
||||
UploadFiles::update(['delete_time'=>time()],['save_name'=>$save_name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$model_app->delete();
|
||||
|
||||
return json_message();
|
||||
}
|
||||
}
|
||||
34
app/admin/controller/Common.php
Normal file
34
app/admin/controller/Common.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use think\facade\Session;
|
||||
use app\model\Admin;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
class Common extends BaseController{
|
||||
|
||||
public $adminInfo = null;
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
|
||||
$admin_id = Session::get('admin_id');
|
||||
|
||||
if($this->request->controller() !== 'Login'){
|
||||
|
||||
if(empty($admin_id)){
|
||||
return $this->error('请登录','admin/Login/index');
|
||||
}
|
||||
|
||||
$this->adminInfo = Admin::find(Session::get('admin_id'));
|
||||
|
||||
if(empty($this->adminInfo)){
|
||||
if($this->request->controller() !== 'Login'){
|
||||
throw new HttpResponseException(redirect('admin/Login/index'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
94
app/admin/controller/Index.php
Normal file
94
app/admin/controller/Index.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Request;
|
||||
use think\facade\Session;
|
||||
use think\facade\View;
|
||||
|
||||
class Index extends Common
|
||||
{
|
||||
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
51
app/admin/controller/Login.php
Normal file
51
app/admin/controller/Login.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Request;
|
||||
use think\facade\View;
|
||||
use think\facade\Validate;
|
||||
use think\validate\ValidateRule as Rule;
|
||||
use app\model\Admin;
|
||||
use think\facade\Session;
|
||||
|
||||
class Login extends Common
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
|
||||
public function auth()
|
||||
{
|
||||
$post_data = $this->request->post();
|
||||
|
||||
$validate = Validate::rule('account',Rule::isRequire())
|
||||
->rule('password',Rule::isRequire());
|
||||
|
||||
if(!$validate->check($post_data)){
|
||||
return json_message($validate->getError());
|
||||
}
|
||||
|
||||
$model_admin = Admin::where('account',$post_data['account'])->find();
|
||||
|
||||
if(empty($model_admin)){
|
||||
return json_message('帐号不存在');
|
||||
}
|
||||
|
||||
if($model_admin->getData('password') !== md5($post_data['password'].$model_admin->getData('salt'))){
|
||||
return json_message('密码错误');
|
||||
}
|
||||
|
||||
Session::set('admin_id',$model_admin->id);
|
||||
|
||||
return json_message();
|
||||
}
|
||||
}
|
||||
84
app/admin/controller/Member.php
Normal file
84
app/admin/controller/Member.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Request;
|
||||
|
||||
class Member extends Common
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
67
app/admin/controller/System.php
Normal file
67
app/admin/controller/System.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Request;
|
||||
use think\facade\View;
|
||||
use app\model\SystemConfig;
|
||||
use think\facade\Cache;
|
||||
use app\model\UploadFiles;
|
||||
use EasyWeChat\Factory;
|
||||
use think\facade\Config;
|
||||
use app\model\WxPublicAccount;
|
||||
|
||||
class System extends Common
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
public function others()
|
||||
{
|
||||
|
||||
return View::fetch();
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
|
||||
$upload_files_config = [
|
||||
'site_logo'
|
||||
];
|
||||
|
||||
$post_data = $this->request->post();
|
||||
|
||||
$list = SystemConfig::column('value','name');
|
||||
|
||||
foreach ($post_data as $key => $value) {
|
||||
if(\in_array($key,$upload_files_config)){
|
||||
$old_save_name = get_system_config($key);
|
||||
UploadFiles::update(['used_time'=>time()],['save_name'=>$value]);
|
||||
if($old_save_name != $value){
|
||||
UploadFiles::destroy(['save_name'=>$old_save_name]);
|
||||
}
|
||||
}
|
||||
if(isset($list[$key])){
|
||||
SystemConfig::where('name',$key)->update(['value'=>$value]);
|
||||
}else{
|
||||
$model_sysconfig = new SystemConfig();
|
||||
$model_sysconfig->name = $key;
|
||||
$model_sysconfig->value = $value;
|
||||
$model_sysconfig->save();
|
||||
}
|
||||
|
||||
$list[$key] = $value;
|
||||
}
|
||||
|
||||
Cache::set('system_config',$list);
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user