Commit 0f12d14e authored by jiangkebao's avatar jiangkebao

Merge branch 'master' of git.huaperfect.com:hwq/micro

parents 62eb3da4 3a163dec
......@@ -26,7 +26,7 @@ composer require meibuyu/micro @dev
> 权限名会拼接env文件中的APP_NAME属性,请注意唯一性
> 所有权限必须存在于用户服务的权限表中,若不存在,请联系管理员添加权限
##### 1、@AutoPerm
在控制器头部添加@AutoPerm注解,为该控制器下所有的方法添加鉴权功能,生成的权限名为`蛇形命名空间_蛇形控制名_蛇形方法名`
在控制器头部添加@AutoPerm注解,为该控制器下所有的方法添加鉴权功能,生成的权限名为`蛇形控制名_蛇形方法名`
```
/**
* @AutoPerm()
......@@ -34,7 +34,7 @@ composer require meibuyu/micro @dev
class UserInfoController {}
```
参数:
> 1. prefix, 前缀(字符串),默认为蛇形命名空间_蛇形控制名(user_info)
> 1. prefix, 前缀(字符串),默认为蛇形控制名(user_info)
> 2. exclude, 要排除的方法名(字符串数组),默认为空
```
/**
......@@ -44,7 +44,7 @@ class UserInfoController {}
```
##### 2、@Perm
在控制器中的方法头部添加@Perm注解,为当前方法添加鉴权功能,生成权限名为`蛇形命名空间_蛇形控制名_蛇形方法名`
在控制器中的方法头部添加@Perm注解,为当前方法添加鉴权功能,生成权限名为`蛇形控制名_蛇形方法名`
```
/**
* @Perm()
......
......@@ -91,8 +91,9 @@ class PermAnnotationAspect extends AbstractAspect
protected function genPrefix(string $className): string
{
$handledNamespace = Str::replaceFirst('Controller', '', Str::after($className, '\\Controller\\'));
$handledNamespace = str_replace('\\', '_', $handledNamespace);
$prefix = Str::snake($handledNamespace);
$namespaceLength = strrpos($handledNamespace, '\\');
$prefix = $namespaceLength ? substr($handledNamespace, $namespaceLength + 1) : $handledNamespace;
$prefix = Str::snake($prefix);
$prefix = str_replace('__', '_', $prefix);
return $prefix;
}
......
......@@ -377,7 +377,7 @@ class MakeModelCommand extends HyperfCommand
$relation .= "\n\t/**\n\t* 属于" . $v['relation_model_name'] . "的关联\n\t*/";
$relation .= "\n\tpublic function " . $v['function'] . "()";
$relation .= "\n\t{";
$relation .= "\n\t\t" . 'return $this->belongsTo(' . $v['relation_model_name'] . "::class,'" . $v['local_table_key'] . "','{$v['relation_table_key']}' );";
$relation .= "\n\t\t" . 'return $this->belongsTo(' . $v['relation_model_name'] . "::class);";
$relation .= "\n\t}";
$properties .= " * @property " . $v['relation_model_name'] . " $" . $v['function'] . "\n";
}
......@@ -390,7 +390,7 @@ class MakeModelCommand extends HyperfCommand
$relation .= "\n\tpublic function " . $v['function'] . "()";
$relation .= "\n\t{";
$relation .= "\n\t\t" . 'return $this->belongsToMany(' . $v['relation_model_name'] . "::class,'"
. $v['relation_table'] . "','{$v['constraint_table_key']}','{$v['local_table_key']}');";
. $v['relation_table'] . "');";
$relation .= "\n\t}";
$properties .= " * @property " . $v['relation_model_name'] . "[] $" . $v['function'] . "\n";
}
......@@ -402,7 +402,7 @@ class MakeModelCommand extends HyperfCommand
$relation .= "\n\t**/";
$relation .= "\n\tpublic function " . $v['function'] . "()";
$relation .= "\n\t{";
$relation .= "\n\t\t" . 'return $this->hasMany(' . $v['relation_model_name'] . "::class,'" . $v['relation_table_key'] . "','" . $v['local_table_key'] . "' );";
$relation .= "\n\t\t" . 'return $this->hasMany(' . $v['relation_model_name'] . "::class);";
$relation .= "\n\t}";
$properties .= " * @property " . $v['relation_model_name'] . "[] $" . $v['function'] . "\n";
}
......
......@@ -172,8 +172,8 @@ class UploadManager
*/
public static function parsePath($options, $documentRoot)
{
if (isset($options['temp']) && $options['temp'] && !isset($options['path'])) {
// 如果是临时文件,且没有指定保存路径,修改保存路径为临时路径
if (isset($options['temp']) && $options['temp']) {
// 如果是临时文件,修改保存路径为临时路径
$options['path'] = 'temp';
}
$path = $documentRoot . self::$pathPrefix . $options['path'] . '/' . date('Y-m-d');
......
......@@ -137,5 +137,4 @@ interface BaseInfoServiceInterface
*/
public function sites(array $relations = [], array $columns = ['id', "name"]): array;
}
......@@ -14,7 +14,8 @@ interface PlatformProductServiceInterface
/**
* 获取单个数据
* @param int $id 平台产品id
* @param array $relations 平台产品的关联关系,支持:["status","product","amazon_warehouse","platform_product_children"]
* @param array $relations 平台产品的关联关系,
* 支持:["status","product","amazon_warehouse","platform_product_children","brand","category","ingredient","product_name","images","price_info","property"]
* @param array $columns 平台产品表的字段,默认全部字段
* ['id', 'sku', 'product_id', 'name', 'team_id', 'site_id', 'price', 'currency_id', 'platform_product_status_id', 'creator_id', 'asin', 'amazon_warehouse_id', 'info_completed']
* @return array|null
......@@ -24,7 +25,8 @@ interface PlatformProductServiceInterface
/**
* 通过id列表获取平台产品数组
* @param array $idList 平台产品id的列表
* @param array $relations 平台产品的关联关系,支持["status","product","amazon_warehouse","platform_product_children"]
* @param array $relations 平台产品的关联关系,
* 支持:["status","product","amazon_warehouse","platform_product_children","brand","category","ingredient","product_name","images","price_info","property"]
* @param array $columns 平台产品表的字段,默认全部字段
* ['id', 'sku', 'product_id', 'name', 'team_id', 'site_id', 'price', 'currency_id', 'platform_product_status_id', 'creator_id', 'asin', 'amazon_warehouse_id', 'info_completed']
* @return array
......@@ -37,4 +39,5 @@ interface PlatformProductServiceInterface
* @return array
*/
public function platformProductStatus(array $columns = ['id', 'name']): array;
}
......@@ -97,4 +97,14 @@ interface UserServiceInterface
*/
public function getListWithLeader(int $userId, array $idList = [], array $columns = ['id', 'name']): array;
/**
* 更新用户考核方案
* @param $userId
* @param array $attributes
* 'review_users' => '1,2,3' // 点评人
* 'cc_person' => '1,2,3' // 抄送人
* @return int
*/
public function updateAssessmentPlan($userId, array $attributes);
}
......@@ -55,7 +55,7 @@ class ExcelImporter
$this->config = container(ConfigInterface::class);
$this->fileType = ucfirst($file->getExtension());
$this->rootPath = $this->config->get('server.settings.document_root', BASE_PATH . '/public');
$path = UploadManager::uploadExcelGetRealPath($file);
$path = UploadManager::uploadExcelGetRealPath($file, ['temp' => true]);
$this->reader = IOFactory::createReaderForFile($path)->load($path);
$this->filePath = $path;
$this->sheet = $this->reader->getSheet($sheetIndex);
......@@ -141,11 +141,15 @@ class ExcelImporter
public function checkNumeric($data, &$errorCount)
{
foreach ($data as $k => $v) {
if (!$v || $v === '') {
continue;
} else {
if (!is_numeric($v)) {
$this->setErrorMessage("{$k}只能是数字", $errorCount);
return false;
}
}
}
return true;
}
......@@ -245,7 +249,7 @@ class ExcelImporter
return true;
}
} else {
if ($list[$key] !== $data[$key]) {
if ($list[$key] != $data[$key]) {
return true;
}
}
......
......@@ -237,7 +237,7 @@ class Exporter
if (isset($data[$v])) {
$result[] = $data[$v];
} else {
new \Exception("key为{$v}的数据不存在");
$result[] = '';
}
} else {
$separate = explode("|", $v);
......@@ -246,7 +246,7 @@ class Exporter
$t = count($list) - 1;
$b = $data;
foreach ($list as $lk => $lv) {
if (isset($b[$lv])) {
if (isset($b[$lv]) && $b[$lv]) {
$b = $b[$lv];
} else {
$b = "";
......
......@@ -616,7 +616,7 @@ if (!function_exists('make_belong_relation_function')) {
* @param callable|null $callback 内嵌级联调用
* @return Closure 返回关联关系的匿名函数
*/
function make_belong_lation_function($relationName, array &$mainModelColumns, $relationColumns = ['id', 'name'], $mainModelRelationKey = "", callable $callback = null)
function make_belong_relation_function($relationName, array &$mainModelColumns, $relationColumns = ['id', 'name'], $mainModelRelationKey = "", callable $callback = null)
{
$key = $mainModelRelationKey ? $mainModelRelationKey : $relationName . "_id";
if (!in_array($key, $mainModelColumns)) array_push($mainModelColumns, $key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment