104 lines
3.6 KiB
PHP
104 lines
3.6 KiB
PHP
<?php
|
||
|
||
namespace app\app\controller;
|
||
|
||
use think\Controller;
|
||
use think\Db;
|
||
use app\bj\controller\Common;
|
||
use think\Log;
|
||
use \think\Validate;
|
||
|
||
class Card extends Controller{
|
||
|
||
|
||
################################################################个人资料卡################################################################
|
||
################################################################个人资料卡################################################################
|
||
################################################################个人资料卡################################################################
|
||
|
||
// 获取默认卡片信息
|
||
// $type 1获取列表,2获取详细信息
|
||
public function get_card_msg($type=1){
|
||
$result = Db::table('app_card_data')->select();
|
||
$data = [];
|
||
if($type == 1){
|
||
for ($i=0; $i < count($result); $i++) {
|
||
array_push($data,['id'=>$result[$i]['id'],'name'=>$result[$i]['name']]);
|
||
}
|
||
}else{
|
||
// 如果需要详细信息再从中编辑信息
|
||
$data = $result;
|
||
}
|
||
return $this->msg(0,'success',$data);
|
||
}
|
||
|
||
// 获取默认卡片规则
|
||
// $type 1获取列表,2获取详细信息
|
||
public function get_card_rule(){
|
||
$result = Db::table('app_card_data')->select();
|
||
$data = [];
|
||
if($type == 1){
|
||
for ($i=0; $i < count($result); $i++) {
|
||
array_push($data,['id'=>$result[$i]['id'],'name'=>$result[$i]['name']]);
|
||
}
|
||
}else{
|
||
// 如果需要详细信息再从中编辑信息
|
||
$data = $result;
|
||
}
|
||
return $this->msg(0,'success',$data);
|
||
}
|
||
|
||
// 新建卡片
|
||
public function create_card(){
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
################################################################other################################################################
|
||
################################################################other################################################################
|
||
################################################################other################################################################
|
||
|
||
public function verify_parameters($data,$type){
|
||
// 设置验证
|
||
$rule = [
|
||
'aan_id' => 'require|number',
|
||
'nickname' => 'require|chsAlpha',
|
||
'birthday' => 'require|date',
|
||
'gender' => 'require|number|in:0,1,2',
|
||
];
|
||
$msg = [
|
||
'aan_id.require' => '账号信息缺失',
|
||
'nickname.require' => '昵称缺失',
|
||
'birthday.require' => '生日缺失',
|
||
'gender.require' => '性别缺失',
|
||
|
||
'aan_id.number' => '账号信息格式错误',
|
||
'nickname.chsAlpha' => '昵称只能是只能是汉字、字母',
|
||
'birthday.date' => '生日信息格式错误',
|
||
'gender.number' => '性别格式错误',
|
||
'gender.in' => '性别信息错误',
|
||
];
|
||
$validate = new Validate($rule,$msg);
|
||
$result = $validate->check($data);
|
||
if(!$result){
|
||
return $validate->getError();
|
||
}
|
||
|
||
$parameter['aan_id'] = $data['aan_id'];
|
||
$parameter['nickname'] = $data['nickname'];
|
||
$parameter['birthday'] = $data['birthday'];
|
||
$parameter['gender'] = $data['gender'];
|
||
$parameter['create_time'] = date('Y-m-d H:i:s');
|
||
$parameter['last_update_time'] = date('Y-m-d H:i:s');
|
||
|
||
|
||
return $parameter;
|
||
}
|
||
|
||
public function msg($code,$msg='',$data=[]){
|
||
return json(['code'=>$code,'msg'=>$msg,'data'=>$data]);
|
||
}
|
||
|
||
} |