123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 健康检测数据
- */
- class Jiankangdata extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- public function submit(){
- $map = [
- 'user_id' => $this->auth->id,
- 'createdate' => date('Y-m-d'),
- ];
- $check = Db::name('jiankangdata')->where($map)->find();
- $data = [
- 'user_id' => $this->auth->id,
- 'xueya_low' => $this->request->post('xueya_low'),
- 'xueya_high' => $this->request->post('xueya_high'),
- 'xuetang' => $this->request->post('xuetang'),
- 'createtime' => time(),
- 'updatetime' => time(),
- 'createdate' => date('Y-m-d'),
- ];
- if($check){
- Db::name('jiankangdata')->where($map)->update($data);
- }else{
- Db::name('jiankangdata')->insert($data);
- }
- $this->success('提交成功');
- }
- public function data(){
- $type = $this->request->post('type','week','trim');
- if($type == 'week'){
- $where = ['createtime' => ['>=', date('Y-m-d', strtotime('-7 day'))]];
- }
- if($type == 'month'){
- $where = ['createtime' => ['>=', date('Y-m-d', strtotime('-30 day'))]];
- }
- $list = Db::name('jiankangdata')->where('user_id',$this->auth->id)->order('id','asc')->select();
- $this->success(1,$list);
- }
- }
|