123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- /**
- * 学科产品设置表控制器类
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2022/8/4
- * Time: 10:07
- */
- class SubjectProductSettingController extends Controller
- {
- /**
- * 学科产品设置列表
- */
- public function actionIndex(){
- //$sql = "select sps_id,subject_id,name,config_text from subject_product_setting where sps_id=2";
- $sql = "select sps_id,subject_id,name,config_text from subject_product_setting";
- $lists = $this->sConn->createCommand($sql)->queryAll();
- $result['status'] = 1;
- $result['msg']='成功';
- $result['data']=array(
- 'lists'=>$lists
- );
- exit(json_encode($result));
- }
- /**
- * 学科产品设置更新设置内容
- */
- public function actionUpdate()
- {
- $spsId = intval(Req::post('sps_id'));
- $configText = Req::post('config_text');
- $configText = str_replace('"', '"', $configText);
- if (!json_decode($configText, true)) {
- exit(json_encode(array('status' => 0, 'msg' => '设置内容错误'), 256));
- }
- $subjectProductSetting = $this->sConn->createCommand("select sps_id,config_text from subject_product_setting where sps_id='{$spsId}'")->queryRow();
- if (!$subjectProductSetting) {
- exit(json_encode(array('status' => 0, 'msg' => '学科产品设置id不正确')));
- }
- $result=SSubjectProductSetting::model()->updateAll(array('config_text'=>$configText,'update_time'=>time()),'sps_id=:sps_id',array(':sps_id'=>$spsId));
- if($result){
- exit(json_encode(array('status'=>1,'msg'=>'保存成功')));
- }else{
- exit(json_encode(array('status'=>0,'msg'=>'保存失败')));
- }
- }
- }
|