12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace app\common\model;
- use think\Db;
- class Notice extends Base
- {
- public function lists($page,$size,$userId,$orgId){
- $createYmd = Db::name('notice')
- ->field('create_yyyymmdd')
- ->where('org_id',$orgId)
- ->where('del',0)
- ->where('user_id',$userId)
- ->group('create_yyyymmdd')
- ->order('create_yyyymmdd desc')
- ->page($page,$size)
- ->select();
- $ret = [];
- foreach ($createYmd as $k=>$v) {
- $lists = Db::name('notice')
- ->alias('n')
- ->field('n.id,n.create_time,n.is_read,n.create_yyyymmdd,n.title,nc.name')
- ->join('notice_cate nc','nc.id=n.cate_id')
- ->where('n.org_id',$orgId)
- ->where('n.user_id',$userId)
- ->where('n.del',0)
- ->where('n.create_yyyymmdd',$v['create_yyyymmdd'])
- ->select();
- $ret[$v['create_yyyymmdd']]=$lists;
- }
- return $ret;
- }
- public function details($id){
- $ret = Db::name('notice')
- ->where('id',$id)
- ->find();
- if($ret){
- $ret['real_name'] = Db::name('user')->where('id',$ret['create_user_id'])->value('real_name');
- if($ret['is_read'] == 0){
- Db::name('notice')->where('id',$id)->update(['is_read'=>1]);
- }
- }
- return $ret;
- }
- }
|