First commit
This commit is contained in:
247
app/admin/controller/Admin.php
Executable file
247
app/admin/controller/Admin.php
Executable file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\AdminRest;
|
||||
use think\App;
|
||||
|
||||
use app\admin\model\Admin as AdminModel;
|
||||
use app\admin\model\User as UserModel;
|
||||
|
||||
class Admin extends AdminRest
|
||||
{
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
}
|
||||
//创建用户
|
||||
public function createAdmin() {
|
||||
$user = $this->_input['user'];
|
||||
$data = checkAccountIsExist($user['account'] ,$this->_uniacid);
|
||||
//判读账号是否存在
|
||||
if($data) return $this->error('account is exist ,please check again.');
|
||||
$user_id = uuid();
|
||||
$user['admin_id'] = $user_id;
|
||||
$user['offset'] = createOffset();
|
||||
$user['passwd'] = createPasswd($user['passwd'] ,$user['offset']);
|
||||
$user['uniacid'] = $this->_uniacid;
|
||||
//生成admin model
|
||||
$admin_model = new AdminModel();
|
||||
//检查用户是否存在
|
||||
if(isset($user['user_id'])) {
|
||||
$user_model = new UserModel();
|
||||
$user_data = $user_model->getUser(['user_id' =>$user['user_id']]);
|
||||
if(empty($user_data)) return $this->error('user is not exist ,please check user id.');
|
||||
//检查用户是否已经是管理员
|
||||
$admin_data = $admin_model->getAdmin(['user_id' => $user['user_id']]);
|
||||
if(!empty($admin_data)) return $this->error('the user is admin already .');
|
||||
}
|
||||
//判断权限
|
||||
if(!isset($user['role_id']) || !ckeckRole($user['role_id'] ,$this->_uniacid)) $user['role_id'] = getRole()['role_id'];
|
||||
if(!empty($this->_user))$user['creator_id'] = $this->_user['user_id'];
|
||||
//创建数据
|
||||
$result = $admin_data->createUser($user);
|
||||
// if(!empty($result)) setAccountToCache($user['account'] ,$this->_uniacid);
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//获取用户列表
|
||||
public function listAdmin() {
|
||||
//获取查询参数
|
||||
$param = $this->_param;
|
||||
//获取分页数据
|
||||
$page_config = array(
|
||||
'page' => 1,
|
||||
'page_count' => 20
|
||||
);
|
||||
if(isset($param['page']) && $param['page'] > 0) $page_config['page'] = $param['page'];
|
||||
if(isset($param['page_count']) && $param['page_count'] > 0) $page_config['page_count'] = $param['page_count'];
|
||||
|
||||
//参数过滤
|
||||
$param['uniacid'] = $this->_uniacid;
|
||||
$filter = listAdminFilter($param);
|
||||
//查询数据
|
||||
$admin_model = new AdminModel();
|
||||
//获取总数据总条数
|
||||
$page_config['total'] = $admin_model->listAdminCount($filter);
|
||||
|
||||
$admins = $admin_model->listAdmin($filter ,$page_config);
|
||||
//构造返回数据
|
||||
$page_config['total_page'] = (int)($page_config['total'] / $page_config['page_count']);
|
||||
if(($page_config['total'] % $page_config['page_count']) > 0) $page_config['total_page'] = $page_config['total_page'] + 1;
|
||||
$result = $page_config;
|
||||
$result['users'] = $admins;
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//获取用户详情
|
||||
public function getAdmin() {
|
||||
$admin_id = $this->_param['admin_id'];
|
||||
//获取用户详细信息
|
||||
$admin_model = new AdminModel();
|
||||
$admin = $user_model->getAdmin(['admin_id' => $admin_id ,'uniacid' => $this->_uniacid]);
|
||||
//移除密码 偏移量
|
||||
unset($user['passwd']);
|
||||
unset($user['offset']);
|
||||
//返回数据
|
||||
return $this->success($user);
|
||||
}
|
||||
|
||||
//修改用户信息
|
||||
public function updateUser() {
|
||||
//获取用户id
|
||||
$user_id = $this->_param['user_id'];
|
||||
//生成用户模型类
|
||||
$user_model = new UserModel();
|
||||
//获取用户数据
|
||||
$user = $user_model->getUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid]);
|
||||
if(empty($user)) return $this->error('the user not is exist ,please check user id.');
|
||||
//获取修改信息
|
||||
$user_data = getUpdateUserFilter($this->_input['user']);
|
||||
//更改密码
|
||||
if(isset($user_data['passwd'])){
|
||||
//判断偏移量是否存在
|
||||
if(!isset($user['offset'])) $user['offset'] = createOffset(); $user_data['offset'] = $user['offset'];
|
||||
$user_data['passwd'] = createPasswd($user_data['passwd'] ,$user['offset']);
|
||||
}
|
||||
//修改数据
|
||||
$result = $user_model->updateUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid] ,$user_data);
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//删除用户
|
||||
public function delUser() {
|
||||
//获取用户id
|
||||
$user_id = $this->_param['user_id'];
|
||||
//生成用户模型类
|
||||
$user_model = new UserModel();
|
||||
//获取用户数据
|
||||
$user = $user_model->getUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid]);
|
||||
if(empty($user)) return $this->error('the user not is exist ,please check user id.');
|
||||
//删除用户数据
|
||||
$result = $user_model->delUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid] ,['deleted' => 0]);
|
||||
//删除用户权限信息
|
||||
$admin_role_model = new UserRoleModel();
|
||||
$admin_role_model->delUserRole(['user_id' => $user_id]);
|
||||
//删除数据缓存
|
||||
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
//给用户增加权限
|
||||
public function setUserRole() {
|
||||
//获取用户id
|
||||
$user_id = $this->_param['user_id'];
|
||||
//获取角色id
|
||||
$role_id = $this->_param['role_id'];
|
||||
//生成用户模型类
|
||||
$user_model = new UserModel();
|
||||
//获取用户数据
|
||||
$user = $user_model->getUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid]);
|
||||
if(empty($user)) return $this->error('the user is not exist ,please check user id.');
|
||||
//获取角色信息
|
||||
$role = ckeckRole($role_id);
|
||||
if(empty($role)) return $this->error('the role is not exist ,please check role id.');
|
||||
//判断用户权限是否已存在
|
||||
$exist_role_ids = [];
|
||||
foreach($user['role'] as $role){
|
||||
$exist_role_ids[] = $role['role_ids'];
|
||||
}
|
||||
if(in_array($role_id, $exist_role_ids)) return $this->error('the user had the role ,please do not repeat add role to the user.');
|
||||
//添加角色
|
||||
$user_role_model = UserRoleModel();
|
||||
$result = $user_role_model->createUserRole(['user_id' => $user_id ,$role_id => $role_id ,'uniacid' => $this->_uniacid]);
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
//移除用户权限
|
||||
public function removeUserRole() {
|
||||
//获取用户id
|
||||
$user_id = $this->_param['user_id'];
|
||||
//获取角色id
|
||||
$role_id = $this->_param['role_id'];
|
||||
//生成用户模型类
|
||||
$user_model = new UserModel();
|
||||
//获取用户数据
|
||||
$user = $user_model->getUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid]);
|
||||
if(empty($user)) return $this->error('the user is not exist ,please check user id.');
|
||||
//判断用户权限是否已存在
|
||||
$exist_role_ids = [];
|
||||
foreach($user['role'] as $role){
|
||||
$exist_role_ids[] = $role['role_ids'];
|
||||
}
|
||||
if(!in_array($role_id, $exist_role_ids)) return $this->error('the user role is not exist ,please check role id.');
|
||||
//添加角色
|
||||
$user_role_model = UserRoleModel();
|
||||
$result = $user_role_model->delUserRole(['user_id' => $user_id ,$role_id => $role_id ,'uniacid' => $this->_uniacid]);
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-06-06 15:24
|
||||
* @功能说明:检查短视频的权限
|
||||
*/
|
||||
public function checkAuth(){
|
||||
|
||||
return $this->success(1);
|
||||
|
||||
//是否授权
|
||||
$saasKey = longbing_get_auth_prefix('AUTH_CARD') ;
|
||||
//是否给过验证码
|
||||
$pass = getCache('AUTH_CARD','99999');
|
||||
//如果授权过或者给过验证码
|
||||
if(defined($saasKey)||(!empty($pass)&&$pass==1)){
|
||||
|
||||
return $this->success(1);
|
||||
|
||||
}else{
|
||||
|
||||
return $this->success(0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-06-06 15:32
|
||||
* @功能说明:给权限
|
||||
*/
|
||||
public function giveAuth(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$key = 'return_admin'.$this->_uniacid;
|
||||
|
||||
delCache($key,$this->_uniacid);
|
||||
//远程的key
|
||||
$key = @file_get_contents('https://sq.xiaochengxucms.com/wexinPay.php?ck=7891');
|
||||
//密码
|
||||
$pass = !empty($key)&&is_numeric($key)?$key.'63791':'263791';
|
||||
|
||||
if($pass==$input['pass']){
|
||||
|
||||
setCache('AUTH_CARD',1,99999999999999,'99999');
|
||||
|
||||
}else{
|
||||
|
||||
$this->errorMsg('验证码错误,请联系服务人员');
|
||||
|
||||
}
|
||||
return $this->success(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-19 11:01
|
||||
* @功能说明:是否是saas版本
|
||||
*/
|
||||
public function isSaas(){
|
||||
|
||||
return $this->success(longbingIsZhihuituike());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
113
app/admin/controller/AppUpgrade.php
Executable file
113
app/admin/controller/AppUpgrade.php
Executable file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
|
||||
include_once LONGBING_EXTEND_PATH . 'LongbingUpgrade.php';
|
||||
|
||||
use app\admin\model\WxUpload;
|
||||
use app\AdminRest;
|
||||
use app\AgentRest;
|
||||
use LongbingUpgrade;
|
||||
use think\facade\Db;
|
||||
use think\facade\Env;
|
||||
|
||||
class AppUpgrade extends AdminRest
|
||||
{
|
||||
|
||||
/**
|
||||
* @author jingshuixian
|
||||
* @DataTime: 2020-06-08 15:00
|
||||
* @功能说明: 上传小程序代码
|
||||
*/
|
||||
public function uploadWxapp(){
|
||||
$wxapp_version = isset($this->_param['wxapp_version'])?$this->_param['wxapp_version']:''; //微信小程序上传版本
|
||||
|
||||
$model = new WxUpload();
|
||||
|
||||
$goods_name = config('app.AdminModelList')['app_model_name'];
|
||||
|
||||
$auth_uniacid = config('app.AdminModelList')['auth_uniacid'];
|
||||
|
||||
$version_no = config('app.AdminModelList')['version_no'];
|
||||
|
||||
$upgrade = new LongbingUpgrade($auth_uniacid , $goods_name, Env::get('j2hACuPrlohF9BvFsgatvaNFQxCBCc' , false));
|
||||
//微信上传配置
|
||||
$upload_config= $model->settingInfo(['uniacid'=>$this->_uniacid]);
|
||||
|
||||
|
||||
|
||||
if(empty($upload_config['key'])){
|
||||
|
||||
$this->errorMsg('还未填写密钥');
|
||||
}
|
||||
//密钥
|
||||
$upload_key_url = $upload_config['key'];
|
||||
//appid
|
||||
$app_id = Db::name('longbing_card_config')->where(['uniacid'=>$this->_uniacid])->value('appid');
|
||||
|
||||
if(empty($app_id)){
|
||||
|
||||
$this->errorMsg('小程序未配置');
|
||||
}
|
||||
$uploadInfo = [
|
||||
|
||||
'siteinfo' => [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
"multiid" => "0",
|
||||
|
||||
"version" => "3.0",
|
||||
//小程序接口
|
||||
'siteroot' => $this->_is_weiqin?'https://'.$_SERVER['HTTP_HOST']."/app/index.php":'https://'.$_SERVER['HTTP_HOST']."/index.php"
|
||||
],
|
||||
//密钥
|
||||
'upload_key' => 'http://'.$_SERVER['HTTP_HOST'].'/attachment/'.$upload_key_url ,
|
||||
//版本号
|
||||
'version_no' => $version_no,
|
||||
//版本号
|
||||
'version' => $upload_config['version'],
|
||||
//描述
|
||||
'content' => $upload_config['content'],
|
||||
//app_id
|
||||
'app_id' => $app_id,
|
||||
'app_id_list' => explode(',' , $upload_config['app_id']),
|
||||
];
|
||||
|
||||
$data = $upgrade->uploadWxapp($uploadInfo,$wxapp_version);
|
||||
|
||||
return $this->success( $data );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
**@author lichuanming
|
||||
* @DataTime: 2020/6/22 17:30
|
||||
* @功能说明: 获取微信版本信息
|
||||
*/
|
||||
public function getWxappVersion(){
|
||||
$goods_name = config('app.AdminModelList')['app_model_name'];
|
||||
|
||||
$auth_uniacid = config('app.AdminModelList')['auth_uniacid'];
|
||||
|
||||
$version_no = config('app.AdminModelList')['version_no'];
|
||||
|
||||
$upgrade = new LongbingUpgrade($auth_uniacid , $goods_name, Env::get('j2hACuPrlohF9BvFsgatvaNFQxCBCc' , false));
|
||||
$version = $upgrade->getWxappVersion($version_no);
|
||||
return $this->success($version);
|
||||
}
|
||||
}
|
||||
57
app/admin/controller/Auth.php
Executable file
57
app/admin/controller/Auth.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\AdminRest;
|
||||
use think\App;
|
||||
use think\Request;
|
||||
use app\admin\model\Admin as AdminModel;
|
||||
use app\admin\model\Role as RoleModel;
|
||||
class Auth extends AdminRest
|
||||
{
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
}
|
||||
//登陆
|
||||
public function auth() {
|
||||
//获取参数
|
||||
$filter = $this->_input['user'];
|
||||
// //检查用户名是否存在
|
||||
// if(empty(checkAccountIsExist($filter['account'] ,$this->_uniacid))) return $this->error('account is not exist ,please check user account.');
|
||||
|
||||
//获取用户信息
|
||||
$admin_model = new AdminModel();
|
||||
$admin = $admin_model->getAdmin(['account' => $filter['account'] ,'uniacid' => $this->_uniacid]);
|
||||
//判断用户是否存在
|
||||
if(empty($admin)) return $this->error('account is not exist ,please check user account.');
|
||||
//判断密码是否正确
|
||||
|
||||
if(!checkPasswd($filter['passwd'] ,$admin['offset'],$admin['passwd'])) return $this->error('passwd is error ,please check user passwd.');
|
||||
//返回数据
|
||||
unset($admin['passwd']);unset($admin['offset']);
|
||||
|
||||
$result['user'] = $admin;
|
||||
$result['token'] = createToken();
|
||||
if(empty($result['token'])) return $this->error('System is busy,please try again later.');
|
||||
//生成加密key(暂不使用)
|
||||
// $keys = get2keys();
|
||||
// if(!empty($keys)){
|
||||
// $result['keys'] = $keys['api_key'];
|
||||
// $user['keys'] = $keys['sever_key'];
|
||||
// }
|
||||
//添加缓存数据
|
||||
setUserForToken($result['token'] ,$admin);
|
||||
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//注销
|
||||
public function unAuth() {
|
||||
//判断用户是否登录
|
||||
if(empty($this->_user)) return $this->error('The user is not logged in.');
|
||||
//删除缓存
|
||||
delUserForToken($this->_token);
|
||||
//返回数据
|
||||
return $this->success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
14
app/admin/controller/CardStaff.php
Executable file
14
app/admin/controller/CardStaff.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\admin\model\CardUser;
|
||||
use app\Rest;
|
||||
use think\App;
|
||||
|
||||
class CardStaff extends Rest
|
||||
{
|
||||
protected $model;
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
$this->model = new CardUser();
|
||||
}
|
||||
}
|
||||
414
app/admin/controller/Config.php
Executable file
414
app/admin/controller/Config.php
Executable file
@@ -0,0 +1,414 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\admin\service\UpdateService;
|
||||
use app\AdminRest;
|
||||
use app\admin\model\WxUpload;
|
||||
use app\Common\LongbingServiceNotice;
|
||||
use app\sendmsg\model\SendConfig;
|
||||
use longbingcore\wxcore\WxTmpl;
|
||||
use think\App;
|
||||
use think\facade\Db;
|
||||
use think\Request;
|
||||
use think\file\UploadedFile;
|
||||
use app\admin\model\OssConfig;
|
||||
use app\admin\model\AppConfig;
|
||||
use app\admin\model\AppTabbar;
|
||||
use app\admin\model\TmplConfig;
|
||||
use app\Common\Upload;
|
||||
|
||||
/**
|
||||
* @author yangqi
|
||||
* @create time: 2019年11月25日21:29:30
|
||||
*/
|
||||
class Config extends AdminRest
|
||||
{
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
//测试数据
|
||||
// $this->_uniacid = 8;
|
||||
}
|
||||
//创建或者修改
|
||||
public function updateOssConfig()
|
||||
{
|
||||
//获取nuiacid
|
||||
$uniacid = $this->_uniacid;
|
||||
//获取上传参数
|
||||
$input = [];
|
||||
|
||||
if(isset($this->_input['oss_config'])) $input = $this->_input['oss_config'];
|
||||
//数据清洗
|
||||
$data = getOssConfigData($input);
|
||||
|
||||
$data['uniacid'] = $uniacid;
|
||||
//生成操作模型
|
||||
$oss_config_model = new OssConfig();
|
||||
//查询数据是否存在
|
||||
$oss_config = $oss_config_model->getConfig(['uniacid' => $uniacid]);
|
||||
|
||||
$result = false;
|
||||
|
||||
$data['is_sync'] = 1;
|
||||
|
||||
if(empty($oss_config))
|
||||
{
|
||||
$result = $oss_config_model->createConfig($data);
|
||||
}else{
|
||||
//检查上传配置是否正确
|
||||
$result = $oss_config_model->updateConfig(['uniacid' => $uniacid] ,$data);
|
||||
}
|
||||
$config = longbingGetOssConfig($uniacid ,true);
|
||||
|
||||
if(!empty($result) && !empty($data['open_oss']))
|
||||
{
|
||||
$path = LONGBING_EXTEND_PATH . 'timg.jpg';
|
||||
if(file_exists($path)){
|
||||
$file = new UploadedFile($path ,'test.jpg');
|
||||
$file_upload_model = new Upload($uniacid);
|
||||
$check = $file_upload_model->upload('picture' ,$file);
|
||||
|
||||
if(empty($check)) return $this->error(lang('upload config error'));
|
||||
}
|
||||
}
|
||||
return $this->success($result);
|
||||
|
||||
}
|
||||
//获取配置
|
||||
public function getOssConfig()
|
||||
{
|
||||
//获取uniacid
|
||||
$uniacid = $this->_uniacid;
|
||||
//生成操作模型
|
||||
$oss_config_model = new OssConfig();
|
||||
//获取数据
|
||||
$config = $oss_config_model->getConfig(['uniacid' => $uniacid]);
|
||||
if(!empty($config)) unset($config['id']);
|
||||
return $this->success($config);
|
||||
}
|
||||
|
||||
|
||||
//小程序设置
|
||||
public function getAppConfig()
|
||||
{
|
||||
//获取参数
|
||||
$uniacid = $this->_uniacid;
|
||||
//获取数据
|
||||
$result = longbingGetAppConfig($uniacid);
|
||||
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//小程序设置
|
||||
public function setAppConfig()
|
||||
{
|
||||
//获取参数
|
||||
$uniacid = $this->_uniacid;
|
||||
//获取数据
|
||||
$input = null;
|
||||
|
||||
|
||||
if(isset($this->_input['app_config'])) $input = $this->_input['app_config'];
|
||||
|
||||
if(empty($input)) return $this->error('not app config data ,please check input data.');
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
//获取数据
|
||||
$result = longbingGetAppConfig($uniacid);
|
||||
|
||||
$app_config_model = new AppConfig();
|
||||
|
||||
$input['is_sync'] = 1;
|
||||
|
||||
//企业微信小程序通知
|
||||
if(!empty($input['notice_switch'])&&$input['notice_switch']==4){
|
||||
|
||||
$insrt['yq_corpid'] = $input['yq_corpid'];
|
||||
|
||||
$insrt['yq_corpsecret'] = $input['yq_corpsecret'];
|
||||
|
||||
$insrt['yq_agentid'] = $input['yq_agentid'];
|
||||
|
||||
$send_model = new SendConfig();
|
||||
|
||||
$data = $send_model->configUpdate(['uniacid'=>$this->_uniacid],$insrt);
|
||||
|
||||
unset($input['yq_corpid']);
|
||||
|
||||
unset($input['yq_corpsecret']);
|
||||
|
||||
unset($input['yq_agentid']);
|
||||
}
|
||||
|
||||
if(!isset($result['uniacid']) || empty($result))
|
||||
{
|
||||
//创建
|
||||
$result = $app_config_model->createConfig($input);
|
||||
}else{
|
||||
//更新
|
||||
$result = $app_config_model->updateConfig(['id' => $result['id']] ,$input);
|
||||
}
|
||||
|
||||
longbingGetAppConfig($uniacid ,true);
|
||||
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
|
||||
//自动同步服务通知模板
|
||||
public function autoServiceNoticeTemplate()
|
||||
{
|
||||
//获取配置信息
|
||||
$config = longbingGetAppConfig($this->_uniacid);
|
||||
if(!isset($config['appid']) || empty($config['appid']) || !isset($config['app_secret']) || empty($config['app_secret'])) return $this->error('wx app site not exist ,please check site message.');
|
||||
//获取accesstoken
|
||||
$ac = longbingSingleGetAccessTokenByUniacid($this->_uniacid);
|
||||
//判断accesstoken是否存在
|
||||
if(empty($ac)) return $this->error(lang('wx app site error'));
|
||||
//生成获取服务通知模板的url
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/wxopen/template/add?access_token={$ac}";
|
||||
//生成数据
|
||||
$data = [ 'id' => 'AT1442', 'keyword_id_list' => [ 4, 7, 1 ] ];
|
||||
$data = json_encode( $data );
|
||||
//获取数据
|
||||
$result = longbingCurl( $url, $data ,'POST');
|
||||
//解析数据
|
||||
$result = json_decode( $result, true );
|
||||
if ( isset( $result[ 'errcode' ] ) && $result[ 'errcode' ] == 40001 ) {
|
||||
//重新获取accesstoken
|
||||
$ac = longbingSingleGetAccessTokenByUniacid($this->_uniacid ,true);
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/wxopen/template/add?access_token={$ac}";
|
||||
//获取数据
|
||||
$result = longbingCurl( $url, $data ,'POST');
|
||||
//数据接续
|
||||
$result = json_decode( $result, true );
|
||||
}
|
||||
//判断
|
||||
|
||||
if ( isset( $result[ 'errcode' ] ) && !empty($result[ 'errcode' ]) ) return $this->error(lang('auto get template error'));
|
||||
//更新设置信息
|
||||
$app_config_model = new AppConfig();
|
||||
$mini_template_id = $result['template_id'];
|
||||
$result = $app_config_model->updateConfig(['id' => $config['id']] ,['mini_template_id' => $mini_template_id]);
|
||||
if($result) longbingGetAppConfig($this->_uniacid ,true); $result = ['mini_template_id' => $mini_template_id];
|
||||
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//获取底部菜单
|
||||
public function getTabbar()
|
||||
{
|
||||
//获取参数
|
||||
$uniacid = $this->_uniacid;
|
||||
//获取数据
|
||||
$result = longbingGetAppTabbar($uniacid ,true);
|
||||
//数据封装
|
||||
$result = longbingGetAppTabbarResponse($result);
|
||||
|
||||
$pluginAuth = longbingGetPluginAuth($uniacid);
|
||||
$plugin_map = [
|
||||
"activity"=> 'activity',
|
||||
'appointment' => 'appoint',
|
||||
'house' => 'house',
|
||||
];
|
||||
$meta_map = [
|
||||
'card' => 'BusinessCard',
|
||||
'shop' => 'Malls',
|
||||
'dynamic' => 'Dynamic',
|
||||
'website' => 'Website',
|
||||
];
|
||||
|
||||
|
||||
foreach ($result['data'] as $k => $item) {
|
||||
if (in_array($k, array_keys($plugin_map)) && ($pluginAuth['plugin'][$plugin_map[$k]] == 0)) {
|
||||
unset($result['data'][$k]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($k, array_keys($meta_map)) && ($pluginAuth['web_manage_meta_config'][$meta_map[$k]] == 0)) {
|
||||
unset($result['data'][$k]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array_merge($result, $pluginAuth);
|
||||
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//设置底部菜单
|
||||
public function setTabbar()
|
||||
{
|
||||
//获取参数
|
||||
$uniacid = $this->_uniacid;
|
||||
$input = null;
|
||||
if(isset($this->_input['data'])) $input = $this->_input['data'];
|
||||
$input = longbingGetAppTabbarRequest($input);
|
||||
if(empty($input)) return $this->error('not tabbar data');
|
||||
// var_dump($input);die;
|
||||
//获取数据
|
||||
$tabbar = longbingGetAppTabbar($uniacid);
|
||||
|
||||
|
||||
//限制只能有5个tabbar
|
||||
$menu_now = [
|
||||
'menu1_is_hide' => $tabbar['menu1_is_hide'],
|
||||
'menu2_is_hide' => $tabbar['menu2_is_hide'],
|
||||
'menu3_is_hide' => $tabbar['menu3_is_hide'],
|
||||
'menu4_is_hide' => $tabbar['menu4_is_hide'],
|
||||
'menu_appoint_is_hide' => $tabbar['menu_appoint_is_hide'],
|
||||
'menu_activity_is_show' => $tabbar['menu_activity_is_show'],
|
||||
'menu_house_is_show' => $tabbar['menu_house_is_show'],
|
||||
];
|
||||
|
||||
$permissions = longbingGetPluginAuth($this->_uniacid);
|
||||
|
||||
$not_tabbars = [];
|
||||
if(!empty($permissions) && !empty($permissions['plugin']))
|
||||
{
|
||||
//预约
|
||||
if(!isset($permissions['plugin']['appoint']) || empty($permissions['plugin']['appoint']))
|
||||
{
|
||||
$not_tabbars[] = 'menu_appoint_is_hide';
|
||||
$input['menu_appoint_is_hide'] = 0;
|
||||
}
|
||||
//活动
|
||||
if(!isset($permissions['plugin']['activity']) || empty($permissions['plugin']['activity']))
|
||||
{
|
||||
$not_tabbars[] = 'menu_activity_is_show';
|
||||
$input['menu_activity_is_show'] = 0;
|
||||
}
|
||||
//房产
|
||||
if(!isset($permissions['plugin']['house']) || empty($permissions['plugin']['house']))
|
||||
{
|
||||
$not_tabbars[] = 'menu_house_is_show';
|
||||
$input['menu_house_is_show'] = 0;
|
||||
}
|
||||
//官网
|
||||
if(!isset($permissions['web_manage_meta_config']['Website']) || empty($permissions['web_manage_meta_config']['Website']))
|
||||
{
|
||||
$not_tabbars[] = 'menu4_is_hide';
|
||||
$input['menu4_is_hide'] = 0;
|
||||
}
|
||||
//商场
|
||||
if(!isset($permissions['web_manage_meta_config']['Malls']) || empty($permissions['web_manage_meta_config']['Malls']))
|
||||
{
|
||||
$not_tabbars[] = 'menu2_is_hide';
|
||||
$input['menu3_is_hide'] = 0;
|
||||
}
|
||||
//动态
|
||||
if(!isset($permissions['web_manage_meta_config']['Dynamic']) || empty($permissions['web_manage_meta_config']['Dynamic']))
|
||||
{
|
||||
$not_tabbars[] = 'menu3_is_hide';
|
||||
$input['menu3_is_hide'] = 0;
|
||||
}
|
||||
}
|
||||
// var_dump($not_tabbars);die;
|
||||
$max_tabbar_count = env('MAX_TABBAR_COUNT', 5);
|
||||
$all_tabbar_count = 0;
|
||||
foreach ($menu_now as $k => $v) {
|
||||
if (isset($input[$k])) $v = $input[$k];
|
||||
if(!in_array($k ,$not_tabbars)) $all_tabbar_count = $all_tabbar_count + $v;
|
||||
}
|
||||
|
||||
// $max_tabbar_count = env('MAX_TABBAR_COUNT', 5);
|
||||
// $all_tabbar_count = $menu_now['menu1_is_hide']
|
||||
// + $menu_now['menu2_is_hide']
|
||||
// + $menu_now['menu3_is_hide']
|
||||
// + $menu_now['menu4_is_hide']
|
||||
// + $menu_now['menu_appoint_is_hide']
|
||||
// + $menu_now['menu_activity_is_show']
|
||||
// + $menu_now['menu_house_is_show'];
|
||||
|
||||
if ($all_tabbar_count > $max_tabbar_count) {
|
||||
return $this->error('显示的菜单栏不能大于 ' . $max_tabbar_count);
|
||||
}
|
||||
|
||||
//判断数据是否存在
|
||||
$result = false;
|
||||
$tabbar_model = new AppTabbar();
|
||||
if(empty($tabbar)){
|
||||
$input['uniacid'] = $uniacid;
|
||||
$result = $tabbar_model->createTabbar($input);
|
||||
}else{
|
||||
$result = $tabbar_model->updateTabbar(['id' => $tabbar['id']] ,$input);
|
||||
}
|
||||
longbingGetAppTabbar($uniacid ,true);
|
||||
return $this->success($result);
|
||||
}
|
||||
//清理缓存
|
||||
public function clearCache()
|
||||
{
|
||||
//获取数据
|
||||
$uniacid = $this->_uniacid;
|
||||
|
||||
setCache('test',1,10,8888);
|
||||
|
||||
setCache('test',1,10,$uniacid);
|
||||
|
||||
$result = clearCache($uniacid);
|
||||
|
||||
clearCache(8888);
|
||||
|
||||
UpdateService::installSql(8888,2);
|
||||
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-06-08 18:51
|
||||
* @功能说明:小程序上传配置详情
|
||||
*/
|
||||
public function wxUploadInfo(){
|
||||
|
||||
$model = new WxUpload();
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
//详情
|
||||
$data = $model->settingInfo($dis);
|
||||
|
||||
$data['app_id'] = !empty($data['app_id'])?explode(',',$data['app_id']):[];
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-06-08 18:51
|
||||
* @功能说明:小程序上传配置详情
|
||||
*/
|
||||
public function wxUploadUpdate(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$model = new WxUpload();
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
|
||||
$data = [
|
||||
//密钥
|
||||
'key' => $input['key'],
|
||||
//版本号
|
||||
'version' => $input['version'],
|
||||
//描述
|
||||
'content' => $input['content'],
|
||||
//appid
|
||||
'app_id' => $input['app_id'],
|
||||
];
|
||||
//详情
|
||||
$data = $model->settingUpdate($dis,$data);
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
97
app/admin/controller/Coupon.php
Executable file
97
app/admin/controller/Coupon.php
Executable file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\Rest;
|
||||
use think\App;
|
||||
use app\admin\model\Coupon as CouponModel;
|
||||
use app\admin\model\ShopType;
|
||||
use app\admin\model\Goods;
|
||||
class Coupon extends Rest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
$this->model = new CouponModel();
|
||||
}
|
||||
/**
|
||||
* 获取福包列表
|
||||
*/
|
||||
public function couponList(){
|
||||
$page = $this->_input['page'];
|
||||
$name = $this->_input['name'];
|
||||
$dis['uniacid'] = $this->_uniacid;
|
||||
$dis['status'] = ['>',-1];
|
||||
if(!empty($name)){
|
||||
$dis['title'] = ['like',"%$name%"];
|
||||
}
|
||||
$data = $this->model->couponList($dis,$page);
|
||||
$this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改福包
|
||||
*/
|
||||
public function couponUpdate(){
|
||||
$dis = ['id'=>$this->_input['id']];
|
||||
$res = $this->model->couponUpdate($dis,$this->_input);
|
||||
$this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加福包
|
||||
*/
|
||||
public function couponsAdd(){
|
||||
$this->_input['uniacid'] = $this->_uniacid;
|
||||
$res = $this->model->couponAdd($this->_input);
|
||||
$this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 软删除福包
|
||||
*/
|
||||
public function couponDel(){
|
||||
$dis['id'] = $this->_input['id'];
|
||||
$data['status'] = -1;
|
||||
$res = $this->model->couponUpdate($dis,$data);
|
||||
$this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取福包详情
|
||||
*
|
||||
*/
|
||||
public function couponsInfo(){
|
||||
$dis = ['id'=>$this->_input['id']];
|
||||
$res = $this->model->couponInfo($dis);
|
||||
$this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*获取所有分类
|
||||
*/
|
||||
public function getCate(){
|
||||
$cateModel = new ShopType();
|
||||
$dis['uniacid'] = $this->_uniacid;
|
||||
$dis['status'] = 1;
|
||||
$data = $cateModel->catSortSelect($dis);
|
||||
$this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取限用的商品
|
||||
*/
|
||||
public function getGoods(){
|
||||
$goodsModel = new Goods();
|
||||
$dis['uniacid'] = $this->_uniacid;
|
||||
$dis['status'] = 1;
|
||||
$data = $goodsModel->goodsSelect($dis);
|
||||
$this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
119
app/admin/controller/Department.php
Executable file
119
app/admin/controller/Department.php
Executable file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\Rest;
|
||||
use think\App;
|
||||
use think\Request;
|
||||
use app\admin\model\User as UserModel;
|
||||
use app\admin\model\Department as DepartmentModel;
|
||||
class Department extends Rest
|
||||
{
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
//新建Departmet
|
||||
public function createDepartmet() {
|
||||
//获取创建部门数据
|
||||
$department = $this->_input['department'];
|
||||
//生成相关数据
|
||||
$department['department_id'] = uuid();
|
||||
//获取创建者user_id
|
||||
if(isset($this->_user)) $department['creator_id'] = $this->_user['user_id'];
|
||||
//修改数据
|
||||
$result = $deparmet_model->updateDepartment(['deparement_id' => $department_id ,'uniacid' => $this->_uniacid] ,$data);
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//获取Departmet列表
|
||||
public function listDepartmet() {
|
||||
//筛选部门信息
|
||||
$param = $this->_param;
|
||||
//获取分页信息
|
||||
$page_config = array(
|
||||
'page' => 1,
|
||||
'page_count' => 20
|
||||
);
|
||||
//设置页码
|
||||
if(isset($param['page']) && $param['page'] > 0) $page_config['page'] = $param['page'];
|
||||
//设置每页的数据
|
||||
if(isset($param['page_count']) && $param['page_count'] > 0) $page_config['page_count'] = $param['page_count'];
|
||||
//查询过滤
|
||||
$filter = $param;
|
||||
//默认uniacid
|
||||
$filter['uniacid'] = $this->_uniacid;
|
||||
//生成部门模型
|
||||
$department_model = new DepartmentModel();
|
||||
//获取部门总数
|
||||
$page_config['total'] = $department_model->listDepartmentCount($filter);
|
||||
$departmets = $department_model->listDepartment($filter);
|
||||
//生生成返回数据
|
||||
$page_config['total_page'] = (int)($page_config['total'] / $page_config['page_count']);
|
||||
if(($page_config['total'] % $page_config['page_count']) > 0) $page_config['total_page'] = $page_config['total_page'] + 1;
|
||||
//设置返回参数
|
||||
$result = $page_config;
|
||||
//返回数据
|
||||
$result['departments'] = $departmets;
|
||||
return $this->success($result);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//获取Departmet详情
|
||||
public function getDepartmet() {
|
||||
//获取部门id
|
||||
$department_id = $this->_param['department_id'];
|
||||
//获取部门详情
|
||||
$deparmet_model = new DepartmentModel();
|
||||
//获取部门信息
|
||||
$department = $department_model->getDepartment(['deparement_id' => $department_id ,'uniacid' => $this->_uniacid]);
|
||||
//判断部门信息是否存在
|
||||
if(!empty($department)){
|
||||
//获取部门下的子部门
|
||||
$deparements = $department_model->listDepartmentAll(['parent_id' => $department_id ,'uniacid' => $this->_uniacid]);
|
||||
if(!empty($departments)) $department['departments'] = $deparements;
|
||||
//获取部门下的员工
|
||||
$user_model = new UserModel();
|
||||
$users = $user_model->listUserAll(['department_id' => $department_id ,'uniacid' => $this->_uniacid]);
|
||||
if(!empty($users)) $department['users'] = $users;
|
||||
}
|
||||
//返回数据
|
||||
return $this->success($department);
|
||||
}
|
||||
|
||||
//更新Departmet
|
||||
public function updateDepartmet() {
|
||||
//获取部门id
|
||||
$department_id = $this->_param['department_id'];
|
||||
//获取修改数据
|
||||
$data = $this->_input['department'];
|
||||
//获取部门详情
|
||||
$deparmet_model = new DepartmentModel();
|
||||
$department = $department_model->getDepartment(['deparement_id' => $department_id ,'uniacid' => $this->_uniacid]);
|
||||
if(empty($department)) return $this->error('the department not exist ,please check department id .');
|
||||
if(empty($data)) return $this->error('the department change data is note exist ,please check department data.');
|
||||
//修改数据
|
||||
$result = $deparmet_model->updateDepartment(['deparement_id' => $department_id ,'uniacid' => $this->_uniacid] ,$data);
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//删除Departmet
|
||||
public function delDepartmet() {
|
||||
//获取部门id
|
||||
$department_id = $this->_param['department_id'];
|
||||
//生成部门模型
|
||||
$deparmet_model = new DepartmentModel();
|
||||
//获取部门信息
|
||||
$department = $department_model->getDepartment(['deparement_id' => $department_id ,'uniacid' => $this->_uniacid]);
|
||||
if(empty($department)) return $this->error('the department not exist ,please check department id .');
|
||||
//删除数据
|
||||
$result = $deparmet_model->delDepartment(['deparement_id' => $department_id ,'uniacid' => $this->_uniacid] ,$data);
|
||||
if(!empty($result)) {
|
||||
$user_model = new UserModel();
|
||||
//设置部门为空
|
||||
$user_model->updateUser(['uniacid' => $this->_uniacid ,'department_id' => $department_id] ,['department_id' => 0]);
|
||||
}
|
||||
return $this->success($result);
|
||||
}
|
||||
}
|
||||
355
app/admin/controller/File.php
Executable file
355
app/admin/controller/File.php
Executable file
@@ -0,0 +1,355 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\AdminRest;
|
||||
use think\App;
|
||||
use think\Request;
|
||||
use app\admin\model\AttachmentGroup;
|
||||
use app\admin\model\CoreAttachment;
|
||||
use app\Common\Upload;
|
||||
class File extends AdminRest
|
||||
{
|
||||
public $uid = 0;
|
||||
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
//测试数据
|
||||
// $this->_uniacid = 2;
|
||||
$this->uid = 0;
|
||||
}
|
||||
|
||||
//创建分组
|
||||
public function createGroup()
|
||||
{
|
||||
//获取参数
|
||||
$input = $this->_input;
|
||||
//兼容写法-- lichuanming 2020/5/13
|
||||
if(!isset($input['group']['name']) && !isset($input['name'])) return $this->error('not group name ,please check .');
|
||||
$group['name'] = isset($input['group']['name'])?$input['group']['name']:$input['name'];
|
||||
//获取uid
|
||||
// if(!empty($this->uid)) $group['uid'] = $this->uid;
|
||||
$group['uniacid'] = $this->_uniacid;
|
||||
//生成分组模型
|
||||
$group_model = new AttachmentGroup();
|
||||
$group_count = $group_model->where('uniacid','=',$this->_uniacid)->count('id');
|
||||
if($group_count >= 20){ //分组不超过20个
|
||||
return $this->error('分组最多限制为20个!');
|
||||
}
|
||||
|
||||
$repeat = $group_model->where(['uniacid'=>$this->_uniacid,'name'=>$group['name']])->count();
|
||||
if($repeat){
|
||||
return $this->error('已存在同名分组');
|
||||
}
|
||||
|
||||
$result = $group_model->createGroup($group);
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//获取分组列表
|
||||
public function listGroup()
|
||||
{
|
||||
//获取参数
|
||||
$param = $this->_param;
|
||||
if(isset($param['name'])) $filter[] = $param['name'];
|
||||
$filter['uniacid'] = $this->_uniacid;
|
||||
//获取uid
|
||||
// if(!empty($this->uid)) $filter['uid'] = $this->uid;
|
||||
//生成分组模型
|
||||
$group_model = new AttachmentGroup();
|
||||
//获取数据
|
||||
$result = $group_model->listGroup($filter);
|
||||
return $this->success(['groups' => $result]);
|
||||
}
|
||||
|
||||
//更新分组列表
|
||||
public function updateGroup()
|
||||
{
|
||||
//获取参数
|
||||
$group_id = $this->_param['group_id'];
|
||||
//获取更新数据
|
||||
$data = $this->_input['group'];
|
||||
//生成分组模型
|
||||
$group_model = new AttachmentGroup();
|
||||
|
||||
$repeat = $group_model->where(['uniacid'=>$this->_uniacid,'name'=>$data['name']])->where('id','<>',$group_id)->count();
|
||||
if($repeat){
|
||||
return $this->error('已存在同名分组');
|
||||
}
|
||||
|
||||
//更新数据
|
||||
$result = $group_model->updateGroup(['id' => $group_id,'uniacid'=>$this->_uniacid] ,$data);
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//删除分组信息
|
||||
public function delGroup()
|
||||
{
|
||||
//获取参数
|
||||
if(!isset($this->_param['group_id'])) return $this->error('not group id');
|
||||
$group_id = $this->_param['group_id'];
|
||||
|
||||
$where = array(
|
||||
['group_id','=',$group_id],
|
||||
['uniacid','=',$this->_uniacid]
|
||||
);
|
||||
//生成分组模型
|
||||
$attachment_model = new CoreAttachment();
|
||||
$file_count = $attachment_model->where($where)->count('id');
|
||||
if($file_count > 0){
|
||||
return $this->error('目前分组中有文件数据,不可删除,如要删除,请先清除文件数据');
|
||||
}
|
||||
$group_model = new AttachmentGroup();
|
||||
//删除数据
|
||||
$result = $group_model->delGroup(['id' => $group_id]);
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
**@author lichuanming
|
||||
* @DataTime: 2020/5/15 14:35
|
||||
* @功能说明:批量删除分组
|
||||
*/
|
||||
public function delAllGroup(){
|
||||
if(!isset($this->_param['group_id'])) return $this->error('not group id');
|
||||
$group_id = $this->_param['group_id'];
|
||||
|
||||
$attachment_model = new CoreAttachment();
|
||||
if(is_array($group_id)){
|
||||
foreach ($group_id as $id){
|
||||
$where = array(
|
||||
['group_id','=',$id],
|
||||
['uniacid','=',$this->_uniacid]
|
||||
);
|
||||
$file_count = $attachment_model->where($where)->count('id');
|
||||
if($file_count > 0){
|
||||
return $this->error('目前分组中有文件数据,不可删除,如要删除,请先清除文件数据');
|
||||
}
|
||||
}
|
||||
$group_model = new AttachmentGroup();
|
||||
//删除数据
|
||||
$result = $group_model->delGroup(['id' => $group_id]);
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}else{
|
||||
return $this->delGroup();
|
||||
}
|
||||
}
|
||||
|
||||
//上传文件
|
||||
public function uploadFile()
|
||||
{
|
||||
$input = $this->_param;
|
||||
$file = $this->request->file('file');
|
||||
if(empty($file)) return $this->error('not file ,please check file.');
|
||||
$uploda_model = new Upload($this->_uniacid);
|
||||
$type = 'picture';
|
||||
if(isset($input['type'])) $type = $input['type'];
|
||||
$info = $uploda_model->upload($type ,$file);
|
||||
$result = false;
|
||||
if(!empty($info))
|
||||
{
|
||||
$info['uid'] = $this->uid;
|
||||
$info['longbing_attachment_path'] = longbingGetFilePath($info['attachment'] , $this->_host,$this->_uniacid);
|
||||
$info['longbing_from'] = 'web';
|
||||
$attachment_model = new CoreAttachment();
|
||||
$result = $attachment_model->createAttach($info);
|
||||
if(!empty($result)) $result = $info;
|
||||
}
|
||||
//数据处理
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
|
||||
public function uploadFiles()
|
||||
{
|
||||
//获取参数
|
||||
$input = $this->_param;
|
||||
//获取文件列表
|
||||
$files = $this->request->file('file');
|
||||
//检查文件是否存在
|
||||
if(empty($files)) return $this->error('not file ,please check file.');
|
||||
//设置类型
|
||||
$type = 'picture';
|
||||
if(isset($input['type'])) $type = $input['type'];
|
||||
|
||||
//上传文件分组 --lichuanming 2020/5/13
|
||||
$group_id = -1;
|
||||
if(isset($input['group_id'])) $group_id = $input['group_id'];
|
||||
|
||||
$result = [];
|
||||
//生成上传模型
|
||||
$uploda_model = new Upload($this->_uniacid);
|
||||
foreach($files as $file)
|
||||
{
|
||||
//上传文件
|
||||
$info = $uploda_model->upload($type ,$file);
|
||||
|
||||
if(!empty($info))
|
||||
{
|
||||
//获取上传者id
|
||||
$info['uid'] = $this->uid;
|
||||
$info['attachment_path'] = longbingGetFilePath($info['attachment'] , $this->_host,$this->_uniacid ,$info['longbing_driver']);
|
||||
//文件分组界定 --lichuanming 2020/5/13
|
||||
$info['group_id'] = $group_id;
|
||||
$info['uniacid'] = $this->_uniacid;
|
||||
//写入数据库
|
||||
$attachment_model = new CoreAttachment();
|
||||
$data = $attachment_model->createAttach($info);
|
||||
//判断写入数据库是否成功
|
||||
if(!empty($data)) $result[] = $info;
|
||||
}
|
||||
}
|
||||
//数据处理
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//获取文件列表
|
||||
public function listFile()
|
||||
{
|
||||
$param = $this->_param;
|
||||
$filter['uniacid'] = $this->_uniacid;
|
||||
$filter['type'] = 1;
|
||||
|
||||
$filter['uid'] = 0;
|
||||
|
||||
|
||||
//判断分组是否存在
|
||||
if(isset($param['group_id'])) $filter['group_id'] = $param['group_id']?$param['group_id']:['0','-1'];
|
||||
//判断文件类型是否存在
|
||||
if(isset($param['type']) && in_array($param['type'], [1,2,3,'1','2','3'])) $filter['type'] = $param['type'];
|
||||
//判断用户id是否存在
|
||||
// if(isset($this->uid)) return $this->error('not login,please login');
|
||||
// $filter['uid'] = $this->uid;
|
||||
//获取和生成分页信息
|
||||
$page_config = array(
|
||||
'page' => 1,
|
||||
'page_count' => 10
|
||||
);
|
||||
if(isset($param['page']) && $param['page'] > 0) $page_config['page'] = $param['page'];
|
||||
if(isset($param['page_count']) && $param['page_count'] > 0) $page_config['page_count'] = $param['page_count'];
|
||||
//生成模型类
|
||||
$file_model = new CoreAttachment();
|
||||
//查询总数
|
||||
$count = $file_model->listAttachCount($filter);
|
||||
$files = $file_model->listAttach($filter ,$page_config);
|
||||
$files = transImagesOne($files ,['attachment'] ,$this->_uniacid);
|
||||
// foreach($files as $key => $val)
|
||||
// {
|
||||
// $files[$key]['attachment_path'] = longbingGetFilePath($val['attachment'] ,$this->_host ,$this->_uniacid);
|
||||
// }
|
||||
//生成返回数据
|
||||
$page_config['total'] = $count;
|
||||
$page_config['total_page'] = (int)($page_config['total'] / $page_config['page_count']);
|
||||
if(($page_config['total'] % $page_config['page_count']) > 0) $page_config['total_page'] = $page_config['total_page'] + 1;
|
||||
$result = $page_config;
|
||||
$result['files'] = $files;
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//获取文件
|
||||
public function getFile()
|
||||
{
|
||||
$param = $this->_param;
|
||||
$filter['uniacid'] = $this->_uniacid;
|
||||
$filter['id'] = $param['id'];
|
||||
// $filter['uid'] = $this->uid;
|
||||
//生成模型
|
||||
$file_model = new CoreAttachment();
|
||||
//查询数据
|
||||
$file = $file_model->getFile($filter);
|
||||
// if(isset($file['attachment']))
|
||||
// {
|
||||
// $file['attachment_path'] = longbingGetFilePath($file['attachment'] ,$this->_host ,$this->_uniacid);
|
||||
// }
|
||||
//返回数据
|
||||
return $this->success($file);
|
||||
}
|
||||
|
||||
//删除文件
|
||||
public function delFile()
|
||||
{
|
||||
//获取参数
|
||||
$input = $this->_input;
|
||||
//获取参数
|
||||
if(!isset($input['ids'])) return $this->error('not file id,please check.');
|
||||
$filter['ids'] = $input['ids'];
|
||||
// $filter['uid'] = $this->uid;
|
||||
$filter['uniacid'] = $this->_uniacid;
|
||||
//生成模型
|
||||
$file_model = new CoreAttachment();
|
||||
//删除
|
||||
$result = $file_model->delAttach($filter);
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-04-08 14:16
|
||||
* @功能说明:获取上传配置
|
||||
*/
|
||||
public function uploadConfig(){
|
||||
|
||||
$data = longbingGetOssConfig($this->_uniacid);
|
||||
|
||||
$data['uniacid'] = $this->_uniacid;
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-04-08 14:17
|
||||
* @功能说明:上传文件到数据库
|
||||
*/
|
||||
public function addFile(){
|
||||
|
||||
$info = $this->_input;
|
||||
|
||||
$group_id = -1;
|
||||
|
||||
if(isset($info['group_id'])) {
|
||||
|
||||
$group_id = $info['group_id'];
|
||||
}
|
||||
//获取上传者id
|
||||
$info['uid'] = $this->uid;
|
||||
//$info['attachment_path'] = longbingGetFilePath($info['attachment'] , $this->_host,$this->_uniacid ,$info['longbing_driver']);
|
||||
//文件分组界定 --lichuanming 2020/5/13
|
||||
$info['group_id'] = $group_id;
|
||||
|
||||
$info['uniacid'] = $this->_uniacid;
|
||||
|
||||
$info['createtime'] = time();
|
||||
|
||||
$attachment_model = new CoreAttachment();
|
||||
|
||||
$data = $attachment_model->addAttach($info);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-08-13 15:26
|
||||
* @功能说明:图片移动分组
|
||||
*/
|
||||
public function moveGroup(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$attachment_model = new CoreAttachment();
|
||||
|
||||
$res = $attachment_model->where('id','in',$input['file_id'])->update(['group_id'=>$input['group_id']]);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
13
app/admin/controller/Index.php
Executable file
13
app/admin/controller/Index.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\Rest;
|
||||
use think\App;
|
||||
use think\facade\View;
|
||||
class Index extends Rest
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
return View::fetch();
|
||||
}
|
||||
}
|
||||
297
app/admin/controller/Menu.php
Executable file
297
app/admin/controller/Menu.php
Executable file
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\Rest;
|
||||
use app\AdminRest;
|
||||
use think\App;
|
||||
use think\Request;
|
||||
use app\admin\model\User as UserModel;
|
||||
use app\admin\model\Role as RoleModel;
|
||||
use app\admin\model\Module as ModuleModel;
|
||||
use app\admin\model\Menu as MenuModel;
|
||||
class Menu extends AdminRest
|
||||
{
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
//获取菜单列表
|
||||
public function listMenu() {
|
||||
//获取查询参数
|
||||
$param = $this->_param;
|
||||
//获取模块
|
||||
$module_model = new ModuleModel();
|
||||
$module_filter = ['is_base' => 1];
|
||||
if(isset($param['is_base'])) $module_filter['is_base'] = $param['is_base'];
|
||||
$modules = $module_model->listModuleAll($module_filter ,$this->_uniacid);
|
||||
//生成返回数据
|
||||
$result = [];
|
||||
foreach($modules as $module){
|
||||
$data = [];
|
||||
if(isset($module['path'])) $data['path'] = $module['path'];
|
||||
if(isset($module['component'])) $data['component'] = $module['component'];
|
||||
if(isset($module['redirect'])) $data['redirect'] = $module['redirect'];
|
||||
if(isset($module['is_base'])) $data['is_base'] = $module['is_base'];
|
||||
if(isset($module['menuName'])) $data['meta']['menuName'] = $module['menuName'];
|
||||
if(isset($module['icon'])) $data['meta']['icon'] = $module['icon'];
|
||||
//获取菜单信息
|
||||
$meun_model = new MenuModel();
|
||||
$menu_filter = ['uniacid' => $this->_uniacid , 'module_id' => $module['module_id'] ,'parent_id' => 0];
|
||||
$module['status'] = 0;
|
||||
if(!empty($module['is_base']) || !empty($module['is_public']))
|
||||
{
|
||||
$module['status'] = 1;
|
||||
}else{
|
||||
if(isset($module['module_app']['status'])) $module['status'] = $module['module_app']['status'];
|
||||
}
|
||||
if(empty($module['status'])) continue;
|
||||
$menus = $meun_model->listMenu($menu_filter);
|
||||
$child = [];
|
||||
$subNavNames = [];
|
||||
foreach($menus as $menu) {
|
||||
if(empty($menu['is_son_menu'])) {
|
||||
$child_data = [];
|
||||
if(isset($menu['menu_path'])) $child_data['path'] = $menu['menu_path'];
|
||||
if(isset($menu['component'])) $child_data['component'] = $menu['component'];
|
||||
if(isset($menu['name'])) $child_data['neme'] = $menu['name'];
|
||||
$child_data['meta']['title'] = null;
|
||||
if(isset($menu['title'])) $child_data['meta']['title'] = $menu['title'];
|
||||
$child_data['meta']['isOnly'] = true;
|
||||
if(empty($menu['isOnly'])) $child_data['meta']['isOnly'] = false;
|
||||
$child_data['meta']['pagePermission'] = [];
|
||||
$menu_filter['parent_id'] = $menu['menu_id'];
|
||||
$menu_filter['is_action'] = 1;
|
||||
$actions = $meun_model->listMenu($menu_filter);
|
||||
$auth = [];
|
||||
foreach($actions as $action){
|
||||
$auth[] = $action['name'];
|
||||
}
|
||||
$child_data['meta']['auth'] = $auth;
|
||||
$child[] = $child_data;
|
||||
}else{
|
||||
$subNavName = [];
|
||||
if(isset($menu['name'])) {
|
||||
$subNavName['subNavName'] = $menu['name'];
|
||||
}else{
|
||||
$subNavName['subNavName'] = null;
|
||||
}
|
||||
$menu_filter['parent_id'] = $menu['menu_id'];
|
||||
$menu_filter['is_action'] = 0;
|
||||
$leval_2_menus = $meun_model->listMenu($menu_filter);
|
||||
foreach($leval_2_menus as $leval_2_menu) {
|
||||
$url = [];
|
||||
if(isset($leval_2_menu['name'])) $url['name'] = $leval_2_menu['name'];
|
||||
if(isset($leval_2_menu['url'])) $url['url'] = $leval_2_menu['url'];
|
||||
$subNavName['url'][] = $url;
|
||||
$child_data = [];
|
||||
if(isset($leval_2_menu['menu_path'])) $child_data['path'] = $leval_2_menu['menu_path'];
|
||||
if(isset($leval_2_menu['name'])) $child_data['name'] = $leval_2_menu['name'];
|
||||
if(isset($leval_2_menu['component'])) $child_data['component'] = $leval_2_menu['component'];
|
||||
|
||||
if(isset($leval_2_menu['title'])) $child_data['meta']['title'] = $leval_2_menu['title'];
|
||||
// if(isset($leval_2_menu['component'])) $child_data['meta']['component'] = $leval_2_menu['component'];
|
||||
$child_data['meta']['isOnly'] = false;
|
||||
if(!empty($leval_2_menu['isOnly'])) $child_data['meta']['isOnly'] = true;
|
||||
|
||||
$child_data['meta']['auth'] = [];
|
||||
|
||||
if(!empty($leval_2_menu['is_son_menu'])){
|
||||
$pagePermissions = [];
|
||||
$menu_filter['parent_id'] = $leval_2_menu['menu_id'];
|
||||
$menu_filter['is_action'] = 0;
|
||||
$leval_3_menus = $meun_model->listMenu($menu_filter);
|
||||
|
||||
// if(in_array('c3', [$leval_2_menu['menu_id']])){
|
||||
// var_dump(json_encode($leval_3_menus));die;
|
||||
// }
|
||||
|
||||
foreach($leval_3_menus as $leval_3_menu){
|
||||
$pagePermission = [];
|
||||
if(isset($leval_3_menu['title'])) $pagePermission['title'] = $leval_3_menu['title'];
|
||||
if(isset($leval_3_menu['index'])) $pagePermission['index'] = $leval_3_menu['index'];
|
||||
$menu_filter['parent_id'] = $leval_3_menu['menu_id'];
|
||||
$menu_filter['is_action'] = 1;
|
||||
$actions = $meun_model->listMenu($menu_filter);
|
||||
foreach($actions as $action) {
|
||||
$pagePermission['auth'][] = $action['name'];
|
||||
}
|
||||
$pagePermissions[] = $pagePermission;
|
||||
}
|
||||
$child_data['meta']['pagePermission'] = $pagePermissions;
|
||||
}
|
||||
$child[] = $child_data;
|
||||
}
|
||||
$subNavNames[] = $subNavName;
|
||||
|
||||
}
|
||||
}
|
||||
$data['meta']['subNavName'] = $subNavNames;
|
||||
$data['children'] = $child;
|
||||
$result[] = $data;
|
||||
}
|
||||
return $this->success($result);
|
||||
}
|
||||
//获取菜单详情
|
||||
public function getMenu() {
|
||||
$param = $this->_param;
|
||||
$module_filter = [];
|
||||
if(isset($param['module_id'])) $module_filter['module_id'] = $param['module_id'];
|
||||
if(empty($module_filter)) return $this->error('module id is not exist ,please check param.');
|
||||
$module_model = new ModuleModel();
|
||||
//获取模块信息
|
||||
$module = $module_model->getModule($module_filter ,$this->_uniacid);
|
||||
|
||||
if(empty($module)) $this->success([]);
|
||||
$module['status'] = 0;
|
||||
if(!empty($module['is_base']) || !empty($module['is_public']))
|
||||
{
|
||||
$module['status'] = 1;
|
||||
}else{
|
||||
if(isset($module['module_app']['status'])) $module['status'] = $module['module_app']['status'];
|
||||
}
|
||||
if(empty($module['status'])) return $this->success([]);
|
||||
//生成返回数据
|
||||
$data = [];
|
||||
if(isset($module['path'])) $data['path'] = $module['path'];
|
||||
if(isset($module['component'])) $data['component'] = $module['component'];
|
||||
if(isset($module['redirect'])) $data['redirect'] = $module['redirect'];
|
||||
if(isset($module['is_base'])) $data['is_base'] = $module['is_base'];
|
||||
if(isset($module['menuName'])) $data['meta']['menuName'] = $module['menuName'];
|
||||
if(isset($module['icon'])) $data['meta']['icon'] = $module['icon'];
|
||||
//获取菜单信息
|
||||
$meun_model = new MenuModel();
|
||||
$menu_filter = ['uniacid' => $this->_uniacid , 'module_id' => $module['module_id'] ,'parent_id' => 0];
|
||||
$module['status'] = 0;
|
||||
if(!empty($module['is_base']) || !empty($module['is_public']))
|
||||
{
|
||||
$module['status'] = 1;
|
||||
}else{
|
||||
if(isset($module['module_app']['status'])) $module['status'] = $module['module_app']['status'];
|
||||
}
|
||||
$menus = $meun_model->listMenu($menu_filter);
|
||||
if(empty($menus)) return $this->success($data);
|
||||
$child = [];
|
||||
$subNavNames = [];
|
||||
foreach($menus as $menu) {
|
||||
if(empty($menu['is_son_menu'])) {
|
||||
$child_data = [];
|
||||
if(isset($menu['menu_path'])) $child_data['path'] = $menu['menu_path'];
|
||||
if(isset($menu['component'])) $child_data['component'] = $menu['component'];
|
||||
if(isset($menu['name'])) $child_data['neme'] = $menu['name'];
|
||||
$child_data['meta']['title'] = null;
|
||||
if(isset($menu['title'])) $child_data['meta']['title'] = $menu['title'];
|
||||
$child_data['meta']['isOnly'] = true;
|
||||
if(empty($menu['isOnly'])) $child_data['meta']['isOnly'] = false;
|
||||
$child_data['meta']['pagePermission'] = [];
|
||||
$menu_filter['parent_id'] = $menu['menu_id'];
|
||||
$menu_filter['is_action'] = 1;
|
||||
$actions = $meun_model->listMenu($menu_filter);
|
||||
$auth = [];
|
||||
foreach($actions as $action){
|
||||
$auth[] = $action['name'];
|
||||
}
|
||||
$child_data['meta']['auth'] = $auth;
|
||||
$child[] = $child_data;
|
||||
}else{
|
||||
$subNavName = [];
|
||||
if(isset($menu['name'])) {
|
||||
$subNavName['subNavName'] = $menu['name'];
|
||||
}else{
|
||||
$subNavName['subNavName'] = null;
|
||||
}
|
||||
$menu_filter['parent_id'] = $menu['menu_id'];
|
||||
$menu_filter['is_action'] = 0;
|
||||
$leval_2_menus = $meun_model->listMenu($menu_filter);
|
||||
foreach($leval_2_menus as $leval_2_menu) {
|
||||
$url = [];
|
||||
if(isset($leval_2_menu['name'])) $url['name'] = $leval_2_menu['name'];
|
||||
if(isset($leval_2_menu['url'])) $url['url'] = $leval_2_menu['url'];
|
||||
$subNavName['url'][] = $url;
|
||||
$child_data = [];
|
||||
if(isset($leval_2_menu['menu_path'])) $child_data['path'] = $leval_2_menu['menu_path'];
|
||||
if(isset($leval_2_menu['name'])) $child_data['name'] = $leval_2_menu['name'];
|
||||
if(isset($leval_2_menu['component'])) $child_data['component'] = $leval_2_menu['component'];
|
||||
|
||||
if(isset($leval_2_menu['title'])) $child_data['meta']['title'] = $leval_2_menu['title'];
|
||||
// if(isset($leval_2_menu['component'])) $child_data['meta']['component'] = $leval_2_menu['component'];
|
||||
$child_data['meta']['isOnly'] = false;
|
||||
if(!empty($leval_2_menu['isOnly'])) $child_data['meta']['isOnly'] = true;
|
||||
|
||||
$child_data['meta']['auth'] = [];
|
||||
|
||||
if(!empty($leval_2_menu['is_son_menu'])){
|
||||
$pagePermissions = [];
|
||||
$menu_filter['parent_id'] = $leval_2_menu['menu_id'];
|
||||
$menu_filter['is_action'] = 0;
|
||||
$leval_3_menus = $meun_model->listMenu($menu_filter);
|
||||
|
||||
// if(in_array('c3', [$leval_2_menu['menu_id']])){
|
||||
// var_dump(json_encode($leval_3_menus));die;
|
||||
// }
|
||||
|
||||
foreach($leval_3_menus as $leval_3_menu){
|
||||
$pagePermission = [];
|
||||
if(isset($leval_3_menu['title'])) $pagePermission['title'] = $leval_3_menu['title'];
|
||||
if(isset($leval_3_menu['index'])) $pagePermission['index'] = $leval_3_menu['index'];
|
||||
$menu_filter['parent_id'] = $leval_3_menu['menu_id'];
|
||||
$menu_filter['is_action'] = 1;
|
||||
$actions = $meun_model->listMenu($menu_filter);
|
||||
foreach($actions as $action) {
|
||||
$pagePermission['auth'][] = $action['name'];
|
||||
}
|
||||
$pagePermissions[] = $pagePermission;
|
||||
}
|
||||
$child_data['meta']['pagePermission'] = $pagePermissions;
|
||||
}
|
||||
$child[] = $child_data;
|
||||
}
|
||||
$subNavNames[] = $subNavName;
|
||||
}
|
||||
}
|
||||
$data['meta']['subNavName'] = $subNavNames;
|
||||
$data['children'] = $child;
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* By.jingshuixian
|
||||
* 2019年11月23日14:17:16
|
||||
*/
|
||||
public function getMenuList()
|
||||
{
|
||||
//By.jingshuixian
|
||||
//2019年11月23日16:23:26
|
||||
//测试新的载入方式
|
||||
$menu_data = longbing_init_info_data('AdminMenu');
|
||||
return $this->success($menu_data);
|
||||
|
||||
|
||||
|
||||
|
||||
//所有的菜单的json文件
|
||||
$allAdminMenus = include APP_PATH . "Common/extend/menu/allAdminMenus.php";
|
||||
//平台的菜单配置
|
||||
$memu_config = Config('app.adminMenus');
|
||||
//菜单权限
|
||||
$pluginAuth = longbingGetPluginAuth($this->_uniacid);
|
||||
$auth = $pluginAuth['web_manage_meta_config'];
|
||||
|
||||
|
||||
$auth_meta_permission = [];//前端导航栏配置json
|
||||
foreach ($memu_config as $menu_name) {
|
||||
if (!isset($allAdminMenus[$menu_name]) || ($menu_name !== 'App' && $auth[$menu_name] !== 1) ) {
|
||||
continue;
|
||||
}
|
||||
$menu_data = json_decode($allAdminMenus[$menu_name], true);
|
||||
//如果代理管理端有版权设置, 【系统】菜单中的子菜单【版权管理】不展示
|
||||
|
||||
|
||||
|
||||
$auth_meta_permission[] = $menu_data;
|
||||
|
||||
}
|
||||
|
||||
return $this->success($auth_meta_permission);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
94
app/admin/controller/Module.php
Executable file
94
app/admin/controller/Module.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\Rest;
|
||||
use app\AdminRest;
|
||||
use think\App;
|
||||
use think\Request;
|
||||
use app\admin\model\User as UserModel;
|
||||
use app\admin\model\Module as ModuleModel;
|
||||
class Module extends Rest
|
||||
{
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
//获取应用列表
|
||||
public function listModule() {
|
||||
//获取模块信息
|
||||
$param = $this->_param;
|
||||
$module_model = new ModuleModel();
|
||||
//设置默认数据
|
||||
$filter['is_base'] = 1;
|
||||
if(isset($param['is_base'])) $filter['is_base'] = $param['is_base'];
|
||||
//获取模块列表
|
||||
$modules = $module_model->listModuleAll($filter ,$this->_uniacid);
|
||||
// echo json_encode($modules ,true);die;
|
||||
$result = [];
|
||||
//处理数据
|
||||
foreach($modules as $module)
|
||||
{
|
||||
//设置默认数据
|
||||
$module['status'] = 1;
|
||||
//判断模块是否是基础模块
|
||||
if(empty($module['is_base'])){
|
||||
//判断插件是否授权
|
||||
if(isset($module['module_app']['status']))
|
||||
{
|
||||
//设置状态
|
||||
$module['status'] = $module['module_app']['status'];
|
||||
}else{
|
||||
$module['status'] = 0;
|
||||
}
|
||||
}
|
||||
//移除module_app信息
|
||||
unset($module['module_app']);
|
||||
$result[] = $module;
|
||||
|
||||
}
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//获取应用详情
|
||||
public function getModule() {
|
||||
//获取参数
|
||||
$param = $this->_param;
|
||||
$filter = [];
|
||||
//判断相关参数是否存在
|
||||
if(isset($param['module_id'])) $filter['module_id'] = $param['module_id'];
|
||||
if(isset($param['is_base'])) $filter['is_base'] = $param['is_base'];
|
||||
//判断查询参数是否存在,不存在抛出异常
|
||||
if(empty($filter)) return $this->error('module id is not exist ,please check param.');
|
||||
//生成模块模型
|
||||
$module_model = new ModuleModel();
|
||||
//查询模块信息
|
||||
$module = $module_model->getModule($filter ,$this->_uniacid);
|
||||
if(!empty($module)) {
|
||||
$module['status'] = 0;
|
||||
if(!empty($module['is_public']) || !empty($module['is_base'])){
|
||||
$module['status'] = 1;
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//判断是否是公共模块
|
||||
if(empty($module['is_public'])){
|
||||
//数据处理
|
||||
if(empty($module['is_base'])){
|
||||
if(isset($module['module_app']['status']))
|
||||
{
|
||||
$module['status'] = $module['module_app']['status'];
|
||||
}else{
|
||||
$module['status'] = 0;
|
||||
}
|
||||
}
|
||||
//移除module_app数据
|
||||
unset($module['module_app']);
|
||||
}
|
||||
}
|
||||
//返回数据
|
||||
return $this->success($module);
|
||||
}
|
||||
}
|
||||
98
app/admin/controller/Role.php
Executable file
98
app/admin/controller/Role.php
Executable file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\Rest;
|
||||
use think\App;
|
||||
use think\Request;
|
||||
use app\admin\model\User as UserModel;
|
||||
use app\admin\model\Role as RoleModel;
|
||||
class Role extends Rest
|
||||
{
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
}
|
||||
//创建权限
|
||||
public function createRole() {
|
||||
//获去角色信息
|
||||
$role = $this->_input['role'];
|
||||
//生成和填充相关数据
|
||||
$role['role_id'] = uuid();
|
||||
$role['uniacid'] = $this->_uniacid;
|
||||
//生成权限数据库操作模型
|
||||
$role_model = new RoleModel;
|
||||
//创建
|
||||
$result = $role_model->createRole($role);
|
||||
//返回相关数据
|
||||
return $this->seccess($result);
|
||||
|
||||
}
|
||||
//获取权限列表
|
||||
public function listRole() {
|
||||
//获取权限查询信息
|
||||
$param = $this->_param;
|
||||
//获取分页信息
|
||||
$page_config = array(
|
||||
'page' => 1,
|
||||
'page_count' => 20
|
||||
);
|
||||
if(isset($param['page']) && $param['page'] > 0) $page_config['page'] = $param['page'];
|
||||
if(isset($param['page_count']) && $param['page_count'] > 0) $page_config['page_count'] = $param['page_count'];
|
||||
//查询过滤
|
||||
$filter = $param;
|
||||
$filter['uniacid'] = $this->_uniacid;
|
||||
//生成权限操作模型
|
||||
$role_model = new RoleModel();
|
||||
//获取权限列表
|
||||
$page_config['totle'] = $role_model->listRoleCount($filter);
|
||||
$roles = $role_model->listRole($filter ,$page_config);
|
||||
//生成返回数据
|
||||
$page_config['total_page'] = (int)($page_config['total'] / $page_config['page_count']);
|
||||
if(($page_config['total'] % $page_config['page_count']) > 0) $page_config['total_page'] = $page_config['total_page'] + 1;
|
||||
$result = $page_config;
|
||||
$result['roles'] = $roles;
|
||||
return $this->success($result);
|
||||
}
|
||||
//获取权限详情
|
||||
public function getRole() {
|
||||
//获取权限id
|
||||
$role_id = $this->_param['role_id'];
|
||||
//生成权限操作模型
|
||||
$role_model = new RoleModel();
|
||||
//获取权限数据
|
||||
$role = $role_model->getRole(['role_id' => $role_id ,'uniacid' => $this->_uniacid]);
|
||||
return $this->success($role);
|
||||
}
|
||||
//更改权限信息
|
||||
public function updateRole() {
|
||||
//获取角色id
|
||||
$role_id = $this->_param['role_id'];
|
||||
//判断权限是否存在
|
||||
$role_model = new RoleModel();
|
||||
$role = $role_model->getRole(['role_id' => $role_id ,'uniacid' => $this->_uniacid]);
|
||||
if(empty($role)) return $this->error('the role is nit exist ,please check the role id.');
|
||||
//获去角色更新信息
|
||||
$role = $this->_input['role'];
|
||||
//更新
|
||||
$result = $role_model->updateRole(['role_id' => $role_id ,'uniacid' => $this->_uniacid] ,$role);
|
||||
//返回相关数据
|
||||
return $this->seccess($result);
|
||||
}
|
||||
//删除权限信息
|
||||
public function delRole() {
|
||||
//获取角色id
|
||||
$role_id = $this->_param['role_id'];
|
||||
//判断权限是否存在
|
||||
$role_model = new RoleModel();
|
||||
$role = $role_model->getRole(['role_id' => $role_id ,'uniacid' => $this->_uniacid]);
|
||||
if(empty($role)) return $this->error('the role is nit exist ,please check the role id.');
|
||||
//更新
|
||||
$result = $role_model->delRole(['role_id' => $role_id ,'uniacid' => $this->_uniacid]);
|
||||
if(!empty($result)) {
|
||||
$user_model = new UserModel();
|
||||
$user_model->update(['role_id' => $role_id ,'uniacid' => $this->_uniacid] ,['role_id' => 0]);
|
||||
}
|
||||
//返回相关数据
|
||||
return $this->seccess($result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
51
app/admin/controller/Update.php
Executable file
51
app/admin/controller/Update.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\admin\service\UpdateService;
|
||||
use app\AdminRest;
|
||||
use app\card\info\InitData;
|
||||
use app\diy\service\DiyService;
|
||||
use think\App;
|
||||
|
||||
class Update extends AdminRest
|
||||
{
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
/**
|
||||
* By.jingshuixian
|
||||
* 2019年11月23日21:43:47
|
||||
* 升级脚本导入执行
|
||||
*/
|
||||
public function update(){
|
||||
|
||||
// return $this->success([]);
|
||||
$key = 'init_all_data';
|
||||
|
||||
$data = getCache($key,$this->_uniacid);
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
return $this->success([]);
|
||||
|
||||
}
|
||||
|
||||
setCache($key,1,7200,$this->_uniacid);
|
||||
|
||||
UpdateService::installSql($this->_uniacid);
|
||||
|
||||
UpdateService::initWeiqinConfigData();
|
||||
|
||||
DiyService::addDefaultDiyData($this->_uniacid);
|
||||
//各个模块初始化数据事件
|
||||
event('InitModelData');
|
||||
//处理雷达
|
||||
lbInitRadarMsg($this->_uniacid);
|
||||
|
||||
return $this->success([]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
168
app/admin/controller/User.php
Executable file
168
app/admin/controller/User.php
Executable file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\Rest;
|
||||
use think\App;
|
||||
use think\Request;
|
||||
use app\admin\model\Admin as UserModel;
|
||||
use app\admin\model\AdminRole as UserRoleModel;
|
||||
class User extends Rest
|
||||
{
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
}
|
||||
//创建用户
|
||||
public function createUser() {
|
||||
$user = $this->_input['user'];
|
||||
$data = checkAccountIsExist($user['account'] ,$this->_uniacid);
|
||||
//判读账号是否存在
|
||||
if($data) return $this->error('account is exist ,please check again.');
|
||||
|
||||
$user_id = uuid();
|
||||
$user['user_id'] = $user_id;
|
||||
$user['offset'] = createOffset();
|
||||
$user['passwd'] = createPasswd($user['passwd'] ,$user['offset']);
|
||||
$user['uniacid'] = $this->_uniacid;
|
||||
//判断权限
|
||||
if(!isset($user['role_id']) || !ckeckRole($user['role_id'] ,$this->_uniacid)) $user['role_id'] = getRole()['role_id'];
|
||||
if(!empty($this->_user))$user['creator_id'] = $this->_user['user_id'];
|
||||
//创建数据
|
||||
$user_model = new UserModel();
|
||||
$result = $user_model->createUser($user);
|
||||
// if(!empty($result)) setAccountToCache($user['account'] ,$this->_uniacid);
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//获取用户列表
|
||||
public function listUser() {
|
||||
//获取查询参数
|
||||
$param = $this->_param;
|
||||
//获取分页数据
|
||||
$page_config = array(
|
||||
'page' => 1,
|
||||
'page_count' => 20
|
||||
);
|
||||
if(isset($param['page']) && $param['page'] > 0) $page_config['page'] = $param['page'];
|
||||
if(isset($param['page_count']) && $param['page_count'] > 0) $page_config['page_count'] = $param['page_count'];
|
||||
|
||||
//参数过滤
|
||||
$param['uniacid'] = $this->_uniacid;
|
||||
$filter = listUserFilter($param);
|
||||
//查询数据
|
||||
$user_model = new UserModel();
|
||||
//获取总数据总条数
|
||||
$page_config['total'] = $user_model->listUserCount($filter);
|
||||
|
||||
$users = $user_model->listUser($filter ,$page_config);
|
||||
//构造返回数据
|
||||
$page_config['total_page'] = (int)($page_config['total'] / $page_config['page_count']);
|
||||
if(($page_config['total'] % $page_config['page_count']) > 0) $page_config['total_page'] = $page_config['total_page'] + 1;
|
||||
$result = $page_config;
|
||||
$result['users'] = $users;
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//获取用户详情
|
||||
public function getUser() {
|
||||
$user_id = $this->_param['user_id'];
|
||||
//获取用户详细信息
|
||||
$user_model = new UserModel();
|
||||
$user = $user_model->getUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid]);
|
||||
//移除密码 偏移量
|
||||
unset($user['passwd']);
|
||||
unset($user['offset']);
|
||||
//返回数据
|
||||
return $this->success($user);
|
||||
}
|
||||
|
||||
//修改用户信息
|
||||
public function updateUser() {
|
||||
//获取用户id
|
||||
$user_id = $this->_param['user_id'];
|
||||
//生成用户模型类
|
||||
$user_model = new UserModel();
|
||||
//获取用户数据
|
||||
$user = $user_model->getUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid]);
|
||||
if(empty($user)) return $this->error('the user not is exist ,please check user id.');
|
||||
//获取修改信息
|
||||
$user_data = getUpdateUserFilter($this->_input['user']);
|
||||
//更改密码
|
||||
if(isset($user_data['passwd'])){
|
||||
//判断偏移量是否存在
|
||||
if(!isset($user['offset'])) $user['offset'] = createOffset(); $user_data['offset'] = $user['offset'];
|
||||
$user_data['passwd'] = createPasswd($user_data['passwd'] ,$user['offset']);
|
||||
}
|
||||
//修改数据
|
||||
$result = $user_model->updateUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid] ,$user_data);
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
//删除用户
|
||||
public function delUser() {
|
||||
//获取用户id
|
||||
$user_id = $this->_param['user_id'];
|
||||
//生成用户模型类
|
||||
$user_model = new UserModel();
|
||||
//获取用户数据
|
||||
$user = $user_model->getUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid]);
|
||||
if(empty($user)) return $this->error('the user not is exist ,please check user id.');
|
||||
//删除用户数据
|
||||
$result = $user_model->delUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid] ,['deleted' => 0]);
|
||||
//删除用户权限信息
|
||||
$admin_role_model = new UserRoleModel();
|
||||
$admin_role_model->delUserRole(['user_id' => $user_id]);
|
||||
//删除数据缓存
|
||||
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
//给用户增加权限
|
||||
public function setUserRole() {
|
||||
//获取用户id
|
||||
$user_id = $this->_param['user_id'];
|
||||
//获取角色id
|
||||
$role_id = $this->_param['role_id'];
|
||||
//生成用户模型类
|
||||
$user_model = new UserModel();
|
||||
//获取用户数据
|
||||
$user = $user_model->getUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid]);
|
||||
if(empty($user)) return $this->error('the user is not exist ,please check user id.');
|
||||
//获取角色信息
|
||||
$role = ckeckRole($role_id);
|
||||
if(empty($role)) return $this->error('the role is not exist ,please check role id.');
|
||||
//判断用户权限是否已存在
|
||||
$exist_role_ids = [];
|
||||
foreach($user['role'] as $role){
|
||||
$exist_role_ids[] = $role['role_ids'];
|
||||
}
|
||||
if(in_array($role_id, $exist_role_ids)) return $this->error('the user had the role ,please do not repeat add role to the user.');
|
||||
//添加角色
|
||||
$user_role_model = UserRoleModel();
|
||||
$result = $user_role_model->createUserRole(['user_id' => $user_id ,$role_id => $role_id ,'uniacid' => $this->_uniacid]);
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
//移除用户权限
|
||||
public function removeUserRole() {
|
||||
//获取用户id
|
||||
$user_id = $this->_param['user_id'];
|
||||
//获取角色id
|
||||
$role_id = $this->_param['role_id'];
|
||||
//生成用户模型类
|
||||
$user_model = new UserModel();
|
||||
//获取用户数据
|
||||
$user = $user_model->getUser(['user_id' => $user_id ,'uniacid' => $this->_uniacid]);
|
||||
if(empty($user)) return $this->error('the user is not exist ,please check user id.');
|
||||
//判断用户权限是否已存在
|
||||
$exist_role_ids = [];
|
||||
foreach($user['role'] as $role){
|
||||
$exist_role_ids[] = $role['role_ids'];
|
||||
}
|
||||
if(!in_array($role_id, $exist_role_ids)) return $this->error('the user role is not exist ,please check role id.');
|
||||
//添加角色
|
||||
$user_role_model = UserRoleModel();
|
||||
$result = $user_role_model->delUserRole(['user_id' => $user_id ,$role_id => $role_id ,'uniacid' => $this->_uniacid]);
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
}
|
||||
47
app/admin/controller/Wx.php
Executable file
47
app/admin/controller/Wx.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use think\App;
|
||||
use app\ApiRest;
|
||||
class Wx extends ApiRest
|
||||
{
|
||||
// 继承 验证用户登陆
|
||||
public function __construct ( App $app )
|
||||
{
|
||||
parent::__construct( $app );
|
||||
}
|
||||
|
||||
public function getTabbar()
|
||||
{
|
||||
$tabbars = longbingGetAppTabbar($this->_uniacid);
|
||||
$tabbars = longbingGetWxAppTabbarResponse($tabbars);
|
||||
|
||||
|
||||
$pluginAuth = longbingGetPluginAuth($this->_uniacid);
|
||||
|
||||
$plugin_map = [
|
||||
"activity"=> 'activity',
|
||||
'appointment' => 'appoint',
|
||||
'house' => 'house',
|
||||
];
|
||||
$meta_map = [
|
||||
'card' => 'BusinessCard',
|
||||
'shop' => 'Malls',
|
||||
'dynamic' => 'Dynamic',
|
||||
'website' => 'Website',
|
||||
];
|
||||
|
||||
|
||||
foreach ($tabbars['data'] as $k => $item) {
|
||||
if (in_array($k, array_keys($plugin_map)) && ($pluginAuth['plugin'][$plugin_map[$k]] == 0)) {
|
||||
unset($tabbars['data'][$k]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($k, array_keys($meta_map)) && ($pluginAuth['web_manage_meta_config'][$meta_map[$k]] == 0)) {
|
||||
unset($tabbars['data'][$k]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return $this->success($tabbars);
|
||||
}
|
||||
}
|
||||
95
app/admin/controller/WxFile.php
Executable file
95
app/admin/controller/WxFile.php
Executable file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
use app\ApiRest;
|
||||
use think\App;
|
||||
use think\Request;
|
||||
use app\admin\model\AttachmentGroup;
|
||||
use app\admin\model\CoreAttachment;
|
||||
use app\Common\Upload;
|
||||
class WxFile extends ApiRest
|
||||
{
|
||||
protected $uid = null;
|
||||
public function __construct(App $app) {
|
||||
parent::__construct($app);
|
||||
//测试数据
|
||||
$this->uid = $this->getUserId();
|
||||
}
|
||||
//上传文件
|
||||
public function uploadFile()
|
||||
{
|
||||
$input = $this->_param;
|
||||
$file = $this->request->file('file');
|
||||
if(empty($file)) $file = $this->request->file('files');
|
||||
if(empty($file)) $file = $this->request->file('filePath');
|
||||
if(empty($file)) return $this->error('not file ,please check file.');
|
||||
$uploda_model = new Upload($this->_uniacid);
|
||||
$type = 'picture';
|
||||
if(isset($input['type'])) $type = $input['type'];
|
||||
$info = $uploda_model->upload($type ,$file);
|
||||
$result = false;
|
||||
if(!empty($info))
|
||||
{
|
||||
if(isset($info['attachment']) && !empty($info['attachment']))
|
||||
{
|
||||
$info['attachment_path'] = $info['attachment'];
|
||||
$info = transImagesOne($info ,['attachment_path'] ,$this->_uniacid);
|
||||
}
|
||||
//获取上传者id
|
||||
$info['uid'] = $this->uid;
|
||||
// $info['attachment_path'] = longbingGetFilePath($info['attachment'] , $this->_host,$this->_uniacid);
|
||||
//数据来源
|
||||
$info['from'] = 'wx';
|
||||
//写入数据库
|
||||
$attachment_model = new CoreAttachment();
|
||||
$data = $attachment_model->createAttach($info);
|
||||
//判断写入数据库是否成功
|
||||
if(!empty($data)) $result = $info;
|
||||
}
|
||||
//数据处理
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
public function uploadFiles()
|
||||
{
|
||||
//获取参数
|
||||
$input = $this->_param;
|
||||
//获取文件列表
|
||||
$files = $this->request->file('file');
|
||||
if(empty($files)) $files = $this->request->file('files');
|
||||
if(empty($files)) $files = $this->request->file('filePath');
|
||||
//检查文件是否存在
|
||||
if(empty($files)) return $this->error('not file ,please check file.');
|
||||
//设置类型
|
||||
$type = 'picture';
|
||||
if(isset($input['type'])) $type = $input['type'];
|
||||
$result = [];
|
||||
//生成上传模型
|
||||
$uploda_model = new Upload($this->_uniacid);
|
||||
foreach($files as $file)
|
||||
{
|
||||
//上传文件
|
||||
$info = $uploda_model->upload($type ,$file);
|
||||
|
||||
if(!empty($info))
|
||||
{
|
||||
if(isset($info['attachment']) && !empty($info['attachment']))
|
||||
{
|
||||
$info['attachment_path'] = $info['attachment'];
|
||||
$info = transImagesOne($info ,['attachment_path'] ,$this->_uniacid);
|
||||
}
|
||||
//获取上传者id
|
||||
$info['uid'] = $this->uid;
|
||||
// $info['attachment_path'] = longbingGetFilePath($info['attachment'] , $this->_host,$this->_uniacid);
|
||||
//数据来源
|
||||
$info['from'] = 'wx';
|
||||
//写入数据库
|
||||
$attachment_model = new CoreAttachment();
|
||||
$data = $attachment_model->createAttach($info);
|
||||
//判断写入数据库是否成功
|
||||
if(!empty($data)) $result[] = $info;
|
||||
}
|
||||
}
|
||||
//数据处理
|
||||
return $this->success($result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user