fix: 修复接受邀请时的异常
parent
b1b884a82e
commit
1ef75e6bda
|
@ -20,9 +20,9 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertFill(MetaObject metaObject) {
|
public void insertFill(MetaObject metaObject) {
|
||||||
this.setFieldValByName("createBy", SecurityUtils.getUsername(), metaObject);
|
this.strictInsertFill(metaObject, "createBy", String.class, SecurityUtils.getUsername());
|
||||||
this.setFieldValByName("createTime", new Date(), metaObject);
|
this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
|
||||||
this.setFieldValByName("tenantId", SecurityUtils.getUserId(), metaObject);
|
this.strictInsertFill(metaObject, "tenantId", Long.class, SecurityUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package com.mcwl.communityCenter.constant;
|
package com.mcwl.communityCenter.constant;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请常量
|
||||||
|
*/
|
||||||
public class InviteConstant {
|
public class InviteConstant {
|
||||||
/**
|
/**
|
||||||
* 邀请类型 0普通用户
|
* 邀请类型 0普通用户
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mcwl.communityCenter.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态常量
|
||||||
|
*/
|
||||||
|
public class StatusConstant {
|
||||||
|
/**
|
||||||
|
* 可用
|
||||||
|
*/
|
||||||
|
public static final int STATUS_AVAILABLE = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不可用
|
||||||
|
*/
|
||||||
|
public static final int STATUS_UNAVAILABLE = 0;
|
||||||
|
|
||||||
|
}
|
|
@ -34,6 +34,11 @@ public class Publish extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布人
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布时间 - 定时发布
|
* 发布时间 - 定时发布
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.common.utils.ShareCodeUtils;
|
import com.mcwl.common.utils.ShareCodeUtils;
|
||||||
import com.mcwl.communityCenter.constant.InviteConstant;
|
import com.mcwl.communityCenter.constant.InviteConstant;
|
||||||
|
import com.mcwl.communityCenter.constant.StatusConstant;
|
||||||
import com.mcwl.communityCenter.domain.Invite;
|
import com.mcwl.communityCenter.domain.Invite;
|
||||||
import com.mcwl.communityCenter.domain.InviteCodeMapping;
|
import com.mcwl.communityCenter.domain.InviteCodeMapping;
|
||||||
import com.mcwl.communityCenter.domain.Publish;
|
import com.mcwl.communityCenter.domain.Publish;
|
||||||
|
@ -24,6 +25,7 @@ import com.mcwl.communityCenter.service.PublishService;
|
||||||
import com.mcwl.communityCenter.service.UserCommunityService;
|
import com.mcwl.communityCenter.service.UserCommunityService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -66,6 +68,7 @@ public class InviteServiceImpl extends ServiceImpl<InviteMapper, Invite> impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean acceptInvite(Long communityId, String inviteCode) {
|
public boolean acceptInvite(Long communityId, String inviteCode) {
|
||||||
|
|
||||||
// 解析邀请码
|
// 解析邀请码
|
||||||
|
@ -74,6 +77,11 @@ public class InviteServiceImpl extends ServiceImpl<InviteMapper, Invite> impleme
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断是否是同一个人
|
||||||
|
if (Objects.equals(userId, SecurityUtils.getUserId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// 查询邀请码
|
// 查询邀请码
|
||||||
InviteCodeMapping inviteCodeMapping = inviteCodeMappingService.lambdaQuery()
|
InviteCodeMapping inviteCodeMapping = inviteCodeMappingService.lambdaQuery()
|
||||||
.eq(InviteCodeMapping::getUserId, userId)
|
.eq(InviteCodeMapping::getUserId, userId)
|
||||||
|
@ -85,6 +93,8 @@ public class InviteServiceImpl extends ServiceImpl<InviteMapper, Invite> impleme
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inviteCodeMapping.setStatus(StatusConstant.STATUS_UNAVAILABLE);
|
||||||
|
inviteCodeMappingService.updateById(inviteCodeMapping);
|
||||||
|
|
||||||
Invite invite = new Invite();
|
Invite invite = new Invite();
|
||||||
invite.setTenantId(userId);
|
invite.setTenantId(userId);
|
||||||
|
|
Loading…
Reference in New Issue