项目数据列表数据读取权限修改

This commit is contained in:
hdm 2022-07-01 11:53:46 +08:00
parent fb89644555
commit 6a093d4e3e
5 changed files with 28 additions and 26 deletions

View File

@ -278,11 +278,12 @@ class Index extends BaseController
$exist = Db::query('show tables like "'.$prefix.'project"');
$res['data'] = [];
if($exist){
$project_ids = Db::name('ProjectUser')->where(['uid' => $this->uid, 'delete_time' => 0])->column('project_id');
$list = Db::name('Project')
->field('a.id,a.name,a.status,a.create_time,a.start_time,a.end_time,u.name as director_name')
->alias('a')
->join('Admin u', 'a.director_uid = u.id')
->where([['a.delete_time','=',0]])
->where([['a.delete_time', '=', 0], ['a.id', 'in', $project_ids]])
->order('a.id desc')
->limit(10)
->select()->toArray();

View File

@ -17,21 +17,20 @@ class Article extends Model
public function detail($id)
{
$article = Db::name('Article')->where(['id' => $id])->find();
if (empty($article)) {
return $this->error('文章知识不存在');
}
$keywrod_array = Db::name('ArticleKeywords')
->field('i.aid,i.keywords_id,k.title')
->alias('i')
->join('Keywords k', 'k.id = i.keywords_id', 'LEFT')
->order('i.create_time asc')
->where(array('i.aid' => $id, 'k.status' => 1))
->select()->toArray();
if (!empty($article)) {
$keywrod_array = Db::name('ArticleKeywords')
->field('i.aid,i.keywords_id,k.title')
->alias('i')
->join('Keywords k', 'k.id = i.keywords_id', 'LEFT')
->order('i.create_time asc')
->where(array('i.aid' => $id, 'k.status' => 1))
->select()->toArray();
$article['keyword_ids'] = implode(",", array_column($keywrod_array, 'keywords_id'));
$article['keyword_names'] = implode(',', array_column($keywrod_array, 'title'));
$article['user'] = Db::name('Admin')->where(['id' => $article['uid']])->value('name');
$article['department'] = Db::name('Department')->where(['id' => $article['did']])->value('title');
$article['keyword_ids'] = implode(",", array_column($keywrod_array, 'keywords_id'));
$article['keyword_names'] = implode(',', array_column($keywrod_array, 'title'));
$article['user'] = Db::name('Admin')->where(['id' => $article['uid']])->value('name');
$article['department'] = Db::name('Department')->where(['id' => $article['did']])->value('title');
}
return $article;
}

View File

@ -190,7 +190,7 @@ class Index extends BaseController
if ($id > 0) {
$detail = Db::name('Message')->where(['id' => $id, 'from_uid' => $this->uid])->find();
if (empty($detail)) {
$this->error('该信息不存在');
echo '<div style="text-align:center;color:red;margin-top:20%;">该信息不存在</div>';exit;
}
$fid = $detail['fid'];
$person_name = [];
@ -244,10 +244,10 @@ class Index extends BaseController
$type = empty(get_params('type')) ? 0 : get_params('type');
$detail = Db::name('Message')->where(['id' => $id, 'template' => 0])->find();
if (empty($detail)) {
$this->error('该信息不存在');
echo '<div style="text-align:center;color:red;margin-top:20%;">该信息不存在</div>';exit;
}
if ($detail['to_uid'] != $this->uid && $detail['from_uid'] != $this->uid) {
$this->error('该信息不存在');
echo '<div style="text-align:center;color:red;margin-top:20%;">该信息不存在</div>';exit;
}
$sender = get_admin($detail['from_uid']);
$detail['person_name'] = $sender['name'];
@ -274,10 +274,10 @@ class Index extends BaseController
$id = $param['id'];
$detail = Db::name('Message')->where(['id' => $id])->find();
if (empty($detail)) {
$this->error('该信息不存在');
echo '<div style="text-align:center;color:red;margin-top:20%;">该信息不存在</div>';exit;
}
if ($detail['to_uid'] != $this->uid && $detail['from_uid'] != $this->uid) {
$this->error('该信息不存在');
echo '<div style="text-align:center;color:red;margin-top:20%;">该信息不存在</div>';exit;
}
Db::name('Message')->where(['id' => $id])->update(['read_time' => time()]);
if($detail['from_uid']==0){

View File

@ -141,7 +141,7 @@ class Work extends BaseController
if ($id > 0) {
$detail = Db::name('Work')->where(['id' => $id,'admin_id' => $this->uid])->find();
if (empty($detail)) {
$this->error('该汇报不存在');
echo '<div style="text-align:center;color:red;margin-top:20%;">该汇报不存在</div>';exit;
}
$person_name = Db::name('Admin')->where('status', 1)->where('id', 'in', $detail['type_user'])->column('name');
$detail['person_name'] = implode(",", $person_name);
@ -171,14 +171,14 @@ class Work extends BaseController
$id = $param['id'];
$detail = Db::name('Work')->where(['id' => $id,'status' => 1])->find();
if (empty($detail)) {
$this->error('该汇报不存在');
echo '<div style="text-align:center;color:red;margin-top:20%;">该汇报不存在</div>';exit;
}
//已读人查询
$read_user_names = [];
if($detail['admin_id'] !=$this->uid){
$record = Db::name('WorkRecord')->where(['wid' => $detail['id'],'to_uid' => $this->uid,'status' => 1])->count();
if ($record == 0) {
$this->error('该汇报不存在');
echo '<div style="text-align:center;color:red;margin-top:20%;">该汇报不存在</div>';exit;
}
else{
Db::name('WorkRecord')->where(['wid' => $detail['id'],'to_uid' => $this->uid,'status' => 1])->update(['read_time' => time()]);
@ -220,7 +220,7 @@ class Work extends BaseController
$id = $param['id'];
$detail = Db::name('Work')->where(['id' => $id,'status' => 1])->find();
if (empty($detail)) {
$this->error('该汇报不存在');
echo '<div style="text-align:center;color:red;margin-top:20%;">该汇报不存在</div>';exit;
}
if($detail['admin_id'] !=$this->uid){
$res = Db::name('WorkRecord')->where(['wid' => $detail['id'],'to_uid' => $this->uid,'status' => 1])->update(['status' => -1]);

View File

@ -105,7 +105,9 @@ class Task extends BaseController
$id = isset($param['id']) ? $param['id'] : 0;
$detail = (new TaskList())->detail($id);
if (empty($detail)) {
return to_assign(1, '任务不存在');
if (empty($detail)) {
echo '<div style="text-align:center;color:red;margin-top:20%;">该任务不存在</div>';exit;
}
} else {
$role_uid = [$detail['admin_id'], $detail['director_uid']];
$role_edit = 'view';
@ -130,7 +132,7 @@ class Task extends BaseController
return view();
}
else{
return to_assign(1, '您没权限查看该任务');
echo '<div style="text-align:center;color:red;margin-top:20%;">您没权限查看该任务</div>';exit;
}
}
}