1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use think\App;
- use think\facade\Db;
- class Version extends BaseController
- {
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->post = $this->request->post();
- }
- public function list(){
- $page = isset($this->post['page'])&&$this->post['page']!="" ? intval($this->post['page']) : 1;
- $size = isset($this->post['size'])&&$this->post['size']!="" ? intval($this->post['size']) :10;
- $count= Db::name("version")->count();
- $total = ceil($count/$size);
- $page = $page>=$total? $total:$page;
- $list = Db::name("version")->page($page,$size)->order("addtime desc")->select();
- return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
- }
- public function create(){
- $title = isset($this->post['title'])&&$this->post['title']!="" ? $this->post['title']:"";
- if($title==""){
- return error_show(1004,"参数title 不能为空");
- }
- $content = isset($this->post['content'])&&$this->post['content']!="" ? $this->post['content']:"";
- if($content==""){
- return error_show(1004,"参数content 不能为空");
- }
- $version = isset($this->post['version'])&&$this->post['version']!="" ? $this->post['version']:"";
- if($version==""){
- return error_show(1004,"参数version 不能为空");
- }
- $data=[
- "title"=>$title,
- "content"=>$content,
- "version"=>$version,
- "addtime"=>date("Y-m-d H:i:s")
- ];
- $inert= Db::name("version")->insert($data);
- if($inert){
- return app_show(0,"版本信息新建成功");
- }else{
- return app_show(0,"版本信息新建失败");
- }
- }
- public function info(){
- $projectNo = isset($this->post['projectNo'])&&$this->post['projectNo']!==""?trim($this->post['projectNo']):"";
- if($projectNo==""){
- return error_show(1004,"参数projectNo不能为空");
- }
- $type = isset($this->post['type'])&&$this->post['type']!=="" ? intval($this->post['type']) :0;
- $info =Db::name("project")->where(["projectNo"=>$projectNo,"is_del"=>0])->find();
- if($info==false){
- return error_show(1004,"未找到项目信息");
- }
- $plat = Db::name("platform")->where(['id'=>$info['platform_id']])->find();
- $info['platform_name']=isset($plat['platform_name'])?$plat['platform_name']:"";
- $info['platform_code']=isset($plat['platform_code'])?$plat['platform_code']:"";
- $khinfo = Db::name("customer_info")->where(["companyNo"=>$info['khNo']])->find();
- $info['khName'] = isset($khinfo['companyName'])?$khinfo['companyName']:"";
- $company = Db::name("business")->where(["companyNo"=>$info['companyNo']])->find();
- $info['company'] = isset($company['company'])?$company['company']:"";
- $ladder = Db::name("project_info")->where(['projectNo'=>$projectNo,"is_del"=>0])->select()->toArray();
- $info['ladder']=[];
- if(!empty($ladder)){
- foreach ($ladder as $value){
- $value["cat_info"]=isset($value['cat_id']) &&$value['cat_id']!=""? made($value['cat_id'],[]):[];
- $condition = $type==0?['pgNo'=>$value['pgNo'],"is_del"=>0] : ['pgNo'=>$value['pgNo'],"is_del"=>0,"status"=>1];
- $feedback = Db::name("project_feedback")->where($condition)->select()->toArray();
- array_walk($feedback,function (&$v){
- $v["cat_info"]=isset($v['cat_id'])&&$v['cat_id']!=""? made($v['cat_id'],[]):[];
- });
- $value['feedback']=$feedback;
- $info['ladder'][]=$value;
- }
- }
- return app_show(0,"获取成功",$info);
- }
- }
|