样机小程序
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\AgreementService;
|
||||
|
||||
class AgreementController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new AgreementService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\BannerService;
|
||||
|
||||
class BannerController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new BannerService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 轮播图模块
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getBannerModule()
|
||||
{
|
||||
try {
|
||||
$raw = $this->service->getBannerModule();
|
||||
$data = $this->transformData($raw, method_exists($this, 'indexFormat')
|
||||
? [$this, 'indexFormat']
|
||||
: null);
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
if (isset($data['image_url']) && !empty($data['image_url'])){
|
||||
$ossservice = new OssService();
|
||||
$data['image_url_pull'] = $ossservice->generatePrivateUrl($data['image_url']);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\MessageNoticeService;
|
||||
|
||||
class MessageNoticeController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new MessageNoticeService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\PostCategoryService;
|
||||
use support\Request;
|
||||
|
||||
class PostCategoryController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new PostCategoryService();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分类树
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function tree(Request $request)
|
||||
{
|
||||
try {
|
||||
$params = $request->all();
|
||||
$result = $this->service->getList($params);
|
||||
return $this->success($result, '获取分类列表');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
$ossservice = new OssService();
|
||||
if (!empty($data['icon_active'])){
|
||||
$data['icon_active_pull'] = $ossservice->generatePrivateUrl($data['icon_active']);
|
||||
}
|
||||
if (!empty($data['icon_inactive'])){
|
||||
$data['icon_inactive_pull'] = $ossservice->generatePrivateUrl($data['icon_inactive']);
|
||||
}
|
||||
if (!empty($data['icon_preset'])){
|
||||
$data['icon_preset_pull'] = $ossservice->generatePrivateUrl($data['icon_preset']);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\PostComment;
|
||||
use app\common\model\User;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\PostCommentService;
|
||||
|
||||
class PostCommentController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new PostCommentService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
if (isset($data['id'])){
|
||||
$data['child'] = [];
|
||||
$child = PostComment::where(['parent_id' => $data['id']])->first();
|
||||
if(!empty($child)){
|
||||
$child = $child->toArray();
|
||||
}
|
||||
$data['count'] = PostComment::where(['parent_id' => $data['id']])->count();
|
||||
if (isset($child['user_id'])){
|
||||
$ossservice = new OssService();
|
||||
$child['user'] = User::where('id', $child['user_id'])->select(['nickname', 'avatar', 'openid'])->first();
|
||||
if(!str_contains($child['user']['avatar'], 'http') && !empty($child['user']['avatar'])){
|
||||
$child['user']['avatar_pull'] = $ossservice->generatePrivateUrl($child['user']['avatar']);
|
||||
}
|
||||
$child['created_at'] = date('Y-m-d H:i:s', strtotime($child['created_at']));
|
||||
$child['updated_at'] = date('Y-m-d H:i:s', strtotime($child['updated_at']));
|
||||
$data['child'][] = $child;
|
||||
}
|
||||
}
|
||||
if (isset($data['user_id'])){
|
||||
$ossservice = new OssService();
|
||||
$data['user'] = User::where('id', $data['user_id'])->select(['nickname', 'avatar', 'openid'])->first();
|
||||
|
||||
if(!str_contains($data['user']['avatar'], 'http') && !empty($data['user']['avatar'])){
|
||||
$data['user']['avatar_pull'] = $ossservice->generatePrivateUrl($data['user']['avatar']);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\PostCategory;
|
||||
use app\common\model\PostMedia;
|
||||
use app\common\model\User;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\PostService;
|
||||
|
||||
class PostController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new PostService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
if (isset($data['id']))
|
||||
$data['media'] = PostMedia::where('post_id', $data['id'])->get();
|
||||
if (isset($data['category_id']))
|
||||
$data['category_name'] = PostCategory::where('id', $data['category_id'])->value('name')??'';
|
||||
|
||||
$ossservice = new OssService();
|
||||
if (isset($data['id'])){
|
||||
$data['media'] = PostMedia::where('post_id', $data['id'])->get()->toArray();
|
||||
foreach ($data['media'] as &$media) {
|
||||
$media['url_pull'] = $ossservice->generatePrivateUrl($media['url']);
|
||||
}
|
||||
}
|
||||
if (isset($data['user_id'])){
|
||||
$data['user'] = User::where('id', $data['user_id'])->first();
|
||||
unset($data['user']['password']);
|
||||
$data['user']['avatar_pull'] = $data['user']['avatar'];
|
||||
if(!str_contains($data['user']['avatar'], 'http') && !empty($data['user']['avatar'])){
|
||||
$data['user']['avatar_pull'] = $ossservice->generatePrivateUrl($data['user']['avatar']);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
if (isset($data['id']))
|
||||
$data['media'] = PostMedia::where('post_id', $data['id'])->get();
|
||||
if (isset($data['category_id']))
|
||||
$data['category_name'] = PostCategory::where('id', $data['category_id'])->value('name')??'';
|
||||
|
||||
$ossservice = new OssService();
|
||||
if (isset($data['id'])){
|
||||
$data['media'] = PostMedia::where('post_id', $data['id'])->get()->toArray();
|
||||
foreach ($data['media'] as &$media) {
|
||||
$media['url_pull'] = $ossservice->generatePrivateUrl($media['url']);
|
||||
}
|
||||
}
|
||||
if (isset($data['user_id'])){
|
||||
$data['user'] = User::where('id', $data['user_id'])->first();
|
||||
unset($data['user']['password']);
|
||||
$data['user']['avatar_pull'] = $data['user']['avatar'];
|
||||
if(!str_contains($data['user']['avatar'], 'http') && !empty($data['user']['avatar'])){
|
||||
$data['user']['avatar_pull'] = $ossservice->generatePrivateUrl($data['user']['avatar']);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\PostFavoriteService;
|
||||
|
||||
class PostFavoriteController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new PostFavoriteService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\PostLikeService;
|
||||
|
||||
class PostLikeController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new PostLikeService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\PostMediaService;
|
||||
|
||||
class PostMediaController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new PostMediaService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\admin\service\RoleService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use support\Request;
|
||||
|
||||
class RoleController extends BaseController
|
||||
{
|
||||
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new RoleService();
|
||||
}
|
||||
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function menuResource(Request $request)
|
||||
{
|
||||
try {
|
||||
// $data = $this->validate($this->service->getValidator(), $request->post(), 'allocation');
|
||||
$data = $request->post();
|
||||
$res = $this->service->menuResource($request, $data);
|
||||
return $this->success($res);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\SkuAttributeService;
|
||||
|
||||
class SkuAttributeController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SkuAttributeService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\SkuAttributeValueService;
|
||||
|
||||
class SkuAttributeValueController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SkuAttributeValueService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\SkuService;
|
||||
|
||||
class SkuController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SkuService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\SystemsService;
|
||||
|
||||
class SystemsController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SystemsService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\Corp;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\UserService;
|
||||
use app\crm\model\Customer;
|
||||
use support\Request;
|
||||
|
||||
class UserController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new UserService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return mixed 返回更新成功的数据或信息
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
if(mb_strlen($data['mobile']) < 11){
|
||||
return $this->error('手机号错误');
|
||||
}
|
||||
$res = $this->service->serviceCreateUser($request, $data);
|
||||
return $this->success([], '添加成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return mixed 返回更新成功的数据或信息
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$res = $this->service->serviceUpdateUser($request, $data);
|
||||
return $this->success([], '更新成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
* @throws \Random\RandomException
|
||||
*/
|
||||
public function savePassword(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->all();
|
||||
if(empty($data['password'])){
|
||||
return $this->error('密码不能为空');
|
||||
}
|
||||
$result = $this->service->savePassword($request,$data);;
|
||||
return $this->success($result, '编辑成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return mixed 返回更新成功的数据或信息
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$data['id'] = $data['id']??$request->user->uid;
|
||||
$res = $this->service->serviceUpdate($request, $data);
|
||||
return $this->success([], '更新成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if(isset($data['records'])){
|
||||
return $data;
|
||||
}
|
||||
$data['sex_txt'] = '';
|
||||
if (isset($data['sex']) && $data['sex'] == 1){
|
||||
$data['sex_txt'] = '男';
|
||||
}elseif(isset($data['sex']) && $data['sex'] == 2){
|
||||
$data['sex_txt'] = '女';
|
||||
}
|
||||
|
||||
$ossservice = new OssService();
|
||||
if(isset($data['avatar']) && !empty($data['avatar']) && strpos($data['avatar'], 'http') === false){
|
||||
//$data['avatar_pull'] = $ossservice->generatePrivateUrl($data['avatar']);
|
||||
$data['avatar_pull'] = '/proxy/ossurl?file='.$data['avatar'];
|
||||
}else{
|
||||
$data['avatar_pull'] = $data['avatar'];
|
||||
}
|
||||
|
||||
switch ($data['status']){
|
||||
case 1:
|
||||
$data['status_txt'] = '正常';
|
||||
break;
|
||||
case 2:
|
||||
$data['status_txt'] = '离职';
|
||||
break;
|
||||
default:
|
||||
$data['status_txt'] = '';
|
||||
break;
|
||||
}
|
||||
|
||||
$data['role_ids'] = [];
|
||||
$data['system_ids'] = [];
|
||||
if (isset($data['roles']) && count($data['roles']) > 0) {
|
||||
foreach ($data['roles'] as $role) {
|
||||
$data['role_ids'][] = $role['id'];
|
||||
}
|
||||
}
|
||||
if (isset($data['systems']) && count($data['systems']) > 0) {
|
||||
foreach ($data['systems'] as $system) {
|
||||
$data['system_ids'][] = $system['id'];
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function authorize(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$res = $this->service->authorize($request, $data);
|
||||
return $this->success([], '分配成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接授权
|
||||
*
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function updateResources(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$res = $this->service->updateResources($request, $data);
|
||||
return $this->success([], '分配成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateSign(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$this->service->serviceUpdateSign($request, $data);
|
||||
return $this->success([], '签名成功');
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user