菜品管理页面
This commit is contained in:
		| @@ -1,35 +1,33 @@ | ||||
| package com.stdiet.web.controller.custom; | ||||
|  | ||||
| import java.util.List; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.PostMapping; | ||||
| import org.springframework.web.bind.annotation.PutMapping; | ||||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||||
| import org.springframework.web.bind.annotation.PathVariable; | ||||
| import org.springframework.web.bind.annotation.RequestBody; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
| import com.stdiet.common.annotation.Log; | ||||
| import com.stdiet.common.core.controller.BaseController; | ||||
| import com.stdiet.common.core.domain.AjaxResult; | ||||
| import com.stdiet.common.enums.BusinessType; | ||||
| import com.stdiet.custom.domain.SysDishes; | ||||
| import com.stdiet.custom.service.ISysDishesService; | ||||
| import com.stdiet.common.utils.poi.ExcelUtil; | ||||
| import com.stdiet.common.core.page.TableDataInfo; | ||||
| import com.stdiet.common.enums.BusinessType; | ||||
| import com.stdiet.common.utils.StringUtils; | ||||
| import com.stdiet.common.utils.poi.ExcelUtil; | ||||
| import com.stdiet.custom.domain.SysDishes; | ||||
| import com.stdiet.custom.domain.SysDishesIngredient; | ||||
| import com.stdiet.custom.domain.SysIngredient; | ||||
| import com.stdiet.custom.service.ISysDishesService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import java.lang.reflect.Array; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 菜品Controller | ||||
|  *  | ||||
|  * | ||||
|  * @author wonder | ||||
|  * @date 2020-12-28 | ||||
|  */ | ||||
| @RestController | ||||
| @RequestMapping("/custom/dishes") | ||||
| public class SysDishesController extends BaseController | ||||
| { | ||||
| public class SysDishesController extends BaseController { | ||||
|     @Autowired | ||||
|     private ISysDishesService sysDishesService; | ||||
|  | ||||
| @@ -38,10 +36,17 @@ public class SysDishesController extends BaseController | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:dishes:list')") | ||||
|     @GetMapping("/list") | ||||
|     public TableDataInfo list(SysDishes sysDishes) | ||||
|     { | ||||
|     public TableDataInfo list(SysDishes sysDishes) { | ||||
|         startPage(); | ||||
|         List<SysDishes> list = sysDishesService.selectSysDishesList(sysDishes); | ||||
|         for (SysDishes dishes : list) { | ||||
|             List<SysDishesIngredient> ingredients = sysDishesService.selectSysIngreditentsById(dishes.getId()); | ||||
|             if (StringUtils.isNull(ingredients)) { | ||||
|                 dishes.setIgdList(new ArrayList<>()); | ||||
|             } else { | ||||
|                 dishes.setIgdList(ingredients); | ||||
|             } | ||||
|         } | ||||
|         return getDataTable(list); | ||||
|     } | ||||
|  | ||||
| @@ -51,8 +56,7 @@ public class SysDishesController extends BaseController | ||||
|     @PreAuthorize("@ss.hasPermi('custom:dishes:export')") | ||||
|     @Log(title = "菜品", businessType = BusinessType.EXPORT) | ||||
|     @GetMapping("/export") | ||||
|     public AjaxResult export(SysDishes sysDishes) | ||||
|     { | ||||
|     public AjaxResult export(SysDishes sysDishes) { | ||||
|         List<SysDishes> list = sysDishesService.selectSysDishesList(sysDishes); | ||||
|         ExcelUtil<SysDishes> util = new ExcelUtil<SysDishes>(SysDishes.class); | ||||
|         return util.exportExcel(list, "dishes"); | ||||
| @@ -63,8 +67,7 @@ public class SysDishesController extends BaseController | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:dishes:query')") | ||||
|     @GetMapping(value = "/{id}") | ||||
|     public AjaxResult getInfo(@PathVariable("id") Long id) | ||||
|     { | ||||
|     public AjaxResult getInfo(@PathVariable("id") Long id) { | ||||
|         return AjaxResult.success(sysDishesService.selectSysDishesById(id)); | ||||
|     } | ||||
|  | ||||
| @@ -74,8 +77,7 @@ public class SysDishesController extends BaseController | ||||
|     @PreAuthorize("@ss.hasPermi('custom:dishes:add')") | ||||
|     @Log(title = "菜品", businessType = BusinessType.INSERT) | ||||
|     @PostMapping | ||||
|     public AjaxResult add(@RequestBody SysDishes sysDishes) | ||||
|     { | ||||
|     public AjaxResult add(@RequestBody SysDishes sysDishes) { | ||||
|         return toAjax(sysDishesService.insertSysDishes(sysDishes)); | ||||
|     } | ||||
|  | ||||
| @@ -85,8 +87,7 @@ public class SysDishesController extends BaseController | ||||
|     @PreAuthorize("@ss.hasPermi('custom:dishes:edit')") | ||||
|     @Log(title = "菜品", businessType = BusinessType.UPDATE) | ||||
|     @PutMapping | ||||
|     public AjaxResult edit(@RequestBody SysDishes sysDishes) | ||||
|     { | ||||
|     public AjaxResult edit(@RequestBody SysDishes sysDishes) { | ||||
|         return toAjax(sysDishesService.updateSysDishes(sysDishes)); | ||||
|     } | ||||
|  | ||||
| @@ -95,9 +96,8 @@ public class SysDishesController extends BaseController | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('custom:dishes:remove')") | ||||
|     @Log(title = "菜品", businessType = BusinessType.DELETE) | ||||
| 	@DeleteMapping("/{ids}") | ||||
|     public AjaxResult remove(@PathVariable Long[] ids) | ||||
|     { | ||||
|     @DeleteMapping("/{ids}") | ||||
|     public AjaxResult remove(@PathVariable Long[] ids) { | ||||
|         return toAjax(sysDishesService.deleteSysDishesByIds(ids)); | ||||
|     } | ||||
| } | ||||
| @@ -45,6 +45,14 @@ public class SysIngredientController extends BaseController | ||||
|         return getDataTable(list); | ||||
|     } | ||||
|  | ||||
|     @PreAuthorize("@ss.hasPermi('custom:ingredient:list')") | ||||
|     @PostMapping("/listAll") | ||||
|     public TableDataInfo listAll(@RequestBody SysIngredient sysIngredient) | ||||
|     { | ||||
|         List<SysIngredient> list = sysIngredientService.selectSysIngredientList(sysIngredient); | ||||
|         return getDataTable(list); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 导出食材列表 | ||||
|      */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user