合并分支 'caihaohan' 到 'master'
Caihaohan 查看合并请求 faw-report-library/faw-report-library-boot!3
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package com.adc.da.report.controller;
|
||||
|
||||
import com.adc.da.report.dto.ReportCommentDTO;
|
||||
import com.adc.da.report.dto.ReportRatingDTO;
|
||||
import com.adc.da.report.service.IReportUserCommentService;
|
||||
import com.adc.da.report.service.IReportUserRatingService;
|
||||
import com.adc.da.report.vo.ReportCommentVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @author CaiHaohan
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "报告评论")
|
||||
@RequestMapping("/${restPath}/report-comment")
|
||||
public class ReportCommentController {
|
||||
|
||||
@Resource
|
||||
private IReportUserCommentService reportUserCommentService;
|
||||
|
||||
/**
|
||||
* 分页获取报表下的评论
|
||||
*/
|
||||
@ApiOperation(value = "分页获取报表下的评论")
|
||||
@GetMapping("/page")
|
||||
public ResponseMessage rating(@Valid ReportCommentDTO reportCommentDTO) {
|
||||
return reportUserCommentService.commentPage(reportCommentDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加评论
|
||||
*/
|
||||
@ApiOperation(value = "添加评论")
|
||||
@PostMapping("/add")
|
||||
public ResponseMessage rating(@Valid @RequestBody ReportCommentVo reportCommentVO) {
|
||||
return reportUserCommentService.addComment(reportCommentVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除评论
|
||||
*/
|
||||
@ApiOperation(value = "删除评论")
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseMessage deleteComment(@PathVariable String id) {
|
||||
return reportUserCommentService.deleteComment(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.adc.da.report.controller;
|
||||
|
||||
import com.adc.da.report.dto.ReportRatingDTO;
|
||||
import com.adc.da.report.service.IReportUserRatingService;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @author CaiHaohan
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "报告评分")
|
||||
@RequestMapping("/${restPath}/report-rating")
|
||||
public class ReportRatingController {
|
||||
|
||||
@Resource
|
||||
private IReportUserRatingService reportUserRatingService;
|
||||
|
||||
/**
|
||||
* 给报告评分
|
||||
*/
|
||||
@ApiOperation(value = "给报告评分")
|
||||
@PutMapping("/rating")
|
||||
public ResponseMessage rating(@Valid ReportRatingDTO reportRatingDTO) {
|
||||
return reportUserRatingService.rating(reportRatingDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取报告评分
|
||||
*/
|
||||
@ApiOperation(value = "给报告评分")
|
||||
@GetMapping("/rating")
|
||||
public ResponseMessage getRating(String reportId) {
|
||||
return reportUserRatingService.getRating(reportId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.adc.da.report.dao.mysql;
|
||||
|
||||
import com.adc.da.report.dto.ReportCommentDTO;
|
||||
import com.adc.da.report.eo.ReportUserCommentEntity;
|
||||
import com.adc.da.report.vo.ReportCommentVo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_report_user_comment】的数据库操作Mapper
|
||||
* @createDate 2023-05-08 09:44:12
|
||||
* @Entity com.adc.da.report.eo.ReportUserComment
|
||||
*/
|
||||
public interface ReportUserCommentDao extends BaseMapper<ReportUserCommentEntity> {
|
||||
|
||||
/**
|
||||
* 评论列表
|
||||
*
|
||||
* @param page
|
||||
* @param reportCommentDTO
|
||||
* @return
|
||||
*/
|
||||
IPage<ReportCommentVo> page(IPage<ReportUserCommentEntity> page, @Param("dto") ReportCommentDTO reportCommentDTO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.adc.da.report.dao.mysql;
|
||||
|
||||
import com.adc.da.report.eo.ReportUserRatingEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_report_user_rating】的数据库操作Mapper
|
||||
* @createDate 2023-05-06 17:03:31
|
||||
* @Entity com.adc.da.report.eo.ReportUserRating
|
||||
*/
|
||||
public interface ReportUserRatingDao extends BaseMapper<ReportUserRatingEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.adc.da.report.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author: CaiHaohan
|
||||
* @Date: 2023/5/8 11:13
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class ReportCommentDTO {
|
||||
|
||||
/**
|
||||
* 报告id
|
||||
*/
|
||||
@NotBlank(message = "报告id不能为空")
|
||||
private String reportId;
|
||||
|
||||
/**
|
||||
* 页数
|
||||
*/
|
||||
@Min(1)
|
||||
private Integer pageNo;
|
||||
|
||||
/**
|
||||
* 每页数量
|
||||
*/
|
||||
@NotNull
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.adc.da.report.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* @author: CaiHaohan
|
||||
* @Date: 2023/5/6 17:18
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class ReportRatingDTO {
|
||||
|
||||
@NotBlank(message = "报表Id不能为空")
|
||||
private String reportId;
|
||||
|
||||
@Min(value = 1, message = "最小评分为1分")
|
||||
@Max(value = 10, message = "最大评分为10分")
|
||||
private Integer userRating;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.adc.da.report.eo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author CaiHaohan
|
||||
* @TableName ts_report_user_comment
|
||||
*/
|
||||
@TableName(value ="ts_report_user_comment")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class ReportUserCommentEntity implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 报告id
|
||||
*/
|
||||
@TableField(value = "report_id")
|
||||
private String reportId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField(value = "user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 评论
|
||||
*/
|
||||
@TableField(value = "comment")
|
||||
private String comment;
|
||||
|
||||
/**
|
||||
* 评论时间
|
||||
*/
|
||||
@TableField(value = "create_time")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 评论时间
|
||||
*/
|
||||
@TableField(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 删除标志(0 未删除 1 已删除)
|
||||
*/
|
||||
@TableField(value = "del_flag")
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.adc.da.report.eo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author CaiHaohan
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@TableName("ts_report_user_rating")
|
||||
public class ReportUserRatingEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 报告id
|
||||
*/
|
||||
@TableField("report_id")
|
||||
private String reportId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 评分(1-5)
|
||||
*/
|
||||
@TableField("user_rating")
|
||||
private Integer userRating;
|
||||
|
||||
private static final long serialVersionUID = 12314234142312314L;
|
||||
}
|
||||
@@ -51,4 +51,12 @@ public interface IReportService {
|
||||
IPage<ReportVo> reportManagerPage(ReportQueryVo vo);
|
||||
|
||||
List<String> isAct(ReportQueryVo vo);
|
||||
|
||||
/**
|
||||
* 判断报告是否删除
|
||||
*
|
||||
* @param reportId
|
||||
* @return
|
||||
*/
|
||||
boolean isReportValid(String reportId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.adc.da.report.service;
|
||||
|
||||
import com.adc.da.report.dto.ReportCommentDTO;
|
||||
import com.adc.da.report.eo.ReportUserCommentEntity;
|
||||
import com.adc.da.report.vo.ReportCommentVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_report_user_comment】的数据库操作Service
|
||||
* @createDate 2023-05-08 09:44:12
|
||||
*/
|
||||
public interface IReportUserCommentService extends IService<ReportUserCommentEntity> {
|
||||
|
||||
/**
|
||||
* 分页获取报表下的评论
|
||||
* @param reportCommentDTO
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage commentPage(ReportCommentDTO reportCommentDTO);
|
||||
|
||||
/**
|
||||
* 添加评论
|
||||
* @param reportCommentVO
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage addComment(ReportCommentVo reportCommentVO);
|
||||
|
||||
/**
|
||||
* 删除评论
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage deleteComment(String id);
|
||||
|
||||
/**
|
||||
* 根据评论id判断评论是否有效
|
||||
* @param commentId
|
||||
* @return
|
||||
*/
|
||||
boolean isCommentValid(String commentId);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.adc.da.report.service;
|
||||
|
||||
|
||||
import com.adc.da.report.dto.ReportRatingDTO;
|
||||
import com.adc.da.report.eo.ReportUserRatingEntity;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_report_user_rating】的数据库操作Service
|
||||
* @createDate 2023-05-06 17:03:31
|
||||
*/
|
||||
public interface IReportUserRatingService extends IService<ReportUserRatingEntity> {
|
||||
|
||||
/**
|
||||
* 评分
|
||||
* @param reportRatingDTO
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage rating(ReportRatingDTO reportRatingDTO);
|
||||
|
||||
/**
|
||||
* 获取报告的平均分
|
||||
* @param reportId
|
||||
* @return
|
||||
*/
|
||||
Double getRatingAvg(String reportId);
|
||||
|
||||
/**
|
||||
* 获取报告评分
|
||||
*
|
||||
* @param reportId
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage getRating(String reportId);
|
||||
}
|
||||
@@ -526,6 +526,12 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
|
||||
return act;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReportValid(String reportId) {
|
||||
ReportEntity report = query().eq("del_flag", 0).eq("id", reportId).one();
|
||||
return report != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建htmlstring
|
||||
*
|
||||
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
package com.adc.da.report.service.impl;
|
||||
|
||||
import com.adc.da.login.util.UserUtils;
|
||||
import com.adc.da.report.dao.mysql.ReportDao;
|
||||
import com.adc.da.report.dto.ReportCommentDTO;
|
||||
import com.adc.da.report.eo.ReportEntity;
|
||||
import com.adc.da.report.vo.ReportCommentVo;
|
||||
import com.adc.da.sys.util.BeanCopyUtils;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import com.adc.da.util.utils.UUID;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.adc.da.report.eo.ReportUserCommentEntity;
|
||||
import com.adc.da.report.service.IReportUserCommentService;
|
||||
import com.adc.da.report.dao.mysql.ReportUserCommentDao;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_report_user_comment】的数据库操作Service实现
|
||||
* @createDate 2023-05-08 09:44:12
|
||||
*/
|
||||
@Service
|
||||
public class IReportUserCommentServiceImpl extends ServiceImpl<ReportUserCommentDao, ReportUserCommentEntity>
|
||||
implements IReportUserCommentService {
|
||||
|
||||
@Resource
|
||||
private ReportDao reportDao;
|
||||
|
||||
@Resource
|
||||
private ReportUserCommentDao reportUserCommentDao;
|
||||
|
||||
@Override
|
||||
public ResponseMessage commentPage(ReportCommentDTO reportCommentDTO) {
|
||||
//分页查询所需数据
|
||||
IPage<ReportUserCommentEntity> page = new Page<>();
|
||||
page.setCurrent(reportCommentDTO.getPageNo());
|
||||
page.setSize(reportCommentDTO.getPageSize());
|
||||
IPage<ReportCommentVo> list = reportUserCommentDao.page(page, reportCommentDTO);
|
||||
|
||||
//设置是否有删除权限
|
||||
//报告上传者有所有评论的删除权限
|
||||
boolean isUploader = false;
|
||||
String curUserId = UserUtils.getUserId();
|
||||
//查询报告的上传者
|
||||
ReportEntity report = reportDao.selectById(reportCommentDTO.getReportId());
|
||||
if (curUserId.equals(report.getCreateUserId())) {
|
||||
isUploader = true;
|
||||
}
|
||||
//评论这只有自己评论的删除权限
|
||||
if (isUploader) {
|
||||
list.getRecords().forEach(reportCommentVo -> {
|
||||
reportCommentVo.setDelPower(1);
|
||||
});
|
||||
} else {
|
||||
list.getRecords().forEach(reportCommentVo -> {
|
||||
if (reportCommentVo.getUserId().equals(curUserId)) {
|
||||
reportCommentVo.setDelPower(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseMessage addComment(ReportCommentVo reportCommentVO) {
|
||||
String curUserId = UserUtils.getUserId();
|
||||
//不能重复评论
|
||||
ReportUserCommentEntity comment = query().eq("del_flag", 0)
|
||||
.eq("report_id", reportCommentVO.getReportId())
|
||||
.eq("user_id", curUserId).one();
|
||||
if (comment != null) {
|
||||
return Result.error("无法重复评论");
|
||||
}
|
||||
ReportUserCommentEntity reportUserCommentEntity = BeanCopyUtils.copyBean(reportCommentVO, ReportUserCommentEntity.class);
|
||||
reportUserCommentEntity.setUserId(curUserId)
|
||||
.setId(UUID.randomUUID10())
|
||||
.setCreateTime(new Date())
|
||||
.setUpdateTime(new Date())
|
||||
.setDelFlag(0);
|
||||
save(reportUserCommentEntity);
|
||||
return Result.success("评论成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseMessage deleteComment(String commentId) {
|
||||
if (!isCommentValid(commentId)) {
|
||||
return Result.error("刪除失败,id无效或评论已删除");
|
||||
}
|
||||
|
||||
ReportUserCommentEntity comment = query().eq("del_flag", 0).eq("id", commentId).one();
|
||||
ReportEntity report = reportDao.selectById(comment.getReportId());
|
||||
//判断是否有权限删除
|
||||
String currentUserId = UserUtils.getUserId();
|
||||
if (!currentUserId.equals(comment.getUserId()) && !currentUserId.equals(report.getCreateUserId())) {
|
||||
return Result.error("无权删除");
|
||||
}
|
||||
comment.setDelFlag(1);
|
||||
updateById(comment);
|
||||
return Result.success("删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据评论id判断评论是否有效
|
||||
* @param commentId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isCommentValid(String commentId) {
|
||||
ReportUserCommentEntity comment = query().eq("del_flag", 0).eq("id", commentId).one();
|
||||
return comment != null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package com.adc.da.report.service.impl;
|
||||
|
||||
|
||||
import com.adc.da.login.util.UserUtils;
|
||||
import com.adc.da.report.dao.mysql.ReportDao;
|
||||
import com.adc.da.report.dto.ReportRatingDTO;
|
||||
import com.adc.da.report.eo.ReportUserRatingEntity;
|
||||
import com.adc.da.report.service.IReportService;
|
||||
import com.adc.da.report.service.IReportUserRatingService;
|
||||
import com.adc.da.report.dao.mysql.ReportUserRatingDao;
|
||||
import com.adc.da.sys.util.BeanCopyUtils;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import com.adc.da.util.utils.UUID;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_report_user_rating】的数据库操作Service实现
|
||||
* @createDate 2023-05-06 17:03:31
|
||||
*/
|
||||
@Service
|
||||
public class IReportUserRatingServiceImpl extends ServiceImpl<ReportUserRatingDao, ReportUserRatingEntity>
|
||||
implements IReportUserRatingService {
|
||||
|
||||
@Resource
|
||||
private ReportUserRatingDao reportUserRatingDao;
|
||||
|
||||
@Resource
|
||||
private IReportService reportService;
|
||||
|
||||
@Override
|
||||
public ResponseMessage rating(ReportRatingDTO reportRatingDTO) {
|
||||
if(!reportService.isReportValid(reportRatingDTO.getReportId())){
|
||||
return Result.error("此报告已失效");
|
||||
}
|
||||
//查询是否是初次评分
|
||||
ReportUserRatingEntity one = query().eq("report_id", reportRatingDTO.getReportId())
|
||||
.eq("user_id", UserUtils.getUserId())
|
||||
.one();
|
||||
ReportUserRatingEntity reportUserRatingEntity = BeanCopyUtils.copyBean(reportRatingDTO, ReportUserRatingEntity.class);
|
||||
//初次评分
|
||||
if (one == null) {
|
||||
reportUserRatingEntity
|
||||
.setId(UUID.randomUUID10())
|
||||
.setUserId(UserUtils.getUserId());
|
||||
save(reportUserRatingEntity);
|
||||
return Result.success("操作成功");
|
||||
}
|
||||
reportUserRatingEntity.setId(one.getId());
|
||||
updateById(reportUserRatingEntity);
|
||||
return Result.success("操作成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getRatingAvg(String reportId) {
|
||||
QueryWrapper<ReportUserRatingEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.select("AVG(user_rating) as user_rating");
|
||||
List<Map<String, Object>> result = reportUserRatingDao.selectMaps(wrapper);
|
||||
BigDecimal userRating = (BigDecimal) result.get(0).get("user_rating");
|
||||
return userRating.doubleValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseMessage getRating(String reportId) {
|
||||
ReportUserRatingEntity entity = query().eq("report_id", reportId).eq("user_id", UserUtils.getUserId()).one();
|
||||
return Result.success(entity.getUserRating());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.adc.da.report.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author: CaiHaohan
|
||||
* @Date: 2023/5/8 11:13
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class ReportCommentVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 报告id
|
||||
*/
|
||||
private String reportId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
private String orgId;
|
||||
|
||||
/**
|
||||
* 部门名
|
||||
*/
|
||||
private String orgName;
|
||||
|
||||
/**
|
||||
* 评论
|
||||
*/
|
||||
private String comment;
|
||||
|
||||
/**
|
||||
* 评论时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 删除权限 0代表没有删除权限 1代表有
|
||||
*/
|
||||
private Integer delPower;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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.adc.da.report.dao.mysql.ReportUserCommentDao">
|
||||
|
||||
<select id="page" resultType="com.adc.da.report.vo.ReportCommentVo">
|
||||
SELECT
|
||||
ruc.user_id AS userId,
|
||||
u.USNAME AS userName,
|
||||
ruc.comment AS comment,
|
||||
ruc.create_time AS createTime,
|
||||
o.ORG_NAME AS orgName
|
||||
FROM
|
||||
`ts_report_user_comment` AS ruc
|
||||
INNER JOIN ts_user AS u ON u.USID = ruc.user_id
|
||||
LEFT JOIN tr_user_org AS uo ON uo.USER_ID = ruc.user_id
|
||||
LEFT JOIN ts_org AS o ON uo.ORG_ID = o.ID
|
||||
WHERE
|
||||
ruc.del_flag = 0
|
||||
AND
|
||||
ruc.report_id = #{dto.reportId}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user