zx/app/controller/merchant/system/openapi/OpenApi.php

96 lines
3.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\merchant\system\openapi;
use app\common\repositories\openapi\OpenAuthRepository;
use app\validate\merchant\OpenAuthValidate;
use crmeb\basic\BaseController;
use think\App;
class OpenApi extends BaseController
{
protected $repository;
public function __construct(App $app, OpenAuthRepository $repository)
{
parent::__construct($app);
$this->repository = $repository;
}
public function lst()
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['title','access_key']);
$where['mer_id'] = $this->request->merId();
$data = $this->repository->getList($where, $page, $limit);
return app('json')->success($data);
}
public function createForm()
{
return app('json')->success(formToData($this->repository->form($this->request->merId())));
}
public function create()
{
$data = $this->checkParams();
$this->repository->create($this->request->merId(),$data);
return app('json')->success('添加成功');
}
public function updateForm($id)
{
return app('json')->success(formToData($this->repository->form($this->request->merId(),$id)));
}
public function update($id)
{
$data = $this->checkParams();
$data['update_time'] = date('Y-m-d H:i:s',time());
$this->repository->update($id,$data);
return app('json')->success('编辑成功');
}
public function switchWithStatus($id)
{
$status = $this->request->param('status',0) == 1 ?: 0;
$this->repository->update($id,['status' => $status]);
return app('json')->success('修改成功');
}
public function delete($id)
{
$this->repository->update($id,['is_del' => 1, 'delete_time' => date('Y-m-d H:i:s',time())]);
return app('json')->success('删除成功');
}
public function getSecretKey($id)
{
$data = $this->repository->getSecretKey($id);
return app('json')->success($data);
}
public function setSecretKey($id)
{
$data = $this->repository->setSecretKey($id, $this->request->merId());
return app('json')->success('重置成功',$data);
}
public function checkParams()
{
$data = $this->request->params(['title','status','mark','auth','sort']);
app()->make(OpenAuthValidate::class)->check($data);
return $data;
}
}