|
@@ -38,7 +38,6 @@ class Role extends Base
|
|
|
|
|
|
$count = Db::name("role")
|
|
|
->alias("a")
|
|
|
-// ->leftJoin("supplier_info b", "a.companyNo=b.code")
|
|
|
->where($condition)
|
|
|
->count('a.id');
|
|
|
$page = isset($post['page']) ? intval($post['page']) : 1;
|
|
@@ -46,7 +45,6 @@ class Role extends Base
|
|
|
$page >= ceil($count / $size) ? $page = (int)ceil($count / $size) : "";
|
|
|
$list = Db::name("role")
|
|
|
->alias("a")
|
|
|
-// ->leftJoin("supplier_info b", "a.companyNo=b.code")
|
|
|
->leftJoin("role_action t", "a.id=t.role_id")
|
|
|
->field("a.*,t.action_conllect as action,t.action_data")
|
|
|
->order("a.addtime desc")
|
|
@@ -88,12 +86,6 @@ class Role extends Base
|
|
|
"level|角色级别"=>"require|number|in:1,2,3",
|
|
|
]);
|
|
|
if ($valid->check($post) == false) return error_show(1004, $valid->getError());
|
|
|
-// if ($post['relaComNo'] != "" && $post["level"] == 1) return error_show(1002, "超管权限角色不可关联业务公司");
|
|
|
-
|
|
|
-// if ($this->level == 1) $companyNo = $post['companyNo'] ?? "";
|
|
|
-// else $companyNo = $post['relaComNo'] ?? "";
|
|
|
-
|
|
|
-// $companyNo = $post['relaComNo']=='' ? $post['companyNo']:'';
|
|
|
|
|
|
$where = [["role_name", "=", $post['role_name']]];
|
|
|
if ($post['relaComNo'] != "") $where[] = ["companyNo", "=", $post['relaComNo']];
|
|
@@ -101,10 +93,10 @@ class Role extends Base
|
|
|
$isT = Db::name("role")->field('id')->where($where)->find();
|
|
|
if ($isT) return error_show(1002, "角色名称已存在");
|
|
|
|
|
|
- $action = isset($post['action']) && is_array($post['action']) ? implode(",", $post['action']) : "";
|
|
|
+ $action = isset($post['action']) && is_array($post['action']) ? $post['action'] : [];
|
|
|
|
|
|
- $data = isset($post['action_data']) && is_array($post['action_data']) ? implode(",", $post['action_data']) : "";
|
|
|
- $private_data = isset($post['private_data']) && is_array($post['private_data']) ? implode(",", $post['private_data']) : "";
|
|
|
+ $data = isset($post['action_data']) && is_array($post['action_data']) ? $post['action_data'] :[];
|
|
|
+ $private_data = isset($post['private_data']) && is_array($post['private_data']) ? $post['private_data'] : "";
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
|
|
@@ -124,9 +116,9 @@ class Role extends Base
|
|
|
if ($role > 0) {
|
|
|
$role_action = [
|
|
|
"role_id" => $role,
|
|
|
- "action_conllect" => $action,
|
|
|
- "action_data" => $data,
|
|
|
- "private_data" => $private_data,
|
|
|
+ "action_conllect" => json_encode($action),
|
|
|
+ "action_data" => json_encode($data),
|
|
|
+ "private_data" => json_encode($private_data),
|
|
|
'private_field' => is_array($post['private_field']) ? implode(',', $post['private_field']) : $post['private_field'],
|
|
|
"status" => 1,
|
|
|
"addtime" => $date,
|
|
@@ -169,15 +161,14 @@ class Role extends Base
|
|
|
->alias("a")
|
|
|
->leftJoin("role_action t", "a.id=t.role_id")
|
|
|
->field("a.*,t.action_conllect,t.action_data,t.private_data,t.private_field")
|
|
|
+ ->json(["action_conllect",'action_data','private_data'])
|
|
|
->where("a.id", "=", $roleid)
|
|
|
->find();
|
|
|
if (!$info) {
|
|
|
return error_show(1002, "未找到对应的数据");
|
|
|
}
|
|
|
|
|
|
- $info['action'] = explode(",", $info['action_conllect']);
|
|
|
- $info['action_data'] = $info['action_data'] != "" ? explode(",", $info['action_data']) : "";
|
|
|
- $info['private_data'] = $info['private_data'] != "" ? explode(",", $info['private_data']) : "";
|
|
|
+ $info['action'] = $info['action_conllect'];
|
|
|
return app_show(0, "获取成功", $info);
|
|
|
}
|
|
|
|
|
@@ -209,15 +200,7 @@ class Role extends Base
|
|
|
if ($valid->check($post) == false) return error_show(1004, $valid->getError());
|
|
|
$info = Db::name("role")->where("id", "=", $post['roleid'])->find();
|
|
|
if (!$info) return error_show(1002, "未找到对应的数据");
|
|
|
-
|
|
|
-// if ($post['relaComNo'] != "" && $info["level"] == 1) return error_show(1002, "超管权限角色不可关联业务公司");
|
|
|
-
|
|
|
-// if($this->level==1){
|
|
|
-// $companyNo =$post['companyNo']??"";
|
|
|
-// }else{
|
|
|
-// $companyNo =$post['relaComNo']??"";
|
|
|
-// }
|
|
|
-
|
|
|
+
|
|
|
$tmp_where=[
|
|
|
["id", '<>', $post['roleid']],
|
|
|
["role_name", "=", $post['role_name']],
|
|
@@ -229,12 +212,12 @@ class Role extends Base
|
|
|
->find();
|
|
|
if ($vers) return error_show(1002, "角色名已存在");
|
|
|
|
|
|
- $action = isset($post['action']) && is_array($post['action']) ? implode(",", $post['action']) : "";
|
|
|
+ $action = isset($post['action']) && is_array($post['action']) ? $post['action']: [];
|
|
|
// if ($action == "") {
|
|
|
// return error_show(1004, "功能权限不能为空");
|
|
|
// }
|
|
|
- $data = isset($post['action_data']) && is_array($post['action_data']) ? implode(",", $post['action_data']) : "";
|
|
|
- $private_data = isset($post['private_data']) && is_array($post['private_data']) ? implode(",", $post['private_data']) : "";
|
|
|
+ $data = isset($post['action_data']) && is_array($post['action_data']) ?$post['action_data']: [];
|
|
|
+ $private_data = isset($post['private_data']) && is_array($post['private_data']) ? $post['private_data']: [];
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$list = [
|
|
@@ -250,10 +233,10 @@ class Role extends Base
|
|
|
if ($role) {
|
|
|
$role_action = [
|
|
|
"role_id" => $post['roleid'],
|
|
|
- "action_conllect" => $action,
|
|
|
- "action_data" => $data,
|
|
|
+ 'action_conllect' => json_encode($action),
|
|
|
+ 'action_data' => json_encode($data),
|
|
|
+ 'private_data' => json_encode($private_data),
|
|
|
'private_field'=>is_array($post['private_field'])?implode(',',$post['private_field']):$post['private_field'],
|
|
|
- "private_data" => $private_data,
|
|
|
"updatetime" => date("Y-m-d H:i:s")
|
|
|
];
|
|
|
$roleaction = Db::name("role_action")->where("role_id", "=", $post['roleid'])->update($role_action);
|