controller
namespace app\service\controller;
use app\service\service\UsersService;
class Index extends Base
{
public function index()
{
$userService = new UsersService();
$userId = '123456';
$userService->userInfo($userId);
}
}
service
namespace app\service\service;
use think\Log;
use think\Model;
use app\service\model\Users;
class UsersService extends Model
{
public function userInfo($userId){
$user_model = new Users();
$list= $user_model->getUserInfo($userId);
return json(['code' => 1, 'data' => $list, 'msg' => '信息返回成功']);
}
}
model
namespace app\service\model;
use think\Model;
class Users extends Model
{
public function getUserInfo($userId){
return db('users')->where('user_id', $userId)->find();
}
}
|