帖子管理模糊查询&前端优化
This commit is contained in:
parent
c6d4b384ac
commit
c7e6667f8f
@ -73,4 +73,15 @@ public class WechatUtil {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Title: isEmpty
|
||||||
|
* @Description: 判断对象是否为空
|
||||||
|
* @param obj
|
||||||
|
* @return
|
||||||
|
* @return Integer
|
||||||
|
*/
|
||||||
|
public static boolean isEmpty(Object obj) {
|
||||||
|
return null == obj || "".equals(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.linfeng.modules.admin.service.impl;
|
package io.linfeng.modules.admin.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@ -53,9 +54,22 @@ public class PostServiceImpl extends ServiceImpl<PostDao, PostEntity> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
|
QueryWrapper<PostEntity> queryWrapper=new QueryWrapper<>();
|
||||||
|
//条件查询
|
||||||
|
String key = (String)params.get("key");
|
||||||
|
String status = (String)params.get("status");
|
||||||
|
if(!WechatUtil.isEmpty(key)){
|
||||||
|
params.put("page","1");//如果是查询分页重置为第一页
|
||||||
|
queryWrapper.like("content", key).or().like("title",key);
|
||||||
|
}
|
||||||
|
if(!WechatUtil.isEmpty(status)){
|
||||||
|
params.put("page","1");//如果是查询分页重置为第一页
|
||||||
|
queryWrapper.eq("status", Integer.parseInt(status));
|
||||||
|
}
|
||||||
|
queryWrapper.lambda().orderByDesc(PostEntity::getId);
|
||||||
IPage<PostEntity> page = this.page(
|
IPage<PostEntity> page = this.page(
|
||||||
new Query<PostEntity>().getPage(params),
|
new Query<PostEntity>().getPage(params),
|
||||||
new QueryWrapper<>()
|
queryWrapper
|
||||||
);
|
);
|
||||||
List<PostEntity> data = page.getRecords();
|
List<PostEntity> data = page.getRecords();
|
||||||
|
|
||||||
@ -63,17 +77,17 @@ public class PostServiceImpl extends ServiceImpl<PostDao, PostEntity> implements
|
|||||||
data.forEach(l->{
|
data.forEach(l->{
|
||||||
PostListResponse response=new PostListResponse();
|
PostListResponse response=new PostListResponse();
|
||||||
BeanUtils.copyProperties(l,response);
|
BeanUtils.copyProperties(l,response);
|
||||||
if (response.getDiscussId() > 0) {
|
if(ObjectUtil.isNotNull(response.getDiscussId())&&response.getDiscussId()>0){
|
||||||
DiscussEntity discussEntity = discussService.getById(response.getDiscussId());
|
DiscussEntity discussEntity = discussService.getById(response.getDiscussId());
|
||||||
|
if(ObjectUtil.isNotNull(discussEntity)){
|
||||||
response.setDiscussTitle(discussEntity.getTitle());
|
response.setDiscussTitle(discussEntity.getTitle());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
response.setTopicName(topicService.getById(response.getTopicId()).getTopicName());
|
response.setTopicName(topicService.getById(response.getTopicId()).getTopicName());
|
||||||
response.setCollectionCount(postCollectionService.collectCount(response.getId()));
|
response.setCollectionCount(postCollectionService.collectCount(response.getId()));
|
||||||
response.setCommentCount(commentService.getCountByTopicId(response.getId()));
|
response.setCommentCount(commentService.getCountByTopicId(response.getId()));
|
||||||
response.setUserInfo(appUserService.getById(response.getUid()));
|
response.setUserInfo(appUserService.getById(response.getUid()));
|
||||||
String jsonString = l.getMedia();
|
response.setMedia(JsonUtils.JsonToList(l.getMedia()));
|
||||||
List<String> list = JsonUtils.JsonToList(jsonString);
|
|
||||||
response.setMedia(list);
|
|
||||||
responseList.add(response);
|
responseList.add(response);
|
||||||
});
|
});
|
||||||
PageUtils pageUtils=new PageUtils(page);
|
PageUtils pageUtils=new PageUtils(page);
|
||||||
|
@ -5,21 +5,26 @@
|
|||||||
:model="dataForm"
|
:model="dataForm"
|
||||||
@keyup.enter.native="getDataList()"
|
@keyup.enter.native="getDataList()"
|
||||||
>
|
>
|
||||||
<!-- <el-form-item>
|
<el-form-item>
|
||||||
<el-input
|
<el-input
|
||||||
v-model="dataForm.key"
|
v-model="dataForm.key"
|
||||||
placeholder="请输入帖子内容搜索"
|
placeholder="帖子内容或标题搜索"
|
||||||
clearable
|
clearable
|
||||||
></el-input>
|
></el-input>
|
||||||
</el-form-item> -->
|
|
||||||
<el-form-item>
|
|
||||||
<!-- <el-button @click="getDataList()">查询</el-button> -->
|
|
||||||
<!-- <el-form-item>
|
|
||||||
<el-radio v-model="dataForm.status" label="0">正常</el-radio>
|
|
||||||
<el-radio v-model="dataForm.status" label="1">待审核</el-radio>
|
|
||||||
<el-radio v-model="dataForm.status" label="2">已下架</el-radio>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-button @click="getDataList()">查询</el-button> -->
|
<el-form-item>
|
||||||
|
<!-- 选择框 -->
|
||||||
|
<el-select v-model="dataForm.status" clearable placeholder="请选择状态">
|
||||||
|
<el-option
|
||||||
|
v-for="item in options"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value">
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
|
||||||
|
<el-button @click="getDataList()">查询</el-button>
|
||||||
|
<el-button @click="refresh()">重置</el-button>
|
||||||
|
|
||||||
<!-- <el-button
|
<!-- <el-button
|
||||||
v-if="isAuth('admin:post:delete')"
|
v-if="isAuth('admin:post:delete')"
|
||||||
@ -123,20 +128,6 @@
|
|||||||
label="文件"
|
label="文件"
|
||||||
>
|
>
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<!-- <img
|
|
||||||
v-if="scope.row.type == 1 && scope.row.media[0]"
|
|
||||||
style="width: 80px; height: 50px"
|
|
||||||
:src="scope.row.media[0]"
|
|
||||||
/> -->
|
|
||||||
<!-- <video
|
|
||||||
v-if="scope.row.type == 2"
|
|
||||||
class="myVideo"
|
|
||||||
id="myVideo"
|
|
||||||
:src="scope.row.media[0]"
|
|
||||||
enable-danmu
|
|
||||||
danmu-btn
|
|
||||||
controls
|
|
||||||
></video> -->
|
|
||||||
<el-button v-if="scope.row.type == 2" type="text" @click="openVideo(scope.row.media[0])">点击预览</el-button>
|
<el-button v-if="scope.row.type == 2" type="text" @click="openVideo(scope.row.media[0])">点击预览</el-button>
|
||||||
<el-button v-if="scope.row.type == 1 && scope.row.media[0]" type="text" @click="openPic(scope.row.media)">点击查看</el-button>
|
<el-button v-if="scope.row.type == 1 && scope.row.media[0]" type="text" @click="openPic(scope.row.media)">点击查看</el-button>
|
||||||
</template>
|
</template>
|
||||||
@ -162,13 +153,13 @@
|
|||||||
label="点赞数"
|
label="点赞数"
|
||||||
>
|
>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<!-- <el-table-column
|
<el-table-column
|
||||||
prop="discussTitle"
|
prop="discussTitle"
|
||||||
header-align="center"
|
header-align="center"
|
||||||
align="center"
|
align="center"
|
||||||
label="话题"
|
label="话题"
|
||||||
>
|
>
|
||||||
</el-table-column> -->
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="postTop"
|
prop="postTop"
|
||||||
header-align="center"
|
header-align="center"
|
||||||
@ -334,6 +325,17 @@ export default {
|
|||||||
dialogVisible2: false,
|
dialogVisible2: false,
|
||||||
videoUrl:"",
|
videoUrl:"",
|
||||||
media: [],
|
media: [],
|
||||||
|
options: [{
|
||||||
|
value: 0,
|
||||||
|
label: '正常'
|
||||||
|
}, {
|
||||||
|
value: 1,
|
||||||
|
label: '待审核'
|
||||||
|
}, {
|
||||||
|
value: 2,
|
||||||
|
label: '已下架'
|
||||||
|
}],
|
||||||
|
// value: ''
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
@ -343,6 +345,13 @@ export default {
|
|||||||
this.getDataList();
|
this.getDataList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
refresh(){
|
||||||
|
this.dataForm.key='';
|
||||||
|
this.dataForm.status='';
|
||||||
|
this.pageIndex=1;
|
||||||
|
this.pageSize=10;
|
||||||
|
this.getDataList();
|
||||||
|
},
|
||||||
// 获取数据列表
|
// 获取数据列表
|
||||||
getDataList() {
|
getDataList() {
|
||||||
this.dataListLoading = true;
|
this.dataListLoading = true;
|
||||||
@ -352,8 +361,8 @@ export default {
|
|||||||
params: this.$http.adornParams({
|
params: this.$http.adornParams({
|
||||||
page: this.pageIndex,
|
page: this.pageIndex,
|
||||||
limit: this.pageSize,
|
limit: this.pageSize,
|
||||||
// key: this.dataForm.key,
|
key: this.dataForm.key,
|
||||||
// status:this.dataForm.status
|
status:this.dataForm.status
|
||||||
}),
|
}),
|
||||||
}).then(({ data }) => {
|
}).then(({ data }) => {
|
||||||
if (data && data.code === 0) {
|
if (data && data.code === 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user