DinnerWechat.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class DinnerWechat extends Base
  5. {
  6. protected $createTime = 'create_time';
  7. protected $updateTime = 'update_time';
  8. public $table = 'dinner_wechat';
  9. protected $validateName = 'DinnerWechat';
  10. public function updates(){
  11. $data = request()->post();
  12. $result = validate($this->validateName)->check($data,[],'');
  13. if(true !== $result){
  14. $this->error = validate($this->validateName)->getError();
  15. return false;
  16. }
  17. $id = $data['id'];
  18. if(isset($data['cert_path']) && !empty($data['cert_path'])){
  19. $cert_path = parse_url($data['cert_path']);
  20. $data['cert_path'] = $cert_path['path'];
  21. }
  22. if(isset($data['key_path']) && !empty($data['key_path'])){
  23. $cert_path = parse_url($data['key_path']);
  24. $data['key_path'] = $cert_path['path'];
  25. }
  26. unset($data['id']);
  27. if($id > 0){
  28. $data['update_time'] = date('Y-m-d H:i:s');
  29. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  30. }else{
  31. $data['create_time'] = date('Y-m-d H:i:s');
  32. $ret = $this->allowField(true)->save($data);
  33. }
  34. if(!$ret){
  35. $this->error = '操作失败';
  36. return false;
  37. }
  38. return true;
  39. }
  40. public function getList(){
  41. $list =$this
  42. ->where('org_id',cur_org_id())
  43. ->where('del',0)
  44. ->where('enable',1)
  45. ->select()
  46. ->toArray();
  47. return $list;
  48. }
  49. }