作者 wangzhi

1111

<?php
/**
* Created by PhpStorm.
* User: 86132
* Date: 2020/7/6
* Time: 10:13
*/
namespace app\api\controller;
use app\common\model\Company;
use think\Db;
use app\common\controller\Api;
/**
* 团队接口
*/
class Team extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = '*';
public function _initialize()
{
parent::_initialize();
}
/**
* @ApiTitle (团队接口-类型,行业展示)
* @ApiSummary (类型,行业展示)
* @ApiMethod (POST)
* @ApiRoute (/api/Team/TypeIndustryList)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
"data": [
{
"type2": [
{
"type": "类型",
"type_id": "id"
]
},
{
"industrys": [
{
"industry": "行业",
"industry_id": "id"
}
]
}
]
})
*/
public function TypeIndustryList()
{
$type = Db::name('type')->select();
$industry = Db::name('industry')->select();
foreach ($type as $k => $v) {
$type1[$k]['type'] = $v['type'];
$type1[$k]['type_id'] = $v['id'];
}
foreach ($industry as $k => $v) {
$industry1[$k]['industry'] = $v['industry'];
$industry1[$k]['industry_id'] = $v['id'];
}
$return[]['types'] = $type1;
$return[]['industrys'] = $industry1;
$this->success('成功', $return);
}
/**
* @ApiTitle (团队接口-申请公司团队)
* @ApiSummary (申请公司团队)
* @ApiMethod (POST)
* @ApiRoute (/api/Team/ApplicationCompanyTeam)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="company_name", type="integer", required=true, description="公司名")
* @ApiParams (name="credit", type="integer", required=true, description="公司信用代码")
* @ApiParams (name="company_address", type="string", required=true, description="公司地址")
* @ApiParams (name="address_con", type="string", required=true, description="公司详细地址")
* @ApiParams (name="invoice_address", type="string", required=true, description="开票地址")
* @ApiParams (name="bank_name", type="string", required=true, description="银行名称")
* @ApiParams (name="bank_num", type="string", required=true, description="银行账号")
* @ApiParams (name="company_tel", type="string", required=true, description="公司电话")
* @ApiParams (name="type_id", type="int", required=true, description="类型")
* @ApiParams (name="industry_id", type="int", required=true, description="行业")
* @ApiParams (name="business_avatar", type="string", required=true, description="营业执照")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
"data": "1"
})
*/
public function ApplicationCompanyTeam()
{
$user_id = $this->is_token($this->request->header());
$param = $this->request->param();
$data = [
'company_name' => $param['company_name'],
'credit' => $param['credit'],
'company_address' => $param['company_address'],
'address_con' => $param['address_con'],
'invoice_address' => $param['invoice_address'],
'bank_name' => $param['bank_name'],
'bank_num' => $param['bank_num'],
'company_tel' => $param['company_tel'],
'type_id' => $param['type_id'],
'industry_id' => $param['industry_id'],
'business_avatar' => $param['business_avatar'],
'status' => 2,
'company_holder' => $user_id
];
$model = new Company();
$res = $model->save($data);
if ($res) {
$this->success('成功', 1);
} else {
$this->error('失败', 0);
}
}
}
\ No newline at end of file
... ...
... ... @@ -126,15 +126,13 @@ class User extends Api
}
/**
* @ApiTitle (用户接口-基本信息修改)
* @ApiSummary (基本信息)
* @ApiTitle (用户接口-修改密码)
* @ApiSummary (修改密码)
* @ApiMethod (POST)
* @ApiRoute (/api/User/UpdateEssentialInformation)
* @ApiRoute (/api/User/UpdatePassword)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="mobile", type="integer", required=true, description="手机号")
* @ApiParams (name="username", type="integer", required=true, description="用户名")
* @ApiParams (name="email", type="string", required=true, description="邮箱")
* @ApiParams (name="code", type="string", required=true, description="验证码")
* @ApiParams (name="old_password", type="string", required=true, description="原密码")
* @ApiParams (name="password", type="string", required=true, description="密码")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
... ... @@ -143,4 +141,19 @@ class User extends Api
"data": "1"
})
*/
public function UpdatePassword()
{
$param = $this->request->param();
$user_id = $this->is_token($this->request->header());
$password = Db::name('user')->where(['id' => $user_id])->find();
if (!($param['old_password'] == $password['password'])) {
$this->error('原密码错误', 0);
}
$res = Db::name('user')->where(['id' => $user_id])->update(['password' => $param['password']]);
if ($res) {
$this->success('修改成功', 1);
} else {
$this->error('修改失败', 0);
}
}
}
... ...
<?php
/**
* Created by PhpStorm.
* User: 86132
* Date: 2020/7/6
* Time: 10:31
*/
namespace app\common\model;
use think\Model;
class Company extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
}
\ No newline at end of file
... ...
... ... @@ -11,6 +11,14 @@
// +----------------------------------------------------------------------
// [ 应用入口文件 ]
// 定义应用目录
header("Access-Control-Allow-Origin: * ");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
if($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
exit;
}
define('APP_PATH', __DIR__ . '/../application/');
// 判断是否安装
... ...