feat(商城): 添加商城分类接口
parent
1582986de1
commit
3d8c558d1e
@ -0,0 +1,22 @@
|
||||
package com.wayn.common.core.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 路由显示信息
|
||||
*/
|
||||
@Data
|
||||
public class VanTreeSelectVo {
|
||||
private Long id;
|
||||
private String text;
|
||||
private String icon;
|
||||
|
||||
public VanTreeSelectVo() {
|
||||
}
|
||||
|
||||
public VanTreeSelectVo(Long id, String text, String icon) {
|
||||
this.id = id;
|
||||
this.text = text;
|
||||
this.icon = icon;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.wayn.mobile.api.controller;
|
||||
|
||||
import com.wayn.common.core.domain.shop.Category;
|
||||
import com.wayn.common.core.domain.vo.VanTreeSelectVo;
|
||||
import com.wayn.common.core.service.shop.ICategoryService;
|
||||
import com.wayn.common.util.R;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("category")
|
||||
public class CategoryController {
|
||||
|
||||
@Autowired
|
||||
private ICategoryService iCategoryService;
|
||||
|
||||
@GetMapping("index")
|
||||
public R index(@RequestParam(required = false) Long id) {
|
||||
R success = R.success();
|
||||
List<VanTreeSelectVo> categoryList = iCategoryService.selectL1Category();
|
||||
Category currentCategory;
|
||||
List<VanTreeSelectVo> subCategoryList;
|
||||
if (Objects.isNull(id) && categoryList.size() > 0) {
|
||||
currentCategory = iCategoryService.getById(categoryList.get(0).getId());
|
||||
subCategoryList = iCategoryService.selectCategoryByPid(currentCategory.getId());
|
||||
} else {
|
||||
currentCategory = iCategoryService.getById(id);
|
||||
subCategoryList = iCategoryService.selectCategoryByPid(id);
|
||||
}
|
||||
success.add("categoryList", categoryList);
|
||||
success.add("currentCategory", currentCategory);
|
||||
success.add("subCategoryList", subCategoryList);
|
||||
return success;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package com.wayn.mobile.api.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class TestController {
|
||||
|
||||
@GetMapping("test")
|
||||
public String test() {
|
||||
return "hello world!";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue