Search in sources :

Example 1 with IssueCommentDTO

use of io.choerodon.agile.infra.dto.IssueCommentDTO in project agile-service by open-hand.

the class IssueCommentServiceImpl method deleteIssueCommentReply.

@Override
public void deleteIssueCommentReply(Long projectId, Long commentId, boolean self) {
    IssueCommentDTO issueCommentDTO = getCommentById(projectId, commentId);
    if (self && !DetailsHelper.getUserDetails().getUserId().equals(issueCommentDTO.getUserId())) {
        throw new CommonException("error.created.user.illegal");
    }
    iIssueCommentService.deleteBaseReply(issueCommentDTO);
}
Also used : IssueCommentDTO(io.choerodon.agile.infra.dto.IssueCommentDTO) CommonException(io.choerodon.core.exception.CommonException)

Example 2 with IssueCommentDTO

use of io.choerodon.agile.infra.dto.IssueCommentDTO in project agile-service by open-hand.

the class IssueCommentServiceImpl method updateIssueComment.

@Override
public IssueCommentVO updateIssueComment(IssueCommentUpdateVO issueCommentUpdateVO, List<String> fieldList, Long projectId) {
    if (fieldList != null && !fieldList.isEmpty()) {
        IssueCommentDTO issueCommentDTO = issueCommentAssembler.toTarget(issueCommentUpdateVO, IssueCommentDTO.class);
        iIssueCommentService.updateBase(issueCommentDTO, fieldList.toArray(new String[fieldList.size()]));
        IssueCommentVO issueCommentVO = queryByProjectIdAndCommentId(projectId, issueCommentDTO.getCommentId());
        IssueDetailDTO issue = issueMapper.queryIssueDetail(projectId, issueCommentVO.getIssueId());
        Long operatorId = DetailsHelper.getUserDetails().getUserId();
        if (issueCommentVO.getReplyToUserId() == null || issueCommentVO.getReplyToUserId() == 0L) {
            sendMsgUtil.sendMsgByIssueComment(projectId, issue, issueCommentVO, operatorId);
        } else if (!issueCommentVO.getReplyToUserId().equals(operatorId)) {
            sendMsgUtil.sendMsgByIssueCommentReply(projectId, issue, issueCommentVO, operatorId);
        }
        return issueCommentVO;
    } else {
        return null;
    }
}
Also used : IssueDetailDTO(io.choerodon.agile.infra.dto.business.IssueDetailDTO) IssueCommentDTO(io.choerodon.agile.infra.dto.IssueCommentDTO)

Example 3 with IssueCommentDTO

use of io.choerodon.agile.infra.dto.IssueCommentDTO in project agile-service by open-hand.

the class IIssueCommentServiceImpl method deleteBase.

@Override
@DataLog(type = "deleteComment")
public int deleteBase(IssueCommentDTO issueCommentDTO) {
    int isDelete = issueCommentMapper.delete(issueCommentDTO);
    if (isDelete != 1) {
        throw new CommonException(DELETE_ERROR);
    }
    IssueCommentDTO childRecord = new IssueCommentDTO();
    childRecord.setParentId(issueCommentDTO.getCommentId());
    childRecord.setIssueId(issueCommentDTO.getIssueId());
    childRecord.setProjectId(issueCommentDTO.getProjectId());
    IssueCommentDTO firstReply = issueCommentMapper.selectOne(childRecord);
    if (!ObjectUtils.isEmpty(firstReply)) {
        firstReply.setParentId(0L);
        firstReply.setReplyToUserId(0L);
        issueCommentMapper.updateByPrimaryKeySelective(firstReply);
        issueCommentMapper.updateChildNewParent(issueCommentDTO.getProjectId(), issueCommentDTO.getCommentId(), firstReply.getCommentId());
    }
    BaseFieldUtil.updateIssueLastUpdateInfo(issueCommentDTO.getIssueId(), issueCommentDTO.getProjectId());
    return isDelete;
}
Also used : CommonException(io.choerodon.core.exception.CommonException) IssueCommentDTO(io.choerodon.agile.infra.dto.IssueCommentDTO) DataLog(io.choerodon.agile.infra.annotation.DataLog)

Example 4 with IssueCommentDTO

use of io.choerodon.agile.infra.dto.IssueCommentDTO in project agile-service by open-hand.

the class IssueCommentValidator method verifyUpdateData.

public void verifyUpdateData(Long projectId, JSONObject issueCommentUpdate, boolean self) {
    if (issueCommentUpdate.get(COMMENT_ID) == null) {
        throw new CommonException("error.IssueCommentRule.commentId");
    }
    IssueCommentDTO issueCommentDTO = new IssueCommentDTO();
    issueCommentDTO.setCommentId(EncryptionUtils.decrypt(issueCommentUpdate.get(COMMENT_ID).toString(), EncryptionUtils.BLANK_KEY));
    issueCommentDTO.setProjectId(projectId);
    IssueCommentDTO originIssueComment = issueCommentMapper.selectByPrimaryKey(issueCommentDTO);
    if (originIssueComment == null) {
        throw new CommonException("error.IssueCommentRule.issueComment");
    }
    if (self && !DetailsHelper.getUserDetails().getUserId().equals(originIssueComment.getUserId())) {
        throw new CommonException("error.created.user.illegal");
    }
}
Also used : CommonException(io.choerodon.core.exception.CommonException) IssueCommentDTO(io.choerodon.agile.infra.dto.IssueCommentDTO)

Example 5 with IssueCommentDTO

use of io.choerodon.agile.infra.dto.IssueCommentDTO in project agile-service by open-hand.

the class IIssueCommentServiceImpl method deleteBaseReply.

@Override
@DataLog(type = "deleteCommentReply")
public void deleteBaseReply(IssueCommentDTO issueCommentDTO) {
    int isDelete = issueCommentMapper.delete(issueCommentDTO);
    if (isDelete != 1) {
        throw new CommonException(DELETE_ERROR);
    }
    IssueCommentDTO childRecord = new IssueCommentDTO();
    childRecord.setIssueId(issueCommentDTO.getIssueId());
    childRecord.setProjectId(issueCommentDTO.getProjectId());
    childRecord.setParentId(issueCommentDTO.getCommentId());
    issueCommentMapper.delete(childRecord);
    BaseFieldUtil.updateIssueLastUpdateInfo(issueCommentDTO.getIssueId(), issueCommentDTO.getProjectId());
}
Also used : CommonException(io.choerodon.core.exception.CommonException) IssueCommentDTO(io.choerodon.agile.infra.dto.IssueCommentDTO) DataLog(io.choerodon.agile.infra.annotation.DataLog)

Aggregations

IssueCommentDTO (io.choerodon.agile.infra.dto.IssueCommentDTO)13 CommonException (io.choerodon.core.exception.CommonException)6 UserMessageDTO (io.choerodon.agile.infra.dto.UserMessageDTO)4 IssueDetailDTO (io.choerodon.agile.infra.dto.business.IssueDetailDTO)3 DataLog (io.choerodon.agile.infra.annotation.DataLog)2 CustomUserDetails (io.choerodon.core.oauth.CustomUserDetails)2 TypeToken (org.modelmapper.TypeToken)2