|
|
|
@ -1,12 +1,14 @@
|
|
|
|
|
package com.supervision.manage.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.supervision.manage.service.AskQuestionLibraryManageService;
|
|
|
|
|
import com.supervision.model.AskTemplateQuestionLibrary;
|
|
|
|
|
import com.supervision.model.CommonDic;
|
|
|
|
|
import com.supervision.service.AskTemplateQuestionLibraryService;
|
|
|
|
|
import com.supervision.service.CommonDicService;
|
|
|
|
|
import com.supervision.util.RedisSequenceUtil;
|
|
|
|
|
import com.supervision.vo.manage.AskQuestionLibraryReqVo;
|
|
|
|
|
import com.supervision.vo.manage.AskQuestionLibraryResVo;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
@ -44,6 +46,24 @@ public class AskQuestionLibraryManageServiceImpl implements AskQuestionLibraryMa
|
|
|
|
|
public String saveQuestionLibrary(AskTemplateQuestionLibrary askTemplateQuestionLibrary) {
|
|
|
|
|
assertSave(askTemplateQuestionLibrary);
|
|
|
|
|
|
|
|
|
|
String nextCode = RedisSequenceUtil.getQuestionLibraryCode(() -> {
|
|
|
|
|
String maxCode = askTemplateQuestionLibraryService.getMaxCode();
|
|
|
|
|
if (StrUtil.isNotEmpty(maxCode)) {
|
|
|
|
|
return Long.parseLong(StrUtil.removePrefix(maxCode, "Q"));
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
String nextDefaultCode = RedisSequenceUtil.getQuestionLibraryDefaultAnswerCode(() -> {
|
|
|
|
|
String code = askTemplateQuestionLibraryService.getMaxDefaultAnswerCode();
|
|
|
|
|
if (StrUtil.isNotEmpty(code)) {
|
|
|
|
|
return Long.parseLong(StrUtil.removePrefix(code, "A"));
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
askTemplateQuestionLibrary.setCode(nextCode);
|
|
|
|
|
askTemplateQuestionLibrary.setDefaultAnswerCode(nextDefaultCode);
|
|
|
|
|
askTemplateQuestionLibraryService.save(askTemplateQuestionLibrary);
|
|
|
|
|
return askTemplateQuestionLibrary.getId();
|
|
|
|
|
}
|
|
|
|
@ -64,8 +84,8 @@ public class AskQuestionLibraryManageServiceImpl implements AskQuestionLibraryMa
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void assertSave(AskTemplateQuestionLibrary askTemplateQuestionLibrary){
|
|
|
|
|
Assert.notEmpty(askTemplateQuestionLibrary.getCode(),"编码不能为空");
|
|
|
|
|
Assert.notEmpty(askTemplateQuestionLibrary.getQuestion(),"问题不能为空");
|
|
|
|
|
Assert.notNull(askTemplateQuestionLibrary.getDictId(),"问题类目不能为空");
|
|
|
|
|
Assert.notEmpty(askTemplateQuestionLibrary.getDescription(),"问题不能为空");
|
|
|
|
|
Assert.notEmpty(askTemplateQuestionLibrary.getDefaultAnswer(),"默认回答不能为空");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|