Skip to content

Commit

Permalink
6.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
simplewindorg committed Aug 2, 2023
1 parent ab03f98 commit d753f0e
Show file tree
Hide file tree
Showing 13 changed files with 505 additions and 115 deletions.
53 changes: 50 additions & 3 deletions src/admin/controller/PublicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,42 @@
use cmf\controller\RestBaseController;
use think\facade\Db;
use think\facade\Validate;
use OpenApi\Annotations as OA;

class PublicController extends RestBaseController
{

// 用户登录 TODO 增加最后登录信息记录,如 ip
/**
* 后台管理员登录
* @throws \think\exception\DbException
* @OA\Post(
* tags={"admin"},
* path="/admin/public/login",
* summary="后台管理员登录",
* description="后台管理员登录(请先使用原来登录页面登录,登录获取token后再使用后台API)",
* @OA\RequestBody(
* description="请求参数",
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(ref="#/components/schemas/LoginRequest")
* ),
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(ref="#/components/schemas/LoginRequest")
* )
* ),
* @OA\Response(
* response="1",
* description="登录成功",
* @OA\JsonContent(ref="#/components/schemas/AdminPublicLoginResponse")
* ),
* @OA\Response(response="0",ref="#/components/responses/0"),
* )
*/
public function login()
{
$this->error('请先使用原来登录页面登录,登录获取token 后再使用后台API');
// TODO 增加最后登录信息记录,如 ip
$validate = new \think\Validate();
$validate->rule([
'username' => 'require',
Expand Down Expand Up @@ -64,7 +93,7 @@ public function login()

if (empty($this->deviceType) && (empty($data['device_type']) || !in_array($data['device_type'], $this->allowedDeviceTypes))) {
$this->error("请求错误,未知设备!");
} else if(!empty($data['device_type'])) {
} else if (!empty($data['device_type'])) {
$this->deviceType = $data['device_type'];
}

Expand Down Expand Up @@ -102,7 +131,24 @@ public function login()
$this->success("登录成功!", ['token' => $token]);
}

// 管理员退出
/**
* 后台管理员退出
* @throws \think\exception\DbException
* @OA\Post(
* tags={"admin"},
* path="/admin/public/logout",
* summary="后台管理员退出",
* description="后台管理员退出",
* @OA\Response(
* response="1",
* @OA\JsonContent(example={"code": 1,"msg": "退出成功!","data": null})
* ),
* @OA\Response(
* response="0",
* @OA\JsonContent(example={"code": 0,"msg": "退出失败!","data": null})
* ),
* )
*/
public function logout()
{
$userId = $this->getUserId();
Expand All @@ -112,6 +158,7 @@ public function logout()
'device_type' => $this->deviceType
])->update(['token' => '']);

session('ADMIN_ID', null);
$this->success("退出成功!");
}

Expand Down
43 changes: 43 additions & 0 deletions src/admin/controller/SettingController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-present http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <[email protected]>
// +----------------------------------------------------------------------
namespace api\admin\controller;

use cmf\controller\RestAdminBaseController;
use cmf\controller\RestBaseController;
use OpenApi\Annotations as OA;
use think\facade\Db;
use think\facade\Validate;

class SettingController extends RestAdminBaseController
{
/**
* 清理缓存
* @throws \think\exception\DbException
* @OA\Post(
* tags={"admin"},
* path="/admin/setting/clearCache",
* summary="清理缓存",
* description="清理缓存",
* @OA\Response(
* response="1",
* @OA\JsonContent(example={"code": 1,"msg": "清除成功!","data": ""})
* ),
* @OA\Response(
* response="0",
* @OA\JsonContent(example={"code": 0,"msg": "清除失败!","data": ""})
* ),
* )
*/
public function clearCache()
{
cmf_clear_cache();
$this->success('清除成功!');
}

}
51 changes: 51 additions & 0 deletions src/admin/swagger/response/AdminPublicLoginResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace api\admin\swagger\response;

use OpenApi\Annotations as OA;


/**
* @OA\Schema()
*/
class AdminPublicLoginResponse
{
/**
* @OA\Property(format="int64",example="1")
* @var int
*/
public $code;

/**
* @OA\Property(example="登录成功!")
* @var string
*/
public $msg;

/**
* @OA\Property(
* type="object",
* ref="#/components/schemas/AdminPublicLoginResponseData"
* )
* @var object
*/
public $data;

}

/**
* @OA\Schema()
*/
class AdminPublicLoginResponseData
{
/**
* @OA\Property(
* type="string",
* example="01227ac27d40f95491c47847bf91b558d7640d81a1578bb72cb2ff8b14fd9cb4"
* )
* @var array
*/
public $token;

}

13 changes: 10 additions & 3 deletions src/home/controller/SlidesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,20 @@ class SlidesController extends RestBaseController
* name="id",
* in="path",
* description="幻灯片分组 id",
* required=false,
* required=true,
* @OA\Schema(
* type="integer",
* )
* ),
* @OA\Response(response="200", description="An example resource"),
* @OA\Response(response="default", description="An example resource")
* @OA\Response(
* response="1",
* description="登录成功",
* @OA\JsonContent(ref="#/components/schemas/HomeSlidesReadResponse")
* ),
* @OA\Response(
* response="0",
* @OA\JsonContent(example={"code": 0,"msg": "该组幻灯片显示数据为空!","data": null})
* ),
* )
*/
public function read()
Expand Down
191 changes: 191 additions & 0 deletions src/home/swagger/response/HomeSlidesReadResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<?php

