-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
|
||
namespace App\Model; | ||
|
||
use fashop\Model; | ||
|
||
class BlsUser extends Model | ||
{ | ||
protected $resultSetType = 'collection'; | ||
|
||
/** | ||
* 添加用户 | ||
* @param array $data 用户信息 | ||
* @author 韩文博 | ||
* @throws \Exception | ||
*/ | ||
public function addBlsUser( array $data ) | ||
{ | ||
$now_time = time(); | ||
$user_id = $this->insertGetId( array_merge( $data, [ | ||
'create_time' => $now_time, | ||
] ) ); | ||
return $user_id; | ||
} | ||
|
||
/** | ||
* 添加多条 | ||
* @datetime 2017-04-20 15:49:43 | ||
* @author 韩文博 | ||
* @param array $data | ||
* @return boolean | ||
*/ | ||
public function addBlsUserAll( $data ) | ||
{ | ||
return $this->insertAll( $data ); | ||
} | ||
|
||
/** | ||
* 修改 | ||
* @datetime 2017-04-20 15:49:43 | ||
* @author 韩文博 | ||
* @param array $condition | ||
* @param array $data | ||
* @return boolean | ||
*/ | ||
public function editBlsUser( $condition = [], $data = [] ) | ||
{ | ||
return $this->update( $data, $condition, true ); | ||
} | ||
|
||
/** | ||
* 删除 | ||
* @datetime 2017-04-20 15:49:43 | ||
* @author 韩文博 | ||
* @param array $condition | ||
* @return boolean | ||
*/ | ||
public function delBlsUser( $condition = [] ) | ||
{ | ||
return $this->where( $condition )->delete(); | ||
} | ||
|
||
/** | ||
* 计算数量 | ||
* @datetime 2017-04-20 15:49:43 | ||
* @author 韩文博 | ||
* @param array $condition 条件 | ||
* @return int | ||
*/ | ||
public function getBlsUserCount( $condition ) | ||
{ | ||
return $this->where( $condition )->count(); | ||
} | ||
|
||
|
||
/** | ||
* 用户列表 | ||
* @param array $condition | ||
* @param string $field | ||
* @param number $page | ||
* @param string $order | ||
*/ | ||
public function getBlsUserList( $condition = [], $field = '*', $order = 'id desc', $page = "1,10" ) | ||
{ | ||
$list = $this->where( $condition )->order( $order )->field( $field )->page( $page )->select(); | ||
return $list ? $list->toArray() : false; | ||
} | ||
|
||
/** | ||
* 获取单个用户信息 | ||
* @datetime 2017-04-20T15:23:09+0800 | ||
* @author 韩文博 | ||
* @param array $condition | ||
* @param string $field | ||
* @param array $extends | ||
* @return array | ||
*/ | ||
public function getBlsUserInfo( $condition = [], $field = '*', $extends = [] ) | ||
{ | ||
$result = $this->field( $field )->where( $condition )->find(); | ||
$user_info = $result ? $result->toArray() : []; | ||
unset( $user_info['pay_password'] ); | ||
return $user_info; | ||
} | ||
|
||
} |