代码初始化

This commit is contained in:
2025-08-07 20:21:47 +08:00
commit 50f3a2dbb0
2191 changed files with 374790 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
<?php
namespace app\api\controller;
use app\common\controller\BaseCom;
use think\Db;
class Search extends BaseCom
{
//搜索
public function search()
{
$search = input('search', '');
$type = input('type', 1);//1用户2房间3公会
//根据类型进行搜索
switch ($type) {
case 1:
$table = 'user';
//判断是否纯数字
if(is_numeric($search)){
$where = [
'user_code' => $search,
'status' => 1
];
}else{
$where = [
'nickname' => ['like', '%'.$search . '%'],
'status' => 1
];
}
break;
case 2:
$table = 'vs_room';
if(is_numeric($search)){
$where = [
'room_number' => $search,
'apply_status' => 2
];
}else{
$where = [
'room_name' => ['like', '%'.$search . '%'],
'apply_status' => 2
];
}
break;
case 3:
$table = 'vs_guild';
if(is_numeric($search)){
$where = [
'guild_special_id' => $search,
'is_show' => 1,
'delete_time' => 0
];
}else{
$where = [
'guild_name' => ['like', '%'.$search . '%'],
'is_show' => 1,
'delete_time' => 0
];
}
break;
}
if($search == '' || $search == null){
return V(0, '请输入搜索内容');
}
$lists = [];
$reslut = db::name($table)->where($where)->select();
if(isset($reslut)){
foreach ($reslut as $k=>$v){
if($type == 1){
$lists[$k]['id'] = $v['id'];
$lists[$k]['name'] = $v['nickname'];
$lists[$k]['picture'] = $v['avatar'];
$lists[$k]['code'] = $v['user_code'];
$lists[$k]['icon'][0] = model('UserData')->user_wealth_icon($v['id']);//财富图标
$lists[$k]['icon'][1] = model('UserData')->user_charm_icon($v['id']);//魅力图标
}elseif($type == 2){
$lists[$k]['id'] = $v['id'];
$lists[$k]['name'] = $v['room_name'];
$lists[$k]['picture'] = $v['room_cover'];
$lists[$k]['code'] = $v['room_number'];
$lists[$k]['label_icon'] = db::name('vs_room_label')->where('id', $v['label_id'])->value('label_icon');
$lists[$k]['hot_value'] = $v['hot_value'];
}elseif($type == 3){
$lists[$k]['id'] = $v['id'];
$lists[$k]['name'] = $v['guild_name'];
$lists[$k]['picture'] = $v['cover'];
$lists[$k]['code'] = $v['guild_special_id'];
}
}
}
return V(1, '获取成功', $lists);
}
}