常用类完善

This commit is contained in:
sugar1569 2019-04-02 18:12:50 +08:00
parent 1a96b654fc
commit 1b449b83df
6 changed files with 44 additions and 10 deletions

View File

@ -15,7 +15,7 @@ class CacheService
protected static $globalCacheName = '_cached_1515146130';
public static function set($name, $value, $expire = 0)
public static function set($name, $value, $expire = 3600)
{
return self::handler()->set($name,$value,$expire);
}

View File

@ -21,7 +21,9 @@ class FormBuilder extends Form
* 1 父级刷新 不能再提交
* 2 父级刷新关闭弹框 不能再提交 成功关闭
* 3 父页面刷新可以重复添加 可以再次提交
* 4 不能再提交
* 4 父级不刷新 不能再提交
* 5 父级不刷新 不能再提交 关闭弹窗
* 6 父级不刷新 当前窗口刷新
* str 自定义
* @return $this
*/
@ -44,6 +46,12 @@ class FormBuilder extends Form
case 4:
$js = '$r.btn.disabled(false);$r.btn.finish();';//提交成功不能再提交
break;
case 5:
$js = '$r.btn.disabled(false);$r.btn.finish();setTimeout(function(){parent.layer.close(parent.layer.getFrameIndex(window.name));},2000);';//父级不刷新 不能再提交 关闭弹窗
break;
case 6:
$js = 'setTimeout(function(){window.location.reload(),2000});';//父级不刷新 当前窗口刷新
break;
default:
$js = $jscallback;
break;

View File

@ -58,4 +58,13 @@ class JsonService
return self::result(400,$msg,$data);
}
public static function success($msg,$data=[])
{
if(true == is_array($msg)){
$data = $msg;
$msg = self::$SUCCESSFUL_DEFAULT_MSG;
}
return self::result(200,$msg,$data);
}
}

View File

@ -1,8 +1,6 @@
<?php
namespace service;
use PHPExcel_IOFactory;
use PHPExcel;
use service\JsonService as Json;
use think\Request;
@ -61,7 +59,7 @@ class PHPExcelService
* return
*/
private static function initialize($data,$fun){
// vendor("PHPExcel.PHPExcel.PHPExcel");
vendor("PHPExcel.PHPExcel.PHPExcel");
self::$PHPExcel= new \PHPExcel();
if($fun!==null && is_callable($fun)){
self::$styleArray=$fun();

View File

@ -9,6 +9,7 @@ namespace service;
use app\admin\model\system\SystemConfig;
use service\CacheService as Cache;
/** 获取系统配置服务类
* Class SystemConfigService
@ -34,16 +35,28 @@ class SystemConfigService
*/
public static function get($key)
{
return SystemConfig::getValue($key);
$cacheName = 'config_'.$key;
$config = Cache::get($cacheName);
if($config) return $config;
$config = SystemConfig::getValue($key);
Cache::set($cacheName,$config);
return $config;
}
/** 获取多个配置
* @param $keys ',' 隔开
* @return array
*/
public static function more($keys)
public static function more($keys,$update = false)
{
return SystemConfig::getMore($keys);
$keys = is_array($keys) ? implode(',',$keys) : $keys;
$cacheName = 'more_'.$keys;
$config = Cache::get($cacheName);
if($config && !$update) return $config;
$config = SystemConfig::getMore($keys);
if(!$config) exception('对应的配置不存在!');
Cache::set($cacheName,$config);
return $config;
}
/**获取全部配置
@ -51,7 +64,13 @@ class SystemConfigService
*/
public static function getAll()
{
return SystemConfig::getAllConfig()?:[];
$cacheName = 'config_all';
$config = Cache::get($cacheName);
if($config) return $config;
$config = SystemConfig::getAllConfig()?:[];
if(!$config) exception('对应的配置不存在!');
Cache::set($cacheName,$config);
return $config;
}
}

View File

@ -68,7 +68,7 @@ class WechatTemplateService
* @param string $defaultColor
* @return bool
*/
public static function sendAdminNoticeTemplate(array $data,$url = null,$defaultColor = '')
public static function sendAdminNoticeTemplate(array $data,$url = 'pages/index/index',$defaultColor = '')
{
$adminIds = explode(',',trim(SystemConfigService::get('site_store_admin_uids')));
$kefuIds = ServiceModel::where('notify',1)->column('uid');