You've already forked qlg.tsgz.moe
							
							TradeRule后台接口,待对接
This commit is contained in:
		| @@ -20,4 +20,50 @@ class TradeRule extends Base | |||||||
|         $rs = $m->pageQuery(); |         $rs = $m->pageQuery(); | ||||||
|         return WSTGrid($rs); |         return WSTGrid($rs); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 获取文章 | ||||||
|  |      */ | ||||||
|  |     public function get(){ | ||||||
|  |         $m = new M(); | ||||||
|  |         $rs = $m->get(Input("post.id/d",0)); | ||||||
|  |         return $rs; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 新增 | ||||||
|  |      */ | ||||||
|  |     public function add(){ | ||||||
|  |         $m = new M(); | ||||||
|  |         $rs = $m->add(); | ||||||
|  |         return $rs; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 编辑 | ||||||
|  |      */ | ||||||
|  |     public function edit(){ | ||||||
|  |         $m = new M(); | ||||||
|  |         $rs = $m->edit(); | ||||||
|  |         return $rs; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 删除 | ||||||
|  |      */ | ||||||
|  |     public function del(){ | ||||||
|  |         $m = new M(); | ||||||
|  |         $rs = $m->del(); | ||||||
|  |         return $rs; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 批量删除 | ||||||
|  |      */ | ||||||
|  |     public function delByBatch(){ | ||||||
|  |         $m = new M(); | ||||||
|  |         $rs = $m->delByBatch(); | ||||||
|  |         return $rs; | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -41,6 +41,90 @@ class TradeRule extends Base | |||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 新增 | ||||||
|  |      */ | ||||||
|  |     public function add(){ | ||||||
|  |         $data = input('post.'); | ||||||
|  |         WSTUnset($data,'id,dataFlag'); | ||||||
|  |         $data['create_time'] = date('Y-m-d H:i:s'); | ||||||
|  |         Db::startTrans(); | ||||||
|  |         try{ | ||||||
|  |             $result = $this->validate('TradeRule.add')->allowField(true)->save($data); | ||||||
|  |             if(false !== $result){ | ||||||
|  |                 WSTClearAllCache(); | ||||||
|  |                 Db::commit(); | ||||||
|  |                 return WSTReturn("新增成功", 1); | ||||||
|  |             } | ||||||
|  |         }catch(\Exception $e){ | ||||||
|  |             Db::rollback();errLog($e); | ||||||
|  |             return WSTReturn($this->getError(),-1); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 编辑 | ||||||
|  |      */ | ||||||
|  |     public function edit(){ | ||||||
|  |         $id = input('post.id/d'); | ||||||
|  |         $data = input('post.'); | ||||||
|  |         WSTUnset($data,'id,dataFlag,create_time'); | ||||||
|  |         Db::startTrans(); | ||||||
|  |         try{ | ||||||
|  |             $result = $this->validate('TradeRule.edit')->allowField(true)->save($data,['articleId'=>$articleId]); | ||||||
|  |             if(false !== $result){ | ||||||
|  |                 WSTClearAllCache(); | ||||||
|  |                 Db::commit(); | ||||||
|  |                 return WSTReturn("修改成功", 1); | ||||||
|  |             } | ||||||
|  |         }catch(\Exception $e){ | ||||||
|  |             Db::rollback();errLog($e); | ||||||
|  |             return WSTReturn($this->getError(),-1); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 删除 | ||||||
|  |      */ | ||||||
|  |     public function del(){ | ||||||
|  |         $id = input('post.id/d'); | ||||||
|  |         $data = []; | ||||||
|  |         $data['dataFlag'] = -1; | ||||||
|  |         Db::startTrans(); | ||||||
|  |         try{ | ||||||
|  |             $result = $this->where(['id'=>$id])->update($data); | ||||||
|  |             if(false !== $result){ | ||||||
|  |                 WSTClearAllCache(); | ||||||
|  |                 Db::commit(); | ||||||
|  |                 return WSTReturn("删除成功", 1); | ||||||
|  |             } | ||||||
|  |         }catch (\Exception $e) { | ||||||
|  |             Db::rollback();errLog($e); | ||||||
|  |             return WSTReturn('删除失败',-1); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 批量删除 | ||||||
|  |      */ | ||||||
|  |     public function delByBatch(){ | ||||||
|  |         $ids = input('post.ids'); | ||||||
|  |         $data = []; | ||||||
|  |         $data['dataFlag'] = -1; | ||||||
|  |         Db::startTrans(); | ||||||
|  |         try{ | ||||||
|  |             $result = $this->where(['articleId'=>['in',$ids]])->update($data); | ||||||
|  |             if(false !== $result){ | ||||||
|  |                 WSTClearAllCache(); | ||||||
|  |                 Db::commit(); | ||||||
|  |                 return WSTReturn("删除成功", 1); | ||||||
|  |             } | ||||||
|  |         }catch (\Exception $e) { | ||||||
|  |             Db::rollback();errLog($e); | ||||||
|  |             return WSTReturn('删除失败',-1); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
							
								
								
									
										23
									
								
								hyhproject/admin/validate/TradeRule.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								hyhproject/admin/validate/TradeRule.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * @filename TradeRule.php | ||||||
|  |  * @author Jerry Yan <792602257@qq.com> | ||||||
|  |  * @date 2020/5/28 12:59 | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  |  | ||||||
|  | namespace wstmart\admin\validate; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class TradeRule | ||||||
|  | { | ||||||
|  |     protected $rule = [ | ||||||
|  |         ['title'  ,'require|max:150','请输入标题|文章不能超过150个字符'], | ||||||
|  |         ['content'  ,'require','请输入文章内容'] | ||||||
|  |     ]; | ||||||
|  |  | ||||||
|  |     protected $scene = [ | ||||||
|  |         'add'   =>  ['title','content'], | ||||||
|  |         'edit'  =>  ['title','content'] | ||||||
|  |     ]; | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user