| @@ -11,6 +11,8 @@ import org.springframework.http.ResponseEntity; | |||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | /** | ||||
| * (Component)表控制层 | * (Component)表控制层 | ||||
| @@ -41,6 +43,22 @@ public class ComponentController { | |||||
| return ResponseEntity.ok(this.componentService.queryByPage(component, pageRequest)); | return ResponseEntity.ok(this.componentService.queryByPage(component, pageRequest)); | ||||
| } | } | ||||
| /** | |||||
| * 查询全部 | |||||
| * | |||||
| * | |||||
| * | |||||
| * @return 查询结果 | |||||
| */ | |||||
| @GetMapping("/components/all") | |||||
| @ApiOperation("查询全部") | |||||
| public ResponseEntity<Map<Integer,List<Component>>> queryAll(){ | |||||
| return ResponseEntity.ok(this.componentService.queryAllGroupedByCategory()); | |||||
| } | |||||
| /** | /** | ||||
| * 通过主键查询单条数据 | * 通过主键查询单条数据 | ||||
| * | * | ||||
| @@ -29,6 +29,9 @@ public interface ComponentDao { | |||||
| */ | */ | ||||
| Component queryById(Integer id); | Component queryById(Integer id); | ||||
| List<Component> queryAll(); | |||||
| /** | /** | ||||
| * 查询指定行数据 | * 查询指定行数据 | ||||
| * | * | ||||
| @@ -90,5 +93,6 @@ public interface ComponentDao { | |||||
| // 检查相同category_id下的component_name是否存在 | // 检查相同category_id下的component_name是否存在 | ||||
| Integer countByNameAndCategoryId(@Param("componentName") String componentName, @Param("categoryId") Integer categoryId); | Integer countByNameAndCategoryId(@Param("componentName") String componentName, @Param("categoryId") Integer categoryId); | ||||
| } | } | ||||
| @@ -5,6 +5,9 @@ import com.ruoyi.platform.vo.ComponentVo; | |||||
| import org.springframework.data.domain.Page; | import org.springframework.data.domain.Page; | ||||
| import org.springframework.data.domain.PageRequest; | import org.springframework.data.domain.PageRequest; | ||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | /** | ||||
| * (Component)表服务接口 | * (Component)表服务接口 | ||||
| * | * | ||||
| @@ -56,4 +59,6 @@ public interface ComponentService { | |||||
| String removeById(Integer id); | String removeById(Integer id); | ||||
| Map<Integer, List<Component>> queryAllGroupedByCategory(); | |||||
| } | } | ||||
| @@ -16,6 +16,9 @@ import org.springframework.data.domain.PageRequest; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import java.util.stream.Collectors; | |||||
| /** | /** | ||||
| * (Component)表服务实现类 | * (Component)表服务实现类 | ||||
| @@ -30,6 +33,8 @@ public class ComponentServiceImpl implements ComponentService { | |||||
| @Value("${pipeline.control_strategy}") | @Value("${pipeline.control_strategy}") | ||||
| private String controlStrategy; | private String controlStrategy; | ||||
| /** | /** | ||||
| * 通过ID查询单条数据 | * 通过ID查询单条数据 | ||||
| * | * | ||||
| @@ -46,6 +51,13 @@ public class ComponentServiceImpl implements ComponentService { | |||||
| return this.componentDao.queryById(id); | return this.componentDao.queryById(id); | ||||
| } | } | ||||
| @Override | |||||
| public Map<Integer, List<Component>> queryAllGroupedByCategory() { | |||||
| List<Component> componentList = this.componentDao.queryAll(); | |||||
| Map<Integer,List<Component>> groupedComponent = componentList.stream().collect(Collectors.groupingBy(Component::getCategoryId)); | |||||
| return groupedComponent; | |||||
| } | |||||
| /** | /** | ||||
| * 分页查询 | * 分页查询 | ||||
| * | * | ||||
| @@ -150,4 +162,6 @@ public class ComponentServiceImpl implements ComponentService { | |||||
| component.setState(0); | component.setState(0); | ||||
| return this.componentDao.update(component)>0?"删除成功":"删除失败"; | return this.componentDao.update(component)>0?"删除成功":"删除失败"; | ||||
| } | } | ||||
| } | } | ||||
| @@ -31,6 +31,12 @@ | |||||
| where id = #{id} and state = 1 | where id = #{id} and state = 1 | ||||
| </select> | </select> | ||||
| <!--查询所有的结果--> | |||||
| <select id="queryAll" resultMap="ComponentMap"> | |||||
| SELECT * FROM component WHERE state = 1 | |||||
| </select> | |||||
| <!--查询指定行数据--> | <!--查询指定行数据--> | ||||
| <select id="queryAllByLimit" resultMap="ComponentMap"> | <select id="queryAllByLimit" resultMap="ComponentMap"> | ||||
| select | select | ||||