Commit 364819ef authored by 张晓林's avatar 张晓林

证照添加接口

parent b094c9dc
......@@ -159,6 +159,7 @@ return [
'extraPatterns'=>[
'GET,OPTIONS licence-list'=>'licence-list',
'GET,OPTIONS licence-detail'=>'licence-detail',
'POST,OPTIONS licence-insert'=>'licence-insert',
],
],
//省市区
......
......@@ -5,12 +5,55 @@ use Yii;
use yii\data\ArrayDataProvider;
use backend\models\v1\branch\BranchLicence;
use backend\controllers\v1\BaseController;
use backend\helpers\Func;
class BranchLicenceController extends BaseController{
public $modelClass = 'backend\models\v1\branch\BranchLicence';
/**
* @OA\POST(
* path="/backend/web/v1/branch/branch-licences/licence-insert",
* tags={"门店&DC"},
* summary="证照添加(张晓林)",
* description="证照添加",
* * @OA\RequestBody(
* required=true,
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* type="object",
* @OA\Property(property="LICENCE_NAME",description="证照名称",type="string"),
* @OA\Property(property="LICENCE_CODE",description="证照编码",type="string"),
* @OA\Property(property="BRANCH_CODE",description="门店编码",type="string"),
* @OA\Property(property="IS_FROM",description="来源",type="string"),
* @OA\Property(property="LICENCE_EXPIRY_DATE",description="到期时间",type="string"),
* @OA\Property(property="IS_SHOW",description="是否显示在前台",type="string"),
* @OA\Property(property="LICENCE_CONTENT",description="证照说明",type="string"),
* )
* )
* ),
* @OA\Response(response=200,description="success"),
* security={{"Authorization": {}}}
* )
*/
public function actionLicenceInsert(){
$param = Yii::$app->request->post();
$model = new BranchLicence();
$model->scenario = 'licenceInsert';
$model['GUID'] = Func::create_guid();
$model->UPDATE_TIME = date('Y-m-d H:i:s',time());
$model->attributes = $param;
if($model->save()){
return [
'CODE'=>200,
'MESSAGE'=>'添加成功'
];
}else{
return $model->errors;
}
}
/**
* @OA\GET(
......
......@@ -13,14 +13,25 @@ class BranchLicence extends ActiveRecord{
public function rules()
{
return [
['GUID','required','on'=>'licenceDetail','message'=>'缺少参数GUID']
['GUID','required','on'=>['licenceDetail','licenceInsert'],'message'=>'缺少参数GUID'],
['GUID','unique','on'=>['licenceDetail','licenceInsert'],'message'=>'GUID不能重复'],
[['LICENCE_CODE','LICENCE_NAME','LICENCE_EXPIRY_DATE','BRANCH_CODE','LICENCE_CONTENT','LICENCE_IMG_URL'],'trim','on'=>'licenceInsert'],
[['GUID','LICENCE_CODE','LICENCE_NAME','LICENCE_EXPIRY_DATE','BRANCH_CODE'],'required','on'=>'licenceInsert','message'=>'缺少参数'],
[['LICENCE_CONTENT','LICENCE_IMG_URL','LICENCE_GRADE'],'default','value'=>'','on'=>'licenceInsert'],
[['LICENCE_CODE','LICENCE_NAME'],'string','max'=>20,'on'=>'licenceInsert'],
[['IS_FROM','IS_SHOW'],'default','value'=>1],
[['LICENCE_EXPIRY_DATE'],'datetime','format'=>'Y-m-d','on'=>'licenceInsert'],
];
}
public function attributeLabels()
{
return [
'GUID'=>'门店GUID'
'GUID'=>'GUID',
'LICENCE_NAME'=>'证照名称',
'LICENCE_CODE'=>'证照编码',
'BRANCH_CODE'=>'门店编码',
'LICENCE_EXPIRY_DATE'=>'到期时间'
];
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment