| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace app\common\model;
- use think\Model;
- abstract class BaseModel extends Model
- {
- public function __call($method, $args)
- {
- return parent::__call($method, $args); // TODO: Change the autogenerated stub
- }
- abstract protected function genSchema(array $schema);
- public function getCreateTimeAttr($v) {
- if(!$v)return $v;
- return date("Y-m-d H:i:s", $v);
- }
- public function getUpdateTimeAttr($v) {
- if(!$v)return $v;
- return date("Y-m-d H:i:s", $v);
- }
- public function deleteByIds(array $ids) {
- return $this->whereIn('id',$ids)->update(['is_delete' => 1, 'delete_time' => time()]);
- }
- /**
- * @param $id
- * @return BaseModel|array|mixed|Model|null
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function findById($id) {
- return $this->where([
- ['id','=',$id],
- ['is_delete','=', 0]
- ])->find();
- }
- public function findByIds(array $ids) {
- return $this->where([
- ['id','in', $ids],
- ['is_delete','=', 0]
- ])->select();
- }
- }
|