后台新增评论统计&微信登录封装
This commit is contained in:
parent
d99d2fbec1
commit
bc6121380e
@ -38,8 +38,7 @@ public class Constant {
|
||||
|
||||
public static final String ORDER_DESC_READCOUNT = "read_count desc";
|
||||
|
||||
public static final Integer NOT_READ = 0;
|
||||
public static final Integer HAS_READ = 1;
|
||||
|
||||
|
||||
/**
|
||||
* 用户是否禁用
|
||||
@ -48,6 +47,14 @@ public class Constant {
|
||||
public static final Integer USER_BANNER = 1;
|
||||
|
||||
|
||||
/**
|
||||
* 评论状态
|
||||
* 0 下架 1正常
|
||||
*/
|
||||
public static final Integer COMMENT_DOWN = 0;
|
||||
public static final Integer COMMENT_NORMAL = 1;
|
||||
|
||||
|
||||
/**
|
||||
* 手机验证码长度
|
||||
*/
|
||||
|
@ -45,5 +45,10 @@ public class HomeRateResponse implements Serializable {
|
||||
@ApiModelProperty(value = "昨日新增用户")
|
||||
private Object yesterdayNewUserNum;
|
||||
|
||||
@ApiModelProperty(value = "昨日评论数量")
|
||||
private Object yesterdayCommentCount;
|
||||
|
||||
@ApiModelProperty(value = "评论数量")
|
||||
private Object commentCount;
|
||||
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ public class CommentEntity implements Serializable {
|
||||
private String content;
|
||||
/**
|
||||
* 评论状态
|
||||
* 0 下架 1正常
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
|
@ -38,5 +38,9 @@ public interface CommentService extends IService<CommentEntity> {
|
||||
Integer getCountByPostId(Integer id);
|
||||
|
||||
AppPageUtils queryCommentPage(Integer postId, Integer page);
|
||||
|
||||
Integer getYesterdayCount();
|
||||
|
||||
Integer getAllCount();
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,9 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
|
||||
@Autowired
|
||||
private SystemService systemService;
|
||||
|
||||
@Autowired
|
||||
private CommentService commentService;
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
@ -125,7 +128,6 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
|
||||
public HomeRateResponse indexDate() {
|
||||
String today = cn.hutool.core.date.DateUtil.date().toString("yyyy-MM-dd");
|
||||
String yesterday = cn.hutool.core.date.DateUtil.yesterday().toString("yyyy-MM-dd");
|
||||
// Integer count = postService.lambdaQuery().eq(PostEntity::getStatus, Constant.POST_REVIEWED).count();
|
||||
Integer postCount = postService.lambdaQuery().select(PostEntity::getId).count();
|
||||
HomeRateResponse response = new HomeRateResponse();
|
||||
response.setTotalPostOfReview(0);
|
||||
@ -133,6 +135,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
|
||||
response.setNewUserNum(this.getRegisterNumByDate(today));
|
||||
response.setYesterdayNewUserNum(this.getRegisterNumByDate(yesterday));
|
||||
response.setTotalUser(this.getTotalNum());
|
||||
response.setYesterdayCommentCount(commentService.getYesterdayCount());
|
||||
response.setCommentCount(commentService.getAllCount());
|
||||
return response;
|
||||
}
|
||||
|
||||
@ -295,27 +299,10 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
|
||||
@Override
|
||||
public Integer miniWxLogin(WxLoginForm form) {
|
||||
|
||||
SystemEntity system = systemService.lambdaQuery().eq(SystemEntity::getConfig, "miniapp").one();
|
||||
|
||||
//小程序唯一标识 (在微信小程序管理后台获取)
|
||||
String appId = system.getValue();
|
||||
//小程序的 app secret (在微信小程序管理后台获取)
|
||||
String secret = system.getExtend();
|
||||
//授权(必填)
|
||||
String grant_type = "authorization_code";
|
||||
//https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code
|
||||
//向微信服务器 使用登录凭证 code 获取 session_key 和 openid
|
||||
String params = "appid=" + appId + "&secret=" + secret + "&js_code=" + form.getCode() + "&grant_type=" + grant_type;
|
||||
//发送请求
|
||||
String sr = HttpRequest.sendGet("https://api.weixin.qq.com/sns/jscode2session", params);
|
||||
//解析相应内容(转换成json对象)
|
||||
JSONObject json = JSON.parseObject(sr);
|
||||
//用户的唯一标识(openId)
|
||||
String openId = (String) json.get("openid");
|
||||
String openId = getOpenId(form.getCode());
|
||||
//根据openId获取数据库信息 判断用户是否登录
|
||||
AppUserEntity user = this.lambdaQuery().eq(AppUserEntity::getOpenid, openId).one();
|
||||
if (ObjectUtil.isNotNull(user)) {
|
||||
//已登录用户
|
||||
if (user.getStatus() == 1) {
|
||||
throw new LinfengException("该账户已被禁用");
|
||||
}
|
||||
@ -376,4 +363,24 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
|
||||
return userDao.selectCount(wrapper);
|
||||
}
|
||||
|
||||
private String getOpenId(String code){
|
||||
SystemEntity system = systemService.lambdaQuery().eq(SystemEntity::getConfig, "miniapp").one();
|
||||
|
||||
//小程序唯一标识 (在微信小程序管理后台获取)
|
||||
String appId = system.getValue();
|
||||
//小程序的 app secret (在微信小程序管理后台获取)
|
||||
String secret = system.getExtend();
|
||||
//授权(必填)
|
||||
String grant_type = "authorization_code";
|
||||
//https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code
|
||||
//向微信服务器 使用登录凭证 code 获取 session_key 和 openid
|
||||
String params = "appid=" + appId + "&secret=" + secret + "&js_code=" + code + "&grant_type=" + grant_type;
|
||||
//发送请求
|
||||
String sr = HttpRequest.sendGet("https://api.weixin.qq.com/sns/jscode2session", params);
|
||||
//解析相应内容(转换成json对象)
|
||||
JSONObject json = JSON.parseObject(sr);
|
||||
//用户的唯一标识(openId)
|
||||
return (String) json.get("openid");
|
||||
}
|
||||
|
||||
}
|
@ -12,8 +12,11 @@
|
||||
*/
|
||||
package io.linfeng.modules.admin.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.linfeng.common.utils.Constant;
|
||||
import io.linfeng.common.vo.AppCommentResponse;
|
||||
import io.linfeng.common.utils.AppPageUtils;
|
||||
import io.linfeng.modules.admin.entity.AppUserEntity;
|
||||
@ -62,7 +65,7 @@ public class CommentServiceImpl extends ServiceImpl<CommentDao, CommentEntity> i
|
||||
@Override
|
||||
public Integer getCountByTopicId(Integer id) {
|
||||
return baseMapper.selectCount(new LambdaQueryWrapper<CommentEntity>()
|
||||
.eq(CommentEntity::getStatus,1)
|
||||
.eq(CommentEntity::getStatus, Constant.COMMENT_NORMAL)
|
||||
.eq(CommentEntity::getPostId, id));
|
||||
}
|
||||
|
||||
@ -78,7 +81,7 @@ public class CommentServiceImpl extends ServiceImpl<CommentDao, CommentEntity> i
|
||||
this.removeById(id);
|
||||
//子评论更改展示状态为屏蔽
|
||||
this.lambdaUpdate()
|
||||
.set(CommentEntity::getStatus, 0)
|
||||
.set(CommentEntity::getStatus, Constant.COMMENT_DOWN)
|
||||
.eq(CommentEntity::getPid, id)
|
||||
.update();
|
||||
});
|
||||
@ -89,7 +92,7 @@ public class CommentServiceImpl extends ServiceImpl<CommentDao, CommentEntity> i
|
||||
public Integer getCountByPostId(Integer id) {
|
||||
return baseMapper.selectCount(
|
||||
new LambdaQueryWrapper<CommentEntity>()
|
||||
.eq(CommentEntity::getStatus, 1)
|
||||
.eq(CommentEntity::getStatus, Constant.COMMENT_NORMAL)
|
||||
.eq(CommentEntity::getPostId, id));
|
||||
}
|
||||
|
||||
@ -98,7 +101,7 @@ public class CommentServiceImpl extends ServiceImpl<CommentDao, CommentEntity> i
|
||||
Page<CommentEntity> commentPage = new Page<>(page,10);
|
||||
QueryWrapper<CommentEntity> queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CommentEntity::getPostId,postId);
|
||||
queryWrapper.lambda().eq(CommentEntity::getStatus,1);
|
||||
queryWrapper.lambda().eq(CommentEntity::getStatus, Constant.COMMENT_NORMAL);
|
||||
Page<CommentEntity> pages = baseMapper.selectPage(commentPage,queryWrapper);
|
||||
AppPageUtils appPage=new AppPageUtils(pages);
|
||||
List<CommentEntity> data = (List<CommentEntity>) appPage.getData();
|
||||
@ -122,4 +125,25 @@ public class CommentServiceImpl extends ServiceImpl<CommentDao, CommentEntity> i
|
||||
appPage.setData(responseList);
|
||||
return appPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取昨天评论数
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Integer getYesterdayCount() {
|
||||
DateTime yesterday = DateUtil.yesterday();
|
||||
return this.lambdaQuery()
|
||||
.ge(CommentEntity::getCreateTime,yesterday)
|
||||
.eq(CommentEntity::getStatus, Constant.COMMENT_NORMAL)
|
||||
.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getAllCount() {
|
||||
return this.lambdaQuery()
|
||||
.eq(CommentEntity::getStatus, Constant.COMMENT_NORMAL)
|
||||
.count();
|
||||
}
|
||||
|
||||
}
|
@ -5,16 +5,16 @@
|
||||
<el-card :bordered="false" dis-hover :padding="12">
|
||||
<div class="acea-row row-between-wrapper">
|
||||
<div class="acea-row align-center">
|
||||
<span class="main_tit">会员充值</span>
|
||||
<span class="main_tit">评论数量</span>
|
||||
</div>
|
||||
<el-tag type="primary">今日</el-tag>
|
||||
<el-tag type="primary">近一天</el-tag>
|
||||
</div>
|
||||
<div class="content" v-if="viewData">
|
||||
<span class="content-number spBlock my15">0</span>
|
||||
<span class="content-number spBlock my15">{{viewData.yesterdayCommentCount}}</span>
|
||||
<el-divider></el-divider>
|
||||
<div class="acea-row row-between-wrapper">
|
||||
<span class="content-time">昨日数据</span>
|
||||
<span class="content-time">0 元</span>
|
||||
<span class="content-time">总评论</span>
|
||||
<span class="content-time">{{viewData.commentCount}}条</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
@ -253,18 +253,17 @@
|
||||
</span>
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
title="图片预览"
|
||||
title="图片预览(点击查看)"
|
||||
:visible.sync="dialogVisible2"
|
||||
width="60%"
|
||||
:before-close="handleClose"
|
||||
>
|
||||
<div class="position">图片展示</div>
|
||||
<div class="images">
|
||||
<div v-for="(item, index) in media" :key="index" class="image-middle">
|
||||
<el-card shadow="hover" :body-style="{ padding: '10px' }" >
|
||||
<img :src="media[index]" class="image" @click="goPic(media[index])"/>
|
||||
<div style="text-align:center;padding-top:12px">
|
||||
<span>图{{index}}</span>
|
||||
<span>图{{index+1}}</span>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user