Commit bbf7f4a2 by 丁伟峰

基础性的技能树列表返回,用于创建订单时候的条件选择

1 parent 9a762940
......@@ -27,4 +27,15 @@ public class PublicController {
}
return res;
}
@GetMapping("/public/skill/tree")
public Result<?> getPublicSkillTree() {
Result<?> res = null;
try {
res = publicService.getSkillTree();
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
}
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface SkillInfoDao extends JpaRepository<SkillInfoEntity, Long> {
List<SkillInfoEntity> getAll();
}
package com.dituhui.pea.order.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
public class PublicSkillTreeDTO {
@Data
public static class Result {
private List<Content> content;
}
@Data
@Accessors(chain = true)
public static class Content {
private String brand;
private String skill;
private String type;
}
}
......@@ -4,4 +4,6 @@ import com.dituhui.pea.common.Result;
public interface PublicService {
Result<?> getPublicParameter();
Result<?> getSkillTree();
}
......@@ -2,8 +2,11 @@ package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.PubParamsDao;
import com.dituhui.pea.order.dao.SkillInfoDao;
import com.dituhui.pea.order.dto.PubParameterDTO;
import com.dituhui.pea.order.dto.PublicSkillTreeDTO;
import com.dituhui.pea.order.entity.PubParamsEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import com.dituhui.pea.order.service.PublicService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -12,6 +15,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
......@@ -20,6 +24,9 @@ public class PublicServiceImpl implements PublicService {
@Autowired
private PubParamsDao pubParamsDao;
@Autowired
private SkillInfoDao skillInfoDao;
@Override
public Result<?> getPublicParameter() {
List<PubParameterDTO.Enum> enums = new ArrayList<>();
......@@ -42,6 +49,19 @@ public class PublicServiceImpl implements PublicService {
return Result.success(rs);
}
@Override
public Result<?> getSkillTree() {
List<PublicSkillTreeDTO.Content> contents = skillInfoDao.getAll().stream().map(entity -> {
return new PublicSkillTreeDTO.Content()
.setBrand(entity.getBrand())
.setType(entity.getType())
.setSkill(entity.getSkill());
}).collect(Collectors.toList());
PublicSkillTreeDTO.Result rs = new PublicSkillTreeDTO.Result();
rs.setContent(contents);
return Result.success(rs);
}
private HashMap<String, String> getMapping() {
String[] pairs = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!