分类管理(WRITE)
This commit is contained in:
@@ -2,6 +2,7 @@ package com.sky.controller.category;
|
||||
|
||||
import com.sky.dto.CategoryDTO;
|
||||
import com.sky.dto.CategoryPageQueryDTO;
|
||||
import com.sky.entity.Category;
|
||||
import com.sky.result.PageResult;
|
||||
import com.sky.result.Result;
|
||||
import com.sky.service.CategoryService;
|
||||
@@ -13,6 +14,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "分类相关接口")
|
||||
@RequestMapping("/admin/category")
|
||||
@@ -88,5 +91,16 @@ public class CategoryController {
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据id查询分类
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("根据id查询分类")
|
||||
public Result<List> list(Integer type){
|
||||
log.info("根据id查询分类");
|
||||
List<Category> result = categoryService.list(type);
|
||||
return Result.success(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.sky.entity.Category;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CategoryMapper {
|
||||
@@ -20,4 +23,7 @@ public interface CategoryMapper {
|
||||
void deleteById(long id);
|
||||
|
||||
void update(Category category);
|
||||
|
||||
@Select("select * from category where type = #{type}")
|
||||
List<Category> selectByType(Integer type);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@ package com.sky.service;
|
||||
|
||||
import com.sky.dto.CategoryDTO;
|
||||
import com.sky.dto.CategoryPageQueryDTO;
|
||||
import com.sky.entity.Category;
|
||||
import com.sky.result.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public interface CategoryService {
|
||||
/**
|
||||
@@ -38,4 +41,11 @@ public interface CategoryService {
|
||||
* @param categoryDTO
|
||||
*/
|
||||
void update(CategoryDTO categoryDTO);
|
||||
|
||||
/**
|
||||
* 根据类型查询分类
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
List<Category> list(Integer type);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@@ -104,4 +105,15 @@ public class CategoryServiceImpl implements CategoryService {
|
||||
BaseContext.removeCurrentId();
|
||||
categoryMapper.update(category);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询分类
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Category> list(Integer type) {
|
||||
List<Category> list = categoryMapper.selectByType(type);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user