Compare commits

...

12 Commits

Author SHA1 Message Date
Diyu0904 a9b0d8806c 更新根据名字查询秘钥接口 2025-03-21 14:41:43 +08:00
Diyu0904 156d3c18c2 修改加密接口路径 2025-03-21 14:32:00 +08:00
Diyu0904 9b675ab620 修改校验文件名字 2025-03-21 14:11:02 +08:00
Diyu0904 a3a0435850 更新文件解密查询名字 2025-03-21 14:06:44 +08:00
Diyu0904 0bfcbe9f0e Merge branch 'feature/admin' into preview 2025-03-21 13:54:55 +08:00
Diyu0904 598c353014 Merge branch 'feature/admin' into preview 2025-03-21 09:28:47 +08:00
Diyu0904 9b4f92beed 删除修改时校验文件 2025-03-21 09:17:58 +08:00
yang d0238c2320 Merge branch 'feature/community-center' into preview 2025-03-20 16:03:25 +08:00
yang 7ce5ac3965 feat(community): 社区加入,调整社区列表 2025-03-20 16:03:07 +08:00
Diyu0904 c5ecdac49d 修改发布实名制null判断 2025-03-20 11:53:29 +08:00
yang a2090eecb8 Merge branch 'feature/community-center' into preview 2025-03-19 17:33:12 +08:00
yang ef826ce25f feat(resource): 调整点赞 2025-03-19 17:29:36 +08:00
32 changed files with 1230 additions and 93 deletions

View File

