|
@@ -1,123 +1,42 @@
|
|
|
package com.etotem.cfc.controller.admin;
|
|
package com.etotem.cfc.controller.admin;
|
|
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.etotem.cfc.common.Result;
|
|
import com.etotem.cfc.common.Result;
|
|
|
-import com.etotem.cfc.entity.EcomSupplier;
|
|
|
|
|
-import com.etotem.cfc.mapper.EcomSupplierMapper;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
-import com.etotem.cfc.util.SortUtil;
|
|
|
|
|
-import com.etotem.cfc.util.ParamUtils;
|
|
|
|
|
|
|
|
|
|
-@Tag(name = "管理端-电商供应商管理")
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * @deprecated 已合并至 /api/admin/supply-system(供应商体系管理)。此接口返回 410。
|
|
|
|
|
+ */
|
|
|
|
|
+@Deprecated
|
|
|
|
|
+@Tag(name = "管理端-电商供应商管理(已废弃)")
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/api/admin/supplier")
|
|
@RequestMapping("/api/admin/supplier")
|
|
|
public class AdminSupplierController {
|
|
public class AdminSupplierController {
|
|
|
|
|
|
|
|
- @Resource
|
|
|
|
|
- private EcomSupplierMapper ecomSupplierMapper;
|
|
|
|
|
-
|
|
|
|
|
- @Operation(summary = "供应商列表")
|
|
|
|
|
|
|
+ @Operation(summary = "【已废弃】供应商列表,请使用 /api/admin/supply-system/list")
|
|
|
@PostMapping("/list")
|
|
@PostMapping("/list")
|
|
|
public Result<Map<String, Object>> list(@RequestBody Map<String, Object> params) {
|
|
public Result<Map<String, Object>> list(@RequestBody Map<String, Object> params) {
|
|
|
- int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
|
|
|
|
|
- int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
|
|
|
|
|
- String keyword = (String) params.get("keyword");
|
|
|
|
|
-
|
|
|
|
|
- Page<EcomSupplier> pageParam = new Page<>(page, size);
|
|
|
|
|
- LambdaQueryWrapper<EcomSupplier> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- if (keyword != null && !keyword.isEmpty()) {
|
|
|
|
|
- wrapper.like(EcomSupplier::getName, keyword);
|
|
|
|
|
- }
|
|
|
|
|
- wrapper.orderByDesc(EcomSupplier::getCreatedAt);
|
|
|
|
|
- SortUtil.applySort(wrapper);
|
|
|
|
|
- Page<EcomSupplier> result = ecomSupplierMapper.selectPage(pageParam, wrapper);
|
|
|
|
|
-
|
|
|
|
|
- Map<String, Object> data = new HashMap<>();
|
|
|
|
|
- data.put("records", result.getRecords());
|
|
|
|
|
- data.put("total", result.getTotal());
|
|
|
|
|
- data.put("page", page);
|
|
|
|
|
- data.put("size", size);
|
|
|
|
|
- return Result.success(data);
|
|
|
|
|
|
|
+ return Result.error(410, "该接口已废弃,请使用 /api/admin/supply-system/list");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Operation(summary = "新增供应商(兼容新旧字段契约)")
|
|
|
|
|
|
|
+ @Operation(summary = "【已废弃】新增供应商")
|
|
|
@PostMapping("/save")
|
|
@PostMapping("/save")
|
|
|
- public Result<EcomSupplier> save(@RequestBody Map<String, Object> body) {
|
|
|
|
|
- EcomSupplier supplier = new EcomSupplier();
|
|
|
|
|
- applyFields(supplier, body);
|
|
|
|
|
- if (supplier.getName() == null || supplier.getName().trim().isEmpty()) {
|
|
|
|
|
- return Result.error("供应商名称不能为空");
|
|
|
|
|
- }
|
|
|
|
|
- supplier.setCreatedAt(new Date());
|
|
|
|
|
- supplier.setUpdatedAt(new Date());
|
|
|
|
|
- ecomSupplierMapper.insert(supplier);
|
|
|
|
|
- return Result.success(supplier);
|
|
|
|
|
|
|
+ public Result<Map<String, Object>> save(@RequestBody Map<String, Object> body) {
|
|
|
|
|
+ return Result.error(410, "该接口已废弃,请使用 /api/admin/supply-system/create");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Operation(summary = "更新供应商(兼容新旧字段契约)")
|
|
|
|
|
|
|
+ @Operation(summary = "【已废弃】更新供应商")
|
|
|
@PostMapping("/update")
|
|
@PostMapping("/update")
|
|
|
- public Result<String> update(@RequestBody Map<String, Object> body) {
|
|
|
|
|
- Long id = ParamUtils.getLong(body.get("id"));
|
|
|
|
|
- if (id == null) return Result.error("id不能为空");
|
|
|
|
|
- EcomSupplier supplier = ecomSupplierMapper.selectById(id);
|
|
|
|
|
- if (supplier == null) return Result.error("供应商不存在");
|
|
|
|
|
- applyFields(supplier, body);
|
|
|
|
|
- supplier.setUpdatedAt(new Date());
|
|
|
|
|
- ecomSupplierMapper.updateById(supplier);
|
|
|
|
|
- return Result.success("ok");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 字段契约兼容:前端表单提交 {phone,nickname,realName,vendorType,vendorStatus},
|
|
|
|
|
- * 库表字段为 {name,contactName,contactPhone,status,remark}。新旧字段都接受,新字段优先。
|
|
|
|
|
- */
|
|
|
|
|
- private void applyFields(EcomSupplier supplier, Map<String, Object> body) {
|
|
|
|
|
- String name = str(body, "nickname", body.get("name"));
|
|
|
|
|
- if (name != null) supplier.setName(name);
|
|
|
|
|
- String contactName = str(body, "realName", body.get("contactName"));
|
|
|
|
|
- if (contactName != null) supplier.setContactName(contactName);
|
|
|
|
|
- String contactPhone = str(body, "phone", body.get("contactPhone"));
|
|
|
|
|
- if (contactPhone != null) supplier.setContactPhone(contactPhone);
|
|
|
|
|
- String remark = str(body, "remark", null);
|
|
|
|
|
- if (remark != null) supplier.setRemark(remark);
|
|
|
|
|
- Object vendorStatus = body.get("vendorStatus") != null ? body.get("vendorStatus") : body.get("status");
|
|
|
|
|
- if (vendorStatus != null) {
|
|
|
|
|
- supplier.setStatus(parseStatus(vendorStatus));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static String str(Map<String, Object> body, String key, Object fallback) {
|
|
|
|
|
- Object v = body.get(key);
|
|
|
|
|
- if (v == null) v = fallback;
|
|
|
|
|
- return v != null ? v.toString() : null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static Integer parseStatus(Object v) {
|
|
|
|
|
- if (v instanceof Number) return ((Number) v).intValue();
|
|
|
|
|
- String s = v.toString().trim();
|
|
|
|
|
- if ("active".equalsIgnoreCase(s) || "enabled".equalsIgnoreCase(s) || "1".equals(s)) return 1;
|
|
|
|
|
- if ("pending".equalsIgnoreCase(s) || "disabled".equalsIgnoreCase(s) || "0".equals(s)) return 0;
|
|
|
|
|
- try {
|
|
|
|
|
- return Integer.valueOf(s);
|
|
|
|
|
- } catch (NumberFormatException e) {
|
|
|
|
|
- return 1;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public Result<Map<String, Object>> update(@RequestBody Map<String, Object> body) {
|
|
|
|
|
+ return Result.error(410, "该接口已废弃,请使用 /api/admin/supply-system/update");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Operation(summary = "删除供应商")
|
|
|
|
|
|
|
+ @Operation(summary = "【已废弃】删除供应商")
|
|
|
@PostMapping("/delete")
|
|
@PostMapping("/delete")
|
|
|
- public Result<String> delete(@RequestBody Map<String, Object> params) {
|
|
|
|
|
- Long id = ParamUtils.getLong(params.get("id"));
|
|
|
|
|
- if (id == null) return Result.error("id不能为空");
|
|
|
|
|
- ecomSupplierMapper.deleteById(id);
|
|
|
|
|
- return Result.success("ok");
|
|
|
|
|
|
|
+ public Result<Map<String, Object>> delete(@RequestBody Map<String, Object> params) {
|
|
|
|
|
+ return Result.error(410, "该接口已废弃,请使用 /api/admin/supply-system/toggle-status");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|