完善需求和逻辑问题

This commit is contained in:
easonzhu 2025-02-10 14:47:05 +08:00
parent 94383b9e23
commit 9ef12e0a82
33 changed files with 642 additions and 191 deletions

34
deploy.bat Normal file
View File

@ -0,0 +1,34 @@
@echo off
:: 1. 运行 Maven 打包
echo Running mvn clean package...
:: call mvn clean package -P thin-jar
call mvn clean package
:: 检查是否打包成功
IF %ERRORLEVEL% NEQ 0 (
echo Maven build failed, exiting...
exit /b %ERRORLEVEL%
)
:: 2. 将 JAR 包传输到 Linux 服务器
echo Copying JAR file to Linux server...
call scp target\AdvisorServer-2.6.7.jar root@8.138.144.54:/root
:: 检查 SCP 命令是否成功
IF %ERRORLEVEL% NEQ 0 (
echo File transfer failed, exiting...
exit /b %ERRORLEVEL%
)
:: 3. 通过 SSH 运行 start.sh 脚本
echo Running start.sh script on Linux server...
call ssh root@8.138.144.54 'bash /root/start.sh'
:: 检查 SSH 命令是否成功
IF %ERRORLEVEL% NEQ 0 (
echo Failed to start the application, exiting...
exit /b %ERRORLEVEL%
)
echo Deployment successful!

23
pom.xml
View File

@ -185,4 +185,27 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<profiles>
<profile>
<id>thin-jar</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.upchina.startup.Main</mainClass>
<layout>ZIP</layout>
<includes>
<include>
<groupId>nothing</groupId>
<artifactId>nothing</artifactId>
</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> </project>

View File

