|
@@ -1,9 +1,16 @@
|
|
|
package com.ims.eval.controller;
|
|
|
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import com.ims.eval.config.CustomException;
|
|
|
+import com.ims.eval.entity.MultipleBrand;
|
|
|
+import com.ims.eval.entity.dto.result.R;
|
|
|
+import com.ims.eval.service.IMultipleBrandService;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -17,4 +24,84 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RequestMapping("//multiple-brand")
|
|
|
public class MultipleBrandController {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IMultipleBrandService multipleBrandService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询
|
|
|
+ *
|
|
|
+ * @param id 主键ID
|
|
|
+ * @param parentId 父类id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "list")
|
|
|
+ public R list(@RequestParam(value = "id", required = false) String id,
|
|
|
+ @RequestParam(value = "parentId", required = false) String parentId) {
|
|
|
+
|
|
|
+ List<MultipleBrand> list =multipleBrandService.getMultipleBranList(id,parentId);
|
|
|
+ return R.ok().data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询
|
|
|
+ *
|
|
|
+ * @param id 主键ID
|
|
|
+ * @param parentId 父类id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "tree")
|
|
|
+ public R tree(@RequestParam(value = "id", required = false) String id,
|
|
|
+ @RequestParam(value = "parentId", required = false) String parentId) {
|
|
|
+
|
|
|
+ List<MultipleBrand> list =multipleBrandService.getMultipleBranTree(id,parentId);
|
|
|
+ return R.ok().data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ *
|
|
|
+ * @param multipleBrand
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+
|
|
|
+ @PostMapping(value = "/save")
|
|
|
+ @ApiOperation(value = "新增(修改)", notes = "新增(修改)")
|
|
|
+ public R addAll(@RequestBody MultipleBrand multipleBrand) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ boolean b = multipleBrandService.saveOrUpdate(multipleBrand);
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("保存失败!");
|
|
|
+ }
|
|
|
+ } catch (CustomException e){
|
|
|
+ return R.customError(e.getMessage()).data("失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/remove/{ids}")
|
|
|
+ @ApiOperation(value = "删除", notes = "删除")
|
|
|
+ public R deleteAll(@PathVariable("ids") String ids) {
|
|
|
+ String[] strings = ids.split(",");
|
|
|
+ boolean b = multipleBrandService.removeByIds(Arrays.asList(strings));
|
|
|
+ if (b) {
|
|
|
+ return R.ok().data(b);
|
|
|
+ } else {
|
|
|
+ return R.error().data("删除失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|