|
@@ -180,27 +180,45 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean updateByEditBo(QuestionEditBo bo) {
|
|
|
- Question update = BeanUtil.toBean(bo, Question.class);
|
|
|
- if (bo.getOptionsList() != null) {
|
|
|
- update.setJsonStr(JSON.toJSONString(bo.getOptionsList()));
|
|
|
- }
|
|
|
- validEntityBeforeSave(update);
|
|
|
- update.setUpdateTime(DateUtils.getNowTime());
|
|
|
- if (bo.getBusinessList() != null) {
|
|
|
- iQuestionBusinessService.remove(new LambdaQueryWrapper<QuestionBusiness>()
|
|
|
- .eq(QuestionBusiness::getMajorId, bo.getQuestionId())
|
|
|
- .eq(QuestionBusiness::getType, QuestionBusiness.TYPE_QUESTION));
|
|
|
- Collection<QuestionBusiness> coll = new HashSet<>();
|
|
|
- for (int i = 0; i < bo.getBusinessList().size(); i++) {
|
|
|
- QuestionBusinessEditBo item = bo.getBusinessList().get(i);
|
|
|
- QuestionBusiness addItem = BeanUtil.toBean(item, QuestionBusiness.class);
|
|
|
- addItem.setMajorId(bo.getQuestionId());
|
|
|
- addItem.setType(QuestionBusiness.TYPE_QUESTION);
|
|
|
- coll.add(addItem);
|
|
|
+ if(bo.getStatus()==-1){
|
|
|
+ //删除
|
|
|
+ if(Validator.isNotEmpty(bo.getQuestionIds())&&bo.getQuestionIds().size()>0){
|
|
|
+ for(Long id : bo.getQuestionIds()){
|
|
|
+ Question update = new Question();
|
|
|
+ update.setQuestionId(id);
|
|
|
+ update.setStatus(-1);
|
|
|
+ }
|
|
|
}
|
|
|
- iQuestionBusinessService.saveBatch(coll);
|
|
|
+ if(Validator.isNotEmpty(bo.getQuestionId())){
|
|
|
+ Question update = new Question();
|
|
|
+ update.setQuestionId(bo.getQuestionId());
|
|
|
+ update.setStatus(-1);
|
|
|
+ return this.updateById(update);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ Question update = BeanUtil.toBean(bo, Question.class);
|
|
|
+ if (bo.getOptionsList() != null) {
|
|
|
+ update.setJsonStr(JSON.toJSONString(bo.getOptionsList()));
|
|
|
+ }
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ if (bo.getBusinessList() != null) {
|
|
|
+ iQuestionBusinessService.remove(new LambdaQueryWrapper<QuestionBusiness>()
|
|
|
+ .eq(QuestionBusiness::getMajorId, bo.getQuestionId())
|
|
|
+ .eq(QuestionBusiness::getType, QuestionBusiness.TYPE_QUESTION));
|
|
|
+ Collection<QuestionBusiness> coll = new HashSet<>();
|
|
|
+ for (int i = 0; i < bo.getBusinessList().size(); i++) {
|
|
|
+ QuestionBusinessEditBo item = bo.getBusinessList().get(i);
|
|
|
+ QuestionBusiness addItem = BeanUtil.toBean(item, QuestionBusiness.class);
|
|
|
+ addItem.setMajorId(bo.getQuestionId());
|
|
|
+ addItem.setType(QuestionBusiness.TYPE_QUESTION);
|
|
|
+ coll.add(addItem);
|
|
|
+ }
|
|
|
+ iQuestionBusinessService.saveBatch(coll);
|
|
|
+ }
|
|
|
+ return this.updateById(update);
|
|
|
}
|
|
|
- return this.updateById(update);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|