|
@@ -12,6 +12,8 @@ import com.diagbot.entity.IntroduceInfo;
|
|
import com.diagbot.entity.IntroduceMap;
|
|
import com.diagbot.entity.IntroduceMap;
|
|
import com.diagbot.entity.QuestionInfo;
|
|
import com.diagbot.entity.QuestionInfo;
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
|
+import com.diagbot.exception.CommonException;
|
|
import com.diagbot.service.IntroduceDetailService;
|
|
import com.diagbot.service.IntroduceDetailService;
|
|
import com.diagbot.service.IntroduceMapService;
|
|
import com.diagbot.service.IntroduceMapService;
|
|
import com.diagbot.service.impl.IntroduceInfoServiceImpl;
|
|
import com.diagbot.service.impl.IntroduceInfoServiceImpl;
|
|
@@ -62,11 +64,18 @@ public class IntroduceInfoFacade extends IntroduceInfoServiceImpl {
|
|
*/
|
|
*/
|
|
public Boolean saveIntroduce(IntroduceVO introduceVO) {
|
|
public Boolean saveIntroduce(IntroduceVO introduceVO) {
|
|
IntroduceInfo introduceInfo = new IntroduceInfo();
|
|
IntroduceInfo introduceInfo = new IntroduceInfo();
|
|
- if (!(introduceVO.getId() == null||introduceInfo.getId().equals(0))) {
|
|
|
|
|
|
+ if (!(introduceVO.getId() == null || introduceInfo.getId().equals(0))) {
|
|
introduceInfo = this.getById(introduceVO.getId());
|
|
introduceInfo = this.getById(introduceVO.getId());
|
|
- introduceInfo.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
|
- introduceInfo.setGmtModified(DateUtil.now());
|
|
|
|
|
|
+ if (introduceInfo == null) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "提示信息不存在");
|
|
|
|
+ } else if (introduceInfo.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "提示信息已删除");
|
|
|
|
+ } else {
|
|
|
|
+ introduceInfo.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
|
+ introduceInfo.setGmtModified(DateUtil.now());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
Date now = DateUtil.now();
|
|
Date now = DateUtil.now();
|
|
String userId = UserUtils.getCurrentPrincipleID();
|
|
String userId = UserUtils.getCurrentPrincipleID();
|
|
introduceInfo.setCreator(userId);
|
|
introduceInfo.setCreator(userId);
|
|
@@ -94,8 +103,10 @@ public class IntroduceInfoFacade extends IntroduceInfoServiceImpl {
|
|
for (IntroduceDetailVO detailVO : introduceVO.getDetailVOList()) {
|
|
for (IntroduceDetailVO detailVO : introduceVO.getDetailVOList()) {
|
|
IntroduceDetail detail = new IntroduceDetail();
|
|
IntroduceDetail detail = new IntroduceDetail();
|
|
detail.setIntroduceId(introduceInfo.getId());
|
|
detail.setIntroduceId(introduceInfo.getId());
|
|
- detail.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
|
- detail.setGmtCreate(DateUtil.now());
|
|
|
|
|
|
+ detail.setCreator(userId);
|
|
|
|
+ detail.setGmtCreate(now);
|
|
|
|
+ detail.setModifier(userId);
|
|
|
|
+ detail.setGmtModified(now);
|
|
detail.setContent(detailVO.getContent());
|
|
detail.setContent(detailVO.getContent());
|
|
detail.setText(detailVO.getText());
|
|
detail.setText(detailVO.getText());
|
|
detail.setTitle(detailVO.getTitle());
|
|
detail.setTitle(detailVO.getTitle());
|
|
@@ -109,8 +120,10 @@ public class IntroduceInfoFacade extends IntroduceInfoServiceImpl {
|
|
|
|
|
|
//更新映射关系
|
|
//更新映射关系
|
|
//删除已有映射关系
|
|
//删除已有映射关系
|
|
|
|
+ List<Long> questionIds = introduceVO.getMapVOList().stream().map(introduceMapVO -> introduceMapVO.getQuestionId()).collect(Collectors.toList());
|
|
|
|
+ Long introudceId = introduceInfo.getId();
|
|
UpdateWrapper<IntroduceMap> introduceMapUpdateWrapper = new UpdateWrapper<>();
|
|
UpdateWrapper<IntroduceMap> introduceMapUpdateWrapper = new UpdateWrapper<>();
|
|
- introduceMapUpdateWrapper.eq("introduce_id", introduceInfo.getId()).
|
|
|
|
|
|
+ introduceMapUpdateWrapper.and(i -> i.eq("introduce_id", introudceId).or().in("question_id", questionIds)).
|
|
eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
set("is_deleted", IsDeleteEnum.Y.getKey()).
|
|
set("is_deleted", IsDeleteEnum.Y.getKey()).
|
|
set("modifier", UserUtils.getCurrentPrincipleID()).
|
|
set("modifier", UserUtils.getCurrentPrincipleID()).
|
|
@@ -122,6 +135,10 @@ public class IntroduceInfoFacade extends IntroduceInfoServiceImpl {
|
|
IntroduceMap introduceMap = new IntroduceMap();
|
|
IntroduceMap introduceMap = new IntroduceMap();
|
|
BeanUtil.copyProperties(introduceMapVO, introduceMap);
|
|
BeanUtil.copyProperties(introduceMapVO, introduceMap);
|
|
introduceMap.setIntroduceId(introduceInfo.getId());
|
|
introduceMap.setIntroduceId(introduceInfo.getId());
|
|
|
|
+ introduceMap.setCreator(userId);
|
|
|
|
+ introduceMap.setGmtCreate(now);
|
|
|
|
+ introduceMap.setModifier(userId);
|
|
|
|
+ introduceMap.setGmtModified(now);
|
|
introduceMapList.add(introduceMap);
|
|
introduceMapList.add(introduceMap);
|
|
}
|
|
}
|
|
introduceMapService.saveBatch(introduceMapList);
|
|
introduceMapService.saveBatch(introduceMapList);
|
|
@@ -135,6 +152,12 @@ public class IntroduceInfoFacade extends IntroduceInfoServiceImpl {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public Boolean deleteRecord(Long id) {
|
|
public Boolean deleteRecord(Long id) {
|
|
|
|
+ IntroduceInfo introduceInfo = this.getById(id);
|
|
|
|
+ if (introduceInfo == null) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "提示信息不存在");
|
|
|
|
+ } else if (introduceInfo.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "提示信息已删除");
|
|
|
|
+ }
|
|
//删除已有映射关系
|
|
//删除已有映射关系
|
|
UpdateWrapper<IntroduceMap> introduceMapUpdateWrapper = new UpdateWrapper<>();
|
|
UpdateWrapper<IntroduceMap> introduceMapUpdateWrapper = new UpdateWrapper<>();
|
|
introduceMapUpdateWrapper.eq("introduce_id", id).
|
|
introduceMapUpdateWrapper.eq("introduce_id", id).
|