实现商品分类、平台属性分组接口
This commit is contained in:
		@@ -1,8 +1,16 @@
 | 
			
		||||
package com.atguigu.ssyx.product.controller;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
import com.atguigu.ssyx.common.result.Result;
 | 
			
		||||
import com.atguigu.ssyx.model.product.Attr;
 | 
			
		||||
import com.atguigu.ssyx.product.service.AttrService;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
import io.swagger.annotations.ApiParam;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * <p>
 | 
			
		||||
@@ -12,9 +20,80 @@ import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 * @author atguigu
 | 
			
		||||
 * @since 2023-09-15
 | 
			
		||||
 */
 | 
			
		||||
@Api(value = "Attr管理", tags = "平台属性管理")
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/product/attr")
 | 
			
		||||
@RequestMapping(value = "/admin/product/attr")
 | 
			
		||||
@CrossOrigin
 | 
			
		||||
public class AttrController {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private AttrService attrService;
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "获取平台属性列表")
 | 
			
		||||
    @GetMapping("{attrGroupId}")
 | 
			
		||||
    public Result index(
 | 
			
		||||
            @ApiParam(name = "attrGroupId", value = "分组id", required = true)
 | 
			
		||||
            @PathVariable Long attrGroupId) {
 | 
			
		||||
        try {
 | 
			
		||||
            return Result.ok(attrService.findByAttrGroupId(attrGroupId));
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("获取平台属性列表异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "获取平台属性")
 | 
			
		||||
    @GetMapping("get/{id}")
 | 
			
		||||
    public Result get(@PathVariable Long id) {
 | 
			
		||||
        try {
 | 
			
		||||
            Attr attr = attrService.getById(id);
 | 
			
		||||
            return Result.ok(attr);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("获取平台属性异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "新增平台属性")
 | 
			
		||||
    @PostMapping("save")
 | 
			
		||||
    public Result save(@RequestBody Attr attr) {
 | 
			
		||||
        try {
 | 
			
		||||
            attrService.save(attr);
 | 
			
		||||
            return Result.ok(null);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("新增平台属性异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "修改平台属性")
 | 
			
		||||
    @PutMapping("update")
 | 
			
		||||
    public Result updateById(@RequestBody Attr attr) {
 | 
			
		||||
        try {
 | 
			
		||||
            attrService.updateById(attr);
 | 
			
		||||
            return Result.ok(null);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("修改平台属性异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "删除平台属性")
 | 
			
		||||
    @DeleteMapping("remove/{id}")
 | 
			
		||||
    public Result remove(@PathVariable Long id) {
 | 
			
		||||
        try {
 | 
			
		||||
            attrService.removeById(id);
 | 
			
		||||
            return Result.ok(null);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("删除平台属性异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "根据id列表删除平台属性")
 | 
			
		||||
    @DeleteMapping("batchRemove")
 | 
			
		||||
    public Result batchRemove(@RequestBody List<Long> idList) {
 | 
			
		||||
        try {
 | 
			
		||||
            attrService.removeByIds(idList);
 | 
			
		||||
            return Result.ok(null);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("根据id列表删除平台属性表异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,20 @@
 | 
			
		||||
package com.atguigu.ssyx.product.controller;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
import com.atguigu.ssyx.common.result.Result;
 | 
			
		||||
import com.atguigu.ssyx.model.product.AttrGroup;
 | 
			
		||||
import com.atguigu.ssyx.product.service.AttrGroupService;
 | 
			
		||||
import com.atguigu.ssyx.vo.product.AttrGroupQueryVo;
 | 
			
		||||
import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
import io.swagger.annotations.ApiParam;
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * <p>
 | 
			
		||||
@@ -12,9 +24,94 @@ import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 * @author atguigu
 | 
			
		||||
 * @since 2023-09-15
 | 
			
		||||
 */
 | 
			
		||||
@Api(value = "AttrGroup管理", tags = "平台属性分组管理")
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/product/attr-group")
 | 
			
		||||
@CrossOrigin
 | 
			
		||||
@RequestMapping(value = "/admin/product/attrGroup")
 | 
			
		||||
public class AttrGroupController {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private AttrGroupService attrGroupService;
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "获取平台属性分组分页列表")
 | 
			
		||||
    @GetMapping("{page}/{limit}")
 | 
			
		||||
    public Result index(@ApiParam(name = "page", value = "当前页码", required = true) @PathVariable Long page,
 | 
			
		||||
                        @ApiParam(name = "limit", value = "每页记录数", required = true) @PathVariable Long limit,
 | 
			
		||||
                        @ApiParam(name = "attrGroupQueryVo", value = "查询对象", required = false)
 | 
			
		||||
                        AttrGroupQueryVo attrGroupQueryVo) {
 | 
			
		||||
        try {
 | 
			
		||||
            Page<AttrGroup> pageParam = new Page<>(page, limit);
 | 
			
		||||
            IPage<AttrGroup> pageModel = attrGroupService.selectPage(pageParam, attrGroupQueryVo);
 | 
			
		||||
            return Result.ok(pageModel);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("获取平台属性分组分页列表异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "获取平台属性分组")
 | 
			
		||||
    @GetMapping("get/{id}")
 | 
			
		||||
    public Result get(@PathVariable Long id) {
 | 
			
		||||
        try {
 | 
			
		||||
            AttrGroup attrGroup = attrGroupService.getById(id);
 | 
			
		||||
            return StringUtils.isNotEmpty(attrGroup.toString()) ? Result.ok(attrGroup) : Result.fail(attrGroup);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("获取商品分类信息异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "新增平台属性分组")
 | 
			
		||||
    @PostMapping("save")
 | 
			
		||||
    public Result save(@RequestBody AttrGroup attrGroup) {
 | 
			
		||||
        try {
 | 
			
		||||
            attrGroupService.save(attrGroup);
 | 
			
		||||
            return Result.ok(null);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("新增平台属性分组异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "修改平台属性分组")
 | 
			
		||||
    @PutMapping("update")
 | 
			
		||||
    public Result updateById(@RequestBody AttrGroup attrGroup) {
 | 
			
		||||
        try {
 | 
			
		||||
            attrGroupService.updateById(attrGroup);
 | 
			
		||||
            return Result.ok(null);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("修改平台属性分组异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "删除平台属性分组")
 | 
			
		||||
    @DeleteMapping("remove/{id}")
 | 
			
		||||
    public Result remove(@PathVariable Long id) {
 | 
			
		||||
        try {
 | 
			
		||||
            attrGroupService.removeById(id);
 | 
			
		||||
            return Result.ok(null);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("删除平台属性分组异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "根据id列表删除平台属性分组")
 | 
			
		||||
    @DeleteMapping("batchRemove")
 | 
			
		||||
    public Result batchRemove(@RequestBody List<Long> idList) {
 | 
			
		||||
        try {
 | 
			
		||||
            attrGroupService.removeByIds(idList);
 | 
			
		||||
            return Result.ok(null);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("根据id列表删除平台属性分组异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "获取全部平台属性分组")
 | 
			
		||||
    @GetMapping("findAllList")
 | 
			
		||||
    public Result findAllList() {
 | 
			
		||||
        try {
 | 
			
		||||
            return Result.ok(attrGroupService.findAllList());
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("获取全部平台属性分组异常", e);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,20 @@
 | 
			
		||||
package com.atguigu.ssyx.product.controller;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
import com.atguigu.ssyx.common.result.Result;
 | 
			
		||||
import com.atguigu.ssyx.model.product.Category;
 | 
			
		||||
import com.atguigu.ssyx.product.service.CategoryService;
 | 
			
		||||
import com.atguigu.ssyx.vo.product.CategoryQueryVo;
 | 
			
		||||
import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
import io.swagger.annotations.ApiParam;
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * <p>
 | 
			
		||||
@@ -12,9 +24,93 @@ import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 * @author atguigu
 | 
			
		||||
 * @since 2023-09-15
 | 
			
		||||
 */
 | 
			
		||||
@Api(value = "Category管理", tags = "商品分类管理")
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/product/category")
 | 
			
		||||
@CrossOrigin
 | 
			
		||||
@RequestMapping(value = "/admin/product/category")
 | 
			
		||||
public class CategoryController {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private CategoryService categoryService;
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "获取商品分类分页列表")
 | 
			
		||||
    @GetMapping("{page}/{limit}")
 | 
			
		||||
    public Result index(
 | 
			
		||||
            @ApiParam(name = "page", value = "当前页码", required = true) @PathVariable Long page,
 | 
			
		||||
            @ApiParam(name = "limit", value = "每页记录数", required = true) @PathVariable Long limit,
 | 
			
		||||
            @ApiParam(name = "categoryQueryVo", value = "查询对象", required = false) CategoryQueryVo categoryQueryVo) {
 | 
			
		||||
        try {
 | 
			
		||||
            Page<Category> pageParam = new Page<>(page, limit);
 | 
			
		||||
            IPage<Category> pageModel = categoryService.selectPage(pageParam, categoryQueryVo);
 | 
			
		||||
            return Result.ok(pageModel);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("获取商品分类分页列表异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "获取商品分类信息")
 | 
			
		||||
    @GetMapping("get/{id}")
 | 
			
		||||
    public Result get(@PathVariable Long id) {
 | 
			
		||||
        try {
 | 
			
		||||
            Category category = categoryService.getById(id);
 | 
			
		||||
            return StringUtils.isNotEmpty(category.toString()) ? Result.ok(category) : Result.fail(category);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("获取商品分类信息异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "新增商品分类")
 | 
			
		||||
    @PostMapping("save")
 | 
			
		||||
    public Result save(@RequestBody Category category) {
 | 
			
		||||
        try {
 | 
			
		||||
            categoryService.save(category);
 | 
			
		||||
            return Result.ok(null);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("新增商品分类异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "修改商品分类")
 | 
			
		||||
    @PutMapping("update")
 | 
			
		||||
    public Result updateById(@RequestBody Category category) {
 | 
			
		||||
        try {
 | 
			
		||||
            categoryService.updateById(category);
 | 
			
		||||
            return Result.ok(null);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("修改商品分类异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "删除商品分类")
 | 
			
		||||
    @DeleteMapping("remove/{id}")
 | 
			
		||||
    public Result remove(@PathVariable Long id) {
 | 
			
		||||
        try {
 | 
			
		||||
            categoryService.removeById(id);
 | 
			
		||||
            return Result.ok(null);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("删除商品分类异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "根据id列表删除商品分类")
 | 
			
		||||
    @DeleteMapping("batchRemove")
 | 
			
		||||
    public Result batchRemove(@RequestBody List<Long> idList) {
 | 
			
		||||
        try {
 | 
			
		||||
            categoryService.removeByIds(idList);
 | 
			
		||||
            return Result.ok(null);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("根据id列表删除商品分类异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "获取全部商品分类")
 | 
			
		||||
    @GetMapping("findAllList")
 | 
			
		||||
    public Result findAllList() {
 | 
			
		||||
        try {
 | 
			
		||||
            return Result.ok(categoryService.findAllList());
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new RuntimeException("获取全部商品分类异常", e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,13 @@
 | 
			
		||||
package com.atguigu.ssyx.product.service;
 | 
			
		||||
 | 
			
		||||
import com.atguigu.ssyx.model.product.AttrGroup;
 | 
			
		||||
import com.atguigu.ssyx.vo.product.AttrGroupQueryVo;
 | 
			
		||||
import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.service.IService;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * <p>
 | 
			
		||||
 * 属性分组 服务类
 | 
			
		||||
@@ -13,4 +18,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 | 
			
		||||
 */
 | 
			
		||||
public interface AttrGroupService extends IService<AttrGroup> {
 | 
			
		||||
 | 
			
		||||
    List<AttrGroup> findAllList();
 | 
			
		||||
 | 
			
		||||
    //平台属性分组列表
 | 
			
		||||
    IPage<AttrGroup> selectPage(Page<AttrGroup> pageParam, AttrGroupQueryVo attrGroupQueryVo);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,8 @@ package com.atguigu.ssyx.product.service;
 | 
			
		||||
import com.atguigu.ssyx.model.product.Attr;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.service.IService;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * <p>
 | 
			
		||||
 * 商品属性 服务类
 | 
			
		||||
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
 | 
			
		||||
 */
 | 
			
		||||
public interface AttrService extends IService<Attr> {
 | 
			
		||||
 | 
			
		||||
    List<Attr> findByAttrGroupId(Long attrGroupId);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,8 +2,13 @@ package com.atguigu.ssyx.product.service;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import com.atguigu.ssyx.model.product.Category;
 | 
			
		||||
import com.atguigu.ssyx.vo.product.CategoryQueryVo;
 | 
			
		||||
import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.service.IService;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * <p>
 | 
			
		||||
 * 商品三级分类 服务类
 | 
			
		||||
@@ -14,4 +19,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 | 
			
		||||
 */
 | 
			
		||||
public interface CategoryService extends IService<Category> {
 | 
			
		||||
 | 
			
		||||
    IPage<Category> selectPage(Page<Category> pageParam, CategoryQueryVo categoryQueryVo);
 | 
			
		||||
 | 
			
		||||
    List<Category> findAllList();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,16 @@ package com.atguigu.ssyx.product.service.impl;
 | 
			
		||||
import com.atguigu.ssyx.model.product.AttrGroup;
 | 
			
		||||
import com.atguigu.ssyx.product.mapper.AttrGroupMapper;
 | 
			
		||||
import com.atguigu.ssyx.product.service.AttrGroupService;
 | 
			
		||||
import com.atguigu.ssyx.vo.product.AttrGroupQueryVo;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.util.StringUtils;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * <p>
 | 
			
		||||
@@ -18,4 +26,35 @@ import org.springframework.stereotype.Service;
 | 
			
		||||
@Service
 | 
			
		||||
public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupMapper, AttrGroup> implements AttrGroupService {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询所有的平台属性分组列表
 | 
			
		||||
     *
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<AttrGroup> findAllList() {
 | 
			
		||||
        //LambdaQueryWrapper<AttrGroup> wrapper = new LambdaQueryWrapper<>();
 | 
			
		||||
        QueryWrapper<AttrGroup> wrapper = new QueryWrapper<>();
 | 
			
		||||
        wrapper.orderByDesc("id");
 | 
			
		||||
        List<AttrGroup> list = baseMapper.selectList(wrapper);
 | 
			
		||||
        return list;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 平台属性分组列表
 | 
			
		||||
     *
 | 
			
		||||
     * @param pageParam
 | 
			
		||||
     * @param attrGroupQueryVo
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public IPage<AttrGroup> selectPage(Page<AttrGroup> pageParam, AttrGroupQueryVo attrGroupQueryVo) {
 | 
			
		||||
        String name = attrGroupQueryVo.getName();
 | 
			
		||||
        LambdaQueryWrapper<AttrGroup> wrapper = new LambdaQueryWrapper<>();
 | 
			
		||||
        if (!StringUtils.isEmpty(name)) {
 | 
			
		||||
            wrapper.like(AttrGroup::getName, name);
 | 
			
		||||
        }
 | 
			
		||||
        IPage<AttrGroup> attrGroupPage = baseMapper.selectPage(pageParam, wrapper);
 | 
			
		||||
        return attrGroupPage;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,9 +3,12 @@ package com.atguigu.ssyx.product.service.impl;
 | 
			
		||||
import com.atguigu.ssyx.model.product.Attr;
 | 
			
		||||
import com.atguigu.ssyx.product.mapper.AttrMapper;
 | 
			
		||||
import com.atguigu.ssyx.product.service.AttrService;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * <p>
 | 
			
		||||
 * 商品属性 服务实现类
 | 
			
		||||
@@ -17,4 +20,11 @@ import org.springframework.stereotype.Service;
 | 
			
		||||
@Service
 | 
			
		||||
public class AttrServiceImpl extends ServiceImpl<AttrMapper, Attr> implements AttrService {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Attr> findByAttrGroupId(Long attrGroupId) {
 | 
			
		||||
        LambdaQueryWrapper<Attr> wrapper = new LambdaQueryWrapper<>();
 | 
			
		||||
        wrapper.eq(Attr::getAttrGroupId, attrGroupId);
 | 
			
		||||
        List<Attr> attrList = baseMapper.selectList(wrapper);
 | 
			
		||||
        return attrList;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,15 @@ package com.atguigu.ssyx.product.service.impl;
 | 
			
		||||
import com.atguigu.ssyx.model.product.Category;
 | 
			
		||||
import com.atguigu.ssyx.product.mapper.CategoryMapper;
 | 
			
		||||
import com.atguigu.ssyx.product.service.CategoryService;
 | 
			
		||||
import com.atguigu.ssyx.vo.product.CategoryQueryVo;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.util.StringUtils;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * <p>
 | 
			
		||||
@@ -17,4 +24,21 @@ import org.springframework.stereotype.Service;
 | 
			
		||||
@Service
 | 
			
		||||
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public IPage<Category> selectPage(Page<Category> pageParam, CategoryQueryVo categoryQueryVo) {
 | 
			
		||||
        String name = categoryQueryVo.getName();
 | 
			
		||||
        LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper<>();
 | 
			
		||||
        if (!StringUtils.isEmpty(name)) {
 | 
			
		||||
            queryWrapper.like(Category::getName, name);
 | 
			
		||||
        }
 | 
			
		||||
        IPage<Category> categoryPage = baseMapper.selectPage(pageParam, queryWrapper);
 | 
			
		||||
        return categoryPage;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Category> findAllList() {
 | 
			
		||||
        LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper<>();
 | 
			
		||||
        queryWrapper.orderByAsc(Category::getSort);
 | 
			
		||||
        return this.list(queryWrapper);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user