@ -1,13 +1,11 @@
package com.mcwl.web.controller.communityCenter;
import cn.hutool.core.bean.BeanUtil;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.communityCenter.domain.Community;
import com.mcwl.communityCenter.domain.dto.CommunityListPageRes;
import com.mcwl.communityCenter.domain.dto.CommunityRes;
import com.mcwl.communityCenter.domain.dto.JoinCommunityRes;
import com.mcwl.communityCenter.service.CommunityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -37,8 +35,8 @@ public class CommunityController {
*/
@ApiOperation(value = "社区列表")
@PostMapping("list")
public TableDataInfo getCommunityList(@RequestBody @Valid PageDomain pageDomain) {
return communityService.listByPage(pageDomain);
public TableDataInfo getCommunityList(@RequestBody @Valid CommunityListPageRes communityListPageRes) {
return communityService.listByPage(communityListPageRes);
}
@ -55,6 +53,16 @@ public class CommunityController {
return R.ok();
}
/**
*
*/
@ApiOperation(value = "加入社区")
@PostMapping("join")
public R<Object> joinCommunity(@Valid JoinCommunityRes joinCommunityRes) {
return communityService.joinCommunity(joinCommunityRes);
}
/**
*
*
@ -64,9 +72,9 @@ public class CommunityController {
@ApiOperation(value = "删除社区")
@GetMapping("delete")
public R<Object> deleteCommunity(@NotNull(message = "id不能为空")
@ApiParam(value = "id", required = true)
@Valid
Long id) {
@ApiParam(value = "id", required = true)
@Valid
Long id) {
communityService.removeById(id);
return R.ok();
}

View File

@ -31,4 +31,39 @@ public class CodeMQConfig {
return new Queue(QueueConstants.MEMBER_BILLING_QUEUE, true);
}
@Bean
public Queue modelLikeQueue() {
return new Queue(QueueConstants.MODEL_LIKE_QUEUE, true);
}
@Bean
public Queue modelCommentLikeQueue() {
return new Queue(QueueConstants.MODEL_COMMENT_LIKE_QUEUE, true);
}
@Bean
public Queue imageLikeQueue() {
return new Queue(QueueConstants.IMAGE_LIKE_QUEUE, true);
}
@Bean
public Queue imageCommentLikeQueue() {
return new Queue(QueueConstants.IMAGE_COMMENT_LIKE_QUEUE, true);
}
@Bean
public Queue workFlowLikeQueue() {
return new Queue(QueueConstants.WORK_FLOW_LIKE_QUEUE, true);
}
@Bean
public Queue workFlowCommentLikeQueue() {
return new Queue(QueueConstants.WORK_FLOW_COMMENT_LIKE_QUEUE, true);
}
}

View File

@ -2,7 +2,6 @@ package com.mcwl.web.controller.resource;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageInfo;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.controller.BaseController;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.R;
@ -97,21 +96,21 @@ public class MallProductController extends BaseController {
public AjaxResult updateModel(@RequestBody RequestModel requestModel) {
for (ModelVersion modelVersion : requestModel.getModelVersionList()) {
//校验名字
ModelVersion modelVersion1 = modelVersionMapper.selectByFileName(modelVersion.getFileName());
if (modelVersion1 != null) {
return AjaxResult.error(HttpStatus.SHOW_ERROR_MSG,"文件名字重复");
}
//校验hash
ModelVersion modelVersion2 = modelVersionMapper.selectByHash(modelVersion.getFileHash());
if (modelVersion2 != null){
return AjaxResult.error(HttpStatus.SHOW_ERROR_MSG,"文件内容重复");
}
}
// for (ModelVersion modelVersion : requestModel.getModelVersionList()) {
//
// //校验名字
// ModelVersion modelVersion1 = modelVersionMapper.selectByFileName(modelVersion.getFileName());
// if (modelVersion1 != null) {
//
// return AjaxResult.error(HttpStatus.SHOW_ERROR_MSG,"文件名字重复");
// }
// //校验hash
// ModelVersion modelVersion2 = modelVersionMapper.selectByHash(modelVersion.getFileHash());
// if (modelVersion2 != null){
//
// return AjaxResult.error(HttpStatus.SHOW_ERROR_MSG,"文件内容重复");
// }
// }
ModelProduct modelProduct = requestModel.getModelProduct();

View File

@ -2,11 +2,9 @@ package com.mcwl.web.controller.resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.controller.BaseController;
import com.mcwl.common.core.domain.R;
import com.mcwl.resource.domain.WorkFlow;
import com.mcwl.resource.domain.WorkFlowVersion;
import com.mcwl.resource.domain.dto.AddRequestWorkFlow;
import com.mcwl.resource.domain.request.RequestWorkFlow;
import com.mcwl.resource.domain.response.ResponseWorkFlow;
@ -101,21 +99,21 @@ public class WorkFlowController extends BaseController {
public R<Object> updateWorkFlow(@RequestBody RequestWorkFlow requestWorkFlow) {
for (WorkFlowVersion workFlowVersion : requestWorkFlow.getWorkFlowVersionList()) {
//校验名字
WorkFlowVersion workFlowVersion1 = workFlowVersionMapper.selectByFileName(workFlowVersion.getFileName());
if (workFlowVersion1 != null) {
return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件名字重复");
}
//校验hash
WorkFlowVersion workFlowVersion2 = workFlowVersionMapper.selectByHash(workFlowVersion.getFileHash());
if (workFlowVersion2 != null){
return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件内容重复");
}
}
// for (WorkFlowVersion workFlowVersion : requestWorkFlow.getWorkFlowVersionList()) {
//
// //校验名字
// WorkFlowVersion workFlowVersion1 = workFlowVersionMapper.selectByFileName(workFlowVersion.getFileName());
// if (workFlowVersion1 != null) {
//
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件名字重复");
// }
// //校验hash
// WorkFlowVersion workFlowVersion2 = workFlowVersionMapper.selectByHash(workFlowVersion.getFileHash());
// if (workFlowVersion2 != null){
//
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件内容重复");
// }
// }
workFlowService.updateWorkFlow(requestWorkFlow);

View File

@ -180,7 +180,7 @@ mqtt:
#用户头像与背景
mcwl:
encryptUrl: http://113.45.190.154:9090/encrypt_and_upload
encryptUrl: http://113.45.190.154:9090/encryptAndUpload
user:
avatar: https://ybl2112.oss-cn-beijing.aliyuncs.com/2025/MARCH/10/7/53/3f5cc1d7-b062-4a22-9f7e-d442bc6dcf42.png
backgroundImg: https://ybl2112.oss-cn-beijing.aliyuncs.com/2025/MARCH/10/8/2/c8387681-8138-4a29-a1c9-4a143da34c5a.png

View File

@ -19,6 +19,25 @@ public class QueueConstants {
// 会员账单队列
public static final String MEMBER_BILLING_QUEUE = "memberBillingQueue";
// 模型点赞队列
public static final String MODEL_LIKE_QUEUE = "modelLikeQueue";
// 模型评论点赞队列
public static final String MODEL_COMMENT_LIKE_QUEUE = "modelCommentLikeQueue";
// 图片点赞队列
public static final String IMAGE_LIKE_QUEUE = "imageLikeQueue";
// 图片评论点赞队列
public static final String IMAGE_COMMENT_LIKE_QUEUE = "imageCommentLikeQueue";
// 工作流点赞队列
public static final String WORK_FLOW_LIKE_QUEUE = "workFlowLikeQueue";
// 工作流评论点赞队列
public static final String WORK_FLOW_COMMENT_LIKE_QUEUE = "workFlowCommentLikeQueue";

View File

@ -30,12 +30,30 @@ public class Community extends BaseEntity {
@TableField(fill = FieldFill.INSERT)
private Long tenantId;
/**
*
*/
@ApiModelProperty(value = "社区图片")
private String imageUrl;
/**
*
*/
@ApiModelProperty(value = "社区名称")
private String communityName;
/**
*
*/
@ApiModelProperty(value = "描述")
private String description;
/**
* id
*/
@ApiModelProperty(value = "社区标签id")
private Long communityTagId;
/**
*
*/

View File

@ -0,0 +1,51 @@
package com.mcwl.communityCenter.domain;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.mcwl.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
*
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("cc_community_user")
@ApiModel(value = "社区用户")
@AllArgsConstructor
@NoArgsConstructor
public class CommunityUser extends BaseEntity {
@TableId
@ApiModelProperty(value = "社区用户id")
private Long id;
/**
* id
*/
@ApiModelProperty(value = "租户id")
@TableField(fill = FieldFill.INSERT)
private Long tenantId;
/**
* id
*/
@ApiModelProperty(value = "社区id")
private Long communityId;
/**
* id
*/
@ApiModelProperty(value = "用户id")
private Long userId;
}

View File

@ -0,0 +1,23 @@
package com.mcwl.communityCenter.domain.dto;
import com.mcwl.common.core.page.PageDomain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "社区列表分页请求参数")
public class CommunityListPageRes extends PageDomain {
/**
* id
*/
@ApiModelProperty(value = "社区标签id")
private Long communityTagId;
}

View File

@ -0,0 +1,32 @@
package com.mcwl.communityCenter.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
*
*/
@Data
@ApiModel(value = "加入社区请求参数")
public class JoinCommunityRes {
/**
* id
*/
@ApiModelProperty(value = "租户id", required = true)
@NotNull(message = "租户id不能为空")
private Long tenantId;
/**
* id
*/
@ApiModelProperty(value = "社区id", required = true)
@NotNull(message = "社区id不能为空")
private Long communityId;
}

View File

@ -22,12 +22,47 @@ public class CommunityVo {
@ApiModelProperty(value = "社区id")
private Long id;
/**
*
*/
@ApiModelProperty(value = "社区图片")
private String imageUrl;
/**
*
*/
@ApiModelProperty(value = "社区名称")
private String communityName;
/**
*
*/
@ApiModelProperty(value = "描述")
private String description;
/**
*
*/
@ApiModelProperty(value = "价格")
private Double price;
/**
*
*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**
*
*/
@ApiModelProperty(value = "创建天数")
private Long createDay;
/**
*
*/
@ApiModelProperty(value = "加入人数")
private Integer joinNum;
}

View File

@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import javax.validation.constraints.NotNull;
import java.util.Map;
@Mapper
public interface CommunityMapper extends BaseMapper<Community> {
@ -17,4 +18,11 @@ public interface CommunityMapper extends BaseMapper<Community> {
@NotNull(message = "社区id不能为空")
@Param("communityId")
Long communityId);
/**
* , mapkeyidvalue
* @return map
*/
@InterceptorIgnore(tenantLine = "true")
Map<Long, Integer> selectCommunityJoinNum();
}

View File

@ -0,0 +1,20 @@
package com.mcwl.communityCenter.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mcwl.communityCenter.domain.Community;
import com.mcwl.communityCenter.domain.CommunityUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import javax.validation.constraints.NotNull;
import java.util.Map;
@Mapper
public interface CommunityUserMapper extends BaseMapper<CommunityUser> {
@InterceptorIgnore(tenantLine = "true")
CommunityUser selectByTenantIdAndCommunityIdAndUserId(@Param("tenantId") Long tenantId,
@Param("communityId") Long communityId,
@Param("userId") Long userId);
}

View File

@ -1,17 +1,28 @@
package com.mcwl.communityCenter.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.communityCenter.domain.Community;
import com.mcwl.communityCenter.domain.dto.CommunityListPageRes;
import com.mcwl.communityCenter.domain.dto.CommunityRes;
import com.mcwl.communityCenter.domain.dto.JoinCommunityRes;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
public interface CommunityService extends IService<Community> {
TableDataInfo listByPage(PageDomain pageDomain);
TableDataInfo listByPage(CommunityListPageRes communityListPageRes);
/**
*
* @param communityRes
*/
void addCommunity(CommunityRes communityRes);
/**
*
* @param joinCommunityRes
*/
R<Object> joinCommunity(JoinCommunityRes joinCommunityRes);
}

View File

@ -0,0 +1,12 @@
package com.mcwl.communityCenter.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.communityCenter.domain.Community;
import com.mcwl.communityCenter.domain.CommunityUser;
import com.mcwl.communityCenter.domain.dto.CommunityListPageRes;
import com.mcwl.communityCenter.domain.dto.CommunityRes;
public interface CommunityUserService extends IService<CommunityUser> {
}

View File

@ -1,55 +1,79 @@
package com.mcwl.communityCenter.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.communityCenter.domain.Community;
import com.mcwl.communityCenter.domain.CommunityUser;
import com.mcwl.communityCenter.domain.dto.CommunityListPageRes;
import com.mcwl.communityCenter.domain.dto.CommunityRes;
import com.mcwl.communityCenter.domain.dto.JoinCommunityRes;
import com.mcwl.communityCenter.domain.vo.CommunityVo;
import com.mcwl.communityCenter.mapper.CommunityMapper;
import com.mcwl.communityCenter.mapper.CommunityUserMapper;
import com.mcwl.communityCenter.service.CommunityService;
import com.mcwl.system.service.ISysUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*;
@Service
@RequiredArgsConstructor
public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community> implements CommunityService {
private final CommunityUserMapper communityUserMapper;
private final ISysUserService sysUserService;
@Override
public TableDataInfo listByPage(PageDomain pageDomain) {
public TableDataInfo listByPage(CommunityListPageRes communityListPageRes) {
Page<Community> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
// 查询社区加入人数以map形式返回key为社区idvalue为加入人数
Map<Long, Integer> communityJoinNumMap = baseMapper.selectCommunityJoinNum();
Page<Community> page = new Page<>(communityListPageRes.getPageNum(), communityListPageRes.getPageSize());
boolean isAsc = Objects.equals(pageDomain.getIsAsc(), "asc");
boolean isAsc = Objects.equals(communityListPageRes.getIsAsc(), "asc");
if (StringUtils.isBlank(pageDomain.getOrderByColumn())) {
pageDomain.setOrderByColumn("create_time");
if (StringUtils.isBlank(communityListPageRes.getOrderByColumn())) {
communityListPageRes.setOrderByColumn("create_time");
}
OrderItem orderItem = new OrderItem(pageDomain.getOrderByColumn(), isAsc);
OrderItem orderItem = new OrderItem(communityListPageRes.getOrderByColumn(), isAsc);
page.addOrder(orderItem);
baseMapper.selectPage(page, null);
baseMapper.selectPage(page, new LambdaQueryWrapper<Community>()
.eq(communityListPageRes.getCommunityTagId() != null, Community::getCommunityTagId, communityListPageRes.getCommunityTagId()));
List<Community> communityList = page.getRecords();
List<CommunityVo> communityVoList = new ArrayList<>();
LocalDate currentLocalDate = LocalDate.now(ZoneId.systemDefault());
for (Community community : communityList) {
CommunityVo communityVo = new CommunityVo();
BeanUtil.copyProperties(community, communityVo);
// 当前时间和创建时间差
Date createTime = community.getCreateTime();
LocalDate createLocalDate = createTime.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
long daysBetween = ChronoUnit.DAYS.between(createLocalDate, currentLocalDate);
communityVo.setCreateDay(daysBetween);
communityVo.setJoinNum(communityJoinNumMap.getOrDefault(community.getId(), 0));
communityVoList.add(communityVo);
}
@ -70,5 +94,47 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
}
/**
*
*
* @param joinCommunityRes
*/
@Override
@Transactional(rollbackFor = Exception.class)
public R<Object> joinCommunity(JoinCommunityRes joinCommunityRes) {
Long tenantId = joinCommunityRes.getTenantId();
Long communityId = joinCommunityRes.getCommunityId();
Community community = baseMapper.getByTenantIdAndCommunityId(tenantId, communityId);
if (Objects.isNull(community)) {
return R.fail("社区不存在,请重新加入");
}
CommunityUser communityUser = communityUserMapper.selectByTenantIdAndCommunityIdAndUserId(tenantId,
communityId,
SecurityUtils.getUserId());
if (Objects.nonNull(communityUser)) {
return R.fail("您已加入该社区,不能重复加入");
}
SysUser user = SecurityUtils.getLoginUser().getUser();
Double wallet = user.getWallet();
Double price = community.getPrice();
if (wallet < price) {
return R.fail("钱包余额不足,请充值");
}
// 扣费
BigDecimal priceBigDecimal = new BigDecimal(price.toString());
BigDecimal walletBigDecimal = new BigDecimal(wallet.toString());
user.setWallet(walletBigDecimal.subtract(priceBigDecimal).doubleValue());
sysUserService.updateUser(user);
communityUserMapper.insert(new CommunityUser(null, tenantId, communityId, SecurityUtils.getUserId()));
return R.ok("加入成功");
}
}

View File

@ -0,0 +1,37 @@
package com.mcwl.communityCenter.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.communityCenter.domain.Community;
import com.mcwl.communityCenter.domain.CommunityUser;
import com.mcwl.communityCenter.domain.dto.CommunityListPageRes;
import com.mcwl.communityCenter.domain.dto.CommunityRes;
import com.mcwl.communityCenter.domain.vo.CommunityVo;
import com.mcwl.communityCenter.mapper.CommunityMapper;
import com.mcwl.communityCenter.mapper.CommunityUserMapper;
import com.mcwl.communityCenter.service.CommunityService;
import com.mcwl.communityCenter.service.CommunityUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*;
@Service
@RequiredArgsConstructor
public class CommunityUserServiceImpl extends ServiceImpl<CommunityUserMapper, CommunityUser> implements CommunityUserService {
}

View File

@ -16,4 +16,13 @@
and id = #{communityId}
and del_flag = '0';
</select>
<select id="selectCommunityJoinNum" resultType="java.util.Map">
select c.id, COALESCE(count(*), 0)
from cc_community c
join cc_invite i on c.id = i.community_id
where c.del_flag = '0'
and i.del_flag = '0'
group by i.community_id
</select>
</mapper>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mcwl.communityCenter.mapper.CommunityUserMapper">
<select id="selectByTenantIdAndCommunityIdAndUserId"
resultType="com.mcwl.communityCenter.domain.CommunityUser">
select id,
tenant_id,
community_id,
user_id
from cc_community_user
where tenant_id = #{tenantId}
and community_id = #{communityId}
and user_id = #{userId}
and del_flag = '0';
</select>
</mapper>

View File

@ -89,22 +89,22 @@ public class RedisConfig extends CachingConfigurerSupport
* redis
* @return RedisConnectionFactory
*/
@Bean
public LettuceConnectionFactory redisConnectionFactory() {
RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration(host, port);
standaloneConfig.setPassword(RedisPassword.of(password));
LettuceClientConfiguration lettuceClientConfig = LettuceClientConfiguration.builder()
.commandTimeout(Duration.ofSeconds(10))
.shutdownTimeout(Duration.ZERO)
.build();
// 创建 Lettuce 连接工厂,并同时设置服务器配置和客户端配置
LettuceConnectionFactory factory = new LettuceConnectionFactory(standaloneConfig, lettuceClientConfig);
factory.afterPropertiesSet(); // 确保配置生效
return factory;
}
// @Bean
// public LettuceConnectionFactory redisConnectionFactory() {
// RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration(host, port);
// standaloneConfig.setPassword(RedisPassword.of(password));
//
// LettuceClientConfiguration lettuceClientConfig = LettuceClientConfiguration.builder()
// .commandTimeout(Duration.ofSeconds(10))
// .shutdownTimeout(Duration.ZERO)
// .build();
//
// // 创建 Lettuce 连接工厂,并同时设置服务器配置和客户端配置
// LettuceConnectionFactory factory = new LettuceConnectionFactory(standaloneConfig, lettuceClientConfig);
// factory.afterPropertiesSet(); // 确保配置生效
//
// return factory;
// }
}

View File

@ -30,7 +30,7 @@ public class EmptyPointsRemindConsumer {
private final ISysUserService sysUserService;
/**
*
*
*/
@RabbitListener(queues = QueueConstants.EMPTY_POINTS_REMIND_QUEUE, ackMode = "MANUAL")
public void emptyPointsRemind(Member member, Channel channel, Message message) {
@ -40,15 +40,12 @@ public class EmptyPointsRemindConsumer {
sysAdvice.setSenderId(sysUser.getUserId());
sysAdvice.setReceiverId(member.getUserId());
sysAdvice.setType(AdviceEnum.SYSTEM_NOTICE);
sysAdvice.setTitle("积分清零提醒");
sysAdvice.setContent("您的积分月底前两天将清零,请及时消费");
sysAdvice.setCreateBy(sysUser.getUserName());
sysAdvice.setUpdateBy(sysUser.getUserName());
sysAdvice.setUpdateTime(new Date());
sysAdvice.setTitle("积分重置提醒");
sysAdvice.setContent("您的积分月底将重置,请及时消费");
sysAdviceService.save(sysAdvice);
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
log.error("处理积分清零提醒消息时出错: {}", e.getMessage(), e);
log.error("处理积分重置提醒消息时出错: {}", e.getMessage(), e);
try {
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
} catch (IOException ex) {

View File

@ -0,0 +1,699 @@
package com.mcwl.resource.consumer;
import com.mcwl.common.constant.QueueConstants;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.exception.ServiceException;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.resource.domain.*;
import com.mcwl.resource.mapper.*;
import com.mcwl.resource.service.ISysAdviceService;
import com.mcwl.system.domain.enums.AdviceEnum;
import com.mcwl.system.service.ISysUserService;
import com.rabbitmq.client.Channel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import java.io.IOException;
import java.util.Map;
import java.util.Objects;
@Slf4j
@Component
@RequiredArgsConstructor
public class LikeConsumer {
private final ModelMapper modelMapper;
private final ModelLikeMapper modelLikeMapper;
private final ISysAdviceService sysAdviceService;
private final ISysUserService sysUserService;
private final ModelCommentMapper modelCommentMapper;
private final ModelCommentLikeMapper modelCommentLikeMapper;
private final ModelImageCommentMapper modelImageCommentMapper;
private final ModelImageCommentLikeMapper modelImageCommentLikeMapper;
private final ModelImageMapper modelImageMapper;
private final ModelImageLikeMapper modelImageLikeMapper;
private final WorkFlowMapper workFlowMapper;
private final WorkFlowLikeMapper workFlowLikeMapper;
private final WorkFlowCommentMapper workFlowCommentMapper;
private final WorkFlowCommentLikeMapper workFlowCommentLikeMapper;
/**
*
*/
@RabbitListener(queues = QueueConstants.MODEL_LIKE_QUEUE, ackMode = "MANUAL")
@Transactional(rollbackFor = Exception.class)
public void modelLikeMsg(Map<String, Long> map, Channel channel, Message message) {
try {
Long userId = map.get("userId");
Long productId = map.get("commentId");
this.modelLike(userId, productId);
// 注册事务同步回调
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
try {
// 事务提交后发送ACK
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (IOException e) {
log.error("ACK失败: {}", e.getMessage());
}
}
@Override
public void afterCompletion(int status) {
if (status == STATUS_ROLLED_BACK) {
try {
// 事务回滚后发送NACK
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
} catch (IOException e) {
log.error("NACK失败: {}", e.getMessage());
}
}
}
});
} catch (Exception e) {
log.error("模型点赞消息出错: {}", e.getMessage(), e);
throw new ServiceException("模型点赞消息出错");
}
}
/**
*
*/
@RabbitListener(queues = QueueConstants.MODEL_COMMENT_LIKE_QUEUE, ackMode = "MANUAL")
@Transactional(rollbackFor = Exception.class)
public void modelCommentLikeMsg(Map<String, Long> map, Channel channel, Message message) {
try {
Long userId = map.get("userId");
Long productId = map.get("commentId");
this.modelCommentLike(userId, productId);
// 注册事务同步回调
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
try {
// 事务提交后发送ACK
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (IOException e) {
log.error("ACK失败: {}", e.getMessage());
}
}
@Override
public void afterCompletion(int status) {
if (status == STATUS_ROLLED_BACK) {
try {
// 事务回滚后发送NACK
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
} catch (IOException e) {
log.error("NACK失败: {}", e.getMessage());
}
}
}
});
} catch (Exception e) {
log.error("模型评论点赞消息出错: {}", e.getMessage(), e);
throw new ServiceException("模型评论点赞消息出错");
}
}
/**
*
*/
@RabbitListener(queues = QueueConstants.IMAGE_LIKE_QUEUE, ackMode = "MANUAL")
@Transactional(rollbackFor = Exception.class)
public void imageLikeMsg(Map<String, Long> map, Channel channel, Message message) {
try {
Long userId = map.get("userId");
Long productId = map.get("commentId");
this.imageLike(userId, productId);
// 注册事务同步回调
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
try {
// 事务提交后发送ACK
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (IOException e) {
log.error("ACK失败: {}", e.getMessage());
}
}
@Override
public void afterCompletion(int status) {
if (status == STATUS_ROLLED_BACK) {
try {
// 事务回滚后发送NACK
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
} catch (IOException e) {
log.error("NACK失败: {}", e.getMessage());
}
}
}
});
} catch (Exception e) {
log.error("图片点赞消息出错: {}", e.getMessage(), e);
throw new ServiceException("图片点赞消息出错");
}
}
/**s
*
*/
@RabbitListener(queues = QueueConstants.IMAGE_COMMENT_LIKE_QUEUE, ackMode = "MANUAL")
@Transactional(rollbackFor = Exception.class)
public void imageCommentLikeMsg(Map<String, Long> map, Channel channel, Message message) {
try {
Long userId = map.get("userId");
Long productId = map.get("commentId");
this.imageCommentLike(userId, productId);
// 注册事务同步回调
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
try {
// 事务提交后发送ACK
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (IOException e) {
log.error("ACK失败: {}", e.getMessage());
}
}
@Override
public void afterCompletion(int status) {
if (status == STATUS_ROLLED_BACK) {
try {
// 事务回滚后发送NACK
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
} catch (IOException e) {
log.error("NACK失败: {}", e.getMessage());
}
}
}
});
} catch (Exception e) {
log.error("图片评论点赞消息出错: {}", e.getMessage(), e);
throw new ServiceException("图片评论点赞消息出错");
}
}
/**
*
*/
@RabbitListener(queues = QueueConstants.WORK_FLOW_LIKE_QUEUE, ackMode = "MANUAL")
@Transactional(rollbackFor = Exception.class)
public void workFlowLikeMsg(Map<String, Long> map, Channel channel, Message message) {
try {
Long userId = map.get("userId");
Long productId = map.get("commentId");
this.workFLowLike(userId, productId);
// 注册事务同步回调
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
try {
// 事务提交后发送ACK
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (IOException e) {
log.error("ACK失败: {}", e.getMessage());
}
}
@Override
public void afterCompletion(int status) {
if (status == STATUS_ROLLED_BACK) {
try {
// 事务回滚后发送NACK
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
} catch (IOException e) {
log.error("NACK失败: {}", e.getMessage());
}
}
}
});
} catch (Exception e) {
log.error("工作流点赞消息出错: {}", e.getMessage(), e);
throw new ServiceException("工作流点赞消息出错");
}
}
/**
*
*/
@RabbitListener(queues = QueueConstants.WORK_FLOW_COMMENT_LIKE_QUEUE, ackMode = "MANUAL")
@Transactional(rollbackFor = Exception.class)
public void workFlowCommentLikeMsg(Map<String, Long> map, Channel channel, Message message) {
try {
Long userId = map.get("userId");
Long productId = map.get("commentId");
this.workFlowCommentLike(userId, productId);
// 注册事务同步回调
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
try {
// 事务提交后发送ACK
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (IOException e) {
log.error("ACK失败: {}", e.getMessage());
}
}
@Override
public void afterCompletion(int status) {
if (status == STATUS_ROLLED_BACK) {
try {
// 事务回滚后发送NACK
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
} catch (IOException e) {
log.error("NACK失败: {}", e.getMessage());
}
}
}
});
} catch (Exception e) {
log.error("工作流评论点赞消息出错: {}", e.getMessage(), e);
throw new ServiceException("工作流评论点赞消息出错");
}
}
private void modelLike(Long userId, Long modelId) {
ModelProduct model = modelMapper.selectById(modelId);
if (Objects.isNull(model)) {
throw new ServiceException("该模型不存在或已下架");
}
ModelLike modelLike = modelLikeMapper.getLike(userId, modelId);
if (Objects.nonNull(modelLike)) {
if (Objects.equals(modelLike.getDelFlag(), "0")) {
modelLike.setDelFlag("2");
int likeNum = model.getLikeNum() - 1;
likeNum = Math.max(likeNum, 0);
model.setLikeNum(likeNum);
} else {
modelLike.setDelFlag("0");
model.setLikeNum(model.getLikeNum() + 1);
this.addLikeAdvice(model, userId);
}
// 更新点赞记录
modelLikeMapper.updateDelFlagById(modelLike);
// 更新图片点赞数
modelMapper.updateById(model);
return;
}
// 添加点赞记录
modelLike = new ModelLike();
modelLike.setUserId(userId);
modelLike.setModelId(modelId);
modelLikeMapper.insert(modelLike);
// 更新图片点赞数
model.setNumbers(model.getLikeNum() + 1);
modelMapper.updateById(model);
this.addLikeAdvice(model, userId);
}
private void addLikeAdvice(ModelProduct model, Long userId) {
Long receiverUserId = model.getUserId();
if (Objects.equals(userId, receiverUserId)) {
return;
}
SysUser sysUser = sysUserService.selectUserById(userId);
String content = StringUtils.format("恭喜!{}点赞了您的模型:{}",
sysUser.getNickName(), model.getModelName());
SysAdvice sysAdvice = new SysAdvice();
sysAdvice.setSenderId(userId);
sysAdvice.setReceiverId(receiverUserId);
sysAdvice.setContent(content);
sysAdvice.setProductId(model.getId());
sysAdvice.setProductType(0);
sysAdvice.setIsRead(0);
sysAdvice.setType(AdviceEnum.LIKE_REMIND);
sysAdviceService.save(sysAdvice);
}
private void modelCommentLike(Long userId, Long commentId) {
ModelComment modelComment = modelCommentMapper.selectById(commentId);
if (Objects.isNull(modelComment)) {
throw new ServiceException("该评论不存在");
}
ModelCommentLike modelCommentLike = modelCommentLikeMapper.getLikeComment(userId, commentId);
if (Objects.nonNull(modelCommentLike)) {
if (Objects.equals(modelCommentLike.getDelFlag(), "0")) {
modelCommentLike.setDelFlag("2");
int likeNum = modelComment.getLikeNum() - 1;
likeNum = Math.max(likeNum, 0);
modelComment.setLikeNum(likeNum);
} else {
modelCommentLike.setDelFlag("0");
modelComment.setLikeNum(modelComment.getLikeNum() + 1);
this.addLikeAdvice(modelComment, userId);
}
// 更新点赞记录
modelCommentLikeMapper.updateDelFlagById(modelCommentLike);
// 更新图片评论点赞数
modelCommentMapper.updateById(modelComment);
return;
}
// 添加点赞记录
modelCommentLike = new ModelCommentLike();
modelCommentLike.setUserId(userId);
modelCommentLike.setModelCommentId(commentId);
modelCommentLikeMapper.insert(modelCommentLike);
// 更新模型点赞数
modelComment.setLikeNum(modelComment.getLikeNum() + 1);
modelCommentMapper.updateById(modelComment);
this.addLikeAdvice(modelComment, userId);
}
private void addLikeAdvice(ModelComment modelComment, Long userId) {
Long receiverUserId = modelComment.getUserId();
if (Objects.equals(userId, receiverUserId)) {
return;
}
SysUser sysUser = sysUserService.selectUserById(userId);
String content = StringUtils.format("恭喜!{}点赞了您的评论",
sysUser.getNickName());
SysAdvice sysAdvice = new SysAdvice();
sysAdvice.setSenderId(userId);
sysAdvice.setReceiverId(receiverUserId);
sysAdvice.setContent(content);
sysAdvice.setProductId(modelComment.getModelId());
sysAdvice.setProductType(0);
sysAdvice.setCommentId(modelComment.getId());
sysAdvice.setIsRead(0);
sysAdvice.setType(AdviceEnum.LIKE_REMIND);
sysAdviceService.save(sysAdvice);
}
private void imageLike(Long userId, Long imageId) {
ModelImage modelImage = modelImageMapper.selectById(imageId);
if (Objects.isNull(modelImage)) {
throw new ServiceException("该图片不存在或已下架");
}
ModelImageLike modelImageLike = modelImageLikeMapper.getLikeImage(userId, imageId);
if (Objects.nonNull(modelImageLike)) {
if (Objects.equals(modelImageLike.getDelFlag(), "0")) {
modelImageLike.setDelFlag("2");
int likeNum = modelImage.getLikeNum() - 1;
likeNum = Math.max(likeNum, 0);
modelImage.setLikeNum(likeNum);
} else {
modelImageLike.setDelFlag("0");
modelImage.setLikeNum(modelImage.getLikeNum() + 1);
this.addLikeAdvice(modelImage, userId);
}
// 更新点赞记录
modelImageLikeMapper.updateDelFlagById(modelImageLike);
// 更新图片点赞数
modelImageMapper.updateById(modelImage);
return;
}
// 添加点赞记录
modelImageLike = new ModelImageLike();
modelImageLike.setUserId(userId);
modelImageLike.setModelImageId(imageId);
modelImageLikeMapper.insert(modelImageLike);
// 更新图片点赞数
modelImage.setLikeNum(modelImage.getLikeNum() + 1);
modelImageMapper.updateById(modelImage);
this.addLikeAdvice(modelImage, userId);
}
private void addLikeAdvice(ModelImage modelImage, Long userId) {
Long receiverUserId = modelImage.getUserId();
if (Objects.equals(userId, receiverUserId)) {
return;
}
SysUser sysUser = sysUserService.selectUserById(userId);
String content = StringUtils.format("恭喜!{}点赞了您的图片:{}",
sysUser.getNickName(), modelImage.getTitle());
SysAdvice sysAdvice = new SysAdvice();
sysAdvice.setSenderId(userId);
sysAdvice.setReceiverId(receiverUserId);
sysAdvice.setContent(content);
sysAdvice.setProductId(modelImage.getId());
sysAdvice.setProductType(2);
sysAdvice.setIsRead(0);
sysAdvice.setType(AdviceEnum.LIKE_REMIND);
sysAdviceService.save(sysAdvice);
}
private void imageCommentLike(Long userId, Long commentId) {
ModelImageComment modelImageComment = modelImageCommentMapper.selectById(commentId);
if (Objects.isNull(modelImageComment)) {
throw new ServiceException("该评论不存在");
}
ModelImageCommentLike modelImageCommentLike = modelImageCommentLikeMapper.getLikeImageComment(userId, commentId);
if (Objects.nonNull(modelImageCommentLike)) {
if (Objects.equals(modelImageCommentLike.getDelFlag(), "0")) {
modelImageCommentLike.setDelFlag("2");
int likeNum = modelImageComment.getLikeNum() - 1;
likeNum = Math.max(likeNum, 0);
modelImageComment.setLikeNum(likeNum);
} else {
modelImageCommentLike.setDelFlag("0");
modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1);
this.addLikeAdvice(modelImageComment, userId);
}
// 更新点赞记录
modelImageCommentLikeMapper.updateDelFlagById(modelImageCommentLike);
// 更新图片评论点赞数
modelImageCommentMapper.updateById(modelImageComment);
return;
}
// 添加点赞记录
modelImageCommentLike = new ModelImageCommentLike();
modelImageCommentLike.setUserId(userId);
modelImageCommentLike.setModelImageCommentId(commentId);
modelImageCommentLikeMapper.insert(modelImageCommentLike);
// 更新图片点赞数
modelImageComment.setLikeNum(modelImageComment.getLikeNum() + 1);
modelImageCommentMapper.updateById(modelImageComment);
this.addLikeAdvice(modelImageComment, userId);
}
private void addLikeAdvice(ModelImageComment modelImageComment, Long userId) {
Long receiverUserId = modelImageComment.getUserId();
if (Objects.equals(userId, receiverUserId)) {
return;
}
SysUser sysUser = sysUserService.selectUserById(userId);
String content = StringUtils.format("恭喜!{}点赞了您的评论",
sysUser.getNickName());
SysAdvice sysAdvice = new SysAdvice();
sysAdvice.setSenderId(userId);
sysAdvice.setReceiverId(receiverUserId);
sysAdvice.setContent(content);
sysAdvice.setProductId(modelImageComment.getModelImageId());
sysAdvice.setProductType(2);
sysAdvice.setCommentId(modelImageComment.getId());
sysAdvice.setIsRead(0);
sysAdvice.setType(AdviceEnum.LIKE_REMIND);
sysAdviceService.save(sysAdvice);
}
private void workFLowLike(Long userId, Long modelId) {
WorkFlow workFlow = workFlowMapper.selectById(modelId);
if (Objects.isNull(workFlow)) {
throw new ServiceException("该工作流不存在或已下架");
}
WorkFlowLike workFlowLike = workFlowLikeMapper.getLike(userId, modelId);
if (Objects.nonNull(workFlowLike)) {
if (Objects.equals(workFlowLike.getDelFlag(), "0")) {
workFlowLike.setDelFlag("2");
int likeCount = workFlow.getLikeNum() - 1;
likeCount = Math.max(likeCount, 0);
workFlow.setLikeNum(likeCount);
} else {
workFlowLike.setDelFlag("0");
workFlow.setLikeNum(workFlow.getLikeNum() + 1);
this.addLikeAdvice(workFlow, userId);
}
// 更新点赞记录
workFlowLikeMapper.updateStatus(workFlowLike);
// 更新图片点赞数
workFlowMapper.updateById(workFlow);
return;
}
// 添加点赞记录
workFlowLike = new WorkFlowLike();
workFlowLike.setUserId(userId);
workFlowLike.setWorkFlowId(modelId);
workFlowLikeMapper.insert(workFlowLike);
// 更新图片点赞数
workFlow.setLikeNum(workFlow.getLikeNum() + 1);
workFlowMapper.updateById(workFlow);
this.addLikeAdvice(workFlow, userId);
}
private void addLikeAdvice(WorkFlow workFlow, Long userId) {
Long receiverUserId = workFlow.getUserId();
if (Objects.equals(userId, receiverUserId)) {
return;
}
SysUser sysUser = sysUserService.selectUserById(userId);
String content = StringUtils.format("恭喜!{}点赞了您的工作流:{}",
sysUser.getNickName(), workFlow.getWorkflowName());
SysAdvice sysAdvice = new SysAdvice();
sysAdvice.setSenderId(userId);
sysAdvice.setReceiverId(receiverUserId);
sysAdvice.setContent(content);
sysAdvice.setProductId(workFlow.getId());
sysAdvice.setProductType(1);
sysAdvice.setIsRead(0);
sysAdvice.setType(AdviceEnum.LIKE_REMIND);
sysAdviceService.save(sysAdvice);
}
private void workFlowCommentLike(Long userId, Long commentId) {
WorkFlowComment workFlowComment = workFlowCommentMapper.selectById(commentId);
if (Objects.isNull(workFlowComment)) {
throw new ServiceException("该评论不存在");
}
WorkFlowCommentLike workFlowCommentLike = workFlowCommentLikeMapper.getLikeComment(userId, commentId);
if (Objects.nonNull(workFlowCommentLike)) {
if (Objects.equals(workFlowCommentLike.getDelFlag(), "0")) {
workFlowCommentLike.setDelFlag("2");
int likeNum = workFlowComment.getLikeNum() - 1;
likeNum = Math.max(likeNum, 0);
workFlowComment.setLikeNum(likeNum);
} else {
workFlowCommentLike.setDelFlag("0");
workFlowComment.setLikeNum(workFlowComment.getLikeNum() + 1);
this.addLikeAdvice(workFlowComment, userId);
}
// 更新点赞记录
workFlowCommentLikeMapper.updateDelFlagById(workFlowCommentLike);
// 更新图片评论点赞数
workFlowCommentMapper.updateById(workFlowComment);
return;
}
// 添加点赞记录
workFlowCommentLike = new WorkFlowCommentLike();
workFlowCommentLike.setUserId(userId);
workFlowCommentLike.setWorkFlowCommentId(commentId);
workFlowCommentLikeMapper.insert(workFlowCommentLike);
// 更新模型点赞数
workFlowComment.setLikeNum(workFlowComment.getLikeNum() + 1);
workFlowCommentMapper.updateById(workFlowComment);
this.addLikeAdvice(workFlowComment, userId);
}
private void addLikeAdvice(WorkFlowComment workFlowComment, Long userId) {
Long receiverUserId = workFlowComment.getUserId();
if (Objects.equals(userId, receiverUserId)) {
return;
}
SysUser sysUser = sysUserService.selectUserById(userId);
String content = StringUtils.format("恭喜!{}点赞了您的评论",
sysUser.getNickName());
SysAdvice sysAdvice = new SysAdvice();
sysAdvice.setSenderId(userId);
sysAdvice.setReceiverId(receiverUserId);
sysAdvice.setContent(content);
sysAdvice.setProductId(workFlowComment.getWorkFlowId());
sysAdvice.setProductType(1);
sysAdvice.setCommentId(workFlowComment.getId());
sysAdvice.setIsRead(0);
sysAdvice.setType(AdviceEnum.LIKE_REMIND);
sysAdviceService.save(sysAdvice);
}
}

