123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace app\common\model;
- use app\hander\HelpHander;
- use think\Db;
- use think\Exception;
- class FCleanPlan extends Base {
- protected $createTime = 'create_time';
- protected $updateTime = 'update_time';
- public $table = 'f_clean_plan';
- protected $validateName = 'FCleanPlan';
- public function updates() {
- $data = request()->post();
- $data['forms'] = !empty($data['forms'])?implode(',',$data['forms']):'';
- $data['addrs'] = !empty($data['addrs'])?implode(',',$data['addrs']):'';
- $data['org_id'] = cur_org_id();
- $result = validate($this->validateName)->check($data, [], 'add');
- if (true !== $result) {
- $this->error = validate($this->validateName)->getError();
- return false;
- }
- $id = $data['id'];
- unset($data['id']);
- $this->startTrans();
- try {
- if ($id > 0) {
- $data['update_time'] = date('Y-m-d H:i:s');
- $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) {
- throw new Exception('任务保存失败');
- }
- $this->commit();
- return true;
- } catch (Exception $e) {
- $this->rollback();
- $this->error = $e->getMessage();
- return false;
- }
- }
- public function mupdates() {
- $data = request()->post();
- $data['forms'] = !empty($data['forms'])?implode(',',$data['forms']):'';
- $data['addrs'] = !empty($data['addrs'])?implode(',',$data['addrs']):'';
- $data['org_id'] = cur_org_id();
- $result = validate($this->validateName)->check($data, [], 'madd');
- if (true !== $result) {
- $this->error = validate($this->validateName)->getError();
- return false;
- }
- $id = $data['id'];
- unset($data['id']);
- $this->startTrans();
- try {
- if ($id > 0) {
- $data['update_time'] = date('Y-m-d H:i:s');
- $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) {
- throw new Exception('任务保存失败');
- }
- $this->commit();
- return true;
- } catch (Exception $e) {
- $this->rollback();
- $this->error = $e->getMessage();
- return false;
- }
- }
- }
|