|
|
@@ -0,0 +1,109 @@
|
|
|
+<?php
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Laravel框架 [ Laravel ]
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 版权所有 2017~2021 Laravel研发中心
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 官方网站: http://www.laravel.cn
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | Author: wesmiler <12345678@qq.com>
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+
|
|
|
+namespace App\Services;
|
|
|
+
|
|
|
+use App\Models\DictModel;
|
|
|
+use App\Models\EnshrineNoticeModel;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 忏悔/回向记录-服务类
|
|
|
+ * @author wesmiler
|
|
|
+ * @since 2020/11/11
|
|
|
+ * Class EnshrineNoticeService
|
|
|
+ * @package App\Services
|
|
|
+ */
|
|
|
+class EnshrineNoticeService extends BaseService
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 构造函数
|
|
|
+ * @author wesmiler
|
|
|
+ * @since 2020/11/11
|
|
|
+ * EnshrineNoticeService constructor.
|
|
|
+ */
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ $this->model = new EnshrineNoticeModel();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取忏悔/回向记录
|
|
|
+ * @param $userId
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getDataList($userId){
|
|
|
+ $params = request()->all();
|
|
|
+ $page = isset($params['pageSize']) ? intval($params['pageSize']) : PAGE;
|
|
|
+ $pageSize = isset($params['pageSize']) ? intval($params['pageSize']) : PERPAGE;
|
|
|
+ $type = isset($params['type'])? $params['type'] : 1;
|
|
|
+ $isHide = isset($params['is_hide'])? $params['is_hide'] : 1;
|
|
|
+
|
|
|
+ $dataList = $this->model::from('enshrine_notices a')
|
|
|
+ ->where(['a.type'=> $type,'a.is_hide','a.mark'=>1,'a.user_id'=> $userId,'a.status'=> 1])
|
|
|
+ ->select(['a.*'])
|
|
|
+ ->orderBy('a.create_time', 'desc')
|
|
|
+ ->paginate($pageSize);
|
|
|
+
|
|
|
+ $dataList = $dataList ? $dataList->toArray() : [];
|
|
|
+ if ($dataList) {
|
|
|
+ foreach ($dataList['data'] as &$item) {
|
|
|
+ $item['create_time'] = $item['create_time'] ? datetime($item['create_time'],'Y-m-d H:i:s') : '';
|
|
|
+ $item['description'] = $item['description']? str_replace("\n",'<br>', $item['description']) : '';
|
|
|
+ }
|
|
|
+ unset($item);
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'code' => 0,
|
|
|
+ 'success'=> true,
|
|
|
+ 'msg' => '操作成功',
|
|
|
+ 'count' => isset($dataList['total']) ? $dataList['total'] : 0,
|
|
|
+ 'data' => isset($dataList['data']) ? $dataList['data'] : 0,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发布记录
|
|
|
+ * @param $userId
|
|
|
+ */
|
|
|
+ public function publish($userId){
|
|
|
+ $params = request()->all();
|
|
|
+ $realname = isset($params['realname'])? $params['realname'] : '';
|
|
|
+ $description = isset($params['description'])? $params['description'] : '';
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除记录
|
|
|
+ * @param $userId
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function del($userId){
|
|
|
+ $id = request()->get('id', 0);
|
|
|
+ if($id<=0){
|
|
|
+ return message('参数错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $info = $this->model::where(['id'=> $id, 'user_id'=> $userId,'mark'=> 1,'status'=> 1])
|
|
|
+ ->select(['id','user_id','real_name'])
|
|
|
+ ->first();
|
|
|
+ if(!$info){
|
|
|
+ return message('记录不存在或已处理', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if($this->model::where(['id'=> $id, 'user_id'=> $userId,'mark'=> 1,'status'=> 1])->delete()){
|
|
|
+ return message('删除成功', true);
|
|
|
+ }else{
|
|
|
+ return message('删除失败', false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|