Merge branch 'feature/community-center' into preview
commit
2ba9f440d3
|
@ -39,8 +39,8 @@ public class InviteController {
|
||||||
* 接受邀请
|
* 接受邀请
|
||||||
*/
|
*/
|
||||||
@GetMapping("acceptInvite")
|
@GetMapping("acceptInvite")
|
||||||
public AjaxResult acceptInvite(@NotNull(message = "communityId不能为空") Long communityId,
|
public AjaxResult acceptInvite(@NotNull(message = "社区不能为空") Long communityId,
|
||||||
@NotBlank(message = "inviteCode不能为空") String inviteCode) {
|
@NotBlank(message = "邀请码不能为空") String inviteCode) {
|
||||||
// 接受邀请
|
// 接受邀请
|
||||||
boolean result = inviteService.acceptInvite(communityId, inviteCode);
|
boolean result = inviteService.acceptInvite(communityId, inviteCode);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
package com.mcwl.web.controller.communityCenter;
|
package com.mcwl.web.controller.communityCenter;
|
||||||
|
|
||||||
|
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
|
import com.mcwl.communityCenter.domain.dto.QuestionRes;
|
||||||
|
import com.mcwl.communityCenter.service.QuestionService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提问
|
* 提问
|
||||||
|
@ -14,6 +19,30 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
public class QuestionController {
|
public class QuestionController {
|
||||||
|
|
||||||
|
|
||||||
|
private final QuestionService questionService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提问
|
||||||
|
*/
|
||||||
|
@PostMapping("addQuestion")
|
||||||
|
public AjaxResult addQuestion(@RequestBody QuestionRes questionRes) {
|
||||||
|
|
||||||
|
questionService.addQuestion(questionRes);
|
||||||
|
|
||||||
|
return AjaxResult.success();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取问题列表
|
||||||
|
*/
|
||||||
|
@GetMapping("list")
|
||||||
|
public TableDataInfo getQuestionList(@NotNull(message = "社区不能为空") Long communityId) {
|
||||||
|
|
||||||
|
// return questionService.getQuestionList(communityId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,14 @@ public class StatusConstant {
|
||||||
*/
|
*/
|
||||||
public static final int STATUS_UNAVAILABLE = 0;
|
public static final int STATUS_UNAVAILABLE = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已回复
|
||||||
|
*/
|
||||||
|
public static final int STATUS_REPLIED = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未回复
|
||||||
|
*/
|
||||||
|
public static final int STATUS_UNREPLIED = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
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 lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社区通知
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("cc_advice")
|
||||||
|
public class CommunityAdvice extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 租户id
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Long tenantId;
|
||||||
|
/**
|
||||||
|
* 社区id
|
||||||
|
*/
|
||||||
|
private Long communityId;
|
||||||
|
/**
|
||||||
|
* 通知人
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
/**
|
||||||
|
* 通知内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
/**
|
||||||
|
* 是否已读
|
||||||
|
*/
|
||||||
|
private String isRead;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package com.mcwl.communityCenter.domain;
|
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.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.mcwl.common.core.domain.BaseEntity;
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
@ -20,7 +22,12 @@ public class Invite extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 用户id - 租户id
|
* 用户id - 租户id
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
/**
|
||||||
|
* 社区id
|
||||||
|
*/
|
||||||
|
private Long communityId;
|
||||||
/**
|
/**
|
||||||
* 被邀请人
|
* 被邀请人
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,6 +21,10 @@ public class InviteCodeMapping extends BaseEntity {
|
||||||
* 用户id
|
* 用户id
|
||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 社区id
|
||||||
|
*/
|
||||||
|
private Long communityId;
|
||||||
/**
|
/**
|
||||||
* 邀请码
|
* 邀请码
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -27,6 +27,11 @@ public class Question extends BaseEntity {
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社区id
|
||||||
|
*/
|
||||||
|
private Long communityId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提问用户id
|
* 提问用户id
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.mcwl.communityCenter.domain.dto;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提问请求参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QuestionRes {
|
||||||
|
/**
|
||||||
|
* 租户id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "租户不能为空")
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 社区id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "社区不能为空")
|
||||||
|
private Long communityId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提问用户id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "提问用户不能为空")
|
||||||
|
private Long questionUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提问内容
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "提问内容不能为空")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提问图片
|
||||||
|
*/
|
||||||
|
private String questionUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否匿名 0 否 1 是
|
||||||
|
*/
|
||||||
|
private Integer isAnonymous = 0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.mcwl.communityCenter.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.communityCenter.domain.Community;
|
||||||
|
import com.mcwl.communityCenter.domain.CommunityAdvice;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CommunityAdviceMapper extends BaseMapper<CommunityAdvice> {
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.mcwl.communityCenter.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.communityCenter.domain.Community;
|
||||||
|
import com.mcwl.communityCenter.domain.CommunityAdvice;
|
||||||
|
|
||||||
|
public interface CommunityAdviceService extends IService<CommunityAdvice> {
|
||||||
|
}
|
|
@ -3,6 +3,17 @@ package com.mcwl.communityCenter.service;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.mcwl.communityCenter.domain.Publish;
|
import com.mcwl.communityCenter.domain.Publish;
|
||||||
import com.mcwl.communityCenter.domain.Question;
|
import com.mcwl.communityCenter.domain.Question;
|
||||||
|
import com.mcwl.communityCenter.domain.dto.QuestionRes;
|
||||||
|
|
||||||
public interface QuestionService extends IService<Question> {
|
public interface QuestionService extends IService<Question> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加问题
|
||||||
|
* @param questionRes 问题信息
|
||||||
|
*/
|
||||||
|
void addQuestion(QuestionRes questionRes);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mcwl.communityCenter.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.communityCenter.domain.Community;
|
||||||
|
import com.mcwl.communityCenter.domain.CommunityAdvice;
|
||||||
|
import com.mcwl.communityCenter.mapper.CommunityAdviceMapper;
|
||||||
|
import com.mcwl.communityCenter.mapper.CommunityMapper;
|
||||||
|
import com.mcwl.communityCenter.service.CommunityAdviceService;
|
||||||
|
import com.mcwl.communityCenter.service.CommunityService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CommunityAdviceServiceImpl extends ServiceImpl<CommunityAdviceMapper, CommunityAdvice>
|
||||||
|
implements CommunityAdviceService {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -61,7 +61,8 @@ public class InviteServiceImpl extends ServiceImpl<InviteMapper, Invite> impleme
|
||||||
InviteCodeMapping inviteCodeMapping = new InviteCodeMapping();
|
InviteCodeMapping inviteCodeMapping = new InviteCodeMapping();
|
||||||
inviteCodeMapping.setUserId(SecurityUtils.getUserId());
|
inviteCodeMapping.setUserId(SecurityUtils.getUserId());
|
||||||
inviteCodeMapping.setInviteCode(idCode);
|
inviteCodeMapping.setInviteCode(idCode);
|
||||||
inviteCodeMapping.setStatus(1);
|
inviteCodeMapping.setCommunityId(communityId);
|
||||||
|
inviteCodeMapping.setStatus(StatusConstant.STATUS_AVAILABLE);
|
||||||
inviteCodeMappingService.save(inviteCodeMapping);
|
inviteCodeMappingService.save(inviteCodeMapping);
|
||||||
|
|
||||||
return inviteCode;
|
return inviteCode;
|
||||||
|
@ -86,7 +87,7 @@ public class InviteServiceImpl extends ServiceImpl<InviteMapper, Invite> impleme
|
||||||
InviteCodeMapping inviteCodeMapping = inviteCodeMappingService.lambdaQuery()
|
InviteCodeMapping inviteCodeMapping = inviteCodeMappingService.lambdaQuery()
|
||||||
.eq(InviteCodeMapping::getUserId, userId)
|
.eq(InviteCodeMapping::getUserId, userId)
|
||||||
.eq(InviteCodeMapping::getInviteCode, inviteCode)
|
.eq(InviteCodeMapping::getInviteCode, inviteCode)
|
||||||
.eq(InviteCodeMapping::getStatus, 1)
|
.eq(InviteCodeMapping::getStatus, StatusConstant.STATUS_AVAILABLE)
|
||||||
.one();
|
.one();
|
||||||
|
|
||||||
if (Objects.isNull(inviteCodeMapping)) {
|
if (Objects.isNull(inviteCodeMapping)) {
|
||||||
|
|
|
@ -1,14 +1,71 @@
|
||||||
package com.mcwl.communityCenter.service.impl;
|
package com.mcwl.communityCenter.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.communityCenter.domain.CommunityAdvice;
|
||||||
|
import com.mcwl.communityCenter.domain.Invite;
|
||||||
import com.mcwl.communityCenter.domain.Publish;
|
import com.mcwl.communityCenter.domain.Publish;
|
||||||
import com.mcwl.communityCenter.domain.Question;
|
import com.mcwl.communityCenter.domain.Question;
|
||||||
|
import com.mcwl.communityCenter.domain.dto.QuestionRes;
|
||||||
|
import com.mcwl.communityCenter.mapper.CommunityAdviceMapper;
|
||||||
import com.mcwl.communityCenter.mapper.PublishMapper;
|
import com.mcwl.communityCenter.mapper.PublishMapper;
|
||||||
import com.mcwl.communityCenter.mapper.QuestionMapper;
|
import com.mcwl.communityCenter.mapper.QuestionMapper;
|
||||||
|
import com.mcwl.communityCenter.service.InviteService;
|
||||||
import com.mcwl.communityCenter.service.PublishService;
|
import com.mcwl.communityCenter.service.PublishService;
|
||||||
import com.mcwl.communityCenter.service.QuestionService;
|
import com.mcwl.communityCenter.service.QuestionService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> implements QuestionService {
|
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> implements QuestionService {
|
||||||
|
|
||||||
|
|
||||||
|
private final CommunityAdviceMapper communityAdviceMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加问题
|
||||||
|
* @param questionRes 问题信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void addQuestion(QuestionRes questionRes) {
|
||||||
|
|
||||||
|
Long questionUserId = questionRes.getQuestionUserId();
|
||||||
|
Long communityId = questionRes.getCommunityId();
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
if (Objects.equals(questionUserId, userId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取租户id
|
||||||
|
Long tenantId = questionRes.getTenantId();
|
||||||
|
|
||||||
|
// 答复人是否是群主
|
||||||
|
boolean isInviteUser = !Objects.equals(tenantId, questionUserId);
|
||||||
|
|
||||||
|
if (isInviteUser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Question question = new Question();
|
||||||
|
BeanUtil.copyProperties(questionRes, question);
|
||||||
|
baseMapper.insert(question);
|
||||||
|
|
||||||
|
|
||||||
|
CommunityAdvice communityAdvice = new CommunityAdvice();
|
||||||
|
communityAdvice.setTenantId(tenantId);
|
||||||
|
communityAdvice.setCommunityId(communityId);
|
||||||
|
communityAdvice.setUserId(questionUserId);
|
||||||
|
communityAdvice.setTitle("您有新的问题");
|
||||||
|
communityAdvice.setContent(questionRes.getContent());
|
||||||
|
communityAdviceMapper.insert(communityAdvice);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue