Commit 8e48403e authored by hujun's avatar hujun

设置角色站点

parent 61fc066e
...@@ -10,6 +10,8 @@ namespace app\index\controller; ...@@ -10,6 +10,8 @@ namespace app\index\controller;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\model\AuthGroup; use app\model\AuthGroup;
use app\model\AuthGroupSetting;
use app\model\AuthGroupSite;
use app\model\AuthRule; use app\model\AuthRule;
use think\Session; use think\Session;
...@@ -450,6 +452,45 @@ class Auth extends Basic ...@@ -450,6 +452,45 @@ class Auth extends Basic
return $this->response(200, '', $data); return $this->response(200, '', $data);
} }
/**
* 设置站点
*
* @return \think\Response
*/
public function setSite() {
$m_auth = new AuthGroupSite();
$msg = '';
$code = 200;
$list = [];
if (empty($this->params['group_id'])) {
return $this->response(101, '参数错误');
}
if ($this->request->isGet()) {
$data = $m_auth->getGroupSiteList('a.id,b.city', ['']);
if ($data['status'] == 'successful') {
$list = $data['data'];
} else {
$code = 101;
$msg = '内部错误:'.$data['msg'];
}
} else {
if (empty($this->params['site_id_string'])) {
return $this->response(101, '站点数据错误');
}
$data['group_id'] = $this->params['group_id'];
$data['site_id'] = $this->params['site_id_string'];
$num = $m_auth->editData($data, $this->params['id']);
if ($num > 0) {
$msg = "操作成功";
} else {
$code = 101;
$msg = "操作失败,或没有数据更新。";
}
}
return $this->response($code, $msg, $list);
}
} }
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: hu jun
* Date: 2018/10/31
* Time: 17:19
*/
namespace app\model;
use think\Db;
class AuthGroupSite extends BaseModel
{
protected $table = "auth_group_site";
private $db_;
/**
* AuthGroupSite constructor.
* @param array $data
*/
public function __construct($data = [])
{
parent::__construct($data);
$this->db_ = Db::name($this->table);
}
/**
* @param $field
* @param $where
* @return mixed
*/
public function getGroupSiteList($field, $where) {
$data['data'] = [];
try {
$list = $this->db_->alias('a')
->field($field)
->join('a_site a','a.site_id = b.id', 'left')
->where($where)
->select();
$data['data'] = $list;
$data['status'] = 'successful';
} catch (\Exception $e) {
$data['status'] = 'successful';
$data['msg'] = $e->getMessage();
}
return $data;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment