fix(food-encyclopedia): 后台食物百科列表/编辑页接入并修复图片URL双前缀
- 新增 FoodEncyclopediaController 及 ToolFoodAdminService,提供 /api/admin/tool/food/* CRUD - ToolFoodAdminServiceImpl 在保存前 clearPrefix 并正则修复历史脏数据中的多层 host 前缀 - 前端 list.vue/edit.vue 修复二次解包导致 listData.list 渲染崩溃 - edit.vue 加载详情时兜底归一化 image 字段,处理 https://host//https://host//crmebimage/... 形式 - content.js 注册 foodManager / foodEdit 路由 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
package com.zbkj.admin.controller;
|
||||
|
||||
import com.zbkj.common.model.tool.V2Food;
|
||||
import com.zbkj.common.page.CommonPage;
|
||||
import com.zbkj.common.request.PageParamRequest;
|
||||
import com.zbkj.common.result.CommonResult;
|
||||
import com.zbkj.service.service.tool.ToolFoodAdminService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 食物百科管理 后台控制器
|
||||
* +----------------------------------------------------------------------
|
||||
* | 提供食物百科 CRUD 管理接口,含图片维护
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("api/admin/tool/food")
|
||||
@Api(tags = "食物百科管理")
|
||||
public class FoodEncyclopediaController {
|
||||
|
||||
@Autowired
|
||||
private ToolFoodAdminService toolFoodAdminService;
|
||||
|
||||
/**
|
||||
* 分页列表
|
||||
*/
|
||||
@ApiOperation(value = "食物列表")
|
||||
@GetMapping("/list")
|
||||
public CommonResult<CommonPage<V2Food>> getList(
|
||||
@RequestParam(required = false) String keyword,
|
||||
@RequestParam(required = false) String category,
|
||||
@RequestParam(required = false) String status,
|
||||
@Validated PageParamRequest pageParamRequest) {
|
||||
return CommonResult.success(CommonPage.restPage(
|
||||
toolFoodAdminService.getAdminList(keyword, category, status, pageParamRequest)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 食物详情
|
||||
*/
|
||||
@ApiOperation(value = "食物详情")
|
||||
@GetMapping("/info/{id}")
|
||||
public CommonResult<V2Food> info(@PathVariable Long id) {
|
||||
return CommonResult.success(toolFoodAdminService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增食物
|
||||
*/
|
||||
@ApiOperation(value = "新增食物")
|
||||
@PostMapping("/save")
|
||||
public CommonResult<String> save(@RequestBody @Validated V2Food food) {
|
||||
if (toolFoodAdminService.create(food)) {
|
||||
return CommonResult.success();
|
||||
}
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改食物
|
||||
*/
|
||||
@ApiOperation(value = "修改食物")
|
||||
@PostMapping("/update/{id}")
|
||||
public CommonResult<String> update(@PathVariable Long id,
|
||||
@RequestBody @Validated V2Food food) {
|
||||
food.setFoodId(id);
|
||||
if (toolFoodAdminService.updateFood(food)) {
|
||||
return CommonResult.success();
|
||||
}
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除食物
|
||||
*/
|
||||
@ApiOperation(value = "删除食物")
|
||||
@GetMapping("/delete/{id}")
|
||||
public CommonResult<String> delete(@PathVariable Long id) {
|
||||
if (toolFoodAdminService.deleteById(id)) {
|
||||
return CommonResult.success();
|
||||
}
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态(上架/下架)
|
||||
*/
|
||||
@ApiOperation(value = "修改上下架状态")
|
||||
@PostMapping("/changeStatus/{id}")
|
||||
public CommonResult<String> changeStatus(@PathVariable Long id,
|
||||
@RequestParam String status) {
|
||||
if (toolFoodAdminService.changeStatus(id, status)) {
|
||||
return CommonResult.success();
|
||||
}
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类列表(用于下拉筛选)
|
||||
*/
|
||||
@ApiOperation(value = "食物分类列表")
|
||||
@GetMapping("/categories")
|
||||
public CommonResult<List<String>> getCategories() {
|
||||
return CommonResult.success(toolFoodAdminService.getAllCategories());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user