Skip to content

Commit

Permalink
init app
Browse files Browse the repository at this point in the history
  • Loading branch information
dashingunique committed May 15, 2020
1 parent 8d1e95a commit 9e2cc6e
Show file tree
Hide file tree
Showing 88 changed files with 5,163 additions and 38 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.idea
/.vscode
/vendor/
/runtime
*.log
.env
compoer.lock
32 changes: 32 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
All rights reserved。
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。

Apache Licence是著名的非盈利开源组织Apache采用的协议。
该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,
允许代码修改,再作为开源或商业软件发布。需要满足
的条件:
1. 需要给代码的用户一份Apache Licence ;
2. 如果你修改了代码,需要在被修改的文件中说明;
3. 在延伸的代码中(修改和有源代码衍生的代码中)需要
带有原来代码中的协议,商标,专利声明和其他原来作者规
定需要包含的说明;
4. 如果再发布的产品中包含一个Notice文件,则在Notice文
件中需要带有本协议内容。你可以在Notice中增加自己的
许可,但不可以表现为对Apache Licence构成更改。
具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# shier-erp library 十贰erp拓展库

基于PHP7.4+

1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

42 changes: 42 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "dashingunique/shier-erp-library",
"description": "erp",
"type": "src",
"license": "Apache-2.0",
"authors": [
{
"name": "dashing unique",
"email": "1107842285@qq.com"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=7.4",
"ext-gd": "*",
"ext-curl": "*",
"ext-json": "*",
"ext-iconv": "*",
"topthink/framework": "^6.0.0",
"topthink/think-orm": "^2.0",
"topthink/think-multi-app": "^1.0",
"topthink/think-queue": "^3.0",
"yupoxiong/region": "^1.1",
"hashids/hashids": "^4.0",
"thans/tp-jwt-auth": "^1.0"
},
"autoload": {
"files": [
"src/common.php"
],
"psr-4": {
"think\\admin\\": "src"
}
},
"extra": {
"think": {
"services": [
"erp\\service\\ErpService"
]
}
}
}
37 changes: 0 additions & 37 deletions index.md

This file was deleted.

53 changes: 53 additions & 0 deletions src/Auth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* 十贰进销存系统
* ==========================================================================
* @link https://github.com/dashingunique/shier-erp
* @license https://github.com/dashingunique/shier-erp/blob/master/LICENSE.txt License
* @Desc 授权驱动类
* ==========================================================================
* @author 张大宝的程序人生 <1107842285@qq.com>
*/

declare(strict_types=1);

namespace erp;

use think\Manager;

class Auth extends Manager
{
/**
* @var string 命名空间
*/
protected $namespace = '\\erp\\library\\auth\\';

/**
* 验证器驱动类
* @param string $name
* @return mixed
*/
public function auth(string $name)
{
return $this->driver(lcfirst($name));
}

/**
* 默认驱动
* @return string|null
*/
public function getDefaultDriver()
{
return null;
}

/**
* 获取驱动参数
* @param $name
* @return array
*/
protected function resolveParams($name): array
{
return [];
}
}
61 changes: 61 additions & 0 deletions src/Erp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* 十贰进销存系统
* ==========================================================================
* @link https://github.com/dashingunique/shier-erp
* @license https://github.com/dashingunique/shier-erp/blob/master/LICENSE.txt License
* @Desc 公用方法类
* ==========================================================================
* @author 张大宝的程序人生 <1107842285@qq.com>
*/

declare(strict_types=1);

namespace erp;

use erp\library\Node;

class Erp
{
/**
* @var string 十贰erp根目录
*/
protected string $erpPath = __DIR__;

/**
* 获取应用导航数据
* @param string $app
* @return array
* @throws \ReflectionException
*/
public function getGrant(string $app = ''): array
{
$config = app()->config->get('erp');
$path = !empty($app) ? $config['menu_cache_path'].$app.DIRECTORY_SEPARATOR.'menu.php' : $config['menu_cache_path'].'menu.php';
if (file_exists($path)) {
$menu = include $path;
} else {
$node = Node::getInstance();
$menu = $node->getAppMenuData($app.'/controller');
}
return $menu;
}

/**
* 获取erp的路径
* @return string
*/
public function getErpPath(): string
{
return $this->erpPath;
}

/**
* 获取十贰erp语言包路径
* @return string
*/
public function getErpLangPath(): string
{
return $this->erpPath.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR;
}
}
91 changes: 91 additions & 0 deletions src/Order.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
/**
* 十贰进销存系统
* ==========================================================================
* @link https://github.com/dashingunique/shier-erp
* @license https://github.com/dashingunique/shier-erp/blob/master/LICENSE.txt License
* @Desc 订单逻辑层
* ==========================================================================
* @author 张大宝的程序人生 <1107842285@qq.com>
*/

namespace erp;

use erp\exceptions\ErpException;
use think\App;
use think\Manager;

abstract class Order extends Manager
{
/**
* @var array 初始化参数
*/
protected array $params = [];

/**
* @var array|mixed|null
*/
protected $config;

/**
* Order constructor.
* @param App $app
*/
public function __construct(App $app)
{
parent::__construct($app);
$this->config = $app->config->get('documents');
}

/**
* @param mixed ...$params
* @return $this
*/
public function setParams(...$params)
{
$this->params = $params;
return $this;
}

/**
* 获取驱动参数
* @param $name
* @return array
*/
protected function resolveParams($name): array
{
return $this->params;
}

/**
* 默认驱动
* @return string|null
*/
public function getDefaultDriver()
{
return null;
}

/**
* 订单驱动类
* @param int $type
* @return mixed
*/
abstract public function order(int $type);

/**
* @param $type
* @return bool
* @throws ErpException
*/
protected function orderAuthority(int $type)
{
if (empty($this->config[$type])) {
throw new ErpException("订单[$type]类型不存在,请稍后再试");
}
if (request()->loginTerminal & $this->config[$type]['auth']) {
return true;
}
// throw new ErpException("没有[".$this->config[$type]['title']."]订单权限");
}
}
Loading

0 comments on commit 9e2cc6e

Please sign in to comment.