12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace app\common\model;
- use think\Db;
- class WxNotice extends Base
- {
- public function updates(){
- $data = request()->post();
- $data['org_id'] = cur_org_id();
- $data['user_id'] = is_login();
- $result = validate('WxNotice')->check($data,[],'');
- if(true !== $result){
- $this->error = validate('WxNotice')->getError();
- return false;
- }
- $id = $data['id'];
- unset($data['id']);
- if($id > 0){
- $ret = $this->allowField(true)->save($data,['id'=>$id]);
- }else{
- $data['create_time'] = date('Y-m-d H:i:s');
- $ret = $this->allowField(true)->save($data);
- }
- if(!$ret){
- $this->error = '操作失败';
- return false;
- }
- return true;
- }
- public function lists($orgId){
- $ret=Db::name('wx_notice')
- ->field('id,title,content,create_time')
- ->where(['org_id'=>$orgId,'del'=>0])
- ->order(['id'=>'desc'])
- ->select();
- return $ret;
- }
- public function getOne($orgId){
- $ret=Db::name('wx_notice')
- ->field('id,title,content,create_time')
- ->where(['org_id'=>$orgId,'del'=>0])
- ->order(['id'=>'desc'])
- ->find();
- return $ret;
- }
- }
|