diff --git a/application/adminapi/controller/RoomEmoji.php b/application/adminapi/controller/RoomEmoji.php new file mode 100644 index 0000000..92aee25 --- /dev/null +++ b/application/adminapi/controller/RoomEmoji.php @@ -0,0 +1,164 @@ +table) + ->where($where) + ->count(); + $list = Db::name($this->table) + ->where($where) + ->order('sort desc,id desc') + ->page($page, $limit) + ->select(); + foreach ($list as &$item) { + $item['createtime'] = date('Y-m-d H:i:s', $item['createtime']); + $item['status_str'] = $item['status'] == 1 ? '显示' : '隐藏'; + } + $return_data = [ + 'page' => $page, + 'limit' => $limit, + 'total' => $total, + 'list' => $list + ]; + return V(1,"成功", $return_data); + } + //添加房间表情 + function add_emoji(){ + $pid = input('pid', 0, 'intval'); + $name = input('name', '', 'trim'); + $img = input('image', '', 'trim'); + $sort = input('sort', 0, 'intval'); + $type_id = input('type_id', 0); + $status = input('status', 1, 'intval'); + if (!$name) { + return V(0, '请输入表情名称'); + } + if (!$img) { + return V(0, '请上传表情图片'); + } + if (!$type_id) { + return V(0, '请选择表情类型'); + } + $data = [ + 'pid' => $pid, + 'name' => $name, + 'image' => $img, + 'sort' => $sort, + 'type_id' => $type_id, + 'status' => $status, + 'createtime' => time(), + ]; + $res = Db::name($this->table)->insert($data); + if ($res) { + return V(1, '添加成功'); + } + } + //房间表情修改 + function edit_emoji(){ + $id = input('id', 0, 'intval'); + $name = input('name', '', 'trim'); + $img = input('image', '', 'trim'); + $sort = input('sort', 0, 'intval'); + $type_id = input('type_id', 0); + $status = input('status', 1, 'intval'); + if (!$id) { + return V(0, '请选择要修改的表情'); + } + if($name){ + $data['name'] = $name; + } + if($img){ + $data['image'] = $img; + } + if($sort){ + $data['sort'] = $sort; + } + if($type_id){ + $data['type_id'] = $type_id; + } + $data['status'] = $status; + $res = Db::name($this->table)->where('id',$id)->update($data); + if ($res) { + return V(1, '修改成功'); + } + } + //房间表情删除 + function del_emoji(){ + $id = input('id', 0, 'intval'); + if (!$id) { + return V(0, '请选择要删除的表情'); + } + $res = Db::name($this->table)->where('id',$id)->update( + ['deletetime' => time()] + ); + if ($res) { + return V(1, '删除成功'); + } + } + //表情详情 + function emoji_detail(){ + $id = input('id', 0, 'intval'); + if (!$id) { + return V(0, '请选择要查看的表情'); + } + $detail = Db::name($this->table)->where('id',$id)->find(); + if (!$detail) { + return V(0, '表情不存在'); + } + return V(1,"成功", $detail); + } + + //表情类型列表 + function emoji_type_list(){ + $emoji_type = Db::name($this->table_type) + ->field('id,type_name') + ->where(['deletetime'=>0,'status'=>1]) + ->order('sort desc,id desc') + ->select(); + return V(1,"成功", $emoji_type); + } + +} \ No newline at end of file diff --git a/application/api/model/RoomEmoji.php b/application/api/model/RoomEmoji.php index ad52508..594b50f 100644 --- a/application/api/model/RoomEmoji.php +++ b/application/api/model/RoomEmoji.php @@ -36,7 +36,7 @@ class RoomEmoji extends Model ->field('id,pid,type_id,name,image') ->where(['status'=>1,'deletetime'=>0]) ->where($where) - ->order('sort asc,id asc') + ->order('sort desc,id desc') ->select(); if ($isTree && !empty($list) && empty($pid)) { $list = $this->buildTree($list);