feat: 提问
parent
84f3caf7af
commit
d5acfb00ae
|
@ -3,6 +3,7 @@ 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.QuestionDetailRes;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionPageRes;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionReplyRes;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionRes;
|
||||
|
@ -43,22 +44,22 @@ public class QuestionController {
|
|||
|
||||
|
||||
/**
|
||||
* 获取未回复问题列表
|
||||
* 获取问题列表
|
||||
*/
|
||||
@PostMapping("listUnReplied")
|
||||
@ApiOperation(value = "获取未回复问题列表")
|
||||
public TableDataInfo listUnReplied(@RequestBody @Valid QuestionPageRes questionPageRes) {
|
||||
@PostMapping("list")
|
||||
@ApiOperation(value = "获取问题列表")
|
||||
public TableDataInfo list(@RequestBody @Valid QuestionPageRes questionPageRes) {
|
||||
|
||||
return questionService.listUnReplied(questionPageRes);
|
||||
return questionService.list(questionPageRes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取问题详情
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
@PostMapping("detail")
|
||||
@ApiOperation(value = "获取问题详情")
|
||||
public AjaxResult getQuestionDetail(@NotNull(message = "id不能为空") @Valid Long id) {
|
||||
QuestionVo questionVo = questionService.getDetail(id);
|
||||
public AjaxResult getQuestionDetail(@RequestBody @Valid QuestionDetailRes questionDetailRes) {
|
||||
QuestionVo questionVo = questionService.getDetail(questionDetailRes);
|
||||
if (Objects.isNull(questionVo)) {
|
||||
return AjaxResult.error("获取详情失败");
|
||||
}
|
||||
|
@ -72,9 +73,7 @@ public class QuestionController {
|
|||
@ApiOperation(value = "回复")
|
||||
public AjaxResult reply(@RequestBody @Valid QuestionReplyRes questionReplyRes) {
|
||||
|
||||
questionService.reply(questionReplyRes);
|
||||
|
||||
return AjaxResult.success();
|
||||
return questionService.reply(questionReplyRes);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
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;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "查看详情请求参数")
|
||||
public class QuestionDetailRes {
|
||||
|
||||
@NotNull(message = "问题id不能为空")
|
||||
@ApiModelProperty(value = "问题id", required = true)
|
||||
private Long questionId;
|
||||
|
||||
@NotNull(message = "租户不能为空")
|
||||
@ApiModelProperty(value = "租户id", required = true)
|
||||
private Long tenantId;
|
||||
|
||||
@NotNull(message = "社区不能为空")
|
||||
@ApiModelProperty(value = "社区id", required = true)
|
||||
private Long communityId;
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.mcwl.communityCenter.domain.dto;
|
|||
import com.mcwl.common.core.page.PageDomain;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.util.AllowableValues;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
@ -13,8 +14,15 @@ import javax.validation.constraints.NotNull;
|
|||
@ApiModel(value = "提问分页请求参数")
|
||||
public class QuestionPageRes extends PageDomain {
|
||||
|
||||
@NotNull(message = "租户不能为空")
|
||||
@ApiModelProperty(value = "租户id", required = true)
|
||||
private Long tenantId;
|
||||
|
||||
@NotNull(message = "社区不能为空")
|
||||
@ApiModelProperty(value = "社区id", required = true)
|
||||
private Long communityId;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ import javax.validation.constraints.NotNull;
|
|||
@ApiModel(value = "回复问题")
|
||||
public class QuestionReplyRes {
|
||||
|
||||
@NotNull(message = "社区不能为空")
|
||||
@ApiModelProperty(value = "社区id", required = true)
|
||||
private Long communityId;
|
||||
|
||||
/**
|
||||
* 问题id
|
||||
*/
|
||||
|
@ -23,6 +27,6 @@ public class QuestionReplyRes {
|
|||
*/
|
||||
@NotBlank(message = "回复内容不能为空")
|
||||
@ApiModelProperty(value = "回复内容", required = true)
|
||||
private String content;
|
||||
private String reply;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull;
|
|||
@Mapper
|
||||
public interface CommunityMapper extends BaseMapper<Community> {
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
Community getByUserIdAndCommunityId(@NotNull(message = "租户id不能为空")
|
||||
Community getByTenantIdAndCommunityId(@NotNull(message = "租户id不能为空")
|
||||
@Param("tenantId")
|
||||
Long tenantId,
|
||||
@NotNull(message = "社区id不能为空")
|
||||
|
|
|
@ -1,10 +1,33 @@
|
|||
package com.mcwl.communityCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mcwl.communityCenter.domain.Community;
|
||||
import com.mcwl.communityCenter.domain.Question;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Mapper
|
||||
public interface QuestionMapper extends BaseMapper<Question> {
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
Page<Question> list(Page<Question> page,
|
||||
@NotNull(message = "租户不能为空")
|
||||
@Param("tenantId")
|
||||
Long tenantId,
|
||||
@NotNull(message = "社区不能为空")
|
||||
@Param("communityId")
|
||||
Long communityId,
|
||||
@Param("status")
|
||||
Integer status);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
Question selectByIdAndTenantIdAndCommunityId(@Param("id")
|
||||
Long id,
|
||||
@Param("tenantId")
|
||||
Long tenantId,
|
||||
@Param("communityId")
|
||||
Long communityId);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.common.core.page.TableDataInfo;
|
||||
import com.mcwl.communityCenter.domain.Question;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionDetailRes;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionPageRes;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionReplyRes;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionRes;
|
||||
|
@ -20,13 +21,13 @@ public interface QuestionService extends IService<Question> {
|
|||
AjaxResult addQuestion(QuestionRes questionRes);
|
||||
|
||||
|
||||
TableDataInfo listUnReplied(QuestionPageRes questionPageRes);
|
||||
TableDataInfo list(QuestionPageRes questionPageRes);
|
||||
|
||||
QuestionVo getDetail(@NotNull(message = "id不能为空") Long id);
|
||||
QuestionVo getDetail(QuestionDetailRes questionDetailRes);
|
||||
|
||||
/**
|
||||
* 回复问题
|
||||
* @param questionReplyRes 回复信息
|
||||
*/
|
||||
void reply(QuestionReplyRes questionReplyRes);
|
||||
AjaxResult reply(QuestionReplyRes questionReplyRes);
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class PublishServiceImpl extends ServiceImpl<PublishMapper, Publish> impl
|
|||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
|
||||
Community community = communityMapper.getByUserIdAndCommunityId(publishRes.getTenantId(), publishRes.getCommunityId());
|
||||
Community community = communityMapper.getByTenantIdAndCommunityId(publishRes.getTenantId(), publishRes.getCommunityId());
|
||||
|
||||
if (Objects.isNull(community)) {
|
||||
return AjaxResult.error(HttpStatus.ERROR, "用户社区未创建");
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.mcwl.communityCenter.constant.StatusConstant;
|
|||
import com.mcwl.communityCenter.domain.Community;
|
||||
import com.mcwl.communityCenter.domain.CommunityAdvice;
|
||||
import com.mcwl.communityCenter.domain.Question;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionDetailRes;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionPageRes;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionReplyRes;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionRes;
|
||||
|
@ -41,7 +42,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|||
|
||||
private final CommunityAdviceMapper communityAdviceMapper;
|
||||
|
||||
private final CommunityService communityService;
|
||||
private final CommunityMapper communityMapper;
|
||||
|
||||
private final ISysUserService sysUserService;
|
||||
|
||||
|
@ -59,9 +60,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|||
// 获取租户id
|
||||
Long tenantId = questionRes.getTenantId();
|
||||
|
||||
Community community = communityService.lambdaQuery()
|
||||
.eq(Community::getId, communityId)
|
||||
.eq(Community::getTenantId, tenantId).one();
|
||||
Community community = communityMapper.getByTenantIdAndCommunityId(tenantId, communityId);
|
||||
|
||||
if (Objects.isNull(community)) {
|
||||
return AjaxResult.error("租户或社区不存在");
|
||||
|
@ -94,7 +93,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo listUnReplied(QuestionPageRes questionPageRes) {
|
||||
public TableDataInfo list(QuestionPageRes questionPageRes) {
|
||||
|
||||
Page<Question> page = new Page<>(questionPageRes.getPageNum(), questionPageRes.getPageSize());
|
||||
OrderItem orderItem = new OrderItem();
|
||||
|
@ -105,11 +104,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|||
orderItem.setAsc(Objects.equals(questionPageRes.getIsAsc(), "asc"));
|
||||
page.addOrder(orderItem);
|
||||
|
||||
|
||||
LambdaQueryWrapper<Question> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(Question::getCommunityId, questionPageRes.getCommunityId())
|
||||
.eq(Question::getStatus, StatusConstant.STATUS_UNREPLIED);
|
||||
baseMapper.selectPage(page, lqw);
|
||||
baseMapper.list(page, questionPageRes.getTenantId(), questionPageRes.getCommunityId(), questionPageRes.getStatus());
|
||||
|
||||
// 获取分页数据
|
||||
List<Question> questionList = page.getRecords();
|
||||
|
@ -137,9 +132,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|||
}
|
||||
|
||||
@Override
|
||||
public QuestionVo getDetail(Long id) {
|
||||
public QuestionVo getDetail(QuestionDetailRes questionDetailRes) {
|
||||
Long questionId = questionDetailRes.getQuestionId();
|
||||
Long tenantId = questionDetailRes.getTenantId();
|
||||
Long communityId = questionDetailRes.getCommunityId();
|
||||
|
||||
Question question = baseMapper.selectById(id);
|
||||
Question question = baseMapper.selectByIdAndTenantIdAndCommunityId(questionId, tenantId, communityId);
|
||||
if (Objects.isNull(question)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -160,25 +158,28 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|||
* @param questionReplyRes 回复信息
|
||||
*/
|
||||
@Override
|
||||
public void reply(QuestionReplyRes questionReplyRes) {
|
||||
public AjaxResult reply(QuestionReplyRes questionReplyRes) {
|
||||
|
||||
Long communityId = questionReplyRes.getCommunityId();
|
||||
Long questionId = questionReplyRes.getQuestionId();
|
||||
LambdaQueryWrapper<Question> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(Question::getId, questionId)
|
||||
.eq(Question::getCommunityId, communityId)
|
||||
.eq(Question::getStatus, StatusConstant.STATUS_UNREPLIED);
|
||||
|
||||
// 查询问题信息
|
||||
Question question = baseMapper.selectOne(lqw);
|
||||
|
||||
if (Objects.isNull(question)) {
|
||||
return;
|
||||
return AjaxResult.error("问题不存在或已被回复");
|
||||
}
|
||||
|
||||
question.setContent(questionReplyRes.getContent());
|
||||
question.setReply(questionReplyRes.getReply());
|
||||
question.setStatus(StatusConstant.STATUS_REPLIED);
|
||||
question.setReplyTime(new Date());
|
||||
|
||||
baseMapper.updateById(question);
|
||||
return AjaxResult.success();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.mcwl.communityCenter.mapper.CommunityMapper">
|
||||
|
||||
<select id="getByUserIdAndCommunityId" resultType="com.mcwl.communityCenter.domain.Community">
|
||||
<select id="getByTenantIdAndCommunityId" resultType="com.mcwl.communityCenter.domain.Community">
|
||||
select id,
|
||||
tenant_id,
|
||||
community_name,
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<?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.QuestionMapper">
|
||||
|
||||
|
||||
<select id="list" resultType="com.mcwl.communityCenter.domain.Question">
|
||||
select id, tenant_id, community_id, question_user_id, content,question_url, reply,reply_time,is_anonymous,status
|
||||
from cc_question
|
||||
where del_flag = '0'
|
||||
and tenant_id = #{tenantId}
|
||||
and community_id = #{communityId}
|
||||
<if test="status != null">
|
||||
and status= #{status}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByIdAndTenantIdAndCommunityId" resultType="com.mcwl.communityCenter.domain.Question">
|
||||
select id, tenant_id, community_id, question_user_id, content,question_url, reply,reply_time,is_anonymous,status
|
||||
from cc_question
|
||||
where id = #{id}
|
||||
and tenant_id = #{tenantId}
|
||||
and community_id = #{communityId}
|
||||
and del_flag = '0'
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue