133 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			133 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace app\api\controller\backend;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use app\common\controller\Api;
							 | 
						||
| 
								 | 
							
								use app\common\library\Ems;
							 | 
						||
| 
								 | 
							
								use app\common\library\Sms;
							 | 
						||
| 
								 | 
							
								use fast\Random;
							 | 
						||
| 
								 | 
							
								use think\Config;
							 | 
						||
| 
								 | 
							
								use think\Validate;
							 | 
						||
| 
								 | 
							
								use think\Db;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * 考评级别
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								class Evaluationlevel extends Api
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    protected $noNeedLogin = ['*'];
							 | 
						||
| 
								 | 
							
								    protected $noNeedRight = '*';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * 列表
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function geEvaluationlevelData()
							 | 
						||
| 
								 | 
							
								    {   
							 | 
						||
| 
								 | 
							
								        $group_id  = $this->request->post('group_id');
							 | 
						||
| 
								 | 
							
								        $page = $this->request->post('page',1);
							 | 
						||
| 
								 | 
							
								        $size = $this->request->post('size',10);
							 | 
						||
| 
								 | 
							
								        if(!$group_id){
							 | 
						||
| 
								 | 
							
								            $this->error(__('Invalid parameters'));
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        $where = [];
							 | 
						||
| 
								 | 
							
								        $where['a.group_id'] = $group_id;
							 | 
						||
| 
								 | 
							
								        // 从数据库中获取所有数据
							 | 
						||
| 
								 | 
							
								        $data = Db::name('evaluation_level')
							 | 
						||
| 
								 | 
							
								                ->field('a.*,p.name as user_group_name')
							 | 
						||
| 
								 | 
							
								                ->alias('a')
							 | 
						||
| 
								 | 
							
								                // ->join('party_group w','a.party_id = w.id','LEFT')
							 | 
						||
| 
								 | 
							
								                ->join('user_group p','a.group_id = p.id','LEFT')
							 | 
						||
| 
								 | 
							
								                ->where($where)
							 | 
						||
| 
								 | 
							
								                ->page($page,$size)
							 | 
						||
| 
								 | 
							
								                ->order('a.id asc')
							 | 
						||
| 
								 | 
							
								                ->select();
							 | 
						||
| 
								 | 
							
								        $count = Db::name('evaluation_level')
							 | 
						||
| 
								 | 
							
								                ->field('a.*,p.name as user_group_name')
							 | 
						||
| 
								 | 
							
								                ->alias('a')
							 | 
						||
| 
								 | 
							
								                // ->join('party_group w','a.party_id = w.id','LEFT')
							 | 
						||
| 
								 | 
							
								                ->join('user_group p','a.group_id = p.id','LEFT')
							 | 
						||
| 
								 | 
							
								                ->where($where)
							 | 
						||
| 
								 | 
							
								                ->order('a.id asc')
							 | 
						||
| 
								 | 
							
								                ->count();
							 | 
						||
| 
								 | 
							
								        $res = [
							 | 
						||
| 
								 | 
							
								                'count' => $count,
							 | 
						||
| 
								 | 
							
								                'data' => $data,
							 | 
						||
| 
								 | 
							
								                ];
							 | 
						||
| 
								 | 
							
								        return $this->success('请求成功',$res);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * 单个用户查询
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function getEvaluationlevelFind()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $id = $this->request->post('id');
							 | 
						||
| 
								 | 
							
								        if (!$id) {
							 | 
						||
| 
								 | 
							
								            $this->error(__('Invalid parameters'));
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        $ret = Db::name('evaluation_level')->where('id',$id)->find();
							 | 
						||
| 
								 | 
							
								        if ($ret) {
							 | 
						||
| 
								 | 
							
								            $this->success(__('Logged in successful'), $ret);
							 | 
						||
| 
								 | 
							
								        } else {
							 | 
						||
| 
								 | 
							
								            $this->error($this->auth->getError());
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public function create()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $data = $this->request->post();
							 | 
						||
| 
								 | 
							
								        // if($data['password']){
							 | 
						||
| 
								 | 
							
								        //     $data['password'] = md5($data['password']);
							 | 
						||
| 
								 | 
							
								        // }
							 | 
						||
| 
								 | 
							
								        // $data['createtime'] = date('Y-m-d H:i:s');
							 | 
						||
| 
								 | 
							
								        // $data['updatetime'] = date('Y-m-d H:i:s');
							 | 
						||
| 
								 | 
							
								        $result = Db::name('evaluation_level')->strict(false)->insert($data);
							 | 
						||
| 
								 | 
							
								        if ($result) {
							 | 
						||
| 
								 | 
							
								            return $this->success('添加成功',$result);
							 | 
						||
| 
								 | 
							
								        } else {
							 | 
						||
| 
								 | 
							
								            return $this->error('添加失败',$result);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * 更新记录
							 | 
						||
| 
								 | 
							
								     *
							 | 
						||
| 
								 | 
							
								     * @param Request $request
							 | 
						||
| 
								 | 
							
								     * @param int $id
							 | 
						||
| 
								 | 
							
								     * @return \think\Response
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function update()
							 | 
						||
| 
								 | 
							
								    {   
							 | 
						||
| 
								 | 
							
								        $id = $this->request->post('id');
							 | 
						||
| 
								 | 
							
								        $data = $this->request->post();
							 | 
						||
| 
								 | 
							
								        $result = Db::name('evaluation_level')->where('id', $id)->strict(false)->update($data);
							 | 
						||
| 
								 | 
							
								        if ($result) {
							 | 
						||
| 
								 | 
							
								            return $this->success('更新成功',$result);
							 | 
						||
| 
								 | 
							
								        } else {
							 | 
						||
| 
								 | 
							
								            return $this->error('更新失败',$result);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    /**
							 | 
						||
| 
								 | 
							
								     * 删除记录
							 | 
						||
| 
								 | 
							
								     *
							 | 
						||
| 
								 | 
							
								     * @param int $id
							 | 
						||
| 
								 | 
							
								     * @return \think\Response
							 | 
						||
| 
								 | 
							
								     */
							 | 
						||
| 
								 | 
							
								    public function delete()
							 | 
						||
| 
								 | 
							
								    {   
							 | 
						||
| 
								 | 
							
								        $id = $this->request->post('id');
							 | 
						||
| 
								 | 
							
								        if(!$id){
							 | 
						||
| 
								 | 
							
								            return $this->error('缺少参数');
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        $result = Db::name('evaluation_level')->delete($id);
							 | 
						||
| 
								 | 
							
								        if ($result) {
							 | 
						||
| 
								 | 
							
								            return $this->success('删除成功',$result);
							 | 
						||
| 
								 | 
							
								        } else {
							 | 
						||
| 
								 | 
							
								            return $this->error('删除失败',$result);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 |