Initial commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
/runtime
|
||||
/.idea
|
||||
/.vscode
|
||||
/vendor
|
||||
*.log
|
||||
.env
|
||||
/tests/tmp
|
||||
/tests/.phpunit.result.cache
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 walkor<walkor@workerman.net> and contributors (see https://github.com/walkor/webman/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,70 @@
|
||||
<div style="padding:18px;max-width: 1024px;margin:0 auto;background-color:#fff;color:#333">
|
||||
<h1>webman</h1>
|
||||
|
||||
基于<a href="https://www.workerman.net" target="__blank">workerman</a>开发的超高性能PHP框架
|
||||
|
||||
|
||||
<h1>学习</h1>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://www.workerman.net/webman" target="__blank">主页 / Home page</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://webman.workerman.net" target="__blank">文档 / Document</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.workerman.net/doc/webman/install.html" target="__blank">安装 / Install</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.workerman.net/questions" target="__blank">问答 / Questions</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.workerman.net/apps" target="__blank">市场 / Apps</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.workerman.net/sponsor" target="__blank">赞助 / Sponsors</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.workerman.net/doc/webman/thanks.html" target="__blank">致谢 / Thanks</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div style="float:left;padding-bottom:30px;">
|
||||
|
||||
<h1>赞助商</h1>
|
||||
|
||||
<h4>特别赞助</h4>
|
||||
<a href="https://www.crmeb.com/?form=workerman" target="__blank">
|
||||
<img src="https://www.workerman.net/img/sponsors/6429/20230719111500.svg" width="200">
|
||||
</a>
|
||||
|
||||
<h4>铂金赞助</h4>
|
||||
<a href="https://www.fadetask.com/?from=workerman" target="__blank"><img src="https://www.workerman.net/img/sponsors/1/20230719084316.png" width="200"></a>
|
||||
<a href="https://www.yilianyun.net/?from=workerman" target="__blank" style="margin-left:20px;"><img src="https://www.workerman.net/img/sponsors/6218/20230720114049.png" width="200"></a>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div style="float:left;padding-bottom:30px;clear:both">
|
||||
|
||||
<h1>请作者喝咖啡</h1>
|
||||
|
||||
<img src="https://www.workerman.net/img/wx_donate.png" width="200">
|
||||
<img src="https://www.workerman.net/img/ali_donate.png" width="200">
|
||||
<br>
|
||||
<b>如果您觉得webman对您有所帮助,欢迎捐赠。</b>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div style="clear: both">
|
||||
<h1>LICENSE</h1>
|
||||
The webman is open-sourced software licensed under the MIT.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\AgreementModel;
|
||||
use app\apis\service\AgreementService;
|
||||
use app\apis\validate\AgreementValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class AgreementController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = AgreementValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new AgreementService(new AgreementModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
return [
|
||||
'id' => $item['id'],
|
||||
'key' => $item['key'],
|
||||
'status' => $item['status'],
|
||||
'title' => isset($item['translation']) ? $item['translation']['title'] : '',
|
||||
'content' => isset($item['translation']) ? $item['translation']['content'] : '',
|
||||
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
|
||||
'updated_at' => date('Y-m-d H:i:s', $item['updated_at'])
|
||||
];
|
||||
}
|
||||
|
||||
if ($scene === 'one') {
|
||||
return [
|
||||
'id' => $item['id'],
|
||||
'title' => isset($item['translation']) ? $item['translation']['title'] : '',
|
||||
'content' => isset($item['translation']) ? $item['translation']['content'] : ''
|
||||
// 'title' => isset($item['translation']) ? htmlspecialchars($item['translation']['title'], ENT_NOQUOTES) : '',
|
||||
// 'content' => isset($item['translation']) ? htmlspecialchars($item['translation']['content'], ENT_NOQUOTES) : ''
|
||||
];
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function one(Request $request, string $scene = 'one'): Response
|
||||
{
|
||||
try {
|
||||
return parent::one($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\AgreementTranslationModel;
|
||||
use app\apis\service\AgreementTranslationService;
|
||||
use app\apis\validate\AgreementTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class AgreementTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = AgreementTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new AgreementTranslationService(new AgreementTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\BrandModel;
|
||||
use app\apis\service\BrandService;
|
||||
use app\apis\validate\BrandValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class BrandController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = BrandValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new BrandService(new BrandModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\BrandTranslationModel;
|
||||
use app\apis\service\BrandTranslationService;
|
||||
use app\apis\validate\BrandTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class BrandTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = BrandTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new BrandTranslationService(new BrandTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\ContactsModel;
|
||||
use app\apis\service\ContactsService;
|
||||
use app\apis\validate\ContactsValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class ContactsController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = ContactsValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new ContactsService(new ContactsModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function store(Request $request): Response
|
||||
{
|
||||
try {
|
||||
return parent::store($request);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\DictItemModel;
|
||||
use app\apis\service\DictItemService;
|
||||
use app\apis\validate\DictItemValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class DictItemController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = DictItemValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new DictItemService(new DictItemModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function all(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::all($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function show(Request $request, int $id, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::show($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function one(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::one($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\DictTypeModel;
|
||||
use app\apis\service\DictTypeService;
|
||||
use app\apis\validate\DictTypeValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class DictTypeController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = DictTypeValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new DictTypeService(new DictTypeModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function options(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$data = $this->getService()->options();
|
||||
return $this->successResponse($data);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getModels(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$data = $this->getService()->getModels($request->get('brand_id'));
|
||||
return $this->successResponse($data);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\EnergyModel;
|
||||
use app\apis\service\EnergyService;
|
||||
use app\apis\validate\EnergyValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class EnergyController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = EnergyValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new EnergyService(new EnergyModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\EnergyTranslationModel;
|
||||
use app\apis\service\EnergyTranslationService;
|
||||
use app\apis\validate\EnergyTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class EnergyTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = EnergyTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new EnergyTranslationService(new EnergyTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\LocationModel;
|
||||
use app\apis\service\LocationService;
|
||||
use app\apis\validate\LocationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class LocationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = LocationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new LocationService(new LocationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\LocationTranslationModel;
|
||||
use app\apis\service\LocationTranslationService;
|
||||
use app\apis\validate\LocationTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class LocationTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = LocationTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new LocationTranslationService(new LocationTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\ModelModel;
|
||||
use app\apis\service\ModelService;
|
||||
use app\apis\validate\ModelValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class ModelController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = ModelValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new ModelService(new ModelModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function all(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::all($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function show(Request $request, int $id, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::show($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单条
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function one(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::one($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\ModelTranslationModel;
|
||||
use app\apis\service\ModelTranslationService;
|
||||
use app\apis\validate\ModelTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class ModelTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = ModelTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new ModelTranslationService(new ModelTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\SubscribeModel;
|
||||
use app\apis\service\SubscribeService;
|
||||
use app\apis\validate\SubscribeValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class SubscribeController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = SubscribeValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new SubscribeService(new SubscribeModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function store(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$params = $this->validateRequest($request->all(), 'store');
|
||||
$params['ip'] = $request->getRealIp();
|
||||
$data = $this->getService()->store($params);
|
||||
return $this->successResponse($data);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\TypesModel;
|
||||
use app\apis\service\TypesService;
|
||||
use app\apis\validate\TypesValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class TypesController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = TypesValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new TypesService(new TypesModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
$item['img'] = $item['img'] ? (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['img']) : '';
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\TypesTranslationModel;
|
||||
use app\apis\service\TypesTranslationService;
|
||||
use app\apis\validate\TypesTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class TypesTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = TypesTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new TypesTranslationService(new TypesTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\UsersModel;
|
||||
use app\apis\service\UsersService;
|
||||
use app\apis\validate\UsersValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class UsersController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = UsersValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new UsersService(new UsersModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\VehicleAlbumModel;
|
||||
use app\apis\service\VehicleAlbumService;
|
||||
use app\apis\validate\VehicleAlbumValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class VehicleAlbumController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = VehicleAlbumValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new VehicleAlbumService(new VehicleAlbumModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\VehicleDataModel;
|
||||
use app\apis\service\VehicleDataService;
|
||||
use app\apis\validate\VehicleDataValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class VehicleDataController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = VehicleDataValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new VehicleDataService(new VehicleDataModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default' || $scene === 'random') {
|
||||
// $isRandom = VehicleDataModel::inRandomOrder()->where('info_status', 1)->first();
|
||||
|
||||
if ($item['cover']) {
|
||||
$item['cover'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['cover']);
|
||||
}
|
||||
return [
|
||||
'id' => $item['id'],
|
||||
'vin' => $item['vin'],
|
||||
'user_nickname' => isset($item['user']) ? $item['user']['nickname'] : '',
|
||||
'price' => $item['price'],
|
||||
'brand' => is_array($item['brand']) && $item['brand'] ? $item['brand']['translation']['name'] : '',
|
||||
'energy' => is_array($item['energy']) && $item['energy'] ? $item['energy']['translation']['name'] : '',
|
||||
'type' => isset($item['types']) && $item['types'] ? $item['types']['translation']['name'] : '',
|
||||
'model' => isset($item['models']) && $item['models'] ? $item['models']['translation']['name'] : '',
|
||||
'mileage' => $item['mileage'],
|
||||
'vehicle_age' => $item['vehicle_age'],
|
||||
'views' => $item['views'],
|
||||
'is_hot' => $item['is_hot'],
|
||||
'name' => isset($item['translation']) ? $item['translation']['name'] : '',
|
||||
'condition_desc' => isset($item['translation']) ? $item['translation']['condition_desc'] : '',
|
||||
'cover' => isset($item['cover']) ? $item['cover'] : '',
|
||||
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
|
||||
'updated_at' => date('Y-m-d H:i:s', $item['updated_at']),
|
||||
'location' => $item['location'] ? $item['location']['translation']['name'] : '',
|
||||
// 'is_random' => $isRandom ? $isRandom->id : 0
|
||||
];
|
||||
}
|
||||
|
||||
if ($scene === 'show') {
|
||||
if ($item['cover']) {
|
||||
$item['cover'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['cover']);
|
||||
}
|
||||
$arr = [];
|
||||
if (isset($item['album'])) {
|
||||
$albumFields = \app\console\model\VehicleAlbumModel::VEHICLE_ALBUM_FIELDS;
|
||||
$arr = [];
|
||||
foreach ($albumFields as $field) {
|
||||
$arr[] = [
|
||||
'field' => $field,
|
||||
'name' => trans($field),
|
||||
'value_full' => $item['album'][$field]
|
||||
? htmlspecialchars((new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['album'][$field]), ENT_NOQUOTES)
|
||||
: '',
|
||||
'value' => $item['album'][$field]
|
||||
];
|
||||
}
|
||||
}
|
||||
return [
|
||||
'id' => $item['id'],
|
||||
'vin' => $item['vin'],
|
||||
'user_nickname' => isset($item['user']) ? $item['user']['nickname'] : '',
|
||||
'price' => $item['price'],
|
||||
|
||||
'brand_name' => is_array($item['brand']) ? $item['brand']['translation']['name'] : '',
|
||||
'energy_name' => is_array($item['energy']) ? $item['energy']['translation']['name'] : '',
|
||||
'type_name' => isset($item['types']) ? $item['types']['translation']['name'] : '',
|
||||
'model_name' => isset($item['models']) ? $item['models']['translation']['name'] : '',
|
||||
|
||||
'mileage' => $item['mileage'],
|
||||
'vehicle_age' => $item['vehicle_age'],
|
||||
'views' => $item['views'],
|
||||
'is_hot' => $item['is_hot'],
|
||||
'store_status' => $item['store_status'],
|
||||
'store_status_name' => trans(VehicleDataModel::STORE_STATUS_VALUE[$item['store_status']]),
|
||||
'name' => isset($item['translation']) ? $item['translation']['name'] : '',
|
||||
'condition_desc' => isset($item['translation']) ? $item['translation']['condition_desc'] : '',
|
||||
'location' => isset($item['translation']) ? $item['translation']['location'] : '',
|
||||
'cover' => isset($item['cover']) ? $item['cover'] : '',
|
||||
'albums' => $arr,
|
||||
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
|
||||
'updated_at' => date('Y-m-d H:i:s', $item['updated_at']),
|
||||
|
||||
'brand' => is_array($item['brand']) ? $item['brand']['translation']['brand_id'] : $item['brand'],
|
||||
'energy' => is_array($item['energy']) ? $item['energy']['translation']['energy_id'] : $item['energy'],
|
||||
'type' => isset($item['types']) ? $item['types']['translation']['type_id'] : $item['type'],
|
||||
'model' => isset($item['models']) ? $item['models']['translation']['model_id'] : $item['model'],
|
||||
'location_name' => $item['location'] ? $item['location']['translation']['name'] : '',
|
||||
'location' => is_array($item['location']) ? $item['location']['translation']['location_id'] : $item['location'],
|
||||
];
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
$params['filters'] = [];
|
||||
$params['filters'][] = ['field' => 'info_status', 'operator' => '=', 'value' => 1];
|
||||
// 是否热门
|
||||
if (isset($params['is_hot']) && $params['is_hot']) {
|
||||
$params['page'] = 1;
|
||||
$params['per_page'] = 4;
|
||||
$params['filters'][] = ['field' => 'is_hot', 'operator' => '=', 'value' => $params['is_hot']];
|
||||
return $params;
|
||||
} else if (isset($params['vehicle_id']) && $params['vehicle_id']) {
|
||||
$params['page'] = 1;
|
||||
$params['per_page'] = 3;
|
||||
$xgInfo = $this->getService()->find($params['vehicle_id']);
|
||||
$params['filters'][] = ['field' => 'brand', 'operator' => '=', 'value' => $xgInfo->brand];
|
||||
return $params;
|
||||
} else {
|
||||
// 品牌
|
||||
if (isset($params['brand']) && $params['brand']) {
|
||||
$params['filters'][] = ['field' => 'brand', 'operator' => '=', 'value' => $params['brand']];
|
||||
}
|
||||
// 车型
|
||||
if (isset($params['model']) && $params['model']) {
|
||||
$params['filters'][] = ['field' => 'model', 'operator' => '=', 'value' => $params['model']];
|
||||
}
|
||||
// 能源
|
||||
if (isset($params['energy']) && $params['energy']) {
|
||||
$params['filters'][] = ['field' => 'energy', 'operator' => '=', 'value' => $params['energy']];
|
||||
}
|
||||
// 状态
|
||||
if (isset($params['store_status']) && $params['store_status']) {
|
||||
$params['filters'][] = ['field' => 'store_status', 'operator' => '=', 'value' => $params['store_status']];
|
||||
}
|
||||
// 类型
|
||||
if (isset($params['type']) && $params['type']) {
|
||||
$params['filters'][] = ['field' => 'type', 'operator' => '=', 'value' => $params['type']];
|
||||
}
|
||||
// 价格
|
||||
if ((isset($params['min_price']) && $params['min_price']) && (isset($params['max_price']) && $params['max_price'])) {
|
||||
$params['filters'][] = ['field' => 'price', 'operator' => '>', 'value' => $params['min_price']];
|
||||
$params['filters'][] = ['field' => 'price', 'operator' => '<', 'value' => $params['max_price']];
|
||||
}
|
||||
// 里程
|
||||
if ((isset($params['min_mileage']) && $params['min_mileage']) && (isset($params['max_mileage']) && $params['max_mileage'])) {
|
||||
$params['filters'][] = ['field' => 'mileage', 'operator' => '>', 'value' => $params['min_mileage']];
|
||||
$params['filters'][] = ['field' => 'mileage', 'operator' => '<', 'value' => $params['max_mileage']];
|
||||
}
|
||||
// 年份
|
||||
if ((isset($params['start_year']) && $params['start_year']) && (isset($params['end_year']) && $params['end_year'])) {
|
||||
$params['filters'][] = ['field' => 'start_use', 'operator' => '=', 'value' => $params['start_year']];
|
||||
$params['filters'][] = ['field' => 'end_use', 'operator' => '=', 'value' => $params['end_year']];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function postProcessItems(array $items, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'detail') {
|
||||
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function show(Request $request, int $id, string $scene = 'show'): Response
|
||||
{
|
||||
try {
|
||||
return parent::show($request, $id, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function random(Request $request, string $scene = 'random'): Response
|
||||
{
|
||||
try {
|
||||
return parent::one($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\apis\model\VehicleDataTranslationModel;
|
||||
use app\apis\service\VehicleDataTranslationService;
|
||||
use app\apis\validate\VehicleDataTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class VehicleDataTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = VehicleDataTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new VehicleDataTranslationService(new VehicleDataTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* AgreementModel
|
||||
*/
|
||||
class AgreementModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_agreement';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'key', 'status', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
public function translation()
|
||||
{
|
||||
return $this->hasOne(AgreementTranslationModel::class, 'agreement_id')->where('locale', locale());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* AgreementTranslationModel
|
||||
*/
|
||||
class AgreementTranslationModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_agreement_translation';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'agreement_id', 'locale', 'title', 'content', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* BrandModel
|
||||
*/
|
||||
class BrandModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_brand';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'status', 'sort', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
public function translation()
|
||||
{
|
||||
return $this->hasOne(BrandTranslationModel::class, 'brand_id')->where('locale', locale());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* BrandTranslationModel
|
||||
*/
|
||||
class BrandTranslationModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_brand_translation';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'brand_id', 'locale', 'name', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* ContactsModel
|
||||
*/
|
||||
class ContactsModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_contacts';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'name', 'phone', 'content', 'vehicle_id', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* DictItemModel
|
||||
*/
|
||||
class DictItemModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_dict_item';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = [];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* DictTypeModel
|
||||
*/
|
||||
class DictTypeModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_dict_type';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = [];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* EnergyModel
|
||||
*/
|
||||
class EnergyModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_energy';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'name', 'name_en', 'name_ru', 'status', 'sort', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
public function translation()
|
||||
{
|
||||
return $this->hasOne(EnergyTranslationModel::class, 'energy_id')->where('locale', locale());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* EnergyTranslationModel
|
||||
*/
|
||||
class EnergyTranslationModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_energy_translation';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'energy_id', 'locale', 'name', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* LocationModel
|
||||
*/
|
||||
class LocationModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_location';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'status', 'sort', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
public function translation()
|
||||
{
|
||||
return $this->hasOne(LocationTranslationModel::class, 'location_id')->where('locale', locale());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* LocationTranslationModel
|
||||
*/
|
||||
class LocationTranslationModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_location_translation';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'location_id', 'locale', 'name', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* ModelModel
|
||||
*/
|
||||
class ModelModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_model';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = [];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
public function translation()
|
||||
{
|
||||
return $this->hasOne(ModelTranslationModel::class, 'model_id')->where('locale', locale());
|
||||
}
|
||||
|
||||
public function brand()
|
||||
{
|
||||
return $this->belongsTo(BrandModel::class, 'brand_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* ModelTranslationModel
|
||||
*/
|
||||
class ModelTranslationModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_model_translation';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'model_id', 'locale', 'name', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* SubscribeModel
|
||||
*/
|
||||
class SubscribeModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_subscribe';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'email', 'ip', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* TypesModel
|
||||
*/
|
||||
class TypesModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_types';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'img', 'status', 'sort', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
public function translation()
|
||||
{
|
||||
return $this->hasOne(TypesTranslationModel::class, 'type_id')->where('locale', locale());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* TypesTranslationModel
|
||||
*/
|
||||
class TypesTranslationModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_types_translation';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'type_id', 'locale', 'name', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* UsersModel
|
||||
*/
|
||||
class UsersModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_users';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'user_sn', 'nickname', 'avatar', 'realname', 'phone', 'company', 'openid', 'language', 'status', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* VehicleAlbumModel
|
||||
*/
|
||||
class VehicleAlbumModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_vehicle_album';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'vehicle_data_id', 'front_45_degree', 'front_left_45_degree', 'front_left_headlight', 'front_view', 'lower_front', 'wheel_hub', 'front_right_seat', 'right_lower_side', 'rear_right_taillight', 'rear_right_45_degree', 'lower_rear', 'trunk', 'left_lower_side', 'rear_seats', 'center_console', 'control_panel', 'gear_shift', 'car_key', 'steering_wheel', 'dashboard', 'odometer_reading', 'front_left_door_panel', 'front_left_door_function_area', 'front_left_seat', 'interior_ceiling', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* 相册字段
|
||||
*/
|
||||
const VEHICLE_ALBUM_FIELDS = [
|
||||
'front_45_degree',
|
||||
'front_left_45_degree',
|
||||
'front_left_headlight',
|
||||
'front_view',
|
||||
'lower_front',
|
||||
'wheel_hub',
|
||||
'front_right_seat',
|
||||
'right_lower_side',
|
||||
'rear_right_taillight',
|
||||
'rear_right_45_degree',
|
||||
'lower_rear',
|
||||
'trunk',
|
||||
'left_lower_side',
|
||||
'rear_seats',
|
||||
'center_console',
|
||||
'control_panel',
|
||||
'gear_shift',
|
||||
'car_key',
|
||||
'steering_wheel',
|
||||
'dashboard',
|
||||
'odometer_reading',
|
||||
'front_left_door_panel',
|
||||
'front_left_door_function_area',
|
||||
'front_left_seat',
|
||||
'interior_ceiling'
|
||||
];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* VehicleDataModel
|
||||
*/
|
||||
class VehicleDataModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_vehicle_data';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'vin', 'user_id', 'name', 'cover', 'brand', 'price', 'type', 'energy', 'model', 'mileage', 'vehicle_age', 'condition_desc', 'info_status', 'is_saled', 'store_status', 'start_use', 'end_use', 'location', 'views', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(UsersModel::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
public function brand()
|
||||
{
|
||||
return $this->belongsTo(BrandModel::class, 'brand', 'id');
|
||||
}
|
||||
|
||||
public function types()
|
||||
{
|
||||
return $this->belongsTo(TypesModel::class, 'type', 'id');
|
||||
}
|
||||
|
||||
public function energy()
|
||||
{
|
||||
return $this->belongsTo(EnergyModel::class, 'energy', 'id');
|
||||
}
|
||||
|
||||
public function models()
|
||||
{
|
||||
return $this->belongsTo(ModelModel::class, 'model', 'id');
|
||||
}
|
||||
|
||||
public function album()
|
||||
{
|
||||
return $this->hasOne(VehicleAlbumModel::class, 'vehicle_data_id', 'id');
|
||||
}
|
||||
|
||||
public function thumb()
|
||||
{
|
||||
return $this->belongsTo(VehicleAlbumModel::class, 'vehicle_id', 'id')->select('front_45_degree');
|
||||
}
|
||||
|
||||
public function location()
|
||||
{
|
||||
return $this->belongsTo(LocationModel::class, 'location');
|
||||
}
|
||||
|
||||
/**
|
||||
* 单条翻译
|
||||
*/
|
||||
public function translation()
|
||||
{
|
||||
return $this->hasOne(VehicleDataTranslationModel::class, 'vehicle_id')->where('locale', locale());
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条翻译
|
||||
*/
|
||||
public function translations()
|
||||
{
|
||||
return $this->hasMany(VehicleDataTranslationModel::class, 'vehicle_id');
|
||||
}
|
||||
|
||||
|
||||
const TRANS_FIELDS = [
|
||||
'name', 'condition_desc'
|
||||
];
|
||||
|
||||
|
||||
const STORE_STATUS = [
|
||||
1 => '现货',
|
||||
2 => '在途',
|
||||
3 => '订购',
|
||||
];
|
||||
const STORE_STATUS_VALUE = [
|
||||
1 => 'in_stock',
|
||||
2 => 'in_transit',
|
||||
3 => 'in_order',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* VehicleDataTranslationModel
|
||||
*/
|
||||
class VehicleDataTranslationModel extends Model
|
||||
{
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'hs_vehicle_data_translation';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* 模型的数据字段的保存格式。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'vehicle_id', 'locale', 'name', 'condition_desc', 'location', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\AgreementModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AgreementService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return AgreementModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
'default' => function ($params) {
|
||||
return [
|
||||
'filters' => [
|
||||
['field' => 'status', 'operator' => '=', 'value' => '1']
|
||||
],
|
||||
'fields' => ['id', 'key', 'status', 'created_at', 'updated_at'],
|
||||
'relations' => [
|
||||
'translation' => ['agreement_id', 'title', 'content']
|
||||
],
|
||||
'sorts' => [
|
||||
['field' => 'id', 'direction' => 'desc']
|
||||
],
|
||||
'pagination' => [
|
||||
'page' => $params['page'] ?? 1,
|
||||
'per_page' => $params['per_page'] ?? 10,
|
||||
]
|
||||
];
|
||||
},
|
||||
'one' => function ($params) {
|
||||
return [
|
||||
'filters' => [
|
||||
['field' => 'status', 'operator' => '=', 'value' => '1'],
|
||||
['field' => 'key', 'operator' => '=', 'value' => 'privacy_web']
|
||||
],
|
||||
'fields' => ['id', 'key', 'status', 'created_at', 'updated_at'],
|
||||
'relations' => [
|
||||
'translation' => ['agreement_id', 'title', 'content']
|
||||
],
|
||||
'sorts' => [
|
||||
['field' => 'id', 'direction' => 'desc']
|
||||
],
|
||||
'pagination' => [
|
||||
'page' => $params['page'] ?? 1,
|
||||
'per_page' => $params['per_page'] ?? 10,
|
||||
]
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\AgreementTranslationModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AgreementTranslationService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return AgreementTranslationModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\BrandModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BrandService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return BrandModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
'default' => function ($params) {
|
||||
return [
|
||||
'filters' => [
|
||||
['field' => 'status', 'operator' => '=', 'value' => '1']
|
||||
],
|
||||
'fields' => ['id', 'status', 'sort', 'created_at', 'updated_at'],
|
||||
'relations' => [
|
||||
'translation' => ['brand_id', 'name']
|
||||
],
|
||||
'sorts' => [
|
||||
['field' => 'id', 'direction' => 'desc']
|
||||
],
|
||||
'pagination' => [
|
||||
'page' => $params['page'] ?? 1,
|
||||
'per_page' => $params['per_page'] ?? 10,
|
||||
]
|
||||
];
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\BrandTranslationModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BrandTranslationService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return BrandTranslationModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\ContactsModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ContactsService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return ContactsModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\DictItemModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DictItemService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return DictItemModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\BrandModel;
|
||||
use app\apis\model\DictTypeModel;
|
||||
use app\apis\model\EnergyModel;
|
||||
use app\apis\model\ModelModel;
|
||||
use app\apis\model\TypesModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DictTypeService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return DictTypeModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function options()
|
||||
{
|
||||
$brand = BrandModel::with('translation')->where('status', 1)->get()->toArray();
|
||||
$brands = [];
|
||||
foreach ($brand as $key => $val) {
|
||||
$brands[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => isset($val['translation']) ? $val['translation']['name'] : ''
|
||||
];
|
||||
}
|
||||
|
||||
$energy = EnergyModel::with('translation')->where('status', 1)->get()->toArray();
|
||||
$energys = [];
|
||||
foreach ($energy as $key => $val) {
|
||||
$energys[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => isset($val['translation']) ? $val['translation']['name'] : ''
|
||||
];
|
||||
}
|
||||
|
||||
$type = TypesModel::with('translation')->where('status', 1)->get()->toArray();
|
||||
$types = [];
|
||||
foreach ($type as $key => $val) {
|
||||
$types[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => isset($val['translation']) ? $val['translation']['name'] : ''
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$min = [];
|
||||
$max = [];
|
||||
for ($i = 0; $i <= 20; $i++) {
|
||||
$min[] = [
|
||||
'value' => $i * 100,
|
||||
'name' => $i * 200 . 'km'
|
||||
];
|
||||
$max[] = [
|
||||
'value' => ($i+1) * 100,
|
||||
'name' => ($i+1) * 200 . 'km'
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'brand' => $brands,
|
||||
'energy' => $energys,
|
||||
'type' => $types,
|
||||
'score_status' => [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => trans('in_stock')
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => trans('in_transit')
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => trans('in_order')
|
||||
|
||||
]
|
||||
],
|
||||
'price' => [
|
||||
[
|
||||
'name' => '0-10w',
|
||||
'value' => '0-10',
|
||||
],
|
||||
[
|
||||
'name' => '10-15w',
|
||||
'value' => '10-15',
|
||||
],
|
||||
[
|
||||
'name' => '15-20w',
|
||||
'value' => '15-20',
|
||||
],
|
||||
[
|
||||
'name' => '20-25w',
|
||||
'value' => '20-25',
|
||||
],
|
||||
[
|
||||
'name' => '25-30w',
|
||||
'value' => '25-30',
|
||||
],
|
||||
[
|
||||
'name' => '35-40w',
|
||||
'value' => '35-40',
|
||||
],
|
||||
[
|
||||
'name' => '45-50w',
|
||||
'value' => '45-50',
|
||||
],
|
||||
[
|
||||
'name' => '50+w',
|
||||
'value' => '50-9000',
|
||||
],
|
||||
],
|
||||
'mileage' => [
|
||||
[
|
||||
'name' => '0-100km',
|
||||
'value' => '0-100',
|
||||
],
|
||||
[
|
||||
'name' => '100-300km',
|
||||
'value' => '100-300',
|
||||
],
|
||||
[
|
||||
'name' => '300-500km',
|
||||
'value' => '300-500',
|
||||
],
|
||||
[
|
||||
'name' => '500-700km',
|
||||
'value' => '500-700',
|
||||
],
|
||||
[
|
||||
'name' => '700-900km',
|
||||
'value' => '700-900',
|
||||
],
|
||||
[
|
||||
'name' => '1000+km',
|
||||
'value' => '1000-90000000',
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function getModels(int $brand_id)
|
||||
{
|
||||
$model = ModelModel::with('translation')->where('status', 1)->where('brand_id', $brand_id)->get()->toArray();
|
||||
$models = [];
|
||||
foreach ($model as $key => $val) {
|
||||
$models[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => isset($val['translation']) ? $val['translation']['name'] : ''
|
||||
];
|
||||
}
|
||||
return $models;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\EnergyModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EnergyService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return EnergyModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\EnergyTranslationModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EnergyTranslationService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return EnergyTranslationModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\LocationModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LocationService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return LocationModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\LocationTranslationModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LocationTranslationService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return LocationTranslationModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\ModelModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ModelService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return ModelModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
'default' => function ($params) {
|
||||
return [
|
||||
'filters' => [
|
||||
['field' => 'status', 'operator' => '=', 'value' => '1']
|
||||
],
|
||||
'fields' => ['id', 'brand_id', 'status', 'sort', 'created_at', 'updated_at'],
|
||||
'relations' => [
|
||||
'translation' => ['model_id', 'name'],
|
||||
'brand.translation' => ['brand_id', 'name']
|
||||
],
|
||||
'sorts' => [
|
||||
['field' => 'id', 'direction' => 'desc']
|
||||
],
|
||||
'pagination' => [
|
||||
'page' => $params['page'] ?? 1,
|
||||
'per_page' => $params['per_page'] ?? 10,
|
||||
]
|
||||
];
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\ModelTranslationModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ModelTranslationService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return ModelTranslationModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\SubscribeModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SubscribeService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return SubscribeModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function store(array $data): Model
|
||||
{
|
||||
$info = $this->getModel()::where('email', strtolower($data['email']))->first();
|
||||
if ($info) {
|
||||
return $info;
|
||||
}
|
||||
$data['email'] = strtolower($data['email']);
|
||||
$data['created_at'] = date('Y-m-d H:i:s');
|
||||
$data['updated_at'] = date('Y-m-d H:i:s');
|
||||
return $this->create($data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\TypesModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TypesService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return TypesModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
'default' => function ($params) {
|
||||
return [
|
||||
'filters' => [
|
||||
['field' => 'status', 'operator' => '=', 'value' => '1']
|
||||
],
|
||||
// 'fields' => ['id', 'name', 'image'],
|
||||
'fields' => ['id', 'img', 'status', 'sort', 'created_at', 'updated_at'],
|
||||
'relations' => [
|
||||
'translation' => ['type_id', 'name']
|
||||
],
|
||||
'sorts' => [
|
||||
['field' => 'id', 'direction' => 'desc']
|
||||
],
|
||||
'pagination' => [
|
||||
'page' => $params['page'] ?? 1,
|
||||
'per_page' => $params['per_page'] ?? 6,
|
||||
]
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\TypesTranslationModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TypesTranslationService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return TypesTranslationModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\UsersModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UsersService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return UsersModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\VehicleAlbumModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class VehicleAlbumService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return VehicleAlbumModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\VehicleAlbumModel;
|
||||
use app\apis\model\VehicleDataModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use app\mzl\modules\upload\service\OssService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Symfony\Polyfill\Intl\Idn\Info;
|
||||
|
||||
class VehicleDataService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return VehicleDataModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
'default' => function(array $params) {
|
||||
return [
|
||||
'filters' => $params['filters'],
|
||||
'fields' => [
|
||||
'id','vin','price','cover',
|
||||
'type','energy','model','mileage','vehicle_age',
|
||||
'views','is_hot','created_at','updated_at', 'brand', 'model', 'user_id', 'location'
|
||||
],
|
||||
'relations' => [
|
||||
'translation' => ['vehicle_id', 'name','condition_desc', 'location'],
|
||||
'brand.translation' => ['brand_id', 'name'],
|
||||
'album' => [
|
||||
'id', 'vehicle_data_id', 'front_45_degree',
|
||||
'front_left_45_degree', 'front_left_headlight',
|
||||
'front_view', 'lower_front', 'wheel_hub',
|
||||
'front_right_seat', 'right_lower_side',
|
||||
'rear_right_taillight', 'rear_right_45_degree',
|
||||
'lower_rear', 'trunk', 'left_lower_side',
|
||||
'rear_seats', 'center_console', 'control_panel',
|
||||
'gear_shift', 'car_key', 'steering_wheel',
|
||||
'dashboard', 'odometer_reading',
|
||||
'front_left_door_panel', 'front_left_door_function_area',
|
||||
'front_left_seat', 'interior_ceiling'
|
||||
],
|
||||
'user' => ['realname', 'nickname'],
|
||||
'types.translation' => ['type_id', 'name'],
|
||||
'energy.translation' => ['energy_id', 'name'],
|
||||
'models.translation' => ['model_id', 'name'],
|
||||
'user' => ['nickname'],
|
||||
'location.translation' => ['location_id', 'name']
|
||||
],
|
||||
'sorts' => [
|
||||
['field'=>'id','direction'=>'desc'],
|
||||
],
|
||||
'pagination' => [
|
||||
'page' => $params['page'] ?? 1,
|
||||
'per_page' => $params['per_page'] ?? 10,
|
||||
],
|
||||
];
|
||||
},
|
||||
'show' => function(array $params) {
|
||||
return [
|
||||
'filters' => [],
|
||||
'fields' => [
|
||||
'id','vin','price','cover',
|
||||
'type','energy','model','mileage','vehicle_age',
|
||||
'views','is_hot','created_at','updated_at', 'brand', 'model', 'user_id', 'store_status', 'location'
|
||||
],
|
||||
'relations' => [
|
||||
'translation' => ['vehicle_id', 'name','condition_desc', 'location'],
|
||||
'brand.translation' => ['brand_id', 'name'],
|
||||
'album' => [
|
||||
'id', 'vehicle_data_id', 'front_45_degree',
|
||||
'front_left_45_degree', 'front_left_headlight',
|
||||
'front_view', 'lower_front', 'wheel_hub',
|
||||
'front_right_seat', 'right_lower_side',
|
||||
'rear_right_taillight', 'rear_right_45_degree',
|
||||
'lower_rear', 'trunk', 'left_lower_side',
|
||||
'rear_seats', 'center_console', 'control_panel',
|
||||
'gear_shift', 'car_key', 'steering_wheel',
|
||||
'dashboard', 'odometer_reading',
|
||||
'front_left_door_panel', 'front_left_door_function_area',
|
||||
'front_left_seat', 'interior_ceiling'
|
||||
],
|
||||
'user' => ['realname', 'nickname'],
|
||||
'types.translation' => ['type_id', 'name'],
|
||||
'energy.translation' => ['energy_id', 'name'],
|
||||
'models.translation' => ['model_id', 'name'],
|
||||
'user' => ['nickname'],
|
||||
'location.translation' => ['location_id', 'name']
|
||||
],
|
||||
'sorts' => [
|
||||
['field'=>'id','direction'=>'desc'],
|
||||
],
|
||||
'pagination' => [
|
||||
'page' => $params['page'] ?? 1,
|
||||
'per_page' => $params['per_page'] ?? 10,
|
||||
],
|
||||
];
|
||||
},
|
||||
// 新增一个 random 场景
|
||||
'random' => function(array $params) {
|
||||
return [
|
||||
'filters' => [],
|
||||
'fields' => [
|
||||
'id','vin','price','cover',
|
||||
'type','energy','model','mileage','vehicle_age',
|
||||
'views','is_hot','created_at','updated_at', 'brand', 'model', 'user_id', 'store_status', 'location'
|
||||
],
|
||||
'relations' => [
|
||||
'translation' => ['vehicle_id', 'name','condition_desc', 'location'],
|
||||
'brand.translation' => ['brand_id', 'name'],
|
||||
'album' => [
|
||||
'id', 'vehicle_data_id', 'front_45_degree',
|
||||
'front_left_45_degree', 'front_left_headlight',
|
||||
'front_view', 'lower_front', 'wheel_hub',
|
||||
'front_right_seat', 'right_lower_side',
|
||||
'rear_right_taillight', 'rear_right_45_degree',
|
||||
'lower_rear', 'trunk', 'left_lower_side',
|
||||
'rear_seats', 'center_console', 'control_panel',
|
||||
'gear_shift', 'car_key', 'steering_wheel',
|
||||
'dashboard', 'odometer_reading',
|
||||
'front_left_door_panel', 'front_left_door_function_area',
|
||||
'front_left_seat', 'interior_ceiling'
|
||||
],
|
||||
'user' => ['realname', 'nickname'],
|
||||
'types.translation' => ['type_id', 'name'],
|
||||
'energy.translation' => ['energy_id', 'name'],
|
||||
'models.translation' => ['model_id', 'name'],
|
||||
'user' => ['nickname'],
|
||||
'location.translation' => ['location_id', 'name']
|
||||
],
|
||||
'custom' => function(\Illuminate\Database\Eloquent\Builder $q) {
|
||||
$q->inRandomOrder();
|
||||
},
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\service;
|
||||
|
||||
use app\apis\model\VehicleDataTranslationModel;
|
||||
use app\mzl\common\services\BaseService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class VehicleDataTranslationService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 定义模型
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel(): string
|
||||
{
|
||||
return VehicleDataTranslationModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多场景配置
|
||||
*/
|
||||
public function queryScenes(): array
|
||||
{
|
||||
return [
|
||||
// 'default' => function ($params) {
|
||||
// $keyword = $params['keyword'] ?? '';
|
||||
// return [
|
||||
// 'filters' => [
|
||||
// ['field' => '***', 'operator' => '=', 'value' => '***']
|
||||
// ],
|
||||
// 'fields' => ['id'],
|
||||
// 'relations' => [],
|
||||
// 'custom' => function(Builder $q) use ($keyword) {
|
||||
// // 示例
|
||||
// if ($keyword) {
|
||||
// $q->where(function($q2) use($keyword) {
|
||||
// $q2->whereHas('***', function($q3) use($keyword) {
|
||||
// $q3->where('***', 'like', "%{$keyword}%");
|
||||
// })->orWhereHas('***', function($q4) use($keyword) {
|
||||
// $q4->where('***', 'like', "%{$keyword}%");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// 'sorts' => [
|
||||
// ['field' => 'created_at', 'direction' => 'desc']
|
||||
// ],
|
||||
// 'pagination' => [
|
||||
// 'page' => $params['page'] ?? 1,
|
||||
// 'per_page' => $params['per_page'] ?? 10,
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class AgreementTranslationValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class AgreementValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class BrandTranslationValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class BrandValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class ContactsValidator extends Validate
|
||||
{
|
||||
// 验证规则
|
||||
protected $rule = [
|
||||
'name' => 'require|max:255|checkEmptyString',
|
||||
'phone' => 'require|checkInternationalPhone',
|
||||
'content' => 'require|min:10|max:65535',
|
||||
'vehicle_id' => 'integer',
|
||||
'email' => 'email'
|
||||
];
|
||||
|
||||
// 错误提示信息
|
||||
protected $message = [
|
||||
'name.require' => '姓名不能为空',
|
||||
'name.max' => '姓名长度不能超过255个字符',
|
||||
'name.checkEmptyString' => '姓名不能只包含空格',
|
||||
'phone.require' => '联系电话不能为空',
|
||||
'phone.checkInternationalPhone' => '请使用国际格式',
|
||||
'content.require' => '内容不能为空',
|
||||
'content.min' => '内容至少需要10个字符',
|
||||
'content.max' => '内容长度超过最大限制',
|
||||
'vehicle_id.integer' => '车辆ID必须为数字',
|
||||
'email.email' => '邮箱格式不正确'
|
||||
];
|
||||
|
||||
// 验证场景
|
||||
protected $scene = [
|
||||
'store' => ['name', 'phone', 'content', 'email', 'vehicle_id']
|
||||
];
|
||||
|
||||
// 自定义验证规则 - 检查国际电话号码
|
||||
protected function checkInternationalPhone($value)
|
||||
{
|
||||
/**
|
||||
* 国际电话验证规则:
|
||||
* 1. 必须以 + 开头
|
||||
* 2. 国家代码1-4位数字
|
||||
* 3. 后续号码总长度8-15位
|
||||
* 4. 允许的格式:
|
||||
* - +8613812345678
|
||||
* - +44 20 7123 4567
|
||||
* - +1 (800) 555-1234
|
||||
*/
|
||||
$pattern = '/^\+\d{1,4}[\d\s\(\)-]{8,}$/';
|
||||
|
||||
// 移除所有非必要字符后验证基础长度
|
||||
$cleanNumber = preg_replace('/[^\d+]/', '', $value);
|
||||
|
||||
return preg_match($pattern, $value) &&
|
||||
strlen($cleanNumber) >= 9 && // +号 + 至少8位数字
|
||||
strlen($cleanNumber) <= 16; // E.164 最大长度15位 + +号
|
||||
}
|
||||
|
||||
// 自定义验证规则 - 检查真实有效姓名
|
||||
protected function checkEmptyString($value)
|
||||
{
|
||||
return trim($value) !== '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class DictItemValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class DictTypeValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class EnergyTranslationValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class EnergyValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class LocationTranslationValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class LocationValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class ModelTranslationValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class ModelValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SubscribeValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
'email' => 'require|email'
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
'name.require' => '姓名不能为空',
|
||||
'email.email' => '邮箱格式不正确'
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
'email'
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class TypesTranslationValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class TypesValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class UsersValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class VehicleAlbumValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class VehicleDataTranslationValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\apis\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class VehicleDataValidator extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\AgreementModel;
|
||||
use app\applet\service\AgreementService;
|
||||
use app\applet\validate\AgreementValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class AgreementController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = AgreementValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new AgreementService(new AgreementModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'one') {
|
||||
return [
|
||||
'id' => $item['id'],
|
||||
'key' => $item['key'],
|
||||
'status' => $item['status'],
|
||||
'title' => isset($item['translation']) ? $item['translation']['title'] : '',
|
||||
'content' => isset($item['translation']) ? $item['translation']['content'] : '',
|
||||
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
|
||||
'updated_at' => date('Y-m-d H:i:s', $item['updated_at'])
|
||||
];
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'one') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
|
||||
public function getOne(Request $request, string $agt, string $scene = 'one'): Response
|
||||
{
|
||||
try {
|
||||
$request->setGet(['key' => $agt]);
|
||||
return parent::one($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\AgreementTranslationModel;
|
||||
use app\applet\service\AgreementTranslationService;
|
||||
use app\applet\validate\AgreementTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class AgreementTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = AgreementTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new AgreementTranslationService(new AgreementTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\BrandModel;
|
||||
use app\applet\service\BrandService;
|
||||
use app\applet\validate\BrandValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class BrandController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = BrandValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new BrandService(new BrandModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
return [
|
||||
'id' => $item['id'],
|
||||
'status' => $item['status'],
|
||||
'sort' => $item['sort'],
|
||||
'name' => isset($item['translation']) ? $item['translation']['name'] : '',
|
||||
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
|
||||
'updated_at' => date('Y-m-d H:i:s', $item['updated_at'])
|
||||
];
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\BrandTranslationModel;
|
||||
use app\applet\service\BrandTranslationService;
|
||||
use app\applet\validate\BrandTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class BrandTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = BrandTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new BrandTranslationService(new BrandTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\DraftsModel;
|
||||
use app\applet\service\DraftsService;
|
||||
use app\applet\validate\DraftsValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class DraftsController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = DraftsValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new DraftsService(new DraftsModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\EnergyModel;
|
||||
use app\applet\service\EnergyService;
|
||||
use app\applet\validate\EnergyValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class EnergyController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = EnergyValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new EnergyService(new EnergyModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
return [
|
||||
'id' => $item['id'],
|
||||
'status' => $item['status'],
|
||||
'sort' => $item['sort'],
|
||||
'name' => isset($item['translation']) ? $item['translation']['name'] : '',
|
||||
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
|
||||
'updated_at' => date('Y-m-d H:i:s', $item['updated_at'])
|
||||
];
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\EnergyTranslationModel;
|
||||
use app\applet\service\EnergyTranslationService;
|
||||
use app\applet\validate\EnergyTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class EnergyTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = EnergyTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new EnergyTranslationService(new EnergyTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\LocationModel;
|
||||
use app\applet\service\LocationService;
|
||||
use app\applet\validate\LocationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class LocationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = LocationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new LocationService(new LocationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\LocationTranslationModel;
|
||||
use app\applet\service\LocationTranslationService;
|
||||
use app\applet\validate\LocationTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class LocationTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = LocationTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new LocationTranslationService(new LocationTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\ModelModel;
|
||||
use app\applet\service\ModelService;
|
||||
use app\applet\validate\ModelValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class ModelController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = ModelValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new ModelService(new ModelModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
return [
|
||||
'id' => $item['id'],
|
||||
'status' => $item['status'],
|
||||
'sort' => $item['sort'],
|
||||
'name' => isset($item['translation']) ? $item['translation']['name'] : '',
|
||||
'brand_id' => $item['brand_id'],
|
||||
'brand' => isset($item['brand']) ? $item['brand']['translation']['name'] : '',
|
||||
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
|
||||
'updated_at' => date('Y-m-d H:i:s', $item['updated_at'])
|
||||
];
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\ModelTranslationModel;
|
||||
use app\applet\service\ModelTranslationService;
|
||||
use app\applet\validate\ModelTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class ModelTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = ModelTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new ModelTranslationService(new ModelTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\TypesModel;
|
||||
use app\applet\service\TypesService;
|
||||
use app\applet\validate\TypesValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class TypesController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = TypesValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new TypesService(new TypesModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
return [
|
||||
'id' => $item['id'],
|
||||
'img_full' => $item['img'] ? (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['img']) : '',
|
||||
'img' => $item['img'],
|
||||
'status' => $item['status'],
|
||||
'sort' => $item['sort'],
|
||||
'name' => isset($item['translation']) ? $item['translation']['name'] : '',
|
||||
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
|
||||
'updated_at' => date('Y-m-d H:i:s', $item['updated_at'])
|
||||
];
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\TypesTranslationModel;
|
||||
use app\applet\service\TypesTranslationService;
|
||||
use app\applet\validate\TypesTranslationValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class TypesTranslationController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = TypesTranslationValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new TypesTranslationService(new TypesTranslationModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\UsersModel;
|
||||
use app\applet\service\UsersService;
|
||||
use app\applet\validate\UsersValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class UsersController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = UsersValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new UsersService(new UsersModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序登录
|
||||
*/
|
||||
public function miniappLogin(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$result = $this->getService()->miniappLogin($request->all());
|
||||
return $this->successResponse($result);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取手机号
|
||||
*/
|
||||
public function miniappPhoneNumber(Request $request): Response
|
||||
{
|
||||
try {
|
||||
$result = $this->getService()->miniappPhoneNumber($request->all());
|
||||
return $this->successResponse($result);
|
||||
} catch (\Throwable $th) {
|
||||
var_dump($th->getFile().$th->getLine());
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function one(Request $request, string $scene = 'one'): Response
|
||||
{
|
||||
try {
|
||||
return parent::one($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateData(Request $request): Response
|
||||
{
|
||||
$data = $this->validateRequest($request->all(), 'update');
|
||||
$result = $this->getService()->update($request->user->user_id, $data);
|
||||
return $result
|
||||
? $this->successResponse([], '更新成功')
|
||||
: $this->errorResponse('更新失败');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\VehicleAlbumModel;
|
||||
use app\applet\service\VehicleAlbumService;
|
||||
use app\applet\validate\VehicleAlbumValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class VehicleAlbumController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = VehicleAlbumValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new VehicleAlbumService(new VehicleAlbumModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\applet\controller;
|
||||
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use app\applet\model\VehicleApplyModel;
|
||||
use app\applet\service\VehicleApplyService;
|
||||
use app\applet\validate\VehicleApplyValidator;
|
||||
use app\mzl\common\controller\BaseController;
|
||||
|
||||
class VehicleApplyController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 不需要验证token的接口
|
||||
* @var array
|
||||
*/
|
||||
protected $noNeedJwt = [];
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected mixed $validator = VehicleApplyValidator::class;
|
||||
|
||||
/**
|
||||
* 返回业务 Service 实例
|
||||
*/
|
||||
protected function getService()
|
||||
{
|
||||
return new VehicleApplyService(new VehicleApplyModel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 额外字段处理 (根据场景处理)
|
||||
* @param array $item
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function postProcessItem(array $item, string $scene): array
|
||||
{
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数预处理 (根据场景处理)
|
||||
* @param Request $request
|
||||
* @param string $scene
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareParams(Request $request, string $scene): array
|
||||
{
|
||||
$params = parent::prepareParams($request, $scene);
|
||||
|
||||
if ($scene === 'default') {
|
||||
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return Response 响应对象
|
||||
*/
|
||||
public function index(Request $request, string $scene = 'default'): Response
|
||||
{
|
||||
try {
|
||||
return parent::index($request, $scene);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->errorResponse($th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user