|
@@ -10,6 +10,7 @@ use Hyperf\RpcServer\Annotation\RpcService;
|
|
|
use App\Tools\Result;
|
|
|
use Hyperf\DbConnection\Db;
|
|
|
use PhpParser\Node\Expr\Clone_;
|
|
|
+use Overtrue\Pinyin\Pinyin;
|
|
|
|
|
|
#[RpcService(name: "FooterService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class FooterService implements FooterServiceInterface
|
|
@@ -58,9 +59,17 @@ class FooterService implements FooterServiceInterface
|
|
|
*/
|
|
|
public function addFooterCategory(array $data): array
|
|
|
{
|
|
|
+
|
|
|
+ //从WebsiteCategory取出alis ,并转成拼音存放到alias_pinyin
|
|
|
+ // $result = WebsiteCategory::where($where)->first();
|
|
|
+ // $result = $result->toArray();
|
|
|
if(empty($data)){
|
|
|
$result = Website::select('website_name','id')->get();
|
|
|
}else{
|
|
|
+ // $alias = $data['name'];
|
|
|
+ // 引入 Pinyin 类
|
|
|
+
|
|
|
+ // $alias_pinyin = $pinyin->permalink($alias, '');
|
|
|
// 底部导航类型 0:内容型;1:列表型;
|
|
|
$webid = Website::select('website_name','id')->where('id',$data['website_id'])->first();
|
|
|
if(empty($webid)){
|
|
@@ -71,12 +80,15 @@ class FooterService implements FooterServiceInterface
|
|
|
if(!empty($name)){
|
|
|
return Result::error("该底部导航名称已存在!");
|
|
|
}
|
|
|
+ $pinyin = new Pinyin();
|
|
|
$result = FooterCategory::insertGetId($data);
|
|
|
+ $name_pinyin['name_pinyin'] = $pinyin->permalink($data['name'], '') . $result;
|
|
|
+ $result = FooterCategory::where('id', $result)->update($name_pinyin);
|
|
|
}
|
|
|
if(empty($result)){
|
|
|
return Result::error("添加失败!");
|
|
|
}else{
|
|
|
- return Result::success($result);
|
|
|
+ return Result::success($data);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
@@ -113,6 +125,8 @@ class FooterService implements FooterServiceInterface
|
|
|
if(empty($webid)){
|
|
|
return Result::error("该网站不存在!");
|
|
|
}
|
|
|
+ $pinyin = new Pinyin();
|
|
|
+ $data['name_pinyin'] = $pinyin->permalink($data['name'], ''). $data['id'];
|
|
|
$result = FooterCategory::where('id', $data['id'])->update($data);
|
|
|
}
|
|
|
if (empty($result)) {
|