|
|
|
@ -16,22 +16,27 @@ import java.util.Map; |
|
|
|
|
public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, QuestionCategories> implements QuestionService { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<String, Object> getList(int page,int num, QuestionCategories entity) { |
|
|
|
|
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( |
|
|
|
|
int total = baseMapper.getListSize( |
|
|
|
|
entity.getIndustryId(), |
|
|
|
|
entity.getServiceTypeId(), |
|
|
|
|
entity.getQuestionContent()); |
|
|
|
|
entity.getQuestionContent() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
map.put("data", data); |
|
|
|
|
map.put("total", total); |
|
|
|
|
|
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -41,56 +46,60 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int add(List<InsQuestionVO> vo) { |
|
|
|
|
int count =0; |
|
|
|
|
for(InsQuestionVO item :vo){ |
|
|
|
|
public boolean addQuestion(List<InsQuestionVO> vo) { |
|
|
|
|
int count = 0; |
|
|
|
|
for (InsQuestionVO item : vo) { |
|
|
|
|
save(convertToEntity(item)); |
|
|
|
|
count ++; |
|
|
|
|
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(","); |
|
|
|
|
} |
|
|
|
|
if (vo.getOptionB() != null) { |
|
|
|
|
if (vo.getOptionB()!= null) { |
|
|
|
|
optionsBuilder.append("B:").append(vo.getOptionB()).append(","); |
|
|
|
|
} |
|
|
|
|
if (vo.getOptionC() != null) { |
|
|
|
|
if (vo.getOptionC()!= null) { |
|
|
|
|
optionsBuilder.append("C:").append(vo.getOptionC()).append(","); |
|
|
|
|
} |
|
|
|
|
if (vo.getOptionD() != null) { |
|
|
|
|
if (vo.getOptionD()!= null) { |
|
|
|
|
optionsBuilder.append("D:").append(vo.getOptionD()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String options = optionsBuilder.toString(); |
|
|
|
|
entity.setOptions(options); |
|
|
|
|
|
|
|
|
|
return entity; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |