增加客户留言板相关功能
This commit is contained in:
parent
355593487d
commit
ff7d6990af
@ -187,4 +187,8 @@ public interface ErrorCodeConstants {
|
||||
// ========== ECG数据 1-002-034-000 ==========
|
||||
ErrorCode ECGDATA_NOT_EXISTS = new ErrorCode(1_002_034_000, "ECG数据不存在");
|
||||
|
||||
ErrorCode FEEDBACK_NOT_EXISTS = new ErrorCode(1_002_035_000, "ID不存在");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,90 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.feedback;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.feedback.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.feedback.FeedbackDO;
|
||||
import cn.iocoder.yudao.module.system.service.feedback.FeedbackService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Tag(name = "管理后台 - 留言板")
|
||||
@RestController
|
||||
@RequestMapping("/system/feedback")
|
||||
@Validated
|
||||
public class FeedbackController {
|
||||
|
||||
@Resource
|
||||
private FeedbackService feedbackService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建留言板")
|
||||
public CommonResult<Integer> createFeedback(@Valid @RequestBody FeedbackSaveReqVO createReqVO) {
|
||||
return success(feedbackService.createFeedback(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新留言板")
|
||||
public CommonResult<Boolean> updateFeedback(@Valid @RequestBody FeedbackSaveReqVO updateReqVO) {
|
||||
feedbackService.updateFeedback(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除留言板")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
public CommonResult<Boolean> deleteFeedback(@RequestParam("id") Integer id) {
|
||||
feedbackService.deleteFeedback(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得留言板")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<FeedbackRespVO> getFeedback(@RequestParam("id") Integer id) {
|
||||
FeedbackDO feedback = feedbackService.getFeedback(id);
|
||||
return success(BeanUtils.toBean(feedback, FeedbackRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得留言板分页")
|
||||
public CommonResult<PageResult<FeedbackRespVO>> getFeedbackPage(@Valid FeedbackPageReqVO pageReqVO) {
|
||||
PageResult<FeedbackDO> pageResult = feedbackService.getFeedbackPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, FeedbackRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出留言板 Excel")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportFeedbackExcel(@Valid FeedbackPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<FeedbackDO> list = feedbackService.getFeedbackPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "留言板.xls", "数据", FeedbackRespVO.class,
|
||||
BeanUtils.toBean(list, FeedbackRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.feedback.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 留言板分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class FeedbackPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "客户提交的反馈内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "医生回复的内容")
|
||||
private String backContent;
|
||||
|
||||
@Schema(description = "客户id", example = "2839")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "医生姓名", example = "张三")
|
||||
private String doctorName;
|
||||
|
||||
@Schema(description = "医生id", example = "30772")
|
||||
private Integer doctorId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "医生回复时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] backTime;
|
||||
|
||||
@Schema(description = "机构ID", example = "9393")
|
||||
private Integer orgid;
|
||||
|
||||
@Schema(description = "机构名称", example = "张三")
|
||||
private String orgname;
|
||||
@Schema(description = "回复状态")
|
||||
private String replyStatus;
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.feedback.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 留言板 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class FeedbackRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1202")
|
||||
@ExcelProperty("主键")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "客户提交的反馈内容")
|
||||
@ExcelProperty("客户提交的反馈内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "医生回复的内容")
|
||||
@ExcelProperty("医生回复的内容")
|
||||
private String backContent;
|
||||
|
||||
@Schema(description = "客户id", example = "2839")
|
||||
@ExcelProperty("客户id")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "医生姓名", example = "张三")
|
||||
@ExcelProperty("医生姓名")
|
||||
private String doctorName;
|
||||
|
||||
@Schema(description = "医生id", example = "30772")
|
||||
@ExcelProperty("医生id")
|
||||
private Integer doctorId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "医生回复时间")
|
||||
@ExcelProperty("医生回复时间")
|
||||
private LocalDateTime backTime;
|
||||
|
||||
@Schema(description = "机构ID", example = "9393")
|
||||
@ExcelProperty("机构ID")
|
||||
private Integer orgid;
|
||||
|
||||
@Schema(description = "机构名称", example = "张三")
|
||||
@ExcelProperty("机构名称")
|
||||
private String orgname;
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.feedback.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 留言板新增/修改 Request VO")
|
||||
@Data
|
||||
public class FeedbackSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1202")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "客户提交的反馈内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "医生回复的内容")
|
||||
private String backContent;
|
||||
|
||||
@Schema(description = "客户id", example = "2839")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "医生姓名", example = "张三")
|
||||
private String doctorName;
|
||||
|
||||
@Schema(description = "医生id", example = "30772")
|
||||
private Integer doctorId;
|
||||
|
||||
@Schema(description = "医生回复时间")
|
||||
private LocalDateTime backTime;
|
||||
|
||||
@Schema(description = "机构ID", example = "9393")
|
||||
private Integer orgid;
|
||||
|
||||
@Schema(description = "机构名称", example = "张三")
|
||||
private String orgname;
|
||||
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.feedback;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 留言板 DO
|
||||
*
|
||||
* @author 全智安
|
||||
*/
|
||||
@TableName("tb_feedback")
|
||||
@KeySequence("tb_feedback_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FeedbackDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 客户提交的反馈内容
|
||||
*/
|
||||
@TableField("content")
|
||||
private String content;
|
||||
/**
|
||||
* 医生回复的内容
|
||||
*/
|
||||
@TableField("back_content")
|
||||
private String backContent;
|
||||
/**
|
||||
* 客户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private Integer userId;
|
||||
/**
|
||||
* 医生姓名
|
||||
*/
|
||||
@TableField("doctor_name")
|
||||
private String doctorName;
|
||||
/**
|
||||
* 医生id
|
||||
*/
|
||||
@TableField("doctor_id")
|
||||
private Integer doctorId;
|
||||
/**
|
||||
* 医生回复时间
|
||||
*/
|
||||
@TableField("back_time")
|
||||
private LocalDateTime backTime;
|
||||
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
/**
|
||||
* 机构ID
|
||||
*/
|
||||
@TableField("orgid")
|
||||
private Integer orgid;
|
||||
/**
|
||||
* 机构名称
|
||||
*/
|
||||
@TableField("orgname")
|
||||
private String orgname;
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.feedback;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.feedback.FeedbackDO;
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.feedback.vo.*;
|
||||
|
||||
/**
|
||||
* 留言板 Mapper
|
||||
*
|
||||
* @author 全智安
|
||||
*/
|
||||
@Mapper
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
public interface FeedbackMapper extends BaseMapperX<FeedbackDO> {
|
||||
|
||||
default PageResult<FeedbackDO> selectPage(FeedbackPageReqVO reqVO) {
|
||||
LambdaQueryWrapperX<FeedbackDO> queryWrapper = new LambdaQueryWrapperX<FeedbackDO>()
|
||||
.eqIfPresent(FeedbackDO::getContent, reqVO.getContent())
|
||||
.eqIfPresent(FeedbackDO::getBackContent, reqVO.getBackContent())
|
||||
.eqIfPresent(FeedbackDO::getUserId, reqVO.getUserId())
|
||||
.likeIfPresent(FeedbackDO::getDoctorName, reqVO.getDoctorName())
|
||||
.eqIfPresent(FeedbackDO::getDoctorId, reqVO.getDoctorId())
|
||||
.betweenIfPresent(FeedbackDO::getBackTime, reqVO.getBackTime())
|
||||
.betweenIfPresent(FeedbackDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(FeedbackDO::getOrgid, reqVO.getOrgid())
|
||||
.likeIfPresent(FeedbackDO::getOrgname, reqVO.getOrgname());
|
||||
|
||||
// 根据 ReplyStatus 添加不同的查询条件
|
||||
if ("replied".equals(reqVO.getReplyStatus())) {
|
||||
queryWrapper.isNotNull(FeedbackDO::getBackTime); // replied: getBackTime 不为 null
|
||||
} else if ("unreplied".equals(reqVO.getReplyStatus())) {
|
||||
queryWrapper.isNull(FeedbackDO::getBackTime); // unreplied: getBackTime 为 null
|
||||
}
|
||||
|
||||
queryWrapper.orderByDesc(FeedbackDO::getId);
|
||||
|
||||
return selectPage(reqVO, queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.system.service.feedback;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.feedback.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.feedback.FeedbackDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 留言板 Service 接口
|
||||
*
|
||||
* @author 全智安
|
||||
*/
|
||||
public interface FeedbackService {
|
||||
|
||||
/**
|
||||
* 创建留言板
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Integer createFeedback(@Valid FeedbackSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新留言板
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateFeedback(@Valid FeedbackSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除留言板
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteFeedback(Integer id);
|
||||
|
||||
/**
|
||||
* 获得留言板
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 留言板
|
||||
*/
|
||||
FeedbackDO getFeedback(Integer id);
|
||||
|
||||
/**
|
||||
* 获得留言板分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 留言板分页
|
||||
*/
|
||||
PageResult<FeedbackDO> getFeedbackPage(FeedbackPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package cn.iocoder.yudao.module.system.service.feedback;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.feedback.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.feedback.FeedbackDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.feedback.FeedbackMapper;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 留言板 Service 实现类
|
||||
*
|
||||
* @author 全智安
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class FeedbackServiceImpl implements FeedbackService {
|
||||
|
||||
@Resource
|
||||
private FeedbackMapper feedbackMapper;
|
||||
|
||||
@Override
|
||||
public Integer createFeedback(FeedbackSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
FeedbackDO feedback = BeanUtils.toBean(createReqVO, FeedbackDO.class);
|
||||
feedbackMapper.insert(feedback);
|
||||
// 返回
|
||||
return feedback.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFeedback(FeedbackSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateFeedbackExists(updateReqVO.getId());
|
||||
// 更新
|
||||
FeedbackDO updateObj = BeanUtils.toBean(updateReqVO, FeedbackDO.class);
|
||||
feedbackMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFeedback(Integer id) {
|
||||
// 校验存在
|
||||
validateFeedbackExists(id);
|
||||
// 删除
|
||||
feedbackMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateFeedbackExists(Integer id) {
|
||||
if (feedbackMapper.selectById(id) == null) {
|
||||
throw exception(FEEDBACK_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeedbackDO getFeedback(Integer id) {
|
||||
return feedbackMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<FeedbackDO> getFeedbackPage(FeedbackPageReqVO pageReqVO) {
|
||||
return feedbackMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<?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="cn.iocoder.yudao.module.system.dal.mysql.feedback.FeedbackMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user