|
@@ -0,0 +1,79 @@
|
|
|
+package com.fjhx.controller.product;
|
|
|
+
|
|
|
+import com.fjhx.entity.product.ProductTag;
|
|
|
+import com.fjhx.params.product.ProductTagVo;
|
|
|
+import com.fjhx.service.product.ProductTagService;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.validation.constraints.NotEmpty;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 产品标签 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author ${author}
|
|
|
+ * @since 2023-02-21
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/productTag")
|
|
|
+public class ProductTagController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductTagService productTagService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 产品标签对象
|
|
|
+ */
|
|
|
+ @PostMapping("/tagMap")
|
|
|
+ public R tagMap(@NotEmpty(message = "产品id列表不能为空") @RequestBody List<Long> productIdList) {
|
|
|
+ Map<Long, List<ProductTag>> result = productTagService.tagMap(productIdList);
|
|
|
+ return R.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加产品标签
|
|
|
+ */
|
|
|
+ @PostMapping("/add")
|
|
|
+ public R add(@Validated @RequestBody ProductTagVo productTagVo) {
|
|
|
+ productTagService.add(productTagVo);
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑产品标签
|
|
|
+ */
|
|
|
+ @PostMapping("/edit")
|
|
|
+ public R edit(@Validated @RequestBody ProductTagVo productTagVo) {
|
|
|
+ productTagService.edit(productTagVo);
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除产品标签
|
|
|
+ */
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public R delete(@RequestBody ProductTagVo productTagVo) {
|
|
|
+ productTagService.delete(productTagVo);
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取去重后的标签名称
|
|
|
+ */
|
|
|
+ @PostMapping("/distinctTagNameList")
|
|
|
+ public R distinctList() {
|
|
|
+ List<String> distinctList = productTagService.getDistinctList(ProductTag::getTagName);
|
|
|
+ return R.success(distinctList);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|