View File

@ -27,4 +27,6 @@ public interface ModelVersionMapper extends BaseMapper<ModelVersion> {
ModelVersion selectByProductId(@Param("id") Long id);
ModelVersion selectByEncryptionFileName(@Param("name") String name);
}

View File

@ -38,14 +38,14 @@ public class FileServiceImpl implements FileService {
if (type.equals("model")) {
ModelVersion modelVersion = versionMapper.selectByFileName(name);
ModelVersion modelVersion = versionMapper.selectByEncryptionFileName(name);
if (modelVersion == null) {
return AjaxResult.error("文件不存在");
}
return AjaxResult.success(modelVersion);
}else if (type.equals("workflow")){
} else if (type.equals("workflow")){
WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectByFileName(name);
if (workFlowVersion == null) {

View File

@ -2,11 +2,13 @@ package com.mcwl.resource.service.impl;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.constant.QueueConstants;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.resource.domain.ModelCommentLike;
import com.mcwl.resource.mapper.ModelCommentLikeMapper;
import com.mcwl.resource.service.ModelCommentLikeService;
import com.mcwl.resource.util.MqttTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -23,12 +25,16 @@ public class ModelCommentLikeServiceImpl extends ServiceImpl<ModelCommentLikeMap
@Autowired
private MqttTemplate mqttTemplate;
@Autowired
private RabbitTemplate rabbitTemplate;
@Override
public void like(Long commentId) {
Map<String, Long> map = new HashMap<>();
map.put("userId", SecurityUtils.getUserId());
map.put("commentId", commentId);
mqttTemplate.publish("modelCommentLike", JSONUtil.toJsonStr(map), 0);
// mqttTemplate.publish("modelCommentLike", JSONUtil.toJsonStr(map), 0);
rabbitTemplate.convertAndSend(QueueConstants.MODEL_COMMENT_LIKE_QUEUE, map);
}

View File

@ -2,12 +2,14 @@ package com.mcwl.resource.service.impl;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.constant.QueueConstants;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.resource.domain.ModelImageCommentLike;
import com.mcwl.resource.mapper.ModelImageCommentLikeMapper;
import com.mcwl.resource.service.ModelImageCommentLikeService;
import com.mcwl.resource.util.MqttTemplate;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -22,15 +24,18 @@ import java.util.Map;
@RequiredArgsConstructor
public class ModelImageCommentLikeServiceImpl extends ServiceImpl<ModelImageCommentLikeMapper, ModelImageCommentLike> implements ModelImageCommentLikeService {
@Autowired
private MqttTemplate mqttTemplate;
private final MqttTemplate mqttTemplate;
private final RabbitTemplate rabbitTemplate;
@Override
public void like(Long commentId) {
Map<String, Long> map = new HashMap<>();
map.put("userId", SecurityUtils.getUserId());
map.put("commentId", commentId);
mqttTemplate.publish("imageCommentLike", JSONUtil.toJsonStr(map),0);
// mqttTemplate.publish("imageCommentLike", JSONUtil.toJsonStr(map),0);
rabbitTemplate.convertAndSend(QueueConstants.IMAGE_COMMENT_LIKE_QUEUE, map);
}

View File

@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.constant.QueueConstants;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
@ -27,6 +28,7 @@ import com.mcwl.resource.util.MqttTemplate;
import com.mcwl.system.domain.enums.AdviceEnum;
import com.mcwl.system.service.ISysUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -46,12 +48,16 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
@Autowired
private MqttTemplate mqttTemplate;
private final RabbitTemplate rabbitTemplate;
@Override
public void like(Long imageId) {
Map<String, Long> map = new HashMap<>();
map.put("userId", SecurityUtils.getUserId());
map.put("commentId", imageId);
mqttTemplate.publish("imageLike", JSONUtil.toJsonStr(map),0);
// mqttTemplate.publish("imageLike", JSONUtil.toJsonStr(map),0);
Long userId = SecurityUtils.getUserId();
rabbitTemplate.convertAndSend(QueueConstants.IMAGE_LIKE_QUEUE, map);
}
@Override

View File

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.constant.QueueConstants;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
@ -20,6 +21,7 @@ import com.mcwl.resource.mapper.ModelMapper;
import com.mcwl.resource.service.ModelLikeService;
import com.mcwl.resource.util.MqttTemplate;
import com.mcwl.system.service.ISysUserService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -41,13 +43,17 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
@Autowired
private MqttTemplate mqttTemplate;
@Autowired
private RabbitTemplate rabbitTemplate;
@Override
public void like(Long modelId) {
Map<String, Long> map = new HashMap<>();
map.put("userId", SecurityUtils.getUserId());
map.put("commentId", modelId);
mqttTemplate.publish("modelLike", JSONUtil.toJsonStr(map),0);
// mqttTemplate.publish("modelLike", JSONUtil.toJsonStr(map), 0);
rabbitTemplate.convertAndSend(QueueConstants.MODEL_LIKE_QUEUE, map);
}
@Override

View File

@ -273,7 +273,8 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
//校验是否实名
SysUser sysUser = sysUserService.selectUserInfoById(SecurityUtils.getUserId());
if (sysUser.getName() == null){
log.info("查询到的个人数据:{}",sysUser);
if (StringUtils.isEmpty(sysUser.getName())){
return R.fail(HttpStatus.SHOW_ERROR_MSG,"实名制后才可以发布");
}

View File

@ -2,11 +2,13 @@ package com.mcwl.resource.service.impl;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.constant.QueueConstants;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.resource.domain.WorkFlowCommentLike;
import com.mcwl.resource.mapper.WorkFlowCommentLikeMapper;
import com.mcwl.resource.service.WorkFlowCommentLikeService;
import com.mcwl.resource.util.MqttTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -28,12 +30,16 @@ public class WorkFlowCommentLikeServiceImpl extends ServiceImpl<WorkFlowCommentL
@Autowired
private MqttTemplate mqttTemplate;
@Autowired
private RabbitTemplate rabbitTemplate;
@Override
public void like(Long commentId) {
Map<String, Long> map = new HashMap<>();
map.put("userId", SecurityUtils.getUserId());
map.put("commentId", commentId);
mqttTemplate.publish("workFlowCommentLike", JSONUtil.toJsonStr(map),0);
// mqttTemplate.publish("workFlowCommentLike", JSONUtil.toJsonStr(map),0);
rabbitTemplate.convertAndSend(QueueConstants.WORK_FLOW_COMMENT_LIKE_QUEUE, map);
}

View File

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.constant.QueueConstants;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
@ -20,6 +21,7 @@ import com.mcwl.resource.mapper.WorkFlowMapper;
import com.mcwl.resource.service.WorkFlowLikeService;
import com.mcwl.resource.util.MqttTemplate;
import com.mcwl.system.service.ISysUserService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -48,12 +50,16 @@ public class WorkFlowLikeServiceImpl extends ServiceImpl<WorkFlowLikeMapper, Wor
@Autowired
private MqttTemplate mqttTemplate;
@Autowired
private RabbitTemplate rabbitTemplate;
@Override
public void like(Long modelId) {
Map<String, Long> map = new HashMap<>();
map.put("userId", SecurityUtils.getUserId());
map.put("commentId", modelId);
mqttTemplate.publish("workFlowLike", JSONUtil.toJsonStr(map),0);
// mqttTemplate.publish("workFlowLike", JSONUtil.toJsonStr(map),0);
rabbitTemplate.convertAndSend(QueueConstants.WORK_FLOW_LIKE_QUEUE, map);
}
@Override

View File

@ -49,7 +49,7 @@
</update>
<select id="selectByFileName" resultType="com.mcwl.resource.domain.ModelVersion">
select key_rate,is_encrypt from model_version where encrypt_file_name = #{name}
select key_rate,is_encrypt from model_version where file_name = #{name}
</select>
<select id="selectByHash" resultType="com.mcwl.resource.domain.ModelVersion">
select * from model_version where file_hash = #{hashCode}
@ -58,5 +58,8 @@
<select id="selectByProductId" resultType="com.mcwl.resource.domain.ModelVersion">
SELECT * FROM model_version WHERE model_id = #{id} LIMIT 1
</select>
<select id="selectByEncryptionFileName" resultType="com.mcwl.resource.domain.ModelVersion">
select key_rate,is_encrypt from model_version where encryption_file_name = #{name}
</select>
</mapper>