Browse Source

系统公告

lizhen_gitee 1 year ago
parent
commit
5632a540ca
1 changed files with 29 additions and 1 deletions
  1. 29 1
      application/api/controller/Index.php

+ 29 - 1
application/api/controller/Index.php

@@ -9,6 +9,7 @@ use \think\Log;
 use Redis;
 use app\common\library\Sms as Smslib;
 use app\common\service\TenimService;
+use think\Db;
 /**
  * 首页接口
  */
@@ -83,6 +84,33 @@ class Index extends Api
     /*
      * 获取系统消息列表
      */
+    public function getMessageSys() {
+        $page = $this->request->request('page',1); // 分页
+        $pageNum = $this->request->request('pageNum',10); // 分页
+        // 分页搜索构建
+        $pageStart = ($page-1)*$pageNum;
+
+        $flag = $this->request->request("flag",1,"intval"); //标识:1=只取一条,0=全部
+        $type = $this->request->request("type",1);
+        $obj = Db::name('message_sys')->where('type',$type)->order("id","desc")->limit($pageStart,$pageNum);
+        if($flag == 1) {
+            $list = $obj->find();
+            $list || $list = [];
+            $list && $list["createtime"] = $this->get_last_time($list["createtime"]);
+        } else {
+            $list = $obj->select();
+            if($list) foreach($list as $k => &$v) {
+                $v["createtime"] = $this->get_last_time($v["createtime"]);
+            }
+        }
+
+        $this->success("获取成功!",$list);
+
+    }
+
+    /*
+     * 获取个人消息列表
+     */
     public function getMessage() {
         $page = $this->request->request('page',1); // 分页
         $pageNum = $this->request->request('pageNum',10); // 分页
@@ -109,7 +137,7 @@ class Index extends Api
     }
 
     /**
-     * 删除系统消息
+     * 删除个人消息
      */
     public function delMessage() {
         $id = $this->request->request("id",0,"intval"); //消息ID