| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace App\Models;
- use DB;
- class Account_group extends BaseModel {
- protected $table = "account_group";
- public $timestamps = false;
- protected function getList($where='',$limit=20){
- $data=$this->orderBy('sort','desc');
- if(is_array($where)&&count($where)>0){
- $data=$data->where($where);
- }
- $data=$data->paginate($limit);
- return $data->toArray();
- }
- protected function addGroup($data){
- if(($res=$this->checkCode($data['group_code'],$data['group_name'])) < 0 ){
- return $res;
- }
- if(!isset($data['create_at'])){
- $data['create_at']=date('Y-m-d H:i:s');
- }
- if(!isset($data['identity'])){
- $data['identity']=UUID();
- }
- $resd=$this->insert($data);
- if(!$resd){
- return -240002;
- }
- return 1;
- }
- //检测重复
- protected function checkCode($code,$name){
- $res=$this->where('group_code',$code)->orWhere('group_name',$name)->first();
- if($res){
- return -240001;
- }
- return 1;
- }
- protected function getGroups($ids){
- $data=$this->whereIn('id',$ids)->get();
- if(!$data){
- return -240004;
- }
- return $data->toArray();
- }
- protected function getInfoById($id){
- $data=$this->where('group_code',$id)->first();
- if(!$data){
- return -240001;
- }
- return $data->toArray();
- }
- protected function getAllInfo(){
- $data=$this->orderBy('group_code','asc')->get();
- if(!$data){
- return array();
- }
- return $data->toArray();
- }
- }
|