公司实习代码阅读开发流程学习

整体开发流程学习
Controller层 - 调用Handler层
@RequestMapping("/business/crm/deliverPlan")
public class CrmDeliverPlanController extends BaseRest {
@GetMapping("/category/query/{groupId}/{type}")
@Description("查询分类")
public ResultDTO queryCategory(@PathVariable("groupId") String groupId,
@PathVariable("type") String type,
@RequestParam(value = "isDefault", required = false) String isDefault) {
List<Category> categories = this.deliverPlanHandler.queryCategory(type, groupId, isDefault);
return ResultDTO.ok(categories);
}
Handler层
数据校验,空指针异常处理-调用Service层,该应用调用的是其他微服务的Service
public List<Category> queryCategory(String type, String groupId, String isDefault) {
List<Category> categories = this.categoryService.listCategory(type, groupId, null, isDefault);
Optional.ofNullable(categories).ifPresent(list -> list.sort(Comparator.comparing(Category::getSort)));
return categories;
}
原文地址:https://www.cnblogs.com/spx88/p/15719806.html