Commit 4462d372 by wangli

新增实现获取技能组列表

1 parent 3fb08783
package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.service.SkillGroupCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/pea-order")
public class SkillController {
@Autowired
SkillGroupCategoryService skillGroupCategoryService;
@GetMapping("/pea-order/skill/group/category")
public Result<?> skillGroupCategory() {
Result<?> res = null;
try {
res = skillGroupCategoryService.querySkillGroupCategoryService();
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
}
package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result;
public interface SkillGroupCategoryService {
public Result<?> querySkillGroupCategoryService();
}
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.SkillGroupMPDao;
import com.dituhui.pea.order.entity.SkillGroup;
import com.dituhui.pea.order.service.SkillGroupCategoryService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class SkillGroupCategoryServiceImpl implements SkillGroupCategoryService {
@Autowired
SkillGroupMPDao skillGroupMPDao;
@Override
public Result<?> querySkillGroupCategoryService() {
List<SkillGroup> records = skillGroupMPDao.selectList(null).stream().sorted(
Comparator.comparing(SkillGroup::getCategory)).collect(Collectors.toList());
List<Category> items = new ArrayList<>();
for (SkillGroup r : records) {
items.add(new Category(r.getSkillGroupCode(), r.getSkillGroup(), r.getCategory()));
}
Response res = new Response();
res.setCategories(items);
return Result.success(res);
}
}
@Data
class Response {
private List<Category> categories;
}
@Data
class Category {
private String skillGroupId;
private String category;
private String skillGroupName;
public Category(String skillGroupId, String skillGroupName, String category) {
this.category = category;
this.skillGroupName = skillGroupName;
this.skillGroupId = skillGroupId;
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!