namespace api\home\swagger\response;

use OpenApi\Annotations as OA;


/**
* @OA\Schema()
*/
class HomeSlidesReadResponse
{
/**
* @OA\Property(format="int64",example="1")
* @var int
*/
public $code;

/**
* @OA\Property(example="该组幻灯片获取成功!")
* @var string
*/
public $msg;

/**
* @OA\Property(
* type="object",
* ref="#/components/schemas/HomeSlidesReadResponseData"
* )
* @var object
*/
public $data;

}

/**
* @OA\Schema()
*/
class HomeSlidesReadResponseData
{
// "id": 1,
// "status": 1,
// "delete_time": 0,
// "name": "幻灯片一",
// "remark": "苦",
/**
* @OA\Property(
* type="int64",
* example="1"
* )
*/
public $id;

/**
* @OA\Property(
* type="int64",
* example="1"
* )
*/
public $status;

/**
* @OA\Property(
* type="int64",
* example="0"
* )
*/
public $delete_time;

/**
* @OA\Property(
* type="string",
* example="幻灯片名称"
* )
*/
public $name;

/**
* @OA\Property(
* type="string",
* example="备注"
* )
*/
public $remark;

/**
* @OA\Property(
* type="array",
* @OA\Items(ref="#/components/schemas/HomeSlidesReadResponseDataItem")
* )
*/
public $items;
}



/**
* @OA\Schema()
*/
class HomeSlidesReadResponseDataItem
{
/**
* @OA\Property(
* type="int64",
* example="1"
* )
*/
public $id;

/**
* @OA\Property(
* type="int64",
* example="1"
* )
*/
public $slide_id;

/**
* @OA\Property(
* type="int64",
* example="1"
* )
*/
public $status;

/**
* @OA\Property(
* type="number",
* example="1.0"
* )
*/
public $list_order;

/**
* @OA\Property(
* type="string",
* example="页面一"
* )
*/
public $title;

/**
* @OA\Property(
* type="string",
* example="http://cmf6.im/upload/portal/20170810/a721883e7f17fb054be63ddb7331ddb5.jpg"
* )
*/
public $image;

/**
* @OA\Property(
* type="string",
* example="http://www.baidu.com"
* )
*/
public $url;

/**
* @OA\Property(
* type="string",
* example="_blank"
* )
*/
public $target;

/**
* @OA\Property(
* type="string",
* example="描述"
* )
*/
public $description;

/**
* @OA\Property(
* type="string",
* example="内容"
* )
*/
public $content;

/**
* @OA\Property(
* type="object",
* example={"xxxx":"xxxx"}
* )
*/
public $more;

}

Loading

0 comments on commit d753f0e

Please sign in to comment.