Version.php 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use think\App;
  5. use think\facade\Db;
  6. class Version extends BaseController
  7. {
  8. public function __construct(App $app)
  9. {
  10. parent::__construct($app);
  11. $this->post = $this->request->post();
  12. }
  13. public function list(){
  14. $page = isset($this->post['page'])&&$this->post['page']!="" ? intval($this->post['page']) : 1;
  15. $size = isset($this->post['size'])&&$this->post['size']!="" ? intval($this->post['size']) :10;
  16. $count= Db::name("version")->count();
  17. $total = ceil($count/$size);
  18. $page = $page>=$total? $total:$page;
  19. $list = Db::name("version")->page($page,$size)->order("addtime desc")->select();
  20. return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
  21. }
  22. public function create(){
  23. $title = isset($this->post['title'])&&$this->post['title']!="" ? $this->post['title']:"";
  24. if($title==""){
  25. return error_show(1004,"参数title 不能为空");
  26. }
  27. $content = isset($this->post['content'])&&$this->post['content']!="" ? $this->post['content']:"";
  28. if($content==""){
  29. return error_show(1004,"参数content 不能为空");
  30. }
  31. $version = isset($this->post['version'])&&$this->post['version']!="" ? $this->post['version']:"";
  32. if($version==""){
  33. return error_show(1004,"参数version 不能为空");
  34. }
  35. $data=[
  36. "title"=>$title,
  37. "content"=>$content,
  38. "version"=>$version,
  39. "addtime"=>date("Y-m-d H:i:s")
  40. ];
  41. $inert= Db::name("version")->insert($data);
  42. if($inert){
  43. return app_show(0,"版本信息新建成功");
  44. }else{
  45. return app_show(0,"版本信息新建失败");
  46. }
  47. }
  48. public function info(){
  49. $projectNo = isset($this->post['projectNo'])&&$this->post['projectNo']!==""?trim($this->post['projectNo']):"";
  50. if($projectNo==""){
  51. return error_show(1004,"参数projectNo不能为空");
  52. }
  53. $type = isset($this->post['type'])&&$this->post['type']!=="" ? intval($this->post['type']) :0;
  54. $info =Db::name("project")->where(["projectNo"=>$projectNo,"is_del"=>0])->find();
  55. if($info==false){
  56. return error_show(1004,"未找到项目信息");
  57. }
  58. $plat = Db::name("platform")->where(['id'=>$info['platform_id']])->find();
  59. $info['platform_name']=isset($plat['platform_name'])?$plat['platform_name']:"";
  60. $info['platform_code']=isset($plat['platform_code'])?$plat['platform_code']:"";
  61. $khinfo = Db::name("customer_info")->where(["companyNo"=>$info['khNo']])->find();
  62. $info['khName'] = isset($khinfo['companyName'])?$khinfo['companyName']:"";
  63. $company = Db::name("business")->where(["companyNo"=>$info['companyNo']])->find();
  64. $info['company'] = isset($company['company'])?$company['company']:"";
  65. $ladder = Db::name("project_info")->where(['projectNo'=>$projectNo,"is_del"=>0])->select()->toArray();
  66. $info['ladder']=[];
  67. if(!empty($ladder)){
  68. foreach ($ladder as $value){
  69. $value["cat_info"]=isset($value['cat_id']) &&$value['cat_id']!=""? made($value['cat_id'],[]):[];
  70. $condition = $type==0?['pgNo'=>$value['pgNo'],"is_del"=>0] : ['pgNo'=>$value['pgNo'],"is_del"=>0,"status"=>1];
  71. $feedback = Db::name("project_feedback")->where($condition)->select()->toArray();
  72. array_walk($feedback,function (&$v){
  73. $v["cat_info"]=isset($v['cat_id'])&&$v['cat_id']!=""? made($v['cat_id'],[]):[];
  74. });
  75. $value['feedback']=$feedback;
  76. $info['ladder'][]=$value;
  77. }
  78. }
  79. return app_show(0,"获取成功",$info);
  80. }
  81. }