SubjectProductSettingController.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * 学科产品设置表控制器类
  4. * Created by PhpStorm.
  5. * User: Administrator
  6. * Date: 2022/8/4
  7. * Time: 10:07
  8. */
  9. class SubjectProductSettingController extends Controller
  10. {
  11. /**
  12. * 学科产品设置列表
  13. */
  14. public function actionIndex(){
  15. //$sql = "select sps_id,subject_id,name,config_text from subject_product_setting where sps_id=2";
  16. $sql = "select sps_id,subject_id,name,config_text from subject_product_setting";
  17. $lists = $this->sConn->createCommand($sql)->queryAll();
  18. $result['status'] = 1;
  19. $result['msg']='成功';
  20. $result['data']=array(
  21. 'lists'=>$lists
  22. );
  23. exit(json_encode($result));
  24. }
  25. /**
  26. * 学科产品设置更新设置内容
  27. */
  28. public function actionUpdate()
  29. {
  30. $spsId = intval(Req::post('sps_id'));
  31. $configText = Req::post('config_text');
  32. $configText = str_replace('&quot;', '"', $configText);
  33. if (!json_decode($configText, true)) {
  34. exit(json_encode(array('status' => 0, 'msg' => '设置内容错误'), 256));
  35. }
  36. $subjectProductSetting = $this->sConn->createCommand("select sps_id,config_text from subject_product_setting where sps_id='{$spsId}'")->queryRow();
  37. if (!$subjectProductSetting) {
  38. exit(json_encode(array('status' => 0, 'msg' => '学科产品设置id不正确')));
  39. }
  40. $result=SSubjectProductSetting::model()->updateAll(array('config_text'=>$configText,'update_time'=>time()),'sps_id=:sps_id',array(':sps_id'=>$spsId));
  41. if($result){
  42. exit(json_encode(array('status'=>1,'msg'=>'保存成功')));
  43. }else{
  44. exit(json_encode(array('status'=>0,'msg'=>'保存失败')));
  45. }
  46. }
  47. }