1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace app\api\controller\company;
- use app\common\controller\Apic;
- use think\Db;
- class Banner extends Apic
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = '*';
-
- public function banner_list(){
- $where = [
- 'company_id' => $this->auth->company_id,
- 'position' => 0,
- ];
- $index = Db::name('banner')->where($where)->order('weigh asc,id asc')->select();
- $index = list_domain_image($index,['image']);
- $where = [
- 'company_id' => $this->auth->company_id,
- 'position' => 1,
- ];
- $store = Db::name('banner')->where($where)->order('weigh asc,id asc')->autopage()->select();
- $store = list_domain_image($store,['image']);
- $rs = [
- 'index' => $index,
- 'store' => $store,
- ];
- $this->success(1,$rs);
- }
-
- public function edit(){
- $index = input('index','');
- $store = input('store','');
- $where = [
- 'company_id' => $this->auth->company_id,
- 'position' => 0,
- ];
- Db::name('banner')->where('company_id',$this->auth->company_id)->delete();
- $data = [];
- if(!empty($index)){
- $index = explode(',',$index);
- foreach($index as $key => $val){
- $data[] = [
- 'company_id' => $this->auth->company_id,
- 'image' => $val,
- 'position' => 0,
- 'status' => 1,
- 'createtime' => time(),
- 'updatetime' => time(),
- ];
- }
- }
- if(!empty($store)){
- $store = explode(',',$store);
- foreach($store as $key => $val){
- $data[] = [
- 'company_id' => $this->auth->company_id,
- 'image' => $val,
- 'position' => 1,
- 'status' => 1,
- 'createtime' => time(),
- 'updatetime' => time(),
- ];
- }
- }
- if(!empty($data)){
- Db::name('banner')->insertAll($data);
- }
- $this->success();
- }
- }
|