dev #1
|
@ -1,9 +1,19 @@
|
||||||
package com.atguigu.ssyx.product.controller;
|
package com.atguigu.ssyx.product.controller;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
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.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -13,9 +23,68 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
* @author bunny
|
* @author bunny
|
||||||
* @since 2024-04-03
|
* @since 2024-04-03
|
||||||
*/
|
*/
|
||||||
|
@Api(value = "AttrGroup管理", tags = "平台属性分组管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/product/attr-group")
|
@RequestMapping(value = "/admin/product/attrGroup")
|
||||||
public class AttrGroupController {
|
public class AttrGroupController {
|
||||||
|
@Autowired
|
||||||
|
private AttrGroupService attrGroupService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取分页列表")
|
||||||
|
@GetMapping("{page}/{limit}")
|
||||||
|
public Result<IPage<AttrGroup>> 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) {
|
||||||
|
Page<AttrGroup> pageParam = new Page<>(page, limit);
|
||||||
|
IPage<AttrGroup> pageModel = attrGroupService.selectPage(pageParam, attrGroupQueryVo);
|
||||||
|
return Result.success(pageModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取")
|
||||||
|
@GetMapping("get/{id}")
|
||||||
|
public Result<AttrGroup> get(@PathVariable Long id) {
|
||||||
|
AttrGroup attrGroup = attrGroupService.getById(id);
|
||||||
|
return Result.success(attrGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result<AttrGroup> save(@RequestBody AttrGroup group) {
|
||||||
|
attrGroupService.save(group);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改")
|
||||||
|
@PutMapping("update")
|
||||||
|
public Result<AttrGroup> updateById(@RequestBody AttrGroup attrGroup) {
|
||||||
|
attrGroupService.updateById(attrGroup);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除")
|
||||||
|
@DeleteMapping("remove/{id}")
|
||||||
|
public Result<Long> remove(@PathVariable Long id) {
|
||||||
|
attrGroupService.removeById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "根据id列表删除")
|
||||||
|
@DeleteMapping("batchRemove")
|
||||||
|
public Result<AttrGroup> batchRemove(@RequestBody List<Long> ids) {
|
||||||
|
attrGroupService.removeByIds(ids);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取全部属性分组")
|
||||||
|
@GetMapping("findAllList")
|
||||||
|
public Result<List<AttrGroup>> findAllList() {
|
||||||
|
return Result.success(attrGroupService.list());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package com.atguigu.ssyx.product.service;
|
package com.atguigu.ssyx.product.service;
|
||||||
|
|
||||||
import com.atguigu.ssyx.model.product.AttrGroup;
|
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 com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,4 +16,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
*/
|
*/
|
||||||
public interface AttrGroupService extends IService<AttrGroup> {
|
public interface AttrGroupService extends IService<AttrGroup> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分页列表
|
||||||
|
*
|
||||||
|
* @param pageParam 分页查询条件
|
||||||
|
* @param vo 查询分页参数
|
||||||
|
* @return 分页查询结果
|
||||||
|
*/
|
||||||
|
IPage<AttrGroup> selectPage(Page<AttrGroup> pageParam, AttrGroupQueryVo vo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@ package com.atguigu.ssyx.product.service.impl;
|
||||||
import com.atguigu.ssyx.model.product.AttrGroup;
|
import com.atguigu.ssyx.model.product.AttrGroup;
|
||||||
import com.atguigu.ssyx.product.mapper.AttrGroupMapper;
|
import com.atguigu.ssyx.product.mapper.AttrGroupMapper;
|
||||||
import com.atguigu.ssyx.product.service.AttrGroupService;
|
import com.atguigu.ssyx.product.service.AttrGroupService;
|
||||||
|
import com.atguigu.ssyx.vo.product.AttrGroupQueryVo;
|
||||||
|
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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -17,4 +21,18 @@ import org.springframework.stereotype.Service;
|
||||||
@Service
|
@Service
|
||||||
public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupMapper, AttrGroup> implements AttrGroupService {
|
public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupMapper, AttrGroup> implements AttrGroupService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分页列表
|
||||||
|
*
|
||||||
|
* @param pageParam 分页查询条件
|
||||||
|
* @param vo 查询分页参数
|
||||||
|
* @return 分页查询结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IPage<AttrGroup> selectPage(Page<AttrGroup> pageParam, AttrGroupQueryVo vo) {
|
||||||
|
QueryWrapper<AttrGroup> wrapper = new QueryWrapper<>();
|
||||||
|
|
||||||
|
wrapper.orderByDesc("id");
|
||||||
|
return baseMapper.selectPage(pageParam, wrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue