mitao
2 天以前 a93ad50197f1626a12ba5067639119400542f455
finance-system/src/main/java/com/finance/system/service/impl/TbQuestionServiceImpl.java
@@ -23,6 +23,7 @@
import java.util.Set;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -41,22 +42,27 @@
    private final ISysUserService sysUserService;
    private final AsyncService asyncService;
    @Value("${fdb.quarter}")
    private String quarter;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addQuestion(QuestionDTO dto) throws Exception {
        TbQuestion tbQuestion = BeanUtils.copyBean(dto, TbQuestion.class);
        tbQuestion.setType(dto.getType());
        tbQuestion.setQuarter(DateUtils.getNowQuarter());
        String previousQuarter = DateUtils.getPreviousQuarter();
        previousQuarter = quarter;
        tbQuestion.setQuarter(previousQuarter);
        this.save(tbQuestion);
        asyncService.subtractScoreWithFixedRules(dto.getDeptAreaCode());
    }
    @Override
    public void editQuestion(QuestionUpdDTO dto) {
    public void editQuestion(QuestionUpdDTO dto) throws Exception {
        TbQuestion tbQuestion = BeanUtils.copyBean(dto, TbQuestion.class);
        tbQuestion.setType(dto.getType());
        this.updateById(tbQuestion);
        asyncService.subtractScoreWithFixedRules(dto.getDeptAreaCode());
    }
    @Override
@@ -89,4 +95,15 @@
        return questionVOPageDTO;
    }
    @Override
    public void delete(Long id) {
        TbQuestion question = this.getById(id);
        try {
            asyncService.subtractScoreWithFixedRules(question.getDeptAreaCode());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        this.removeById(id);
    }
}