73 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace app\api\controller\school;
 | 
						|
 | 
						|
/**
 | 
						|
 * 户外运动接口
 | 
						|
 */
 | 
						|
class SporApply extends Base
 | 
						|
{
 | 
						|
    protected $noNeedLogin = ["add"];
 | 
						|
    protected $noNeedRight = '*';
 | 
						|
 | 
						|
    protected $model = null;
 | 
						|
 | 
						|
 | 
						|
    /**
 | 
						|
     * 初始化操作
 | 
						|
     * @access protected
 | 
						|
     */
 | 
						|
    protected function _initialize()
 | 
						|
    {
 | 
						|
 | 
						|
        $this->model = new \app\common\model\school\SportApply();
 | 
						|
        parent::_initialize();
 | 
						|
 | 
						|
        //判断登录用户是否是员工
 | 
						|
        $this->setUrlLock();
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    /**
 | 
						|
     * @ApiTitle( 户外运动招募申请表单)
 | 
						|
     * @ApiSummary(户外运动招募申请表单)
 | 
						|
     * @ApiMethod(POST)
 | 
						|
     * @ApiParams(name = "name", type = "string",required=true,description = "联系人")
 | 
						|
     * @ApiParams(name = "mobile", type = "string",required=true,description = "联系电话")
 | 
						|
     * @ApiParams(name = "enterprise_name", type = "string",required=true,description = "企业名称")
 | 
						|
     * @ApiParams(name = "enterprise_addr", type = "string",required=true,description = "企业地址")
 | 
						|
     * @ApiParams(name = "outdoor_sport", type = "string",required=true,description = "经营/热爱的户外运动")
 | 
						|
     * @ApiReturn({
 | 
						|
     *
 | 
						|
     *})
 | 
						|
     */
 | 
						|
    public function add(){
 | 
						|
 | 
						|
 | 
						|
        //敏感词过滤
 | 
						|
        $this->checkSensitivewords(["name"]);
 | 
						|
 | 
						|
        $user_id = 0;
 | 
						|
        $user = $this->auth->getUser();//登录用户
 | 
						|
        if($user)$user_id = $user['id'];
 | 
						|
        $params = [
 | 
						|
            "user_id" =>$user_id,
 | 
						|
        ];
 | 
						|
        $params["name"] =  $this->request->post('name/s', ''); //搜索关键字
 | 
						|
        $params["mobile"] =  $this->request->post('mobile/s', ''); //搜索关键字
 | 
						|
        $params["enterprise_name"] =  $this->request->post('enterprise_name/s', ''); //搜索关键字
 | 
						|
        $params["enterprise_addr"] =  $this->request->post('enterprise_addr/s', ''); //搜索关键字
 | 
						|
        $params["outdoor_sport"] =  $this->request->post('outdoor_sport/s', ''); //搜索关键字.
 | 
						|
 | 
						|
        try{
 | 
						|
            $res = $this->model->add($params,true);
 | 
						|
        }catch (\Throwable $e){
 | 
						|
            $this->error($e->getMessage());
 | 
						|
        }
 | 
						|
        $this->success('添加成功', $res);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
} |