DiverseYouthNightSchool/application/api/controller/school/worker/Classes.php

253 lines
13 KiB
PHP
Raw Permalink 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
namespace app\api\controller\school\worker;
use app\common\model\school\classes\Cate;
use app\common\model\school\classes\ClassesLib;
use app\common\model\school\classes\Label;
use app\common\model\school\classes\Type;
use app\common\model\school\SearchCity;
use think\Cache;
use think\Log;
/**
* 员工管理机构课程接口
*/
class Classes extends Base
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $model = null;
/**
* 初始化操作
* @access protected
*/
protected function _initialize()
{
$this->model = new ClassesLib;
parent::_initialize();
//判断登录用户是否是员工 'add','edit','del'
$this->setUrlLock();
}
/**
* @ApiTitle(员工课程添加)
* @ApiSummary(员工课程添加)
* @ApiMethod(POST)
* @ApiParams(name = "classes_num", type = "int",required=true,description = "核销次数")
* @ApiParams(name = "status", type = "string",required=true,description = "上架状态:1=上架,2=下架,3=平台下架")
* @ApiParams(name = "teacher_id", type = "int",required=true,description = "老师id")
* @ApiParams(name = "classes_type", type = "string",required=true,description = "课程类型")
* @ApiParams(name = "classes_cate_ids", type = "string",required=true,description = "课程标签ids 多值逗号拼接")
* @ApiParams(name = "classes_label_ids", type = "string",required=true,description = "课程热门标签")
* @ApiParams(name = "self_label_tag", type = "string",required=true,description = "机构热门标签:多值逗号拼接")
* @ApiParams(name = "title", type = "string",required=true,description = "课程标题")
* @ApiParams(name = "headimage", type = "string",required=true,description = "课程头图")
* @ApiParams(name = "images", type = "string",required=true,description = "课程轮播图多值逗号拼接")
* @ApiParams(name = "type", type = "string",required=true,description = "地点类型:out=户外,in=室内")
* @ApiParams(name = "spec", type = "string",required=true,description = "课时多规格:[{'id':665,'classes_lib_id':570,'name':'xxxxx','limit_num':100,'status':'1','weigh':665,'time':'2024\/12\/12 19:00 - 2024\/12\/12 20:00'}] ")
* @ApiParams(name = "address_type", type = "string",required=true,description = "地址类型:1=按机构,2=独立位置")
* @ApiParams(name = "province", type = "string",required=false,description = "省编号")
* @ApiParams(name = "city", type = "string",required=false,description = "市编号")
* @ApiParams(name = "district", type = "string",required=false,description = "县区编号")
* @ApiParams(name = "address", type = "string",required=false,description = "地图定位地址")
* @ApiParams(name = "address_detail", type = "string",required=false,description = "手录详细地址")
* @ApiParams(name = "longitude", type = "string",required=false,description = "经度")
* @ApiParams(name = "latitude", type = "string",required=false,description = "纬度")
* @ApiParams(name = "content", type = "string",required=false,description = "课程详情")
* @ApiParams(name = "notice", type = "string",required=false,description = "课程须知")
* @ApiParams(name = "price", type = "string",required=false,description = "课程价格 0为免费")
* @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是")
* @ApiReturn({
*
*})
*/
public function add(){
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$params = [];
$params["status"] = $this->request->post('status/s', 0); //上架状态:1=上架,2=下架,3=平台下架
$params["teacher_id"] = $this->request->post('teacher_id/d', 0); //老师id
$params["classes_type"] = $this->request->post('classes_type/s', ''); //老师id
$params["classes_cate_ids"] = $this->request->post('classes_cate_ids/s', ''); //课程标签
$params["classes_label_ids"] = $this->request->post('classes_label_ids/s', ''); //课程热门标签
$params["self_label_tag"] = $this->request->post('self_label_tag/s', ''); //老师id
$params["title"] = $this->request->post('title/s', ''); //老师id
$params["headimage"] = $this->request->post('headimage/s', ''); //老师id
$params["images"] = $this->request->post('images/s', ''); //老师id
$params["type"] = $this->request->post('type/s', ''); //老师id
$params["spec"] = $this->request->post('spec/s', ''); //老师id
$params["classes_num"] = $this->request->post('classes_num/d', 0); //核销次数
//
$params["address_type"] = $this->request->post('address_type/s', ''); //老师id
$params["province"] = $this->request->post('province/d', 0); //老师id
$params["city"] = $this->request->post('city/d', 0); //老师id
$params["district"] = $this->request->post('district/d', 0); //老师id
$params["address"] = $this->request->post('address/s', ''); //老师id
$params["address_detail"] = $this->request->post('address_detail/s', ''); //老师id
$params["longitude"] = $this->request->post('longitude/s', 0); //老师id
$params["latitude"] = $this->request->post('latitude/s', 0); //老师id
$params["content"] = $this->request->post('content/s', ''); //老师id
$params["notice"] = $this->request->post('notice/s', ''); //老师id
$params["price"] = $this->request->post('price/f', 0); //老师id
$params["selfhot"] = $this->request->post('selfhot/s', ''); //老师id
//classes_type
try{
$res = $this->model->createClassesByOper($params,true,'user',$user_id,true);
}catch (\Throwable $e){
$this->error($e->getMessage());
}
$this->success('添加成功', $res);
}
/**
* @ApiTitle(员工课程编辑)
* @ApiSummary(员工课程编辑)
* @ApiMethod(POST)
* @ApiParams(name = "id", type = "string",required=true,description = "课程id")
* @ApiParams(name = "status", type = "string",required=true,description = "上架状态:1=上架,2=下架,3=平台下架")
* @ApiParams(name = "teacher_id", type = "int",required=true,description = "老师id")
* @ApiParams(name = "classes_type", type = "string",required=true,description = "课程类型")
* @ApiParams(name = "classes_cate_ids", type = "string",required=true,description = "课程标签ids 多值逗号拼接")
* @ApiParams(name = "classes_label_ids", type = "string",required=true,description = "课程热门标签")
* @ApiParams(name = "self_label_tag", type = "string",required=true,description = "机构热门标签:多值逗号拼接")
* @ApiParams(name = "title", type = "string",required=true,description = "课程标题")
* @ApiParams(name = "headimage", type = "string",required=true,description = "课程头图")
* @ApiParams(name = "images", type = "string",required=true,description = "课程轮播图多值逗号拼接")
* @ApiParams(name = "type", type = "string",required=true,description = "地点类型:out=户外,in=室内")
* @ApiParams(name = "spec", type = "string",required=true,description = "课时多规格:[{'id':665,'classes_lib_id':570,'name':'xxxxx','limit_num':100,'status':'1','weigh':665,'time':'2024\/12\/12 19:00 - 2024\/12\/12 20:00'}] ")
* @ApiParams(name = "address_type", type = "string",required=true,description = "地址类型:1=按机构,2=独立位置")
* @ApiParams(name = "province", type = "string",required=false,description = "省编号")
* @ApiParams(name = "city", type = "string",required=false,description = "市编号")
* @ApiParams(name = "district", type = "string",required=false,description = "县区编号")
* @ApiParams(name = "address", type = "string",required=false,description = "地图定位地址")
* @ApiParams(name = "address_detail", type = "string",required=false,description = "手录详细地址")
* @ApiParams(name = "longitude", type = "string",required=false,description = "经度")
* @ApiParams(name = "latitude", type = "string",required=false,description = "纬度")
* @ApiParams(name = "content", type = "string",required=false,description = "课程详情")
* @ApiParams(name = "notice", type = "string",required=false,description = "课程须知")
* @ApiParams(name = "price", type = "string",required=false,description = "课程价格 0为免费")
* @ApiParams(name = "selfhot", type = "string",required=false,description = "机构热门:0=否,1=是")
* @ApiReturn({
*
*})
*/
public function edit(){
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$params = [];
$id = $this->request->post('id/d', 0);
$params["status"] = $this->request->post('status/s', ''); //上架状态:1=上架,2=下架,3=平台下架
$params["teacher_id"] = $this->request->post('teacher_id/d', 0); //老师id
$params["classes_type"] = $this->request->post('classes_type/s', ''); //老师id
$params["classes_cate_ids"] = $this->request->post('classes_cate_ids/s', ''); //课程标签
$params["classes_label_ids"] = $this->request->post('classes_label_ids/s', ''); //课程热门标签
$params["self_label_tag"] = $this->request->post('self_label_tag/s', ''); //老师id
$params["title"] = $this->request->post('title/s', ''); //老师id
$params["headimage"] = $this->request->post('headimage/s', ''); //老师id
$params["images"] = $this->request->post('images/s', ''); //老师id
$params["type"] = $this->request->post('type/s', ''); //老师id
$params["spec"] = $this->request->post('spec/s', ''); //老师id
$params["address_type"] = $this->request->post('address_type/s', ''); //老师id
$params["province"] = $this->request->post('province/d', 0); //老师id
$params["city"] = $this->request->post('city/d', 0); //老师id
$params["district"] = $this->request->post('district/d', 0); //老师id
$params["address"] = $this->request->post('address/s', ''); //老师id
$params["address_detail"] = $this->request->post('address_detail/s', ''); //老师id
$params["longitude"] = $this->request->post('longitude/s', 0); //老师id
$params["latitude"] = $this->request->post('latitude/s', 0); //老师id
$params["content"] = $this->request->post('content/s', ''); //老师id
$params["notice"] = $this->request->post('notice/s', ''); //老师id
$params["price"] = $this->request->post('price/f', 0); //老师id
$params["selfhot"] = $this->request->post('selfhot/s', ''); //老师id
//classes_type
try{
$res = $this->model->updateClassesByOper($params,$id,true,'user',$user_id,true);
}catch (\Throwable $e){
$this->error($e->getMessage());
}
$this->success('编辑成功', $res);
}
/**
* @ApiTitle(员工课程批量删除)
* @ApiSummary(员工课程批量删除)
* @ApiMethod(POST)
* @ApiParams(name = "ids", type = "string",required=true,description = "需要删除的一组课程id多值逗号拼接")
* @ApiReturn({
*
*})
*/
public function del(){
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$ids = $this->request->post('ids/s', '');
try{
$res = $this->model->deleteClassesByOper($ids,true,'user',$user_id,true);
}catch (\Throwable $e){
$this->error($e->getMessage());
}
$this->success("成功删除{$res}条数据",["delete_number"=>$res]);
}
/**
* @ApiTitle(课程更改状态)
* @ApiSummary(课程更改状态)
* @ApiMethod(POST)
* @ApiParams(name = "id", type = "string",required=true,description = "需要更改状态的课程id")
* @ApiParams(name = "status", type = "string",required=true,description = "需要更改状态:1=上架,2=下架")
* @ApiReturn({
*
*})
*/
public function update_status(){
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$id = $this->request->post('id/s', '');
$status = $this->request->post('status/s', '');
try{
$res = $this->model->updateStatusByOper($status,$id,true,'user',$user_id,true);
}catch (\Throwable $e){
$this->error($e->getMessage());
}
$this->success("状态更改成功",["self"=>$res]);
}
}