1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\api\controller\tvuser;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 健康档案设备数据,使用自动注册的用户
- */
- class Device extends Api
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['*'];
- public function index(){
- $ids = Db::name('user')->where('tv_userid',$this->auth->tv_userid)->column('id');//自动注册的用户 和 app注册并绑定盒子的app用户,理论上只需要第二个
- $device_number = Db::name('user_device')->where('user_id','IN',$ids)->count('sn');//两个用户绑定的设备号
- $result = [
- 'device_number' => $device_number,
- 'text_1' => config('site.tv_device_index_text1'),
- 'text_2' => config('site.tv_device_index_text2'),
- 'qrcode' => localpath_to_netpath(config('site.tv_device_index_image')),
- 'device' => [
- ['type_id' => 1,'type' => 'GLUC','name'=>'血糖'],
- ['type_id' => 2,'type' => 'UA','name'=>'尿酸'],
- ['type_id' => 3,'type' => 'CHOL','name'=>'总胆固醇'],
- ],
- ];
- $this->success(1,$result);
- }
- //
- public function lists(){
- $ids = Db::name('user')->where('tv_userid',$this->auth->tv_userid)->column('id');//自动注册的用户 和 app注册并绑定盒子的app用户,理论上只需要第二个
- $sn_arr = Db::name('user_device')->where('user_id','IN',$ids)->column('sn');//两个用户绑定的设备号
- //数据类型
- $type = input('type',1);
- $type_arr = [
- 1 => 'GLUC',
- 2 => 'UA',
- 3 => 'CHOL',
- ];
- $list = Db::name('device_sanheyi')->field('id,createtime,type,type_text,value')->where('sn','IN',$sn_arr)->where('type',$type_arr[$type])->autopage()->select();
- $this->success(1,$list);
- }
- }
|