|
@@ -45,6 +45,7 @@ use PhpParser\Node\Stmt\Return_;
|
|
|
use function PHPUnit\Framework\isNull;
|
|
|
use Overtrue\Pinyin\Pinyin;
|
|
|
use App\Tools\buildTree;
|
|
|
+use App\Model\Size;
|
|
|
#[RpcService(name: "WebsiteService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class WebsiteService implements WebsiteServiceInterface
|
|
|
{
|
|
@@ -2680,5 +2681,103 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 获取尺寸列表
|
|
|
+ * @param array $data
|
|
|
+ */
|
|
|
+ public function getSizeList(array $data): array
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ if(isset($data['width']) &&!empty($data['width'])){
|
|
|
+ array_push($where, ['width','like','%'.$data['width'].'%']);
|
|
|
+ }
|
|
|
+ if(isset($data['height']) &&!empty($data['height'])){
|
|
|
+ array_push($where, ['height','like','%'.$data['height'].'%']);
|
|
|
+ }
|
|
|
+ $query = Size::when($where, function ($query) use ($where) {
|
|
|
+ $query->where($where);
|
|
|
+ })
|
|
|
+ ->orderBy('updated_at', 'desc');
|
|
|
+ $count = $query->count();
|
|
|
+ $rep = $query
|
|
|
+ ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
+ ->limit($data['pageSize'])
|
|
|
+ ->get();
|
|
|
+ $result = [
|
|
|
+ 'row' => $rep,
|
|
|
+ 'count' => $count,
|
|
|
+ ];
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("获取失败", 0);
|
|
|
+ } else {
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 添加尺寸
|
|
|
+ * @param array $data
|
|
|
+ */
|
|
|
+ public function addSize(array $data): array
|
|
|
+ {
|
|
|
+ $size = Size::where('width', $data['width'])->where('height', $data['height'])->first();
|
|
|
+ if (!empty($size)) {
|
|
|
+ return Result::error("尺寸已存在", 0);
|
|
|
+ }
|
|
|
+ $result = Size::insertGetId($data);
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("添加失败", 0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 删除尺寸
|
|
|
+ * @param array $data
|
|
|
+ */
|
|
|
+ public function delSize(array $data): array
|
|
|
+ {
|
|
|
+ $where = [
|
|
|
+ 'id' => $data['id'],
|
|
|
+ ];
|
|
|
+ $result = Size::where($where)->delete();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("删除失败", 0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 修改尺寸
|
|
|
+ * @param array $data
|
|
|
+ */
|
|
|
+ public function upSize(array $data): array
|
|
|
+ {
|
|
|
+ $where = [
|
|
|
+ 'id' => $data['id'],
|
|
|
+ ];
|
|
|
+ $size = Size::where('id','!=', $data['id'])->where('width',$data['width'])->where('height',$data['height'])->first();
|
|
|
+ if (!empty($size)) {
|
|
|
+ return Result::error("尺寸已存在", 0);
|
|
|
+ }
|
|
|
+ $result = Size::where($where)->update($data);
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("修改失败", 0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取尺寸详情
|
|
|
+ * @param array $data
|
|
|
+ */
|
|
|
+ public function getSizeInfo(array $data): array
|
|
|
+ {
|
|
|
+ $where = [
|
|
|
+ 'id' => $data['id'],
|
|
|
+ ];
|
|
|
+ $result = Size::where($where)->first();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("获取失败", 0);
|
|
|
+ } else {
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ }
|
|
|
// --自助建站-----------20250522fr----------------------end
|
|
|
}
|