AssetExportTemp.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\common\model;
  3. use app\hander\HelpHander;
  4. use think\Db;
  5. use think\Model;
  6. class AssetExportTemp extends Model
  7. {
  8. public function add(){
  9. $data = [
  10. 'id' => input('id/d',0),
  11. 'title' => input('title','','trim'),
  12. 'content' => input('content','','trim'),
  13. ];
  14. $result = validate('AssetExportTemp')->check($data,[],'');
  15. if(true !== $result){
  16. HelpHander::error(validate('AssetExportTemp')->getError());
  17. }
  18. $id = $data['id'];
  19. unset($data['id']);
  20. if($id > 0){
  21. $data['update_time'] = date('Y-m-d H:i:s');
  22. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  23. }else{
  24. $data['create_time'] = date('Y-m-d H:i:s');
  25. $ret = $this->allowField(true)->save($data);
  26. }
  27. if(!$ret){
  28. HelpHander::error('操作失败');
  29. }
  30. return true;
  31. }
  32. public function all($orgId){
  33. $lists = $this
  34. ->field('id,title,content')
  35. ->order('id desc')
  36. ->select();
  37. return $lists?$lists->toArray():[];
  38. }
  39. public function del($id){
  40. $ret = $this->where('id',$id)->delete();
  41. if(!$ret){
  42. HelpHander::error('删除失败');
  43. }
  44. return true;
  45. }
  46. }