feat: 社区
parent
2ba9f440d3
commit
5ef3c1bcd3
|
@ -3,6 +3,8 @@ package com.mcwl.web.controller.communityCenter;
|
|||
|
||||
import com.mcwl.communityCenter.domain.Community;
|
||||
import com.mcwl.communityCenter.service.CommunityService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -14,6 +16,7 @@ import java.util.List;
|
|||
@RestController
|
||||
@RequestMapping("community")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "社区管理")
|
||||
public class CommunityController {
|
||||
|
||||
private final CommunityService communityService;
|
||||
|
@ -23,6 +26,7 @@ public class CommunityController {
|
|||
* 社区列表
|
||||
* @return 社区列表
|
||||
*/
|
||||
@ApiOperation(value = "社区列表")
|
||||
@GetMapping("list")
|
||||
public List<Community> getCommunityList(){
|
||||
return communityService.list();
|
||||
|
@ -34,6 +38,7 @@ public class CommunityController {
|
|||
* @param community 社区
|
||||
* @return 添加结果
|
||||
*/
|
||||
@ApiOperation(value = "添加社区")
|
||||
@PostMapping("add")
|
||||
public boolean addCommunity(@RequestBody Community community){
|
||||
return communityService.save(community);
|
||||
|
|
|
@ -3,14 +3,18 @@ package com.mcwl.web.controller.communityCenter;
|
|||
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.common.utils.StringUtils;
|
||||
import com.mcwl.communityCenter.domain.Community;
|
||||
import com.mcwl.communityCenter.service.InviteService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 邀请
|
||||
|
|
|
@ -2,13 +2,21 @@ package com.mcwl.web.controller.communityCenter;
|
|||
|
||||
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.common.core.page.PageDomain;
|
||||
import com.mcwl.common.core.page.TableDataInfo;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionPageRes;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionReplyDto;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionRes;
|
||||
import com.mcwl.communityCenter.domain.vo.QuestionVo;
|
||||
import com.mcwl.communityCenter.service.QuestionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 提问
|
||||
|
@ -16,6 +24,7 @@ import javax.validation.constraints.NotNull;
|
|||
@RestController
|
||||
@RequestMapping("question")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "提问管理")
|
||||
public class QuestionController {
|
||||
|
||||
|
||||
|
@ -25,6 +34,7 @@ public class QuestionController {
|
|||
* 提问
|
||||
*/
|
||||
@PostMapping("addQuestion")
|
||||
@ApiOperation(value = "提问")
|
||||
public AjaxResult addQuestion(@RequestBody QuestionRes questionRes) {
|
||||
|
||||
questionService.addQuestion(questionRes);
|
||||
|
@ -35,13 +45,36 @@ public class QuestionController {
|
|||
|
||||
|
||||
/**
|
||||
* 获取问题列表
|
||||
* 获取未回复问题列表
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public TableDataInfo getQuestionList(@NotNull(message = "社区不能为空") Long communityId) {
|
||||
@GetMapping("listUnReplied")
|
||||
public TableDataInfo listUnReplied(QuestionPageRes questionPageRes) {
|
||||
|
||||
return questionService.listUnReplied(questionPageRes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取问题详情
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public AjaxResult getQuestionDetail(@NotNull(message = "id不能为空") Long id) {
|
||||
QuestionVo questionVo = questionService.getDetail(id);
|
||||
if (Objects.isNull(questionVo)) {
|
||||
return AjaxResult.error("获取详情失败");
|
||||
}
|
||||
return AjaxResult.success(questionVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回复
|
||||
*/
|
||||
@PostMapping("reply")
|
||||
public AjaxResult reply(QuestionReplyDto questionReplyDto) {
|
||||
|
||||
questionService.reply(questionReplyDto);
|
||||
|
||||
return AjaxResult.success();
|
||||
|
||||
// return questionService.getQuestionList(communityId);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -142,3 +142,5 @@ xss:
|
|||
excludes: /system/notice
|
||||
# 匹配链接
|
||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||
knife4j:
|
||||
enable: true
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.mcwl.communityCenter.domain;
|
|||
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.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
@ -12,29 +14,35 @@ import lombok.EqualsAndHashCode;
|
|||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("cc_community")
|
||||
@ApiModel(value = "社区")
|
||||
public class Community extends BaseEntity {
|
||||
|
||||
@TableId
|
||||
@ApiModelProperty(value = "社区id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 社区名称
|
||||
*/
|
||||
@ApiModelProperty(value = "社区名称")
|
||||
private String communityName;
|
||||
|
||||
/**
|
||||
* 社区类型
|
||||
*/
|
||||
@ApiModelProperty(value = "社区类型")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
@ApiModelProperty(value = "价格")
|
||||
private Double price;
|
||||
|
||||
/**
|
||||
* 有效期类型
|
||||
*/
|
||||
@ApiModelProperty(value = "有效期类型")
|
||||
private Integer validityType;
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ import com.mcwl.common.core.domain.BaseEntity;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 提问
|
||||
*/
|
||||
|
@ -52,6 +54,11 @@ public class Question extends BaseEntity {
|
|||
*/
|
||||
private String reply;
|
||||
|
||||
/**
|
||||
* 回复时间
|
||||
*/
|
||||
private Date replyTime;
|
||||
|
||||
/**
|
||||
* 提问图片
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.mcwl.communityCenter.domain.dto;
|
||||
|
||||
import com.mcwl.common.core.page.PageDomain;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class QuestionPageRes extends PageDomain {
|
||||
|
||||
@NotNull(message = "社区不能为空")
|
||||
private Long communityId;
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.mcwl.communityCenter.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class QuestionReplyDto {
|
||||
|
||||
/**
|
||||
* 问题id
|
||||
*/
|
||||
@NotNull(message = "问题id不能为空")
|
||||
private Long questionId;
|
||||
|
||||
/**
|
||||
* 回复内容
|
||||
*/
|
||||
@NotBlank(message = "回复内容不能为空")
|
||||
private String content;
|
||||
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package com.mcwl.communityCenter.domain.dto;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
@ -10,39 +12,47 @@ import javax.validation.constraints.NotNull;
|
|||
* 提问请求参数
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("提问请求参数")
|
||||
public class QuestionRes {
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@NotNull(message = "租户不能为空")
|
||||
@ApiModelProperty(value = "租户ID", hidden = true)
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 社区id
|
||||
*/
|
||||
@NotNull(message = "社区不能为空")
|
||||
@ApiModelProperty(value = "社区ID", required = true, position = 1)
|
||||
private Long communityId;
|
||||
|
||||
/**
|
||||
* 提问用户id
|
||||
*/
|
||||
@NotNull(message = "提问用户不能为空")
|
||||
@ApiModelProperty(value = "提问用户id", required = true, position = 2)
|
||||
private Long questionUserId;
|
||||
|
||||
/**
|
||||
* 提问内容
|
||||
*/
|
||||
@NotBlank(message = "提问内容不能为空")
|
||||
@ApiModelProperty(value = "提问内容", required = true, position = 3)
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 提问图片
|
||||
*/
|
||||
@ApiModelProperty(value = "提问图片", position = 4)
|
||||
private String questionUrl;
|
||||
|
||||
/**
|
||||
* 是否匿名 0 否 1 是
|
||||
*/
|
||||
//swagger给上默认值
|
||||
@ApiModelProperty(value = "是否匿名", example = "0", allowableValues = "0,1", position = 5)
|
||||
private Integer isAnonymous = 0;
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package com.mcwl.communityCenter.domain.vo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class QuestionVo {
|
||||
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 社区id
|
||||
*/
|
||||
private Long communityId;
|
||||
|
||||
/**
|
||||
* 提问用户id
|
||||
*/
|
||||
private Long questionUserId;
|
||||
|
||||
/**
|
||||
* 提问用户名
|
||||
*/
|
||||
private String questionUserName;
|
||||
|
||||
/**
|
||||
* 提问用户头像
|
||||
*/
|
||||
private String questionUserAvatar;
|
||||
|
||||
/**
|
||||
* 提问内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 提问图片
|
||||
*/
|
||||
private String questionUrl;
|
||||
|
||||
/**
|
||||
* 提问时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 答复用户id
|
||||
*/
|
||||
private Long replyUserId;
|
||||
|
||||
/**
|
||||
* 回复内容
|
||||
*/
|
||||
private String reply;
|
||||
|
||||
/**
|
||||
* 回复时间
|
||||
*/
|
||||
private Date replyTime;
|
||||
|
||||
/**
|
||||
* 是否匿名
|
||||
*/
|
||||
private Integer isAnonymous;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,9 +1,15 @@
|
|||
package com.mcwl.communityCenter.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.common.core.page.TableDataInfo;
|
||||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.Question;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionPageRes;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionReplyDto;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionRes;
|
||||
import com.mcwl.communityCenter.domain.vo.QuestionVo;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public interface QuestionService extends IService<Question> {
|
||||
|
||||
|
@ -14,6 +20,13 @@ public interface QuestionService extends IService<Question> {
|
|||
void addQuestion(QuestionRes questionRes);
|
||||
|
||||
|
||||
TableDataInfo listUnReplied(QuestionPageRes questionPageRes);
|
||||
|
||||
QuestionVo getDetail(@NotNull(message = "id不能为空") Long id);
|
||||
|
||||
/**
|
||||
* 回复问题
|
||||
* @param questionReplyDto 回复信息
|
||||
*/
|
||||
void reply(QuestionReplyDto questionReplyDto);
|
||||
}
|
||||
|
|
|
@ -1,23 +1,38 @@
|
|||
package com.mcwl.communityCenter.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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.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.constant.StatusConstant;
|
||||
import com.mcwl.communityCenter.domain.CommunityAdvice;
|
||||
import com.mcwl.communityCenter.domain.Invite;
|
||||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.Question;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionPageRes;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionReplyDto;
|
||||
import com.mcwl.communityCenter.domain.dto.QuestionRes;
|
||||
import com.mcwl.communityCenter.domain.vo.QuestionVo;
|
||||
import com.mcwl.communityCenter.mapper.CommunityAdviceMapper;
|
||||
import com.mcwl.communityCenter.mapper.PublishMapper;
|
||||
import com.mcwl.communityCenter.mapper.QuestionMapper;
|
||||
import com.mcwl.communityCenter.service.InviteService;
|
||||
import com.mcwl.communityCenter.service.PublishService;
|
||||
import com.mcwl.communityCenter.service.QuestionService;
|
||||
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.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -28,8 +43,11 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|||
|
||||
private final CommunityAdviceMapper communityAdviceMapper;
|
||||
|
||||
private final ISysUserService sysUserService;
|
||||
|
||||
/**
|
||||
* 添加问题
|
||||
*
|
||||
* @param questionRes 问题信息
|
||||
*/
|
||||
@Override
|
||||
|
@ -55,6 +73,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|||
|
||||
Question question = new Question();
|
||||
BeanUtil.copyProperties(questionRes, question);
|
||||
question.setStatus(StatusConstant.STATUS_UNREPLIED);
|
||||
baseMapper.insert(question);
|
||||
|
||||
|
||||
|
@ -68,4 +87,95 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo listUnReplied(QuestionPageRes questionPageRes) {
|
||||
|
||||
Page<Question> page = new Page<>(questionPageRes.getPageNum(), questionPageRes.getPageSize());
|
||||
OrderItem orderItem = new OrderItem();
|
||||
if (StringUtils.isBlank(questionPageRes.getOrderByColumn())) {
|
||||
questionPageRes.setOrderByColumn("create_time");
|
||||
}
|
||||
orderItem.setColumn(questionPageRes.getOrderByColumn());
|
||||
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);
|
||||
|
||||
// 获取分页数据
|
||||
List<Question> questionList = page.getRecords();
|
||||
// Question数据转为QuestionVo
|
||||
List<QuestionVo> questionVoList = new ArrayList<>();
|
||||
for (Question question : questionList) {
|
||||
QuestionVo questionVo = new QuestionVo();
|
||||
BeanUtil.copyProperties(question, questionVo);
|
||||
Long questionUserId = question.getQuestionUserId();
|
||||
SysUser sysUser = sysUserService.selectUserById(questionUserId);
|
||||
questionVo.setQuestionUserName(sysUser.getUserName());
|
||||
questionVo.setQuestionUserAvatar(sysUser.getAvatar());
|
||||
questionVoList.add(questionVo);
|
||||
|
||||
}
|
||||
|
||||
// 封装分页信息
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(questionVoList);
|
||||
rspData.setTotal(page.getTotal());
|
||||
|
||||
return rspData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuestionVo getDetail(Long id) {
|
||||
|
||||
Question question = baseMapper.selectById(id);
|
||||
if (Objects.isNull(question)) {
|
||||
return null;
|
||||
}
|
||||
QuestionVo questionVo = new QuestionVo();
|
||||
BeanUtil.copyProperties(question, questionVo);
|
||||
Long questionUserId = question.getQuestionUserId();
|
||||
SysUser sysUser = sysUserService.selectUserById(questionUserId);
|
||||
questionVo.setQuestionUserName(sysUser.getUserName());
|
||||
questionVo.setQuestionUserAvatar(sysUser.getAvatar());
|
||||
|
||||
|
||||
return questionVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 回复问题
|
||||
*
|
||||
* @param questionReplyDto 回复信息
|
||||
*/
|
||||
@Override
|
||||
public void reply(QuestionReplyDto questionReplyDto) {
|
||||
|
||||
Long questionId = questionReplyDto.getQuestionId();
|
||||
LambdaQueryWrapper<Question> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(Question::getId, questionId)
|
||||
.eq(Question::getStatus, StatusConstant.STATUS_UNREPLIED);
|
||||
|
||||
// 查询问题信息
|
||||
Question question = baseMapper.selectOne(lqw);
|
||||
|
||||
if (Objects.isNull(question)) {
|
||||
return;
|
||||
}
|
||||
|
||||
question.setContent(questionReplyDto.getContent());
|
||||
question.setStatus(StatusConstant.STATUS_REPLIED);
|
||||
question.setReplyTime(new Date());
|
||||
|
||||
baseMapper.updateById(question);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue