|
|
@ -1,9 +1,15 @@
|
|
|
|
package com.wayn.admin.api.controller.shop;
|
|
|
|
package com.wayn.admin.api.controller.shop;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.plugins.pagination.Page;
|
|
|
|
import com.wayn.common.base.controller.BaseController;
|
|
|
|
import com.wayn.common.base.controller.BaseController;
|
|
|
|
import com.wayn.common.core.domain.shop.Column;
|
|
|
|
import com.wayn.common.core.domain.shop.Column;
|
|
|
|
|
|
|
|
import com.wayn.common.core.domain.shop.ColumnGoodsRelation;
|
|
|
|
|
|
|
|
import com.wayn.common.core.domain.shop.Goods;
|
|
|
|
|
|
|
|
import com.wayn.common.core.service.shop.IColumnGoodsRelationService;
|
|
|
|
import com.wayn.common.core.service.shop.IColumnService;
|
|
|
|
import com.wayn.common.core.service.shop.IColumnService;
|
|
|
|
|
|
|
|
import com.wayn.common.core.service.shop.IGoodsService;
|
|
|
|
import com.wayn.common.util.R;
|
|
|
|
import com.wayn.common.util.R;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
@ -11,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("shop/column")
|
|
|
|
@RequestMapping("shop/column")
|
|
|
@ -19,6 +26,12 @@ public class ColumnController extends BaseController {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IColumnService iColumnService;
|
|
|
|
private IColumnService iColumnService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IColumnGoodsRelationService iColumnGoodsRelationService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IGoodsService iGoodsService;
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
@GetMapping("/list")
|
|
|
|
public R list(Column column) {
|
|
|
|
public R list(Column column) {
|
|
|
|
Page<Column> page = getPage();
|
|
|
|
Page<Column> page = getPage();
|
|
|
@ -47,4 +60,33 @@ public class ColumnController extends BaseController {
|
|
|
|
return R.result(iColumnService.removeByIds(columnIds));
|
|
|
|
return R.result(iColumnService.removeByIds(columnIds));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("bindGoodsList")
|
|
|
|
|
|
|
|
public R bindGoodsList(Goods goods, Long columnId) {
|
|
|
|
|
|
|
|
Page<Goods> page = getPage();
|
|
|
|
|
|
|
|
List<ColumnGoodsRelation> goodsRelationList = iColumnGoodsRelationService.list(new QueryWrapper<ColumnGoodsRelation>()
|
|
|
|
|
|
|
|
.eq("column_id", columnId));
|
|
|
|
|
|
|
|
List<Long> columnGoodsIds = goodsRelationList.stream().map(ColumnGoodsRelation::getGoodsId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
IPage<Goods> listPage = iGoodsService.listColumnBindGoodsPage(page, goods, columnGoodsIds);
|
|
|
|
|
|
|
|
return R.success().add("page", listPage);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("unBindGoodsList")
|
|
|
|
|
|
|
|
public R unBindGoodsList(Goods goods, Long columnId) {
|
|
|
|
|
|
|
|
Page<Goods> page = getPage();
|
|
|
|
|
|
|
|
List<ColumnGoodsRelation> goodsRelationList = iColumnGoodsRelationService.list(new QueryWrapper<ColumnGoodsRelation>()
|
|
|
|
|
|
|
|
.eq("column_id", columnId));
|
|
|
|
|
|
|
|
List<Long> columnGoodsIds = goodsRelationList.stream().map(ColumnGoodsRelation::getGoodsId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
IPage<Goods> listPage = iGoodsService.listColumnUnBindGoodsPage(page, goods, columnGoodsIds);
|
|
|
|
|
|
|
|
return R.success().add("page", listPage);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("goods")
|
|
|
|
|
|
|
|
public R addGoods(@RequestBody ColumnGoodsRelation columnGoodsRelation) {
|
|
|
|
|
|
|
|
return R.result(iColumnGoodsRelationService.save(columnGoodsRelation));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping("goods/{id}")
|
|
|
|
|
|
|
|
public R deleteGoods(@PathVariable Long id) {
|
|
|
|
|
|
|
|
return R.result(iColumnGoodsRelationService.removeById(id));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|