1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- /**
- * Author: luzheng.liu
- * Time: 2020/12/16 23:06
- */
- namespace app\api\controller;
- use app\api\BaseController;
- use app\api\model\GroupModel;
- use app\common\until\Until;
- class Group extends BaseController {
- /**
- * @OA\Get(path="/api/Group/index",
- * tags={"集团管理"},
- * summary="集团列表",
- * @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
- * @OA\Parameter(name="page", in="query", description="页码", @OA\Schema(type="ineger",default="1")),
- * @OA\Parameter(name="pageSize", in="query", description="页尺寸", @OA\Schema(type="integer",default="10")),
- * @OA\RequestBody(
- * ),
- * @OA\Response(response="200", description="请求成功")
- * )
- */
- public function index() {
- $input = request()->get();
- $model = new GroupModel();
- $model->setPage($input['page'] ?? 1);
- $model->setPageSize($input['pageSize'] ?? 10);
- $where = [];
- $where[] = ['gr.admin_id','=',$this->adminId];
- $model->setWhere($where);
- $data = $model->getGroupList();
- Until::output($data);
- }
- /**
- * @OA\Post(path="/api/Group/save",
- * tags={"集团管理"},
- * summary="保存集团信息",
- * @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
- * @OA\RequestBody(
- * @OA\MediaType(
- * mediaType="multipart/form-data",
- * @OA\Schema(
- * @OA\Property(description="集团名称", property="name", type="string", default="四海集团"),
- * required={"name"})
- * )
- * ),
- * @OA\Response(response="200", description="请求成功")
- * )
- */
- public function save() {
- $input = Until::getInput();
- $rule = [
- 'name|集团名称' => 'require',
- ];
- Until::check($rule, $input);
- $model = new GroupModel();
- if (!empty($input['id']) ) {
- $id = (int)$input['id'];
- $model::where(['id' => $id])->update([
- 'group_name' => $input['name']
- ]);
- } else {
- $id = $model->insertGetId([
- 'group_name' => $input['name']
- ]);
- }
- $info = $model::get($id);
- Until::output(['info' => Until::modelToArray($info)]);
- }
- public function delete($id,$status) {
- $model = new GroupModel();
- $where[] = ['id', '=', (int)$id];
- $data = ['status' => (int)$status];
- $isSuccess = $model::where($where)->update($data);
- Until::output(['isSuccess' => $isSuccess]);
- }
- }
|