|
|
|
@ -19,19 +19,24 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
|
public Map<String, Object> getList(int page, int num, QuestionCategories entity) { |
|
|
|
|
int offset = (page - 1) * num; |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
List<QuestionCategories> data = baseMapper.getList( |
|
|
|
|
entity.getIndustryId(), |
|
|
|
|
entity.getServiceTypeId(), |
|
|
|
|
entity.getQuestionContent(), |
|
|
|
|
offset, |
|
|
|
|
num); |
|
|
|
|
num |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
int total = baseMapper.getListSize( |
|
|
|
|
entity.getIndustryId(), |
|
|
|
|
entity.getServiceTypeId(), |
|
|
|
|
entity.getQuestionContent()); |
|
|
|
|
entity.getQuestionContent() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
map.put("data", data); |
|
|
|
|
map.put("total", total); |
|
|
|
|
|
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -41,41 +46,43 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int add(List<InsQuestionVO> vo) { |
|
|
|
|
public boolean addQuestion(List<InsQuestionVO> vo) { |
|
|
|
|
int count = 0; |
|
|
|
|
for (InsQuestionVO item : vo) { |
|
|
|
|
save(convertToEntity(item)); |
|
|
|
|
count++; |
|
|
|
|
} |
|
|
|
|
return count; |
|
|
|
|
return count > 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean update(InsQuestionVO vo) { |
|
|
|
|
public boolean editQuestion(InsQuestionVO vo) { |
|
|
|
|
return updateById(convertToEntity(vo)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Industry> getDictionary() { |
|
|
|
|
return baseMapper.getIndustry(); |
|
|
|
|
public QuestionCategories getQuestionDetail(String id) { |
|
|
|
|
return baseMapper.getQuestionDetail(Long.valueOf(id)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public QuestionCategories getQuestionDetail(String id){ |
|
|
|
|
return baseMapper.getQuestionDetail(Long.valueOf(id)); |
|
|
|
|
public List<Industry> findDictionary() { |
|
|
|
|
return baseMapper.getIndustry(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 将VO转换为实体类 |
|
|
|
|
* 将VO转换为Entity |
|
|
|
|
*/ |
|
|
|
|
private QuestionCategories convertToEntity(InsQuestionVO vo) { |
|
|
|
|
QuestionCategories entity = new QuestionCategories(); |
|
|
|
|
|
|
|
|
|
entity.setId(vo.getId()); |
|
|
|
|
entity.setQuestionTypes(vo.getQuestionTypes()); |
|
|
|
|
entity.setIndustryId(vo.getIndustryId()); |
|
|
|
|
entity.setServiceTypeId(vo.getServiceTypeId()); |
|
|
|
|
entity.setQuestionContent(vo.getQuestionContent()); |
|
|
|
|
entity.setAnswer(vo.getAnswer()); |
|
|
|
|
|
|
|
|
|
StringBuilder optionsBuilder = new StringBuilder(); |
|
|
|
|
if (vo.getOptionA()!= null) { |
|
|
|
|
optionsBuilder.append("A:").append(vo.getOptionA()).append(","); |
|
|
|
@ -89,8 +96,10 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
|
if (vo.getOptionD()!= null) { |
|
|
|
|
optionsBuilder.append("D:").append(vo.getOptionD()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String options = optionsBuilder.toString(); |
|
|
|
|
entity.setOptions(options); |
|
|
|
|
|
|
|
|
|
return entity; |
|
|
|
|
} |
|
|
|
|
} |