@ -324,6 +324,7 @@ public class CacheKey {
public static final String COMMENT_BLACK = "comment_black"; public static final String COMMENT_BLACK = "comment_black";
public static class CommentBlackKey { public static class CommentBlackKey {
public static final String ALL_BLACK_COMMENT = "all_black_comment";
public static final String ALL_BLACK_USER = "all_black_user"; public static final String ALL_BLACK_USER = "all_black_user";
} }

View File

@ -0,0 +1,28 @@
package com.upchina.common.constant;
// 范围类型 1产品 2产品类型 3全局
public enum CommentBlackScope {
PRODUCT(1, "产品"),
PRODUCT_TYPE(2, "产品类型"),
GLOBAL(3, "全局"),
;
public final Integer value;
public final String name;
CommentBlackScope(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
}

View File

@ -2,6 +2,7 @@ package com.upchina.common.controller;
import com.upchina.common.query.AddCommentBlackQuery; import com.upchina.common.query.AddCommentBlackQuery;
import com.upchina.common.query.CommentBlackQuery; import com.upchina.common.query.CommentBlackQuery;
import com.upchina.common.query.RemoveCommentBlackQuery;
import com.upchina.common.result.CommonResult; import com.upchina.common.result.CommonResult;
import com.upchina.common.result.Pager; import com.upchina.common.result.Pager;
import com.upchina.common.service.CommentBlackService; import com.upchina.common.service.CommentBlackService;
@ -27,18 +28,20 @@ public class CommentBlackController {
@ApiOperation("添加用户禁言") @ApiOperation("添加用户禁言")
@PostMapping("/admin/comment/addCommentBlack") @PostMapping("/admin/comment/addCommentBlack")
public CommonResult<Integer> addCommentBlack(@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO, public CommonResult<Integer> addCommentBlack(@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO,
@Validated @RequestBody AddCommentBlackQuery addCommentBlackQuery) { @Validated @RequestBody AddCommentBlackQuery query) {
Integer id = commentBlackService.addCommentBlack(backendUserVO, addCommentBlackQuery); Integer id = commentBlackService.addCommentBlack(backendUserVO, query);
return CommonResult.success(id); return CommonResult.success(id);
} }
@ApiOperation("解除用户禁言") @ApiOperation("解除用户禁言")
@GetMapping("/admin/comment/removeCommentBlack") @GetMapping("/admin/comment/removeCommentBlack")
public CommonResult<Void> removeCommentBlack(@NotNull @ApiParam(value = "用户手机号") @RequestParam("phone") String phone) { public CommonResult<Void> removeCommentBlack(@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO,
commentBlackService.removeCommentBlack(phone); @Validated @RequestBody RemoveCommentBlackQuery query) {
commentBlackService.removeCommentBlack(backendUserVO, query);
return CommonResult.success(); return CommonResult.success();
} }
@ApiOperation("中台查询禁言列表") @ApiOperation("中台查询禁言列表")
@PostMapping("/admin/comment/queryCommentBlackList") @PostMapping("/admin/comment/queryCommentBlackList")
public CommonResult<Pager<CommentBlackVO>> queryCommentBlackList(@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO, public CommonResult<Pager<CommentBlackVO>> queryCommentBlackList(@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO,

View File

@ -63,10 +63,15 @@ public class CommentBlack implements Serializable {
private String attachment; private String attachment;
/** /**
* 禁言类型0次日解禁 1一个月之后解禁 2永久禁言 * 时间类型0次日解禁 1一个月之后解禁 2永久禁言
*/ */
private Integer type; private Integer type;
/**
* 范围类型 1产品 2产品类型 3全局
*/
private Integer scope;
/** /**
* 禁言开始时间 * 禁言开始时间
*/ */
@ -174,6 +179,14 @@ public class CommentBlack implements Serializable {
this.type = type; this.type = type;
} }
public Integer getScope() {
return scope;
}
public void setScope(Integer scope) {
this.scope = scope;
}
public LocalDateTime getStartTime() { public LocalDateTime getStartTime() {
return startTime; return startTime;
} }

View File

@ -27,40 +27,30 @@ public class WebSocketAuthHandler {
private Set<Integer> VALID_PRODUCT_TYPES = ImmutableSet.of(ProductType.VIDEO_SINGLE.value, ProductType.GROUP.value); private Set<Integer> VALID_PRODUCT_TYPES = ImmutableSet.of(ProductType.VIDEO_SINGLE.value, ProductType.GROUP.value);
public Message<?> handleConnect(Message<?> message, StompHeaderAccessor header) { public Message<?> handleConnect(Message<?> message, StompHeaderAccessor header) {
validateHeaders(header);
Map<String, Object> attributes = header.getSessionAttributes(); Map<String, Object> attributes = header.getSessionAttributes();
if (attributes == null) {
throw new BizException(ResponseStatus.PARM_ERROR, "header里没有包含attributes");
}
String userId = authenticateUser(header); String userId = authenticateUser(header);
if (userId == null) { if (userId == null) {
throw new BizException(ResponseStatus.SESSION_EXPIRY); throw new BizException(ResponseStatus.SESSION_EXPIRY);
} }
String sessionId = header.getFirstNativeHeader("sessionId"); String sessionId = header.getFirstNativeHeader("sessionId");
if (StrUtil.isEmpty(sessionId)) {
throw new BizException(ResponseStatus.PARM_ERROR, "sessionId错误" + sessionId);
}
Integer productType = getInteger(header, "productType"); Integer productType = getInteger(header, "productType");
if (productType == null || !VALID_PRODUCT_TYPES.contains(productType)) { if (productType == null || !VALID_PRODUCT_TYPES.contains(productType)) {
throw new BizException(ResponseStatus.PARM_ERROR, "产品类型错误" + productType); throw new BizException(ResponseStatus.PARM_ERROR, "产品类型错误" + productType);
} }
Integer productId = getInteger(header, "productId"); Integer productId = getInteger(header, "productId");
if (productId == null) {
throw new BizException(ResponseStatus.PARM_ERROR, "产品ID错误" + productId);
}
populateAttributes(attributes, userId, sessionId, productType, productId); populateAttributes(attributes, userId, sessionId, productType, productId);
return message; return message;
} }
private void validateHeaders(StompHeaderAccessor header) {
String sessionId = header.getFirstNativeHeader("sessionId");
if (StrUtil.isEmpty(sessionId)) {
throw new BizException(ResponseStatus.PARM_ERROR, "header里没有包含sessionId");
}
String groupId = header.getFirstNativeHeader("GroupId");
if (StrUtil.isEmpty(groupId)) {
throw new BizException(ResponseStatus.PARM_ERROR, "header里没有包含videoId");
}
if (header.getSessionAttributes() == null) {
throw new BizException(ResponseStatus.PARM_ERROR, "header里没有包含attributes");
}
}
private String authenticateUser(StompHeaderAccessor header) { private String authenticateUser(StompHeaderAccessor header) {
String authorization = header.getFirstNativeHeader("Authorization"); String authorization = header.getFirstNativeHeader("Authorization");
if (StrUtil.isNotEmpty(authorization)) { if (StrUtil.isNotEmpty(authorization)) {

View File

@ -40,10 +40,17 @@ public class AddCommentBlackQuery {
@Max(2) @Max(2)
private Integer type; private Integer type;
@ApiModelProperty("范围类型 1产品 2产品类型 3全局")
@NotNull
@Min(1)
@Max(3)
private Integer scope;
public String getUserPhone() { public String getUserPhone() {
return userPhone; return userPhone;
} }
public void setUserPhone(String userPhone) { public void setUserPhone(String userPhone) {
this.userPhone = userPhone; this.userPhone = userPhone;
} }
@ -103,4 +110,12 @@ public class AddCommentBlackQuery {
public void setType(Integer type) { public void setType(Integer type) {
this.type = type; this.type = type;
} }
public Integer getScope() {
return scope;
}
public void setScope(Integer scope) {
this.scope = scope;
}
} }

View File

@ -48,8 +48,15 @@ public class CommentBlackQuery extends PageQuery {
private String endOpTime; private String endOpTime;
@ApiModelProperty("禁言类型0次日解禁 1一个月之后解禁 2永久禁言,不传查全部") @ApiModelProperty("禁言类型0次日解禁 1一个月之后解禁 2永久禁言,不传查全部")
@Min(0)
@Max(2)
private Integer type; private Integer type;
@ApiModelProperty("范围类型 1产品 2产品类型 3全局")
@Min(1)
@Max(3)
private Integer scope;
public String getUserName() { public String getUserName() {
return userName; return userName;
} }
@ -153,4 +160,12 @@ public class CommentBlackQuery extends PageQuery {
public void setType(Integer type) { public void setType(Integer type) {
this.type = type; this.type = type;
} }
public Integer getScope() {
return scope;
}
public void setScope(Integer scope) {
this.scope = scope;
}
} }

View File

@ -0,0 +1,46 @@
package com.upchina.common.query;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import io.swagger.annotations.ApiModelProperty;
public class RemoveCommentBlackQuery {
@ApiModelProperty("产品id")
@NotNull
private Integer productId;
@ApiModelProperty("产品类型")
@NotNull
private Integer productType;
@ApiModelProperty("用户手机号")
@NotBlank
private String userPhone;
public Integer getProductId() {
return productId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public Integer getProductType() {
return productType;
}
public void setProductType(Integer productType) {
this.productType = productType;
}
public String getUserPhone() {
return userPhone;
}
public void setUserPhone(String userPhone) {
this.userPhone = userPhone;
}
}

View File

@ -1,6 +1,5 @@
package com.upchina.common.service; package com.upchina.common.service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -9,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Table; import com.google.common.collect.Table;
import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.map.IMap; import com.hazelcast.map.IMap;
import com.upchina.common.constant.CommentBlackScope;
import com.upchina.common.constant.CommentBlackStatus; import com.upchina.common.constant.CommentBlackStatus;
import com.upchina.common.constant.CommentBlackType; import com.upchina.common.constant.CommentBlackType;
import com.upchina.common.entity.CommentBlack; import com.upchina.common.entity.CommentBlack;
@ -17,6 +17,7 @@ import com.upchina.common.mapper.CommentBlackMapper;
import com.upchina.common.query.AddCommentBlackQuery; import com.upchina.common.query.AddCommentBlackQuery;
import com.upchina.common.query.BaseProductQuery; import com.upchina.common.query.BaseProductQuery;
import com.upchina.common.query.CommentBlackQuery; import com.upchina.common.query.CommentBlackQuery;
import com.upchina.common.query.RemoveCommentBlackQuery;
import com.upchina.common.result.Pager; import com.upchina.common.result.Pager;
import com.upchina.common.result.ResponseStatus; import com.upchina.common.result.ResponseStatus;
import com.upchina.common.util.HideUtils; import com.upchina.common.util.HideUtils;
@ -26,11 +27,9 @@ import com.upchina.common.vo.CommentBlackVO;
import com.upchina.common.vo.MergeProductInfoVO; import com.upchina.common.vo.MergeProductInfoVO;
import com.upchina.rbac.entity.Dept; import com.upchina.rbac.entity.Dept;
import com.upchina.rbac.entity.UserDept; import com.upchina.rbac.entity.UserDept;
import com.upchina.rbac.service.AuthService;
import com.upchina.rbac.service.DeptService; import com.upchina.rbac.service.DeptService;
import com.upchina.rbac.service.UserService; import com.upchina.rbac.service.UserService;
import ma.glasnost.orika.MapperFacade; import ma.glasnost.orika.MapperFacade;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -42,17 +41,12 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.upchina.common.config.cache.CacheKey.COMMENT_BLACK; import static com.upchina.common.config.cache.CacheKey.COMMENT_BLACK;
import static com.upchina.common.config.cache.CacheKey.CommentBlackKey.ALL_BLACK_COMMENT;
import static com.upchina.common.config.cache.CacheKey.CommentBlackKey.ALL_BLACK_USER; import static com.upchina.common.config.cache.CacheKey.CommentBlackKey.ALL_BLACK_USER;
@Service @Service
public class CommentBlackService { public class CommentBlackService {
@Value("${rsa.priKey}")
private String ypPriKey;
@Value("${rsa.pubKey}")
private String ypPubKey;
@Resource @Resource
private MapperFacade mapperFacade; private MapperFacade mapperFacade;
@ -71,40 +65,14 @@ public class CommentBlackService {
@Resource @Resource
private CacheService cacheService; private CacheService cacheService;
@Resource
private AuthService authService;
@Resource @Resource
private DeptService deptService; private DeptService deptService;
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
public Set<String> getAllBlackUser() {
LocalDateTime now = LocalDateTime.now();
List<CommentBlack> list = cacheService.get(COMMENT_BLACK, ALL_BLACK_USER, () -> {
QueryWrapper<CommentBlack> wrapper = Wrappers.query();
wrapper.in("status", Arrays.asList(CommentBlackStatus.EFFECT.value, CommentBlackStatus.EXPIRED.value));
List<CommentBlack> commentBlackList = commentBlackMapper.selectList(wrapper);
LoggerUtil.info("db当前黑名单用户" + JSONObject.toJSONString(commentBlackList));
if (CollectionUtils.isEmpty(commentBlackList)) {
return null;
}
return commentBlackList;
});
if (CollUtil.isEmpty(list)) {
return null;
}
Set<String> set = list.stream()
.filter(black -> now.isAfter(black.getStartTime()) && now.isBefore(black.getEndTime()))
.map(CommentBlack::getPhone).collect(Collectors.toSet());
LoggerUtil.info("当前黑名单用户:" + JSONObject.toJSONString(set));
return set;
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Integer addCommentBlack(BackendUserVO backendUserVO, AddCommentBlackQuery addCommentBlackQuery) { public Integer addCommentBlack(BackendUserVO backendUserVO, AddCommentBlackQuery query) {
// String userPhone = RsaUtil.priKeyDecryption(ypPriKey, addCommentBlackQuery.getUserPhone()); String userPhone = query.getUserPhone();
String userPhone = addCommentBlackQuery.getUserPhone();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
//禁言开始时间-1s //禁言开始时间-1s
now = now.minusSeconds(1L); now = now.minusSeconds(1L);
@ -117,8 +85,8 @@ public class CommentBlackService {
if (validSize > 0) { if (validSize > 0) {
throw new BizException(ResponseStatus.REPETITIVE_ERROR); throw new BizException(ResponseStatus.REPETITIVE_ERROR);
} }
CommentBlack commentBlack = mapperFacade.map(addCommentBlackQuery, CommentBlack.class); CommentBlack commentBlack = mapperFacade.map(query, CommentBlack.class);
commentBlack.setUserName(addCommentBlackQuery.getUserName()); commentBlack.setUserName(query.getUserName());
commentBlack.setPhone(userPhone); commentBlack.setPhone(userPhone);
commentBlack.setStartTime(now); commentBlack.setStartTime(now);
commentBlack.setStatus(CommentBlackStatus.EFFECT.value); commentBlack.setStatus(CommentBlackStatus.EFFECT.value);
@ -136,15 +104,17 @@ public class CommentBlackService {
if (count < 1) { if (count < 1) {
throw new BizException(ResponseStatus.DB_SAVE_ERROR); throw new BizException(ResponseStatus.DB_SAVE_ERROR);
} }
this.clearCache(Collections.singletonList(ALL_BLACK_USER)); this.clearCache(ALL_BLACK_USER, ALL_BLACK_COMMENT);
return commentBlack.getId(); return commentBlack.getId();
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void removeCommentBlack(String phone) { public void removeCommentBlack(BackendUserVO backendUserVO, RemoveCommentBlackQuery query) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
QueryWrapper<CommentBlack> wrapper = Wrappers.query(); QueryWrapper<CommentBlack> wrapper = Wrappers.query();
wrapper.eq("phone", phone) wrapper.eq("phone", query.getUserPhone())
.eq("product_id", query.getProductId())
.eq("product_type", query.getProductType())
.in("status", Arrays.asList(CommentBlackStatus.EFFECT.value, CommentBlackStatus.EXPIRED.value)) .in("status", Arrays.asList(CommentBlackStatus.EFFECT.value, CommentBlackStatus.EXPIRED.value))
.lt("start_time", now) .lt("start_time", now)
.ge("end_time", now); .ge("end_time", now);
@ -163,46 +133,41 @@ public class CommentBlackService {
throw new BizException(ResponseStatus.DB_SAVE_ERROR); throw new BizException(ResponseStatus.DB_SAVE_ERROR);
} }
} }
this.clearCache(Collections.singletonList(ALL_BLACK_USER)); this.clearCache(ALL_BLACK_USER, ALL_BLACK_COMMENT);
} }
public Pager<CommentBlackVO> queryCommentBlackList(BackendUserVO backendUserVO, CommentBlackQuery commentBlackQuery) { public Pager<CommentBlackVO> queryCommentBlackList(BackendUserVO backendUserVO, CommentBlackQuery query) {
LocalDateTime startTime = null; LocalDateTime startTime = null;
LocalDateTime endTime = null; LocalDateTime endTime = null;
LocalDateTime startOpTime = null; LocalDateTime startOpTime = null;
LocalDateTime endOpTime = null; LocalDateTime endOpTime = null;
if (StrUtil.isNotEmpty(commentBlackQuery.getStartTime())) { if (StrUtil.isNotEmpty(query.getStartTime())) {
startTime = LocalDateTime.parse(commentBlackQuery.getStartTime(), formatter); startTime = LocalDateTime.parse(query.getStartTime(), formatter);
} }
if (StrUtil.isNotEmpty(commentBlackQuery.getEndTime())) { if (StrUtil.isNotEmpty(query.getEndTime())) {
endTime = LocalDateTime.parse(commentBlackQuery.getEndTime(), formatter); endTime = LocalDateTime.parse(query.getEndTime(), formatter);
} }
if (StrUtil.isNotEmpty(commentBlackQuery.getStartOpTime())) { if (StrUtil.isNotEmpty(query.getStartOpTime())) {
startOpTime = LocalDateTime.parse(commentBlackQuery.getStartOpTime(), formatter); startOpTime = LocalDateTime.parse(query.getStartOpTime(), formatter);
} }
if (StrUtil.isNotEmpty(commentBlackQuery.getEndOpTime())) { if (StrUtil.isNotEmpty(query.getEndOpTime())) {
endOpTime = LocalDateTime.parse(commentBlackQuery.getEndOpTime(), formatter); endOpTime = LocalDateTime.parse(query.getEndOpTime(), formatter);
} }
/*Set<Integer> advisorIdSet = authService.getAccessibleAdviserSet(null, backendUserVO, UserType.fromValue(commentBlackQuery.getUserType()));
if (advisorIdSet != null && advisorIdSet.isEmpty()) {
return Pager.emptyPager();
}*/
QueryWrapper<CommentBlack> wrapper = Wrappers.query(); QueryWrapper<CommentBlack> wrapper = Wrappers.query();
wrapper.like(StrUtil.isNotEmpty(commentBlackQuery.getUserName()), "user_name", commentBlackQuery.getUserName()) wrapper.like(StrUtil.isNotEmpty(query.getUserName()), "user_name", query.getUserName())
.eq(StrUtil.isNotEmpty(commentBlackQuery.getPhone()), "phone", commentBlackQuery.getPhone()) .eq(StrUtil.isNotEmpty(query.getPhone()), "phone", query.getPhone())
.eq(commentBlackQuery.getType() != null, "type", commentBlackQuery.getType()) .eq(query.getType() != null, "type", query.getType())
//.in(!CollectionUtils.isEmpty(advisorIdSet), "advisor_id", advisorIdSet) .eq(query.getProductType() != null, "product_type", query.getProductType())
.eq(commentBlackQuery.getProductType() != null, "product_type", commentBlackQuery.getProductType()) .eq(query.getProductType() != null && query.getProductId() != null, "product_id", query.getProductId())
.eq(commentBlackQuery.getProductType() != null && commentBlackQuery.getProductId() != null, "product_id", commentBlackQuery.getProductId()) .like(StrUtil.isNotBlank(query.getContent()), "content", query.getContent())
.like(StrUtil.isNotBlank(commentBlackQuery.getContent()), "content", commentBlackQuery.getContent()) .like(StrUtil.isNotEmpty(query.getReason()), "reason", query.getReason())
.like(StrUtil.isNotEmpty(commentBlackQuery.getReason()), "reason", commentBlackQuery.getReason()) .eq(query.getOperatorId() != null, "operator_id", query.getOperatorId())
.eq(commentBlackQuery.getOperatorId() != null, "operator_id", commentBlackQuery.getOperatorId())
.ge(startTime != null, "start_time", startTime) .ge(startTime != null, "start_time", startTime)
.lt(endTime != null, "start_time", endTime) .lt(endTime != null, "start_time", endTime)
.ge(startOpTime != null, "end_time", startOpTime) .ge(startOpTime != null, "end_time", startOpTime)
.lt(endOpTime != null, "end_time", endOpTime); .lt(endOpTime != null, "end_time", endOpTime);
wrapper.orderByDesc("start_time"); wrapper.orderByDesc("start_time");
Page<CommentBlack> page = commentBlackMapper.selectPage(commentBlackQuery.toPage(), wrapper); Page<CommentBlack> page = commentBlackMapper.selectPage(query.toPage(), wrapper);
List<CommentBlack> list = page.getRecords(); List<CommentBlack> list = page.getRecords();
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return Pager.emptyPager(); return Pager.emptyPager();
@ -246,7 +211,7 @@ public class CommentBlackService {
return new Pager<>(voList, page.getTotal()); return new Pager<>(voList, page.getTotal());
} }
private void clearCache(List<String> cacheKeys) { private void clearCache(String... cacheKeys) {
IMap<String, Object> cacheMap = hazelcastInstance.getMap(COMMENT_BLACK); IMap<String, Object> cacheMap = hazelcastInstance.getMap(COMMENT_BLACK);
for (String key : cacheKeys) { for (String key : cacheKeys) {
cacheMap.remove(key); cacheMap.remove(key);
@ -256,12 +221,50 @@ public class CommentBlackService {
/** /**
* 校验是否禁言 * 校验是否禁言
*/ */
public void check(String phone) { public boolean checkIsBlack(String phone, Integer productId, Integer productType) {
// 判断是否禁言用户 // 判断是否禁言用户
Set<String> blackUsers = getAllBlackUser(); Set<String> blackUsers = getAllBlackUser();
if (CollUtil.isNotEmpty(blackUsers) && blackUsers.contains(phone)) { if (!blackUsers.contains(phone)) {
throw new BizException("禁言用户,禁止发言"); return false;
} }
List<CommentBlack> blackComments = getAllBlackComment();
if (CollectionUtils.isEmpty(blackComments)) {
return false;
}
for (CommentBlack commentBlack : blackComments) {
if (commentBlack.getPhone().equals(phone)) {
if (CommentBlackScope.PRODUCT.value.equals(commentBlack.getScope())) {
if (commentBlack.getProductId().equals(productId) && commentBlack.getProductType().equals(productType)) {
return true;
}
} else if (CommentBlackScope.PRODUCT_TYPE.value.equals(commentBlack.getScope())) {
if (commentBlack.getProductType().equals(productType)) {
return true;
}
} else if (CommentBlackScope.GLOBAL.value.equals(commentBlack.getScope())) {
return true;
}
}
}
return false;
}
private Set<String> getAllBlackUser() {
return cacheService.get(COMMENT_BLACK, ALL_BLACK_USER, () ->
getAllBlackComment().stream().map(CommentBlack::getPhone).collect(Collectors.toSet()));
}
private List<CommentBlack> getAllBlackComment() {
LocalDateTime now = LocalDateTime.now();
return cacheService.get(COMMENT_BLACK, ALL_BLACK_COMMENT, () -> {
QueryWrapper<CommentBlack> wrapper = Wrappers.<CommentBlack>query()
.in("status", Arrays.asList(CommentBlackStatus.EFFECT.value, CommentBlackStatus.EXPIRED.value))
.lt("start_time", now)
.gt("end_time", now);
List<CommentBlack> commentBlackList = commentBlackMapper.selectList(wrapper);
LoggerUtil.info("db当前黑名单用户" + JSONObject.toJSONString(commentBlackList));
return commentBlackList;
});
} }
} }

View File

@ -29,7 +29,6 @@ import com.upchina.rbac.entity.UserDept;
import com.upchina.rbac.service.DeptService; import com.upchina.rbac.service.DeptService;
import com.upchina.rbac.service.UserService; import com.upchina.rbac.service.UserService;
import ma.glasnost.orika.MapperFacade; import ma.glasnost.orika.MapperFacade;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -47,9 +46,6 @@ import static com.upchina.common.config.cache.CacheKey.CommentKey.APP_COMMENT_SO
@Service @Service
public class CommentService { public class CommentService {
@Value("${rsa.pubKey}")
private String ypPubKey;
@Resource @Resource
private CommentMapper commentMapper; private CommentMapper commentMapper;
@ -87,7 +83,9 @@ public class CommentService {
// 敏感词判断 // 敏感词判断
sensitiveWordService.check(query.getCommentContent()); sensitiveWordService.check(query.getCommentContent());
// 判断是否禁言用户 // 判断是否禁言用户
commentBlackService.check(frontUserVO.getUserId()); if (commentBlackService.checkIsBlack(frontUserVO.getUserId(), query.getProductId(), query.getProductType())) {
throw new BizException(ResponseStatus.COMMENT_BLACK_USER_ERROR);
}
Comment comment = new Comment(); Comment comment = new Comment();
mapperFacade.map(frontUserVO, comment); mapperFacade.map(frontUserVO, comment);
mapperFacade.map(query, comment); mapperFacade.map(query, comment);
@ -201,16 +199,11 @@ public class CommentService {
Table<Integer, Integer, MergeProductInfoVO> productTable = mergeProductService.queryMergeProductInfo(baseProductQueryList); Table<Integer, Integer, MergeProductInfoVO> productTable = mergeProductService.queryMergeProductInfo(baseProductQueryList);
Map<Integer, UserDept> userMap = userService.getUserMap(); Map<Integer, UserDept> userMap = userService.getUserMap();
// 判断是否禁言用户 // 判断是否禁言用户
Set<String> blackUsers = commentBlackService.getAllBlackUser();
Map<String, Dept> deptMap = deptService.getDeptMap(); Map<String, Dept> deptMap = deptService.getDeptMap();
Map<Integer, AdvisorBasic> userIdAdvisorMap = advisorInfoService.getUserIdAdvisorMap(); Map<Integer, AdvisorBasic> userIdAdvisorMap = advisorInfoService.getUserIdAdvisorMap();
List<CommentVO> result = list.stream().map(comment -> { List<CommentVO> result = list.stream().map(comment -> {
CommentVO commentVO = mapperFacade.map(comment, CommentVO.class); CommentVO commentVO = mapperFacade.map(comment, CommentVO.class);
if (!CollectionUtils.isEmpty(blackUsers) && blackUsers.contains(commentVO.getPhone())) { commentVO.setTaboo(commentBlackService.checkIsBlack(commentVO.getPhone(), commentVO.getProductId(), commentVO.getProductType()) ? IsOrNot.IS.value : IsOrNot.NOT.value);
commentVO.setTaboo(IsOrNot.IS.value);
} else {
commentVO.setTaboo(IsOrNot.NOT.value);
}
if (commentVO.getReplyUserId() != null) { if (commentVO.getReplyUserId() != null) {
UserDept user = userMap.get(commentVO.getReplyUserId()); UserDept user = userMap.get(commentVO.getReplyUserId());
if (user != null) { if (user != null) {

View File

@ -54,6 +54,9 @@ public class CommentBlackVO extends CommonPhoneVO {
@ApiModelProperty("禁言类型0次日解禁 1一个月之后解禁 2永久禁言") @ApiModelProperty("禁言类型0次日解禁 1一个月之后解禁 2永久禁言")
private Integer type; private Integer type;
@ApiModelProperty("范围类型 1产品 2产品类型 3全局")
private Integer scope;
public String getContent() { public String getContent() {
return content; return content;
} }
@ -181,4 +184,12 @@ public class CommentBlackVO extends CommonPhoneVO {
public void setType(Integer type) { public void setType(Integer type) {
this.type = type; this.type = type;
} }
public Integer getScope() {
return scope;
}
public void setScope(Integer scope) {
this.scope = scope;
}
} }

View File

@ -9,6 +9,7 @@ import com.upchina.common.vo.BackendUserVO;
import com.upchina.common.vo.InsertIdVO; import com.upchina.common.vo.InsertIdVO;
import com.upchina.group.query.ListGroupQuery; import com.upchina.group.query.ListGroupQuery;
import com.upchina.group.query.SaveGroupQuery; import com.upchina.group.query.SaveGroupQuery;
import com.upchina.group.query.SetNoticeQuery;
import com.upchina.group.query.UpdateGroupQuery; import com.upchina.group.query.UpdateGroupQuery;
import com.upchina.group.query.UpdateGroupStatusQuery; import com.upchina.group.query.UpdateGroupStatusQuery;
import com.upchina.group.service.GroupInfoService; import com.upchina.group.service.GroupInfoService;
@ -73,4 +74,12 @@ public class AdminGroupInfoController {
GroupVO vo = groupInfoService.get(query, backendUserVO); GroupVO vo = groupInfoService.get(query, backendUserVO);
return CommonResult.success(vo); return CommonResult.success(vo);
} }
@ApiOperation("后台设置交易圈公告")
@PostMapping("/admin/group/info/setNotice")
public CommonResult<Void> setNotice(@Validated @RequestBody @ApiParam(required = true) SetNoticeQuery query,
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
groupInfoService.setNotice(query, backendUserVO);
return CommonResult.success();
}
} }

View File

@ -75,6 +75,15 @@ public class AdminGroupMessageController {
return CommonResult.success(vo); return CommonResult.success(vo);
} }
@ApiOperation("后台设置消息精选")
@PostMapping("/admin/group/message/setMessageRecommend")
public CommonResult<Void> setMessageRecommend(@Validated @RequestBody @ApiParam(required = true) GroupMessageRecommendQuery query,
@RequestAttribute(value = "backendUser", required = false) BackendUserVO backendUserVO) {
adminGroupMessageService.setMessageRecommend(query, backendUserVO);
return CommonResult.success();
}
@ApiOperation("设置互动状态") @ApiOperation("设置互动状态")
@PostMapping("/admin/group/message/setInteractiveStatus") @PostMapping("/admin/group/message/setInteractiveStatus")
public CommonResult<Void> setInteractiveStatus( public CommonResult<Void> setInteractiveStatus(

View File

@ -58,6 +58,11 @@ public class GroupInfo implements Serializable {
@TableField("welcome_message") @TableField("welcome_message")
private String welcomeMessage; private String welcomeMessage;
/**
* 公告
*/
private String notice;
/** /**
* 互动状态 1:开启 2:关闭 * 互动状态 1:开启 2:关闭
*/ */
@ -207,6 +212,7 @@ public class GroupInfo implements Serializable {
public void setId(Integer id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
public Integer getAdvisorId() { public Integer getAdvisorId() {
return advisorId; return advisorId;
} }
@ -214,6 +220,7 @@ public class GroupInfo implements Serializable {
public void setAdvisorId(Integer advisorId) { public void setAdvisorId(Integer advisorId) {
this.advisorId = advisorId; this.advisorId = advisorId;
} }
public String getName() { public String getName() {
return name; return name;
} }
@ -221,6 +228,7 @@ public class GroupInfo implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getRemark() { public String getRemark() {
return remark; return remark;
} }
@ -228,6 +236,7 @@ public class GroupInfo implements Serializable {
public void setRemark(String remark) { public void setRemark(String remark) {
this.remark = remark; this.remark = remark;
} }
public String getApplicableUser() { public String getApplicableUser() {
return applicableUser; return applicableUser;
} }
@ -235,6 +244,7 @@ public class GroupInfo implements Serializable {
public void setApplicableUser(String applicableUser) { public void setApplicableUser(String applicableUser) {
this.applicableUser = applicableUser; this.applicableUser = applicableUser;
} }
public String getDetail() { public String getDetail() {
return detail; return detail;
} }
@ -242,6 +252,7 @@ public class GroupInfo implements Serializable {
public void setDetail(String detail) { public void setDetail(String detail) {
this.detail = detail; this.detail = detail;
} }
public String getWelcomeMessage() { public String getWelcomeMessage() {
return welcomeMessage; return welcomeMessage;
} }
@ -249,6 +260,15 @@ public class GroupInfo implements Serializable {
public void setWelcomeMessage(String welcomeMessage) { public void setWelcomeMessage(String welcomeMessage) {
this.welcomeMessage = welcomeMessage; this.welcomeMessage = welcomeMessage;
} }
public String getNotice() {
return notice;
}
public void setNotice(String notice) {
this.notice = notice;
}
public Integer getInteractiveStatus() { public Integer getInteractiveStatus() {
return interactiveStatus; return interactiveStatus;
} }
@ -256,6 +276,7 @@ public class GroupInfo implements Serializable {
public void setInteractiveStatus(Integer interactiveStatus) { public void setInteractiveStatus(Integer interactiveStatus) {
this.interactiveStatus = interactiveStatus; this.interactiveStatus = interactiveStatus;
} }
public Integer getPrivateChatStatus() { public Integer getPrivateChatStatus() {
return privateChatStatus; return privateChatStatus;
} }
@ -263,6 +284,7 @@ public class GroupInfo implements Serializable {
public void setPrivateChatStatus(Integer privateChatStatus) { public void setPrivateChatStatus(Integer privateChatStatus) {
this.privateChatStatus = privateChatStatus; this.privateChatStatus = privateChatStatus;
} }
public Integer getShowMemberCount() { public Integer getShowMemberCount() {
return showMemberCount; return showMemberCount;
} }
@ -270,6 +292,7 @@ public class GroupInfo implements Serializable {
public void setShowMemberCount(Integer showMemberCount) { public void setShowMemberCount(Integer showMemberCount) {
this.showMemberCount = showMemberCount; this.showMemberCount = showMemberCount;
} }
public Integer getShowNickName() { public Integer getShowNickName() {
return showNickName; return showNickName;
} }
@ -277,6 +300,7 @@ public class GroupInfo implements Serializable {
public void setShowNickName(Integer showNickName) { public void setShowNickName(Integer showNickName) {
this.showNickName = showNickName; this.showNickName = showNickName;
} }
public Integer getFirstAudit() { public Integer getFirstAudit() {
return firstAudit; return firstAudit;
} }
@ -284,6 +308,7 @@ public class GroupInfo implements Serializable {
public void setFirstAudit(Integer firstAudit) { public void setFirstAudit(Integer firstAudit) {
this.firstAudit = firstAudit; this.firstAudit = firstAudit;
} }
public Integer getPageId() { public Integer getPageId() {
return pageId; return pageId;
} }
@ -291,6 +316,7 @@ public class GroupInfo implements Serializable {
public void setPageId(Integer pageId) { public void setPageId(Integer pageId) {
this.pageId = pageId; this.pageId = pageId;
} }
public BigDecimal getOriginalPrice() { public BigDecimal getOriginalPrice() {
return originalPrice; return originalPrice;
} }
@ -298,6 +324,7 @@ public class GroupInfo implements Serializable {
public void setOriginalPrice(BigDecimal originalPrice) { public void setOriginalPrice(BigDecimal originalPrice) {
this.originalPrice = originalPrice; this.originalPrice = originalPrice;
} }
public BigDecimal getActivityPrice() { public BigDecimal getActivityPrice() {
return activityPrice; return activityPrice;
} }
@ -305,6 +332,7 @@ public class GroupInfo implements Serializable {
public void setActivityPrice(BigDecimal activityPrice) { public void setActivityPrice(BigDecimal activityPrice) {
this.activityPrice = activityPrice; this.activityPrice = activityPrice;
} }
public String getPaymentUrl() { public String getPaymentUrl() {
return paymentUrl; return paymentUrl;
} }
@ -312,6 +340,7 @@ public class GroupInfo implements Serializable {
public void setPaymentUrl(String paymentUrl) { public void setPaymentUrl(String paymentUrl) {
this.paymentUrl = paymentUrl; this.paymentUrl = paymentUrl;
} }
public String getAuthorityId() { public String getAuthorityId() {
return authorityId; return authorityId;
} }
@ -319,6 +348,7 @@ public class GroupInfo implements Serializable {
public void setAuthorityId(String authorityId) { public void setAuthorityId(String authorityId) {
this.authorityId = authorityId; this.authorityId = authorityId;
} }
public Integer getMemberLimit() { public Integer getMemberLimit() {
return memberLimit; return memberLimit;
} }
@ -326,6 +356,7 @@ public class GroupInfo implements Serializable {
public void setMemberLimit(Integer memberLimit) { public void setMemberLimit(Integer memberLimit) {
this.memberLimit = memberLimit; this.memberLimit = memberLimit;
} }
public String getCoverImage() { public String getCoverImage() {
return coverImage; return coverImage;
} }
@ -333,6 +364,7 @@ public class GroupInfo implements Serializable {
public void setCoverImage(String coverImage) { public void setCoverImage(String coverImage) {
this.coverImage = coverImage; this.coverImage = coverImage;
} }
public Integer getStatus() { public Integer getStatus() {
return status; return status;
} }
@ -340,6 +372,7 @@ public class GroupInfo implements Serializable {
public void setStatus(Integer status) { public void setStatus(Integer status) {
this.status = status; this.status = status;
} }
public String getReason() { public String getReason() {
return reason; return reason;
} }
@ -347,6 +380,7 @@ public class GroupInfo implements Serializable {
public void setReason(String reason) { public void setReason(String reason) {
this.reason = reason; this.reason = reason;
} }
public Integer getRiskLevel() { public Integer getRiskLevel() {
return riskLevel; return riskLevel;
} }
@ -354,6 +388,7 @@ public class GroupInfo implements Serializable {
public void setRiskLevel(Integer riskLevel) { public void setRiskLevel(Integer riskLevel) {
this.riskLevel = riskLevel; this.riskLevel = riskLevel;
} }
public LocalDateTime getCreateTime() { public LocalDateTime getCreateTime() {
return createTime; return createTime;
} }
@ -361,6 +396,7 @@ public class GroupInfo implements Serializable {
public void setCreateTime(LocalDateTime createTime) { public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
public LocalDateTime getUpdateTime() { public LocalDateTime getUpdateTime() {
return updateTime; return updateTime;
} }
@ -368,6 +404,7 @@ public class GroupInfo implements Serializable {
public void setUpdateTime(LocalDateTime updateTime) { public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime; this.updateTime = updateTime;
} }
public LocalDateTime getAuditTime() { public LocalDateTime getAuditTime() {
return auditTime; return auditTime;
} }
@ -375,6 +412,7 @@ public class GroupInfo implements Serializable {
public void setAuditTime(LocalDateTime auditTime) { public void setAuditTime(LocalDateTime auditTime) {
this.auditTime = auditTime; this.auditTime = auditTime;
} }
public Integer getCreateUserId() { public Integer getCreateUserId() {
return createUserId; return createUserId;
} }
@ -382,6 +420,7 @@ public class GroupInfo implements Serializable {
public void setCreateUserId(Integer createUserId) { public void setCreateUserId(Integer createUserId) {
this.createUserId = createUserId; this.createUserId = createUserId;
} }
public Integer getAuditUserId() { public Integer getAuditUserId() {
return auditUserId; return auditUserId;
} }
@ -389,6 +428,7 @@ public class GroupInfo implements Serializable {
public void setAuditUserId(Integer auditUserId) { public void setAuditUserId(Integer auditUserId) {
this.auditUserId = auditUserId; this.auditUserId = auditUserId;
} }
public Integer getIsRecommend() { public Integer getIsRecommend() {
return isRecommend; return isRecommend;
} }
@ -396,6 +436,7 @@ public class GroupInfo implements Serializable {
public void setIsRecommend(Integer isRecommend) { public void setIsRecommend(Integer isRecommend) {
this.isRecommend = isRecommend; this.isRecommend = isRecommend;
} }
public Integer getIsDisplay() { public Integer getIsDisplay() {
return isDisplay; return isDisplay;
} }
@ -403,6 +444,7 @@ public class GroupInfo implements Serializable {
public void setIsDisplay(Integer isDisplay) { public void setIsDisplay(Integer isDisplay) {
this.isDisplay = isDisplay; this.isDisplay = isDisplay;
} }
public String getMainPageText() { public String getMainPageText() {
return mainPageText; return mainPageText;
} }
@ -410,6 +452,7 @@ public class GroupInfo implements Serializable {
public void setMainPageText(String mainPageText) { public void setMainPageText(String mainPageText) {
this.mainPageText = mainPageText; this.mainPageText = mainPageText;
} }
public Integer getWechatWorkId() { public Integer getWechatWorkId() {
return wechatWorkId; return wechatWorkId;
} }
@ -421,37 +464,38 @@ public class GroupInfo implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "GroupInfo{" + return "GroupInfo{" +
"id=" + id + "id=" + id +
", advisorId=" + advisorId + ", advisorId=" + advisorId +
", name=" + name + ", name='" + name + '\'' +
", remark=" + remark + ", remark='" + remark + '\'' +
", applicableUser=" + applicableUser + ", applicableUser='" + applicableUser + '\'' +
", detail=" + detail + ", detail='" + detail + '\'' +
", welcomeMessage=" + welcomeMessage + ", welcomeMessage='" + welcomeMessage + '\'' +
", interactiveStatus=" + interactiveStatus + ", notice='" + notice + '\'' +
", privateChatStatus=" + privateChatStatus + ", interactiveStatus=" + interactiveStatus +
", showMemberCount=" + showMemberCount + ", privateChatStatus=" + privateChatStatus +
", showNickName=" + showNickName + ", showMemberCount=" + showMemberCount +
", firstAudit=" + firstAudit + ", showNickName=" + showNickName +
", pageId=" + pageId + ", firstAudit=" + firstAudit +
", originalPrice=" + originalPrice + ", pageId=" + pageId +
", activityPrice=" + activityPrice + ", originalPrice=" + originalPrice +
", paymentUrl=" + paymentUrl + ", activityPrice=" + activityPrice +
", authorityId=" + authorityId + ", paymentUrl='" + paymentUrl + '\'' +
", memberLimit=" + memberLimit + ", authorityId='" + authorityId + '\'' +
", coverImage=" + coverImage + ", memberLimit=" + memberLimit +
", status=" + status + ", coverImage='" + coverImage + '\'' +
", reason=" + reason + ", status=" + status +
", riskLevel=" + riskLevel + ", reason='" + reason + '\'' +
", createTime=" + createTime + ", riskLevel=" + riskLevel +
", updateTime=" + updateTime + ", createTime=" + createTime +
", auditTime=" + auditTime + ", updateTime=" + updateTime +
", createUserId=" + createUserId + ", auditTime=" + auditTime +
", auditUserId=" + auditUserId + ", createUserId=" + createUserId +
", isRecommend=" + isRecommend + ", auditUserId=" + auditUserId +
", isDisplay=" + isDisplay + ", isRecommend=" + isRecommend +
", mainPageText=" + mainPageText + ", isDisplay=" + isDisplay +
", wechatWorkId=" + wechatWorkId + ", mainPageText='" + mainPageText + '\'' +
"}"; ", wechatWorkId=" + wechatWorkId +
'}';
} }
} }

View File

@ -0,0 +1,47 @@
package com.upchina.group.query;
import java.time.LocalDateTime;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import com.upchina.group.entity.GroupInfo;
import io.swagger.annotations.ApiModelProperty;
public class SetNoticeQuery {
@ApiModelProperty("交易圈ID")
@NotNull
private Integer id;
@ApiModelProperty("公告")
@NotBlank
private String notice;
public GroupInfo toPO() {
GroupInfo groupInfo = new GroupInfo();
groupInfo.setId(id);
groupInfo.setNotice(notice);
groupInfo.setUpdateTime(LocalDateTime.now());
return groupInfo;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNotice() {
return notice;
}
public void setNotice(String notice) {
this.notice = notice;
}
}

View File

@ -0,0 +1,49 @@
package com.upchina.group.query.message;
import java.time.LocalDateTime;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import com.upchina.group.entity.GroupMessage;
import io.swagger.annotations.ApiModelProperty;
public class GroupMessageRecommendQuery {
@ApiModelProperty(value = "消息ID")
@NotNull
private Integer messageId;
@ApiModelProperty(value = "是否精选 1:是 2:否")
@NotNull
@Min(1)
@Max(2)
private Integer isRecommend;
public GroupMessage toPO() {
GroupMessage message = new GroupMessage();
message.setId(messageId);
message.setIsRecommend(isRecommend);
message.setUpdateTime(LocalDateTime.now());
return message;
}
public Integer getMessageId() {
return messageId;
}
public void setMessageId(Integer messageId) {
this.messageId = messageId;
}
public Integer getIsRecommend() {
return isRecommend;
}
public void setIsRecommend(Integer isRecommend) {
this.isRecommend = isRecommend;
}
}

View File

@ -1,9 +1,11 @@
package com.upchina.group.query.message; package com.upchina.group.query.message;
import io.swagger.annotations.ApiModelProperty; import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import io.swagger.annotations.ApiModelProperty;
public class ListGroupMessageQuery { public class ListGroupMessageQuery {
@ApiModelProperty(value = "交易圈ID", required = true) @ApiModelProperty(value = "交易圈ID", required = true)
@ -11,11 +13,18 @@ public class ListGroupMessageQuery {
private Integer groupId; private Integer groupId;
@ApiModelProperty("消息状态:1初始;2已审核;3已删除") @ApiModelProperty("消息状态:1初始;2已审核;3已删除")
@Min(1)
@Max(3)
private Integer status; private Integer status;
@ApiModelProperty("查询类型:1全部;2投顾;3用户;4精选") @ApiModelProperty("查询类型:1全部;2投顾;3用户;4精选;5私聊")
@Min(1)
@Max(5)
private Integer type; private Integer type;
@ApiModelProperty("用户ID(私聊时有效)")
private String userId;
@ApiModelProperty("关键字") @ApiModelProperty("关键字")
private String keyword; private String keyword;
@ -23,6 +32,7 @@ public class ListGroupMessageQuery {
private Integer lastId; private Integer lastId;
@ApiModelProperty("消息数量") @ApiModelProperty("消息数量")
@Max(100)
private Integer size; private Integer size;
public Integer getGroupId() { public Integer getGroupId() {
@ -49,6 +59,14 @@ public class ListGroupMessageQuery {
this.type = type; this.type = type;
} }
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getKeyword() { public String getKeyword() {
return keyword; return keyword;
} }
@ -72,4 +90,5 @@ public class ListGroupMessageQuery {
public void setSize(Integer size) { public void setSize(Integer size) {
this.size = size; this.size = size;
} }
} }

View File

@ -60,7 +60,7 @@ public class SendGroupMessageAdminQuery {
message.setToUserId(toUserId); message.setToUserId(toUserId);
message.setPrivateUserId(toUserId); message.setPrivateUserId(toUserId);
} }
message.setStatus(GroupMessageStatus.INITIAL.value); message.setStatus(GroupMessageStatus.AUDITED.value);
message.setCreateUserId(userVO.getUserId().toString()); message.setCreateUserId(userVO.getUserId().toString());
message.setCreateTime(LocalDateTime.now()); message.setCreateTime(LocalDateTime.now());
message.setIsRecommend(isRecommend); message.setIsRecommend(isRecommend);

View File

@ -30,7 +30,7 @@ public class SendGroupMessageAppQuery {
@Max(2) @Max(2)
private Integer interactiveType; private Integer interactiveType;
public GroupMessage toPO(FrontUserVO userVO) { public GroupMessage toPO(FrontUserVO userVO, GroupMessageStatus status) {
GroupMessage message = new GroupMessage(); GroupMessage message = new GroupMessage();
message.setGroupId(groupId); message.setGroupId(groupId);
message.setMsgType(GroupMessageType.NORMAL.value); message.setMsgType(GroupMessageType.NORMAL.value);
@ -41,7 +41,7 @@ public class SendGroupMessageAppQuery {
message.setContentType(GroupMessageContentType.TEXT.value); message.setContentType(GroupMessageContentType.TEXT.value);
message.setInteractiveType(interactiveType); message.setInteractiveType(interactiveType);
message.setPrivateUserId(userVO.getUserId()); message.setPrivateUserId(userVO.getUserId());
message.setStatus(GroupMessageStatus.INITIAL.value); message.setStatus(status.value);
message.setCreateUserId(userVO.getUserId()); message.setCreateUserId(userVO.getUserId());
message.setCreateTime(LocalDateTime.now()); message.setCreateTime(LocalDateTime.now());
return message; return message;

View File

@ -171,6 +171,16 @@ public class GroupInfoService {
); );
} }
public void setNotice(SetNoticeQuery query, BackendUserVO backendUserVO) {
GroupInfo groupInDB = groupInfoMapper.selectById(query.getId());
if (groupInDB == null) {
throw new BizException(ResponseStatus.ID_NOT_EXIST_ERROR);
}
GroupInfo groupInfo = query.toPO();
groupInfoMapper.updateById(groupInfo);
clearCache(query.getId());
}
/** /**
* APP端查询交易圈详情 * APP端查询交易圈详情
*/ */
@ -283,7 +293,8 @@ public class GroupInfoService {
return advisorId; return advisorId;
} }
private void clearCache(Integer id) { public void clearCache(Integer id) {
groupCache.delete(CacheKey.GroupKey.GROUP_INFO + id); groupCache.delete(CacheKey.GroupKey.GROUP_INFO + id);
} }
} }

View File

@ -1,6 +1,19 @@
package com.upchina.group.service.admin; package com.upchina.group.service.admin;
import cn.hutool.core.util.StrUtil; import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.hazelcast.map.IMap;
import com.upchina.common.config.cache.CacheKey;
import com.upchina.group.service.GroupInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -14,24 +27,27 @@ import com.upchina.common.result.ResponseStatus;
import com.upchina.common.state.StateMachine; import com.upchina.common.state.StateMachine;
import com.upchina.common.vo.BackendUserVO; import com.upchina.common.vo.BackendUserVO;
import com.upchina.common.vo.OnlyIdVO; import com.upchina.common.vo.OnlyIdVO;
import com.upchina.group.constant.*; import com.upchina.group.constant.GroupMessageChannel;
import com.upchina.group.constant.GroupMessageContentType;
import com.upchina.group.constant.GroupMessageStatus;
import com.upchina.group.constant.GroupMessageType;
import com.upchina.group.constant.GroupMessageUserType;
import com.upchina.group.constant.QueryGroupMessageType;
import com.upchina.group.entity.GroupInfo; import com.upchina.group.entity.GroupInfo;
import com.upchina.group.entity.GroupMessage; import com.upchina.group.entity.GroupMessage;
import com.upchina.group.mapper.GroupInfoMapper; import com.upchina.group.mapper.GroupInfoMapper;
import com.upchina.group.mapper.GroupMessageMapper; import com.upchina.group.mapper.GroupMessageMapper;
import com.upchina.group.query.message.*; import com.upchina.group.query.message.GroupMessageProductQuery;
import com.upchina.group.query.message.GroupMessageRecommendQuery;
import com.upchina.group.query.message.GroupMessageStatusQuery;
import com.upchina.group.query.message.ListGroupMessageQuery;
import com.upchina.group.query.message.SendGroupMessageAdminQuery;
import com.upchina.group.query.message.UpdateGroupMessageStatusQuery;
import com.upchina.group.service.common.GroupCacheService; import com.upchina.group.service.common.GroupCacheService;
import com.upchina.group.service.common.GroupMessageService; import com.upchina.group.service.common.GroupMessageService;
import com.upchina.group.vo.message.GroupMessageVO; import com.upchina.group.vo.message.GroupMessageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import cn.hutool.core.util.StrUtil;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service @Service
public class AdminGroupMessageService { public class AdminGroupMessageService {
@ -54,6 +70,12 @@ public class AdminGroupMessageService {
@Resource @Resource
private AdvisorInfoService advisorInfoService; private AdvisorInfoService advisorInfoService;
@Resource
private GroupInfoService groupInfoService;
@Resource
private IMap<String, Object> groupCache;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public OnlyIdVO sendAdvisorMessage(SendGroupMessageAdminQuery query, BackendUserVO backendUser) { public OnlyIdVO sendAdvisorMessage(SendGroupMessageAdminQuery query, BackendUserVO backendUser) {
GroupInfo group = groupInfoMapper.selectById(query.getGroupId()); GroupInfo group = groupInfoMapper.selectById(query.getGroupId());
@ -63,9 +85,7 @@ public class AdminGroupMessageService {
GroupMessage message = query.toPO(backendUser); GroupMessage message = query.toPO(backendUser);
groupMessageMapper.insert(message); groupMessageMapper.insert(message);
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.NORMAL, query.getGroupId(), message.getContent()); publishGroupMessage(message);
groupCacheService.addMessage(message);
return new OnlyIdVO(message.getId()); return new OnlyIdVO(message.getId());
} }
@ -92,8 +112,7 @@ public class AdminGroupMessageService {
groupCacheService.removeMessage(groupMessageInDB); groupCacheService.removeMessage(groupMessageInDB);
} else if (GroupMessageStatus.AUDITED.equals(targetStatus)) { } else if (GroupMessageStatus.AUDITED.equals(targetStatus)) {
if (!IsOrNot.IS.value.equals(group.getFirstAudit())) { if (!IsOrNot.IS.value.equals(group.getFirstAudit())) {
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.NORMAL, groupId, groupMessageInDB.getContent()); publishGroupMessage(groupMessageInDB);
groupCacheService.addMessage(groupMessageInDB);
} }
} }
} }
@ -102,6 +121,7 @@ public class AdminGroupMessageService {
Integer groupId = query.getGroupId(); Integer groupId = query.getGroupId();
Integer status = query.getStatus(); Integer status = query.getStatus();
Integer type = query.getType(); Integer type = query.getType();
String userId = query.getUserId();
String keyword = query.getKeyword(); String keyword = query.getKeyword();
Integer lastId = query.getLastId(); Integer lastId = query.getLastId();
Integer size = query.getSize(); Integer size = query.getSize();
@ -112,8 +132,10 @@ public class AdminGroupMessageService {
.in(QueryGroupMessageType.ADVISOR.value.equals(type), GroupMessage::getUserType, GroupMessageUserType.ADVISOR.value, GroupMessageUserType.ASSISTANT.value) .in(QueryGroupMessageType.ADVISOR.value.equals(type), GroupMessage::getUserType, GroupMessageUserType.ADVISOR.value, GroupMessageUserType.ASSISTANT.value)
.eq(QueryGroupMessageType.CUSTOMER.value.equals(type), GroupMessage::getUserType, GroupMessageUserType.CUSTOMER.value) .eq(QueryGroupMessageType.CUSTOMER.value.equals(type), GroupMessage::getUserType, GroupMessageUserType.CUSTOMER.value)
.eq(QueryGroupMessageType.SELECTED.value.equals(type), GroupMessage::getIsRecommend, IsOrNot.IS.value) .eq(QueryGroupMessageType.SELECTED.value.equals(type), GroupMessage::getIsRecommend, IsOrNot.IS.value)
.eq(QueryGroupMessageType.PRIVATE.value.equals(type) && StrUtil.isNotEmpty(userId), GroupMessage::getPrivateUserId, userId)
.eq(status != null, GroupMessage::getStatus, query.getStatus()) .eq(status != null, GroupMessage::getStatus, query.getStatus())
.like(StrUtil.isNotEmpty(keyword),GroupMessage::getContent, keyword) .like(StrUtil.isNotEmpty(keyword),GroupMessage::getContent, keyword)
.eq(StrUtil.isNotEmpty(keyword), GroupMessage::getContentType, GroupMessageContentType.TEXT.value) .eq(StrUtil.isNotEmpty(keyword), GroupMessage::getContentType, GroupMessageContentType.TEXT.value)
.lt(lastId != null, GroupMessage::getId, lastId) .lt(lastId != null, GroupMessage::getId, lastId)
.orderByDesc(GroupMessage::getId) .orderByDesc(GroupMessage::getId)
@ -161,6 +183,19 @@ public class AdminGroupMessageService {
return new OnlyIdVO(message.getId()); return new OnlyIdVO(message.getId());
} }
public void setMessageRecommend(GroupMessageRecommendQuery query, BackendUserVO backendUserVO) {
GroupMessage messageInDB = groupMessageMapper.selectById(query.getMessageId());
if (messageInDB == null) {
throw new BizException(ResponseStatus.ID_NOT_EXIST_ERROR);
}
GroupMessage message = query.toPO();
groupMessageMapper.updateById(message);
groupCacheService.addMessage(message);
clearCache(query.getMessageId());
}
/** /**
* 发送开启/关闭互动消息 * 发送开启/关闭互动消息
*/ */
@ -175,6 +210,8 @@ public class AdminGroupMessageService {
groupInfoMapper.updateById(group); groupInfoMapper.updateById(group);
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.OPEN_INTERACTIVE, groupId, query.getStatus()); groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.OPEN_INTERACTIVE, groupId, query.getStatus());
groupInfoService.clearCache(groupId);
} }
/** /**
@ -191,6 +228,8 @@ public class AdminGroupMessageService {
groupInfoMapper.updateById(group); groupInfoMapper.updateById(group);
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.OPEN_PRIVATE_CHAT, groupId, query.getStatus()); groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.OPEN_PRIVATE_CHAT, groupId, query.getStatus());
groupInfoService.clearCache(groupId);
} }
/** /**
@ -207,6 +246,8 @@ public class AdminGroupMessageService {
groupInfoMapper.updateById(group); groupInfoMapper.updateById(group);
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.SHOW_GROUP_MEMBER_COUNT, groupId, query.getStatus()); groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.SHOW_GROUP_MEMBER_COUNT, groupId, query.getStatus());
groupInfoService.clearCache(groupId);
} }
public void setShowNickName(GroupMessageStatusQuery query, BackendUserVO backendUser) { public void setShowNickName(GroupMessageStatusQuery query, BackendUserVO backendUser) {
@ -219,8 +260,9 @@ public class AdminGroupMessageService {
GroupInfo group = query.toShowNickNamePO(); GroupInfo group = query.toShowNickNamePO();
groupInfoMapper.updateById(group); groupInfoMapper.updateById(group);
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.SHOW_FULL_NICKNAME, groupId, query.getStatus()); groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.SHOW_FULL_NICKNAME, groupId, query.getStatus());
groupInfoService.clearCache(groupId);
} }
public void setFirstAudit(GroupMessageStatusQuery query, BackendUserVO backendUser) { public void setFirstAudit(GroupMessageStatusQuery query, BackendUserVO backendUser) {
@ -234,6 +276,20 @@ public class AdminGroupMessageService {
groupInfoMapper.updateById(group); groupInfoMapper.updateById(group);
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.PRE_CHECK_SEND, groupId, query.getStatus()); groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.PRE_CHECK_SEND, groupId, query.getStatus());
groupInfoService.clearCache(groupId);
}
private void publishGroupMessage(GroupMessage message) {
Map<Integer, AdvisorBasicVO> advisorMap = advisorInfoService.getAdvisorVoMap();
GroupMessageVO vo = groupCacheService.getMessage(message, advisorMap);
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.NORMAL, message.getGroupId(), vo);
groupCacheService.addMessage(message);
}
private void clearCache(Integer messageId) {
groupCache.remove(CacheKey.GroupKey.GROUP_MESSAGE_DETAIL + messageId);
} }
} }

View File

@ -3,6 +3,7 @@ package com.upchina.group.service.app;
import com.upchina.advisor.service.AdvisorInfoService; import com.upchina.advisor.service.AdvisorInfoService;
import com.upchina.advisor.vo.AdvisorBasicVO; import com.upchina.advisor.vo.AdvisorBasicVO;
import com.upchina.common.constant.IsOrNot; import com.upchina.common.constant.IsOrNot;
import com.upchina.common.constant.ProductType;
import com.upchina.common.handler.BizException; import com.upchina.common.handler.BizException;
import com.upchina.common.query.OnlyIdQuery; import com.upchina.common.query.OnlyIdQuery;
import com.upchina.common.result.AppPager; import com.upchina.common.result.AppPager;
@ -12,6 +13,7 @@ import com.upchina.common.service.SensitiveWordService;
import com.upchina.common.util.TextUtil; import com.upchina.common.util.TextUtil;
import com.upchina.common.vo.FrontUserVO; import com.upchina.common.vo.FrontUserVO;
import com.upchina.group.constant.GroupMessageChannel; import com.upchina.group.constant.GroupMessageChannel;
import com.upchina.group.constant.GroupMessageStatus;
import com.upchina.group.constant.GroupMessageType; import com.upchina.group.constant.GroupMessageType;
import com.upchina.group.constant.QueryGroupMessageType; import com.upchina.group.constant.QueryGroupMessageType;
import com.upchina.group.entity.GroupMessage; import com.upchina.group.entity.GroupMessage;
@ -107,14 +109,17 @@ public class AppGroupMessageService {
} }
// 禁言check // 禁言check
commentBlackService.check(frontUser.getUserId()); if (commentBlackService.checkIsBlack(frontUser.getUserId(), groupId, ProductType.GROUP.value)) {
throw new BizException(ResponseStatus.COMMENT_BLACK_USER_ERROR);
}
GroupMessage message = query.toPO(frontUser); GroupMessageStatus status = IsOrNot.IS.value.equals(groupVO.getFirstAudit()) ? GroupMessageStatus.INITIAL : GroupMessageStatus.AUDITED;
GroupMessage message = query.toPO(frontUser, status);
message.setContent(TextUtil.cleanUnsafeHtml(content)); message.setContent(TextUtil.cleanUnsafeHtml(content));
groupMessageMapper.insert(message); groupMessageMapper.insert(message);
Map<Integer, AdvisorBasicVO> advisorMap = advisorInfoService.getAdvisorVoMap(); Map<Integer, AdvisorBasicVO> advisorMap = advisorInfoService.getAdvisorVoMap();
GroupMessageVO vo = new GroupMessageVO(message, advisorMap.get(message.getAdvisorId())); GroupMessageVO vo = groupCacheService.getMessage(message, advisorMap);
if (!IsOrNot.IS.value.equals(groupVO.getFirstAudit())) { if (!IsOrNot.IS.value.equals(groupVO.getFirstAudit())) {
groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.NORMAL, groupId, vo); groupMessageService.publishGroupMessage(GroupMessageChannel.ALL, GroupMessageType.NORMAL, groupId, vo);

View File

@ -50,9 +50,6 @@ public class GroupCacheService {
// } // }
public NavigableSet<Integer> getMessageIdSet(Integer groupId, String userId, QueryGroupMessageType type) { public NavigableSet<Integer> getMessageIdSet(Integer groupId, String userId, QueryGroupMessageType type) {
if (QueryGroupMessageType.CUSTOMER.equals(type)) {
throw new BizException(ResponseStatus.PARM_ERROR, "查询类型错误");
}
String cacheKey = buildMessageIdSetKey(userId, type); String cacheKey = buildMessageIdSetKey(userId, type);
return cacheService.get(groupCache, cacheKey, () -> { return cacheService.get(groupCache, cacheKey, () -> {
LambdaQueryWrapper<GroupMessage> wrapper = Wrappers.<GroupMessage>lambdaQuery() LambdaQueryWrapper<GroupMessage> wrapper = Wrappers.<GroupMessage>lambdaQuery()
@ -134,10 +131,17 @@ public class GroupCacheService {
if (message == null) { if (message == null) {
return null; return null;
} }
return new GroupMessageVO(message, advisorMap.get(message.getAdvisorId())); return getMessage(message, advisorMap);
}); });
} }
public GroupMessageVO getMessage(GroupMessage message, Map<Integer, AdvisorBasicVO> advisorMap) {
GroupMessageVO vo = new GroupMessageVO(message, advisorMap.get(message.getAdvisorId()));
vo.setReplyMessage(getMessage(message.getReplyId(), advisorMap));
vo.setQuoteMessage(getMessage(message.getQuoteId(), advisorMap));
return vo;
}
public IMap<String, OnlineUser> getTotalOnlineMap(Integer groupId) { public IMap<String, OnlineUser> getTotalOnlineMap(Integer groupId) {
return cacheService.getMap(CacheKey.GroupKey.USER_TOTAL_ONLINE + groupId, () -> { return cacheService.getMap(CacheKey.GroupKey.USER_TOTAL_ONLINE + groupId, () -> {
synchronized (GroupCacheService.class) { synchronized (GroupCacheService.class) {

View File

@ -1,5 +1,6 @@
package com.upchina.group.service.common; package com.upchina.group.service.common;
import cn.hutool.json.JSONUtil;
import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.topic.ITopic; import com.hazelcast.topic.ITopic;
import com.upchina.common.config.cache.CacheKey; import com.upchina.common.config.cache.CacheKey;
@ -100,6 +101,7 @@ public class GroupMessageService {
if (containSessionId) { if (containSessionId) {
destination += "/" + payload.getSessionId(); destination += "/" + payload.getSessionId();
} }
System.out.println("===Listener destination:" + destination + ", payload" + JSONUtil.toJsonStr(payload));
simpMessagingTemplate.convertAndSend(destination, payload); simpMessagingTemplate.convertAndSend(destination, payload);
}); });
return topic; return topic;

View File

@ -36,6 +36,9 @@ public class GroupVO implements Serializable {
@ApiModelProperty("欢迎语") @ApiModelProperty("欢迎语")
private String welcomeMessage; private String welcomeMessage;
@ApiModelProperty("公告")
private String notice;
@ApiModelProperty("互动状态 1:开启 2:关闭") @ApiModelProperty("互动状态 1:开启 2:关闭")
private Integer interactiveStatus; private Integer interactiveStatus;
@ -122,6 +125,7 @@ public class GroupVO implements Serializable {
this.applicableUser = groupInfo.getApplicableUser(); this.applicableUser = groupInfo.getApplicableUser();
this.detail = groupInfo.getDetail(); this.detail = groupInfo.getDetail();
this.welcomeMessage = groupInfo.getWelcomeMessage(); this.welcomeMessage = groupInfo.getWelcomeMessage();
this.notice = groupInfo.getNotice();
this.privateChatStatus = groupInfo.getPrivateChatStatus(); this.privateChatStatus = groupInfo.getPrivateChatStatus();
this.interactiveStatus = groupInfo.getInteractiveStatus(); this.interactiveStatus = groupInfo.getInteractiveStatus();
this.showMemberCount = groupInfo.getShowMemberCount(); this.showMemberCount = groupInfo.getShowMemberCount();
@ -212,10 +216,19 @@ public class GroupVO implements Serializable {
this.welcomeMessage = welcomeMessage; this.welcomeMessage = welcomeMessage;
} }
public String getNotice() {
return notice;
}
public void setNotice(String notice) {
this.notice = notice;
}
public Integer getInteractiveStatus() { public Integer getInteractiveStatus() {
return interactiveStatus; return interactiveStatus;
} }
public void setInteractiveStatus(Integer interactiveStatus) { public void setInteractiveStatus(Integer interactiveStatus) {
this.interactiveStatus = interactiveStatus; this.interactiveStatus = interactiveStatus;
} }

View File

@ -21,7 +21,7 @@ public class GroupMessageVO implements Serializable {
@ApiModelProperty("交互类型:1群聊;2私聊;3会话消息") @ApiModelProperty("交互类型:1群聊;2私聊;3会话消息")
private Integer interactiveType; private Integer interactiveType;
@ApiModelProperty("用户类型") @ApiModelProperty("用户类型1投顾2用户3助教4运营人员")
private Integer userType; private Integer userType;
@ApiModelProperty("用户ID") @ApiModelProperty("用户ID")
@ -33,7 +33,7 @@ public class GroupMessageVO implements Serializable {
@ApiModelProperty("消息内容") @ApiModelProperty("消息内容")
private String content; private String content;
@ApiModelProperty("发布类型") @ApiModelProperty("发布类型 1:文本 2:图片 3:文件 4:产品 5:问卷")
private Integer contentType; private Integer contentType;
@ApiModelProperty("回复消息ID") @ApiModelProperty("回复消息ID")
@ -48,7 +48,7 @@ public class GroupMessageVO implements Serializable {
@ApiModelProperty("引用消息") @ApiModelProperty("引用消息")
private GroupMessageVO quoteMessage; private GroupMessageVO quoteMessage;
@ApiModelProperty("状态") @ApiModelProperty("状态1初始2已审核3已删除")
private Integer status; private Integer status;
@ApiModelProperty("创建时间") @ApiModelProperty("创建时间")
@ -57,6 +57,9 @@ public class GroupMessageVO implements Serializable {
@ApiModelProperty("投顾ID") @ApiModelProperty("投顾ID")
private Integer advisorId; private Integer advisorId;
@ApiModelProperty("是否精选 1是 2否")
private Integer isRecommend;
@ApiModelProperty("投顾") @ApiModelProperty("投顾")
private AdvisorBasicVO advisor; private AdvisorBasicVO advisor;
@ -78,6 +81,7 @@ public class GroupMessageVO implements Serializable {
this.status = message.getStatus(); this.status = message.getStatus();
this.createTime = message.getCreateTime(); this.createTime = message.getCreateTime();
this.advisorId = message.getAdvisorId(); this.advisorId = message.getAdvisorId();
this.isRecommend = message.getIsRecommend();
this.advisor = advisor; this.advisor = advisor;
} }
@ -209,6 +213,14 @@ public class GroupMessageVO implements Serializable {
this.advisorId = advisorId; this.advisorId = advisorId;
} }
public Integer getIsRecommend() {
return isRecommend;
}
public void setIsRecommend(Integer isRecommend) {
this.isRecommend = isRecommend;
}
public AdvisorBasicVO getAdvisor() { public AdvisorBasicVO getAdvisor() {
return advisor; return advisor;
} }

View File

@ -194,7 +194,7 @@ public class AdminVideoMessageService {
List<VideoProductInfoVO> prdList = videoCommonService.getMergeProductList(vo.getVideoId(), new String[]{message.getRecommendProduct()}); List<VideoProductInfoVO> prdList = videoCommonService.getMergeProductList(vo.getVideoId(), new String[]{message.getRecommendProduct()});
vo.setProductBasic(prdList.isEmpty() ? null : prdList.get(0)); vo.setProductBasic(prdList.isEmpty() ? null : prdList.get(0));
} }
vo.setIsForbid(videoCommonService.checkAppForbidden(message.getUserId()) ? IsOrNot.IS.value : IsOrNot.NOT.value); vo.setIsForbid(videoCommonService.checkAppForbidden(message.getUserId(), videoId) ? IsOrNot.IS.value : IsOrNot.NOT.value);
vo.setIsCurrentUser(backendUser != null && backendUser.getAdvisorId() != null && backendUser.getAdvisorId().toString().equals(message.getUserId()) ? IsOrNot.IS.value : IsOrNot.NOT.value); vo.setIsCurrentUser(backendUser != null && backendUser.getAdvisorId() != null && backendUser.getAdvisorId().toString().equals(message.getUserId()) ? IsOrNot.IS.value : IsOrNot.NOT.value);
// 手机号及用户名脱敏 // 手机号及用户名脱敏
if (VideoHelper.isPhone(message.getUserId())) { if (VideoHelper.isPhone(message.getUserId())) {

View File

@ -169,7 +169,7 @@ public class AppVideoMessageService {
VideoLiveMessage message = videoCacheService.getVideoMessageInfo(messageId); VideoLiveMessage message = videoCacheService.getVideoMessageInfo(messageId);
VideoMessageAppVO vo = new VideoMessageAppVO(message); VideoMessageAppVO vo = new VideoMessageAppVO(message);
if (StrUtil.isNotBlank(message.getUserId())) { if (StrUtil.isNotBlank(message.getUserId())) {
vo.setIsForbid(videoCommonService.checkAppForbidden(message.getUserId()) ? IsOrNot.IS.value : IsOrNot.NOT.value); vo.setIsForbid(videoCommonService.checkAppForbidden(message.getUserId(), vo.getVideoId()) ? IsOrNot.IS.value : IsOrNot.NOT.value);
} }
if (message.getReplyId() != null) { if (message.getReplyId() != null) {
VideoLiveMessage replyMessage = videoCacheService.getVideoMessageInfo(message.getReplyId()); VideoLiveMessage replyMessage = videoCacheService.getVideoMessageInfo(message.getReplyId());
@ -259,7 +259,7 @@ public class AppVideoMessageService {
commentService.saveComment(commentQuery, frontUser); commentService.saveComment(commentQuery, frontUser);
} else { } else {
// 直播走消息接口 // 直播走消息接口
if (videoCommonService.checkAppForbidden(userId)) { if (videoCommonService.checkAppForbidden(userId, videoId)) {
throw new BizException(ResponseStatus.COMMENT_BLACK_USER_ERROR, "您已被禁言"); throw new BizException(ResponseStatus.COMMENT_BLACK_USER_ERROR, "您已被禁言");
} }
message.setContent(TextUtil.cleanUnsafeHtml(message.getContent())); message.setContent(TextUtil.cleanUnsafeHtml(message.getContent()));
@ -268,7 +268,7 @@ public class AppVideoMessageService {
videoLiveMessageMapper.insert(message); videoLiveMessageMapper.insert(message);
VideoMessageAppVO vo = new VideoMessageAppVO(message); VideoMessageAppVO vo = new VideoMessageAppVO(message);
if (StrUtil.isNotBlank(message.getUserId())) { if (StrUtil.isNotBlank(message.getUserId())) {
if (videoCommonService.checkAppForbidden(message.getUserId())) { if (videoCommonService.checkAppForbidden(message.getUserId(), videoId)) {
vo.setIsForbid(IsOrNot.IS.value); vo.setIsForbid(IsOrNot.IS.value);
} else { } else {
vo.setIsForbid(IsOrNot.NOT.value); vo.setIsForbid(IsOrNot.NOT.value);

View File

@ -331,12 +331,8 @@ public class VideoCommonService {
* *
* @param phone 客户手机号 * @param phone 客户手机号
*/ */
public boolean checkAppForbidden(String phone) { public boolean checkAppForbidden(String phone, Integer videoId) {
Set<String> blackUser = commentBlackService.getAllBlackUser(); return commentBlackService.checkIsBlack(phone, videoId, ProductType.VIDEO_SINGLE.value);
if (blackUser == null || StrUtil.isEmpty(phone)) {
return false;
}
return blackUser.contains(phone);
} }
/** /**

View File

@ -276,7 +276,7 @@ public class VideoMessageService {
// vo.setUserName(VideoHelper.maskUserName(message.getUserName())); // vo.setUserName(VideoHelper.maskUserName(message.getUserName()));
} }
if (StrUtil.isNotBlank(message.getUserId())) { if (StrUtil.isNotBlank(message.getUserId())) {
if (videoCommonService.checkAppForbidden(message.getUserId())) { if (videoCommonService.checkAppForbidden(message.getUserId(), message.getVideoId())) {
vo.setIsForbid(IsOrNot.IS.value); vo.setIsForbid(IsOrNot.IS.value);
} else { } else {
vo.setIsForbid(IsOrNot.NOT.value); vo.setIsForbid(IsOrNot.NOT.value);

View File

@ -15,16 +15,16 @@ hazelcast:
serverPort: 5709 #自己作为缓存服务器监听的端口号 serverPort: 5709 #自己作为缓存服务器监听的端口号
scheduledEnable: true scheduledEnable: true
cron: cron:
saveVideoCount: "10 * * * * ?" #从cache刷新视频播放量到DB 每分钟的第10s执行 collectLivingVideo: "30 1/5 * * * ?" #每分钟统计已开始但未结束的视频直播数据
refreshTranscodeStatus: "2 3/5 * * * ?" #从腾讯云拉取录播上传视频信息更新到DB saveVideoCount: "30 2/2 * * * ?" #从cache刷新视频播放量到DB 每分钟的第10s执行
updateLiveStatus: "3 1 * * * ?" #更新视频录播状态 saveVideoUserDataToDB: "30 3/5 * * * ?"
saveCustomerDataToDB: "30 4/5 * * * ?" #收集用户信息
refreshTranscodeStatus: "30 0/5 * * * ?" #从腾讯云拉取录播上传视频信息更新到DB
updateLiveStatus: "0 1 * * * ?" #更新视频录播状态
stopLivingVideo: "0 1-5 0 * * ?" #结束前一天直播中/暂停中的视频直播 stopLivingVideo: "0 1-5 0 * * ?" #结束前一天直播中/暂停中的视频直播
saveVideoUserDataToDB: "20 * * * * ?" saveWatchSeconds: "0 0/5 * * * ?" #保存短视频观看时长
saveCustomerDataToDB: "50 * * * * ?" #收集用户信息
saveWatchSeconds: "5 4/5 * * * ?" #保存短视频观看时长
collectLastWeek: "0 30 3 * * ?" #统计一周内的数据 collectLastWeek: "0 30 3 * * ?" #统计一周内的数据
collectLivingVideo: "0 * * * * ?" #每分钟统计已开始但未结束的视频直播数据 collectRecentEndVideo: "0 2/5 * * * ?" #每5分钟统计已结束48小时以内的视频直播数据
collectRecentEndVideo: "8 */5 * * * ?" #每5分钟统计已结束48小时以内的视频直播数据
user: user:
admin: admin:
roles: 1,3,4,5 #管理员角色id用逗号隔开 roles: 1,3,4,5 #管理员角色id用逗号隔开
@ -45,7 +45,7 @@ aes:
iv: gbb9qknndntteqc1 iv: gbb9qknndntteqc1
resizeUrl: resizeUrl:
main: http://8.138.144.54:8080/s/ #生产配置 http://s.upchina.com/s/ main: http://8.138.144.54:8080/s/ #生产配置 http://s.upchina.com/s/
original: http://8.138.144.54:8080/syzbh5/videoPlay original: http://8.138.144.54:8080/syzbh5
urlMain: /videoPlay?id= urlMain: /videoPlay?id=
shortVideoUrl: /shotVideoPlay?id= shortVideoUrl: /shotVideoPlay?id=
pc: pc: