WxNotice.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class WxNotice extends Base
  5. {
  6. public function updates(){
  7. $data = request()->post();
  8. $data['org_id'] = cur_org_id();
  9. $data['user_id'] = is_login();
  10. $result = validate('WxNotice')->check($data,[],'');
  11. if(true !== $result){
  12. $this->error = validate('WxNotice')->getError();
  13. return false;
  14. }
  15. $id = $data['id'];
  16. unset($data['id']);
  17. if($id > 0){
  18. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  19. }else{
  20. $data['create_time'] = date('Y-m-d H:i:s');
  21. $ret = $this->allowField(true)->save($data);
  22. }
  23. if(!$ret){
  24. $this->error = '操作失败';
  25. return false;
  26. }
  27. return true;
  28. }
  29. public function lists($orgId){
  30. $ret=Db::name('wx_notice')
  31. ->field('id,title,content,create_time')
  32. ->where(['org_id'=>$orgId,'del'=>0])
  33. ->order(['id'=>'desc'])
  34. ->select();
  35. return $ret;
  36. }
  37. public function getOne($orgId){
  38. $ret=Db::name('wx_notice')
  39. ->field('id,title,content,create_time')
  40. ->where(['org_id'=>$orgId,'del'=>0])
  41. ->order(['id'=>'desc'])
  42. ->find();
  43. return $ret;
  44. }
  45. }