package com.zt.life.modules.testReviewComment.service;
|
|
import cn.hutool.core.convert.Convert;
|
import com.zt.common.service.BaseService;
|
import com.zt.life.export.dto.WordFile;
|
import com.zt.life.export.service.WordFileService;
|
import com.zt.life.modules.baselineRelease.dto.BaselineDto;
|
import com.zt.life.modules.baselineRelease.model.BaselineRelease;
|
import com.zt.life.modules.baselineRelease.model.BaselineReleaseRemark;
|
import com.zt.life.modules.baselineRelease.service.BaselineReleaseRemarkService;
|
import com.zt.life.modules.project.service.ProjectService;
|
import com.zt.life.modules.testReviewComment.dao.TestReviewCommentDao;
|
import com.zt.life.modules.testReviewComment.dto.ReviewCommentDto;
|
import com.zt.life.modules.testReviewComment.model.TestReviewComment;
|
import com.zt.life.sys.dto.OssDto;
|
import com.zt.modules.coderule.service.SysCodeRuleService;
|
import com.zt.modules.oss.service.SysOssService;
|
import com.zt.modules.workflow.dto.FlowInfoDto;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import com.zt.common.db.query.QueryFilter;
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.FileNotFoundException;
|
import java.io.UnsupportedEncodingException;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
|
/**
|
* test_review_comment
|
*
|
* @author zt generator
|
* @since 1.0.0 2023-12-28
|
*/
|
@Service
|
public class TestReviewCommentService extends BaseService<TestReviewCommentDao, TestReviewComment> {
|
|
@Autowired
|
private SysOssService sysOssService;
|
|
@Autowired
|
private ProjectService projectService;
|
|
@Autowired
|
private SysCodeRuleService sysCodeRuleService;
|
|
@Autowired
|
private WordFileService wordFileService;
|
|
/**
|
* 分页查询
|
*
|
* @param queryFilter
|
* @return
|
*/
|
public List<TestReviewComment> page(QueryFilter queryFilter) {
|
List<TestReviewComment> list = baseDao.getList(queryFilter.getQueryParams());
|
if (list.size() > 0) {
|
sysOssService.setListOsses(list, "test_review_comment");
|
}
|
return list;
|
}
|
|
/**
|
* 删除
|
*
|
* @param ids
|
*/
|
public void delete(Long[] ids) {
|
super.deleteLogic(ids);
|
}
|
|
|
public ReviewCommentDto getDto(Long commentId, Long projectId, String pageCode) {
|
ReviewCommentDto data = new ReviewCommentDto();
|
data.setPageCode(pageCode);
|
if (commentId != null) {
|
data.setId(commentId);
|
TestReviewComment reviewComment = this.get(commentId);
|
data.setReviewComment(reviewComment);
|
if (reviewComment != null && projectId == null) {
|
projectId = reviewComment.getProjectId();
|
}
|
} else {
|
TestReviewComment reviewComment = new TestReviewComment();
|
reviewComment.setPageCode(pageCode);
|
data.setReviewComment(reviewComment);
|
}
|
if (projectId != null) {
|
data.setProjectId(projectId);
|
data.setProject(projectService.get(projectId));
|
}
|
return data;
|
}
|
public Long save(ReviewCommentDto reviewCommentDto) {
|
Long commentId = reviewCommentDto.getReviewComment().getId();
|
if (commentId != null)
|
baseDao.updateById(reviewCommentDto.getReviewComment());
|
else {
|
Map<String, String> map = new HashMap<>();
|
String pagecode = reviewCommentDto.getPageCode();
|
map.put("funCode", "test_review_comment_" + pagecode);
|
map.put("projectId", reviewCommentDto.getProjectId().toString());
|
reviewCommentDto.getReviewComment().setProjectId(reviewCommentDto.getProjectId());
|
reviewCommentDto.getReviewComment().setCode(sysCodeRuleService.getNewCode(map));
|
baseDao.insert(reviewCommentDto.getReviewComment());
|
commentId = reviewCommentDto.getReviewComment().getId();
|
}
|
return commentId;
|
}
|
|
public void exportReviewComment(Long id, String pageCode, HttpServletRequest request, HttpServletResponse response) {
|
try {
|
ReviewCommentDto dataObj = this.getDto(id, null, pageCode);
|
WordFile wordFile = new WordFile();
|
wordFile.setModulePath("基线发布书.docx");
|
wordFile.setWordName(dataObj.getProject().getSoftwareName() + "_基线发布书.docx");
|
wordFileService.exportWordFile(request, dataObj, wordFile, response);
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
} catch (FileNotFoundException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|