AssetAdd.php 995 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class AssetAdd extends Base
  5. {
  6. protected $createTime = 'create_time';
  7. public function updates(){
  8. $data = request()->post();
  9. $data['org_id'] = cur_org_id();
  10. $result = validate('AssetAdd')->check($data,[],'');
  11. if(true !== $result){
  12. $this->error = validate('AssetAdd')->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 getList($orgId){
  30. $lists = Db::name('asset_add')
  31. ->where('org_id',$orgId)
  32. ->select();
  33. return $lists;
  34. }
  35. }