Commit c915b558 authored by 刘基明's avatar 刘基明

点赞收藏相关

parent cee42399
package com.tanpu.community.api.constants;
public enum BlockTypeEnum {
USER(1,"屏蔽用户"),CONTENT(2,"屏蔽内容");
private Integer code;
private String type;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
BlockTypeEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
}
......@@ -43,6 +43,13 @@
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<!-- mybatis-plus自动生成所需包-->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.3</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-consul-discovery</artifactId>-->
......
package com.tanpu.community.controller;
import com.alibaba.fastjson.JSON;
import com.tanpu.community.dao.entity.community.FansRelEntity;
import com.tanpu.community.manager.HomePageManager;
import com.tanpu.community.model.req.homepage.AddIdolReq;
......@@ -38,4 +37,12 @@ public class HomePageController {
return "11";
}
@PostMapping(value = "/query/likeTheme")
@ApiOperation("我的点赞")
@ResponseBody
public String likeList(){
String userId="123";
return "success";
}
}
package com.tanpu.community.controller;
import com.tanpu.community.service.RedisService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@RequestMapping(value = "/metric")
public class MetricsController {
@Autowired
private RedisService redisService;
@ApiOperation("浏览量埋点")
@RequestMapping("/pv")
public void pageView(@RequestParam String themeId){
redisService.incr("pv"+themeId, 1L);
}
}
package com.tanpu.community.dao.mapper.community;
import com.tanpu.community.dao.entity.community.BlackListEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 黑名单 Mapper 接口
* </p>
*
* @author xudong
* @since 2021-06-16
*/
public interface BlackListMapper extends BaseMapper<BlackListEntity> {
}
......@@ -2,7 +2,6 @@ package com.tanpu.community.dao.mapper.community;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
......
......@@ -2,7 +2,6 @@ package com.tanpu.community.dao.mapper.community;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
......@@ -12,7 +11,6 @@ import org.apache.ibatis.annotations.Mapper;
* @author xudong
* @since 2021-06-10
*/
@Mapper
public interface TopicMapper extends BaseMapper<TopicEntity> {
}
package com.tanpu.community.manager;
import com.tanpu.community.api.constants.BlockTypeEnum;
import com.tanpu.community.api.constants.CollectionTypeEnum;
import com.tanpu.community.api.constants.CommentTypeEnum;
import com.tanpu.community.dao.entity.community.CollectionEntity;
import com.tanpu.community.dao.entity.community.CommentEntity;
import com.tanpu.community.dao.entity.community.FansRelEntity;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.service.CollectionService;
import com.tanpu.community.service.CommentService;
import com.tanpu.community.service.FansRelService;
import com.tanpu.community.service.ThemeService;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.tomcat.jni.Local;
import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -34,15 +27,18 @@ public class ThemeManager {
@Autowired
private FansRelService fansRelService;
@Autowired
private BlackListService blackListService;
//返回推荐主题文章
public List<ThemeEntity> selectHotThemes(){
//TOTO:根据算法计算推荐主题
return null;
}
//返回关注主题
public List<ThemeEntity> selectInterestThemes(String userId){
List<String> fansRelEntities = fansRelService.queryFansByFollowerId(userId).stream().map(FansRelEntity::getIdolId).collect(Collectors.toList());
return null;
}
......@@ -87,12 +83,25 @@ public class ThemeManager {
collectionEntity.setCreateTime(LocalDateTime.now());
collectionService.insertCollection(collectionEntity);
}
//投诉
//投诉(主题)
public void complaint(String themeId, String user) {
}
//屏蔽
public void conceal(String themeId, String user) {
//屏蔽(用户)
public void blockUser(String themeId, String userId) {
BlackListEntity blackListEntity = new BlackListEntity();
blackListEntity.setBlockedId(themeService.selectTheme(themeId).getAuthorId());
blackListEntity.setBlocker(userId);
blackListEntity.setBlockedType(BlockTypeEnum.USER.getCode());
blackListService.insertBlackList(blackListEntity);
}
//屏蔽(内容)
public void blockContent(String themeId, String userId) {
BlackListEntity blackListEntity = new BlackListEntity();
blackListEntity.setBlockedId(themeId);
blackListEntity.setBlocker(userId);
blackListEntity.setBlockedType(BlockTypeEnum.CONTENT.getCode());
blackListService.insertBlackList(blackListEntity);
}
}
package com.tanpu.community.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanpu.community.dao.entity.community.BlackListEntity;
import com.tanpu.community.dao.mapper.community.BlackListMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class BlackListService {
@Resource
private BlackListMapper blackListMapper;
public void insertBlackList(BlackListEntity blackListEntity){
blackListMapper.insert(blackListEntity);
}
public void deleteBlackList(String blocker,String blockId,String blockType){
blackListMapper.delete(new LambdaQueryWrapper<BlackListEntity>().eq(BlackListEntity::getBlocker,blocker).
eq(BlackListEntity::getBlockedId,blockId).eq(BlackListEntity::getBlockedType,blockType));
return;
}
}
package com.tanpu.community.service;
import com.tanpu.common.exception.BizException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
......@@ -45,4 +45,26 @@ public class RedisService {
Object v = redisTemplate.opsForValue().get(key);
return v == null ? null : (Integer) v;
}
/**
* incr
*/
public long incr(String key,Long delta){
if (delta<0){
throw new BizException("递增银子必须大于0");
}
return redisTemplate.opsForValue().increment(key,delta);
}
/**
* incr
*/
public long decr(String key,Long delta){
if (delta<0){
throw new BizException("递减银子必须大于0");
}
return redisTemplate.opsForValue().decrement(key,delta);
}
}
......@@ -111,7 +111,7 @@ CREATE TABLE `file_record` (
CREATE TABLE `black_list` (
`id` varchar(64) PRIMARY KEY COMMENT 'id',
`blocker` varchar(64) NOT NULL COMMENT '屏蔽发起人',
`blocked_type` int(4) NOT NULL COMMENT '屏蔽类型',
`blocked_type` int(4) NOT NULL COMMENT '屏蔽类型,1:用户,2:内容',
`blocked_id` varchar(64) NOT NULL COMMENT '被屏蔽的',
`create_by` varchar(64) DEFAULT '',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
......
......@@ -36,7 +36,7 @@
<dependency>
<groupId>com.tanpu</groupId>
<artifactId>common</artifactId>
<version>1.0.3-RELEASE</version>
<version>1.0.4-RELEASE</version>
</dependency>
<dependency>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment